Only suppress the "extern variable has an initializer" warning when the extern entity being initialized is const.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101821 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 045b3e8..115b7bf 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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);
diff --git a/test/SemaCXX/storage-class.cpp b/test/SemaCXX/storage-class.cpp
index a31e67b..4025595 100644
--- a/test/SemaCXX/storage-class.cpp
+++ b/test/SemaCXX/storage-class.cpp
@@ -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}}