From: Neil Booth Date: Wed, 29 Aug 2007 22:00:19 +0000 (+0000) Subject: Ensure we diagnose long long literals in C90 mode. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b94495155dd551ee81ad0c1865acd9ff1bbd632d;p=clang Ensure we diagnose long long literals in C90 mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41581 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Lex/PPExpressions.cpp b/Lex/PPExpressions.cpp index 590c0eeeef..6793a0123c 100644 --- a/Lex/PPExpressions.cpp +++ b/Lex/PPExpressions.cpp @@ -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. diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index b613cd90a2..272fc6f93d 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -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); diff --git a/test/Sema/c89.c b/test/Sema/c89.c index a5855b21d0..2c1adcf959 100644 --- a/test/Sema/c89.c +++ b/test/Sema/c89.c @@ -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