[cfe-commits] r41543 - in /cfe/trunk: Sema/SemaType.cpp include/clang/Basic/DiagnosticKinds.def test/Sema/c89.c

Chris Lattner sabre at nondot.org
Tue Aug 28 09:40:32 PDT 2007


Author: lattner
Date: Tue Aug 28 11:40:32 2007
New Revision: 41543

URL: http://llvm.org/viewvc/llvm-project?rev=41543&view=rev
Log:
warn about long long when in c89 mode.

Modified:
    cfe/trunk/Sema/SemaType.cpp
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/test/Sema/c89.c

Modified: cfe/trunk/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaType.cpp?rev=41543&r1=41542&r2=41543&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/trunk/Sema/SemaType.cpp Tue Aug 28 11:40:32 2007
@@ -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.

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=41543&r1=41542&r2=41543&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Tue Aug 28 11:40:32 2007
@@ -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,

Modified: cfe/trunk/test/Sema/c89.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/c89.c?rev=41543&r1=41542&r2=41543&view=diff

==============================================================================
--- cfe/trunk/test/Sema/c89.c (original)
+++ cfe/trunk/test/Sema/c89.c Tue Aug 28 11:40:32 2007
@@ -17,3 +17,6 @@
     __extension__ int j; /* expected-warning {{mixing declarations and code}} */
   }
 }
+
+long long x;   /* expected-warning {{extension}} */
+





More information about the cfe-commits mailing list