forked from OSchip/llvm-project
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:
parent
73519609d4
commit
fceea36501
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
Loading…
Reference in New Issue