]> granicus.if.org Git - clang/commitdiff
warn about long long when in c89 mode.
authorChris Lattner <sabre@nondot.org>
Tue, 28 Aug 2007 16:40:32 +0000 (16:40 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 28 Aug 2007 16:40:32 +0000 (16:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41543 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaType.cpp
include/clang/Basic/DiagnosticKinds.def
test/Sema/c89.c

index 17ab64a196290bbf730ce89d93db12182071d40d..bbf8457acff3a68ac8de96deab20efc59cbe41ee 100644 (file)
@@ -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 @@ static QualType ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) {
 /// 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.
index e8b4dab25b2849a90cf1029353d7a8301890bdd2..dbf1b270a093b0bdf3c2c7d44f839d7b54303a5b 100644 (file)
@@ -438,6 +438,8 @@ DIAG(err_invalid_long_spec, ERROR,
      "'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,
index 57085db64460586f328204d71a32062566334938..a78472222a8c918012770a9fc37550e7de894491 100644 (file)
@@ -17,3 +17,6 @@ void foo() {
     __extension__ int j; /* expected-warning {{mixing declarations and code}} */
   }
 }
+
+long long x;   /* expected-warning {{extension}} */
+