[PATCH] D78661: [Sema] Split off warn_impcast_integer_float_precision_constant into -Wimplicit-const-int-float-conversion
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 22 14:41:55 PDT 2020
MaskRay updated this revision to Diff 259398.
MaskRay marked an inline comment as done.
MaskRay added a comment.
Change RUN lines
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78661/new/
https://reviews.llvm.org/D78661
Files:
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/Sema/implicit-int-float-conversion.c
Index: clang/test/Sema/implicit-int-float-conversion.c
===================================================================
--- clang/test/Sema/implicit-int-float-conversion.c
+++ clang/test/Sema/implicit-int-float-conversion.c
@@ -1,8 +1,12 @@
-// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-float-conversion
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -verify -Wno-implicit-int-float-conversion -Wimplicit-const-int-float-conversion
+// RUN: %clang_cc1 %s -DNONCONST=1 -verify -Wimplicit-int-float-conversion
+#ifdef NONCONST
long testReturn(long a, float b) {
return a + b; // expected-warning {{implicit conversion from 'long' to 'float' may lose precision}}
}
+#endif
void testAssignment() {
float f = 222222;
@@ -12,7 +16,9 @@
float ffff = 222222222222UL; // expected-warning {{changes value from 222222222222 to 222222221312}}
long l = 222222222222L;
+#ifdef NONCOST
float fff = l; // expected-warning {{implicit conversion from 'long' to 'float' may lose precision}}
+#endif
}
void testExpression() {
@@ -24,7 +30,9 @@
float c = 22222222 + 22222223; // expected-warning {{implicit conversion from 'int' to 'float' changes value from 44444445 to 44444444}}
int i = 0;
+#ifdef NONCONST
float d = i + a; // expected-warning {{implicit conversion from 'int' to 'float' may lose precision}}
+#endif
double e = 0.0;
double f = i + e;
@@ -36,5 +44,7 @@
float a = {222222222222L}; // expected-warning {{changes value from 222222222222 to 222222221312}}
long b = 222222222222L;
+#ifdef NONCONST
float c = {b}; // expected-warning {{implicit conversion from 'long' to 'float' may lose precision}}
+#endif
}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3549,7 +3549,7 @@
InGroup<ImplicitIntFloatConversion>, DefaultIgnore;
def warn_impcast_integer_float_precision_constant : Warning<
"implicit conversion from %2 to %3 changes value from %0 to %1">,
- InGroup<ImplicitIntFloatConversion>;
+ InGroup<ImplicitConstIntFloatConversion>;
def warn_impcast_float_to_integer : Warning<
"implicit conversion from %0 to %1 changes value from %2 to %3">,
Index: clang/include/clang/Basic/DiagnosticGroups.td
===================================================================
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -85,7 +85,9 @@
DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
def ImplicitIntConversion : DiagGroup<"implicit-int-conversion",
[ObjCSignedCharBoolImplicitIntConversion]>;
-def ImplicitIntFloatConversion : DiagGroup<"implicit-int-float-conversion">;
+def ImplicitConstIntFloatConversion : DiagGroup<"implicit-const-int-float-conversion">;
+def ImplicitIntFloatConversion : DiagGroup<"implicit-int-float-conversion",
+ [ImplicitConstIntFloatConversion]>;
def ObjCSignedCharBoolImplicitFloatConversion :
DiagGroup<"objc-signed-char-bool-implicit-float-conversion">;
def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78661.259398.patch
Type: text/x-patch
Size: 3243 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200422/b9642fa6/attachment.bin>
More information about the cfe-commits
mailing list