warn about long long when in c89 mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41543 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaType.cpp b/Sema/SemaType.cpp
index 17ab64a..bbf8457 100644
--- a/Sema/SemaType.cpp
+++ b/Sema/SemaType.cpp
@@ -16,6 +16,7 @@
#include "clang/AST/Decl.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Lex/IdentifierTable.h"
+#include "clang/Basic/LangOptions.h"
using namespace clang;
/// ConvertDeclSpecToType - Convert the specified declspec to the appropriate
@@ -122,6 +123,11 @@
/// GetTypeForDeclarator - Convert the type for the specified declarator to Type
/// instances.
QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
+ // long long is a C99 feature.
+ if (!getLangOptions().C99 &&
+ D.getDeclSpec().getTypeSpecWidth() == DeclSpec::TSW_longlong)
+ Diag(D.getDeclSpec().getTypeSpecWidthLoc(), diag::ext_longlong);
+
QualType T = ConvertDeclSpecToType(D.getDeclSpec(), Context);
// Apply const/volatile/restrict qualifiers to T.
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index e8b4dab..dbf1b27 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -438,6 +438,8 @@
"'long %0' is invalid")
DIAG(err_invalid_longlong_spec, ERROR,
"'long long %0' is invalid")
+DIAG(ext_longlong, EXTENSION,
+ "'long long' is an extension when C99 mode is not enabled")
DIAG(err_invalid_complex_spec, ERROR,
"'_Complex %0' is invalid")
DIAG(err_invalid_thread_spec, ERROR,
diff --git a/test/Sema/c89.c b/test/Sema/c89.c
index 57085db..a784722 100644
--- a/test/Sema/c89.c
+++ b/test/Sema/c89.c
@@ -17,3 +17,6 @@
__extension__ int j; /* expected-warning {{mixing declarations and code}} */
}
}
+
+long long x; /* expected-warning {{extension}} */
+