From 66c42d443982a0891ce58deb7391d641ca87adc5 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 15 Oct 2010 01:21:46 +0000 Subject: [PATCH] Don't complain about a variable within a linkage-specification that is initialized. Fixes PR7076. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116553 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 2 +- test/SemaCXX/linkage-spec.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 93909f995d..4a834cd560 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4339,7 +4339,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) { } } } else if (VDecl->isFileVarDecl()) { - if (VDecl->getStorageClass() == SC_Extern && + if (VDecl->getStorageClassAsWritten() == SC_Extern && (!getLangOptions().CPlusPlus || !Context.getBaseElementType(VDecl->getType()).isConstQualified())) Diag(VDecl->getLocation(), diag::warn_extern_init); diff --git a/test/SemaCXX/linkage-spec.cpp b/test/SemaCXX/linkage-spec.cpp index 86c3d3e87a..b5a10a795e 100644 --- a/test/SemaCXX/linkage-spec.cpp +++ b/test/SemaCXX/linkage-spec.cpp @@ -86,3 +86,6 @@ namespace N { } extern "C++" using N::value; + +// PR7076 +extern "C" const char *Version_string = "2.9"; -- 2.40.0