[cfe-commits] r101818 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/storage-class.cpp

Douglas Gregor dgregor at apple.com
Mon Apr 19 14:31:25 PDT 2010


Author: dgregor
Date: Mon Apr 19 16:31:25 2010
New Revision: 101818

URL: http://llvm.org/viewvc/llvm-project?rev=101818&view=rev
Log:
Disable the "'extern' variable has an initializer" warning in C++,
since it makes sense there to have const extern variables. Fixes
PR6495.

Added:
    cfe/trunk/test/SemaCXX/storage-class.cpp
Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=101818&r1=101817&r2=101818&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Apr 19 16:31:25 2010
@@ -3818,7 +3818,8 @@
       }
     }
   } else if (VDecl->isFileVarDecl()) {
-    if (VDecl->getStorageClass() == VarDecl::Extern)
+    if (VDecl->getStorageClass() == VarDecl::Extern && 
+        !getLangOptions().CPlusPlus)
       Diag(VDecl->getLocation(), diag::warn_extern_init);
     if (!VDecl->isInvalidDecl()) {
       InitializationSequence InitSeq(*this, Entity, Kind, &Init, 1);

Added: cfe/trunk/test/SemaCXX/storage-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/storage-class.cpp?rev=101818&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/storage-class.cpp (added)
+++ cfe/trunk/test/SemaCXX/storage-class.cpp Mon Apr 19 16:31:25 2010
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+extern const int PR6495 = 42;





More information about the cfe-commits mailing list