Ensure we diagnose long long literals in C90 mode.

llvm-svn: 41581
This commit is contained in:
Neil Booth 2007-08-29 22:00:19 +00:00
parent 4e5f99da6c
commit ac582c5ecb
3 changed files with 15 additions and 0 deletions

View 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.

View 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);

View 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