[cfe-commits] r101580 - in /cfe/trunk: lib/Lex/LiteralSupport.cpp test/Preprocessor/if_warning.c
Chris Lattner
sabre at nondot.org
Fri Apr 16 16:44:05 PDT 2010
Author: lattner
Date: Fri Apr 16 18:44:05 2010
New Revision: 101580
URL: http://llvm.org/viewvc/llvm-project?rev=101580&view=rev
Log:
emit warn_char_constant_too_large at most once per literal, fixing PR6852
Modified:
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/test/Preprocessor/if_warning.c
Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=101580&r1=101579&r2=101580&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Fri Apr 16 18:44:05 2010
@@ -654,6 +654,7 @@
llvm::APInt LitVal(PP.getTargetInfo().getIntWidth(), 0);
unsigned NumCharsSoFar = 0;
+ bool Warned = false;
while (begin[0] != '\'') {
uint64_t ResultChar;
if (begin[0] != '\\') // If this is a normal character, consume it.
@@ -670,8 +671,10 @@
} else {
// Narrow character literals act as though their value is concatenated
// in this implementation, but warn on overflow.
- if (LitVal.countLeadingZeros() < 8)
+ if (LitVal.countLeadingZeros() < 8 && !Warned) {
PP.Diag(Loc, diag::warn_char_constant_too_large);
+ Warned = true;
+ }
LitVal <<= 8;
}
}
Modified: cfe/trunk/test/Preprocessor/if_warning.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/if_warning.c?rev=101580&r1=101579&r2=101580&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/if_warning.c (original)
+++ cfe/trunk/test/Preprocessor/if_warning.c Fri Apr 16 18:44:05 2010
@@ -19,3 +19,9 @@
#else 1 // Should not warn due to C99 6.10p4
#endif
#endif
+
+
+// PR6852
+#if 'somesillylongthing' // expected-warning {{character constant too long for its type}} \
+ // expected-warning {{multi-character character constant}}
+#endif
More information about the cfe-commits
mailing list