]> granicus.if.org Git - clang/commitdiff
Disable the "'extern' variable has an initializer" warning in C++,
authorDouglas Gregor <dgregor@apple.com>
Mon, 19 Apr 2010 21:31:25 +0000 (21:31 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 19 Apr 2010 21:31:25 +0000 (21:31 +0000)
since it makes sense there to have const extern variables. Fixes
PR6495.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101818 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/storage-class.cpp [new file with mode: 0644]

index 182a85aee80f636303de73740ab0272c60aa1738..045b3e8c381e8d7cb1bf25a6c99e6dc2ce1438ca 100644 (file)
@@ -3818,7 +3818,8 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
       }
     }
   } 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);
diff --git a/test/SemaCXX/storage-class.cpp b/test/SemaCXX/storage-class.cpp
new file mode 100644 (file)
index 0000000..a31e67b
--- /dev/null
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+extern const int PR6495 = 42;