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

Douglas Gregor dgregor at apple.com
Mon Apr 19 15:34:40 PDT 2010


Author: dgregor
Date: Mon Apr 19 17:34:40 2010
New Revision: 101821

URL: http://llvm.org/viewvc/llvm-project?rev=101821&view=rev
Log:
Only suppress the "extern variable has an initializer" warning when the extern entity being initialized is const.

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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=101821&r1=101820&r2=101821&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Apr 19 17:34:40 2010
@@ -3819,7 +3819,7 @@
     }
   } else if (VDecl->isFileVarDecl()) {
     if (VDecl->getStorageClass() == VarDecl::Extern && 
-        !getLangOptions().CPlusPlus)
+        (!getLangOptions().CPlusPlus || !VDecl->getType().isConstQualified()))
       Diag(VDecl->getLocation(), diag::warn_extern_init);
     if (!VDecl->isInvalidDecl()) {
       InitializationSequence InitSeq(*this, Entity, Kind, &Init, 1);

Modified: cfe/trunk/test/SemaCXX/storage-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/storage-class.cpp?rev=101821&r1=101820&r2=101821&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/storage-class.cpp (original)
+++ cfe/trunk/test/SemaCXX/storage-class.cpp Mon Apr 19 17:34:40 2010
@@ -1,2 +1,3 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-extern const int PR6495 = 42;
+extern const int PR6495a = 42;
+extern int PR6495b = 42; // expected-warning{{'extern' variable has an initializer}}





More information about the cfe-commits mailing list