aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-22 14:36:26 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-22 14:36:26 +0000
commit66dd9394994654b5af2c62ed24f311432bacede5 (patch)
treef29812b6e320315bed17540c5dcf608051c4956d
parent050b78acf11900cb8c47563376200a1d7bd97f59 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102066 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDecl.cpp6
-rw-r--r--test/SemaCXX/storage-class.cpp1
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 8fce6393c6..c9001f1030 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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;
diff --git a/test/SemaCXX/storage-class.cpp b/test/SemaCXX/storage-class.cpp
index 4025595de1..a2e206323a 100644
--- a/test/SemaCXX/storage-class.cpp
+++ b/test/SemaCXX/storage-class.cpp
@@ -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};