From b98cf79a3add5c80b40a956a4cd3d9b3a23b9b22 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sun, 5 May 2013 18:24:05 +0000 Subject: Use lexical contexts when checking for conflicting language linkages. This fixes pr14958. I will audit other calls to isExternCContext to see if there are any similar bugs left. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181163 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 4 ++-- test/SemaCXX/linkage-spec.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 7b332f9fda..b5e2c6ebe8 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2247,10 +2247,10 @@ static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New) { LanguageLinkage OldLinkage = Old->getLanguageLinkage(); if (OldLinkage == CXXLanguageLinkage && - New->getDeclContext()->isExternCContext()) + New->getLexicalDeclContext()->isExternCContext()) return true; if (OldLinkage == CLanguageLinkage && - New->getDeclContext()->isExternCXXContext()) + New->getLexicalDeclContext()->isExternCXXContext()) return true; return false; } diff --git a/test/SemaCXX/linkage-spec.cpp b/test/SemaCXX/linkage-spec.cpp index 0ba9508124..504df0d35c 100644 --- a/test/SemaCXX/linkage-spec.cpp +++ b/test/SemaCXX/linkage-spec.cpp @@ -106,3 +106,11 @@ namespace PR9162 { return sizeof(ArtsSink); } } + +namespace pr14958 { + namespace js { extern int ObjectClass; } + extern "C" { + namespace js {} + } + int js::ObjectClass; +} -- cgit v1.2.3-18-g5258