]> granicus.if.org Git - clang/commitdiff
Ensure we diagnose long long literals in C90 mode.
authorNeil Booth <neil@daikokuya.co.uk>
Wed, 29 Aug 2007 22:00:19 +0000 (22:00 +0000)
committerNeil Booth <neil@daikokuya.co.uk>
Wed, 29 Aug 2007 22:00:19 +0000 (22:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41581 91177308-0d34-0410-b5e6-96231b3b80d8

Lex/PPExpressions.cpp
Sema/SemaExpr.cpp
test/Sema/c89.c

index 590c0eeeeff3047ea8698e5cee5914023f3133b1..6793a0123ca47da91edf868466265a1b50e33e3c 100644 (file)
@@ -167,6 +167,11 @@ static bool EvaluateValue(llvm::APSInt &Result, Token &PeekTok,
     }
     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.
index b613cd90a2c64b179fe2cd4b1d3c93ff896d254c..272fc6f93db244ca0fdac3c30b773e952b2fbcfe 100644 (file)
@@ -156,6 +156,11 @@ Action::ExprResult Sema::ParseNumericConstant(const Token &Tok) {
   } 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);
    
index a5855b21d00340f42f4359a382715b363e7153d8..2c1adcf959d08f467eb3f51346eedcb08f0869da 100644 (file)
@@ -24,3 +24,8 @@ long long test2;   /* expected-warning {{extension}} */
 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