When checking whether to diagnose an initialized "extern" variable,

look for the const on the base type rather than on the top-level
type. Fixes PR6495 properly.

llvm-svn: 102066
This commit is contained in:
Douglas Gregor 2010-04-22 14:36:26 +00:00
parent 73519609d4
commit fceea36501
2 changed files with 6 additions and 1 deletions

View File

@ -3856,7 +3856,8 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
}
} else if (VDecl->isFileVarDecl()) {
if (VDecl->getStorageClass() == VarDecl::Extern &&
(!getLangOptions().CPlusPlus || !VDecl->getType().isConstQualified()))
(!getLangOptions().CPlusPlus ||
!Context.getBaseElementType(VDecl->getType()).isConstQualified()))
Diag(VDecl->getLocation(), diag::warn_extern_init);
if (!VDecl->isInvalidDecl()) {
InitializationSequence InitSeq(*this, Entity, Kind, &Init, 1);
@ -5667,6 +5668,9 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) {
// Check whether the member was user-declared.
switch (member) {
case CXXInvalid:
break;
case CXXConstructor:
if (RD->hasUserDeclaredConstructor()) {
typedef CXXRecordDecl::ctor_iterator ctor_iter;

View File

@ -1,3 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
extern const int PR6495a = 42;
extern int PR6495b = 42; // expected-warning{{'extern' variable has an initializer}}
extern const int PR6495c[] = {42,43,44};