[cfe-commits] r41581 - in /cfe/trunk: Lex/PPExpressions.cpp Sema/SemaExpr.cpp test/Sema/c89.c
Neil Booth
neil at daikokuya.co.uk
Wed Aug 29 15:00:19 PDT 2007
Author: neil
Date: Wed Aug 29 17:00:19 2007
New Revision: 41581
URL: http://llvm.org/viewvc/llvm-project?rev=41581&view=rev
Log:
Ensure we diagnose long long literals in C90 mode.
Modified:
cfe/trunk/Lex/PPExpressions.cpp
cfe/trunk/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/c89.c
Modified: cfe/trunk/Lex/PPExpressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/PPExpressions.cpp?rev=41581&r1=41580&r2=41581&view=diff
==============================================================================
--- cfe/trunk/Lex/PPExpressions.cpp (original)
+++ cfe/trunk/Lex/PPExpressions.cpp Wed Aug 29 17:00:19 2007
@@ -167,6 +167,11 @@
}
assert(Literal.isIntegerLiteral() && "Unknown ppnumber");
+ // long long is a C99 feature.
+ if (!PP.getLangOptions().C99 && !PP.getLangOptions().CPlusPlus0x
+ && Literal.isLongLong)
+ PP.Diag(PeekTok, diag::ext_longlong);
+
// Parse the integer literal into Result.
if (Literal.GetIntegerValue(Result)) {
// Overflow parsing integer literal.
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=41581&r1=41580&r2=41581&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Wed Aug 29 17:00:19 2007
@@ -156,6 +156,11 @@
} else {
QualType t;
+ // long long is a C99 feature.
+ if (!getLangOptions().C99 && !getLangOptions().CPlusPlus0x &&
+ Literal.isLongLong)
+ Diag(Tok.getLocation(), diag::ext_longlong);
+
// Get the value in the widest-possible width.
llvm::APInt ResultVal(Context.Target.getIntMaxTWidth(Tok.getLocation()), 0);
Modified: cfe/trunk/test/Sema/c89.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/c89.c?rev=41581&r1=41580&r2=41581&view=diff
==============================================================================
--- cfe/trunk/test/Sema/c89.c (original)
+++ cfe/trunk/test/Sema/c89.c Wed Aug 29 17:00:19 2007
@@ -24,3 +24,8 @@
void test3(int i) {
int A[i]; /* expected-warning {{variable length array}} */
}
+
+int test4 = 0LL; /* expected-warning {{long long}} */
+
+#if 1LL /* expected-warning {{long long}} */
+#endif
More information about the cfe-commits
mailing list