]> granicus.if.org Git - clang/commitdiff
When checking whether to diagnose an initialized "extern" variable,
authorDouglas Gregor <dgregor@apple.com>
Thu, 22 Apr 2010 14:36:26 +0000 (14:36 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 22 Apr 2010 14:36:26 +0000 (14:36 +0000)
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

lib/Sema/SemaDecl.cpp
test/SemaCXX/storage-class.cpp

index 8fce6393c646f0fe4283d817295b4a66df657d4f..c9001f10303a9e80fcab2d19d93ecb98ef6f2a71 100644 (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;
index 4025595de12bfcef904abf3b5bf809f5ec27633b..a2e206323a0741c2e3a4eba3db7b44768830c5ea 100644 (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};