[cfe-commits] r102066 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/storage-class.cpp
Douglas Gregor
dgregor at apple.com
Thu Apr 22 07:36:26 PDT 2010
Author: dgregor
Date: Thu Apr 22 09:36:26 2010
New Revision: 102066
URL: http://llvm.org/viewvc/llvm-project?rev=102066&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/storage-class.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=102066&r1=102065&r2=102066&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Apr 22 09:36:26 2010
@@ -3856,7 +3856,8 @@
}
} 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 @@
// Check whether the member was user-declared.
switch (member) {
+ case CXXInvalid:
+ break;
+
case CXXConstructor:
if (RD->hasUserDeclaredConstructor()) {
typedef CXXRecordDecl::ctor_iterator ctor_iter;
Modified: cfe/trunk/test/SemaCXX/storage-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/storage-class.cpp?rev=102066&r1=102065&r2=102066&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/storage-class.cpp (original)
+++ cfe/trunk/test/SemaCXX/storage-class.cpp Thu Apr 22 09:36:26 2010
@@ -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};
More information about the cfe-commits
mailing list