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

llvm-svn: 101821
This commit is contained in:
Douglas Gregor 2010-04-19 22:34:40 +00:00
parent e637ff5e9a
commit f4cd8f4ece
2 changed files with 3 additions and 2 deletions

View File

@ -3819,7 +3819,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
}
} 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);

View File

@ -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}}