diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-01-03 02:34:35 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-01-03 02:34:35 +0000 |
commit | 99f54799d1e44ae06a5851ec15cb43b1ac841c9f (patch) | |
tree | 85240448ceac1614291a3eef6e63d03f23ddf08c /clang/lib | |
parent | dd74d83f849a65410b251eefec0ed4da1ec8c7df (diff) | |
download | bcm5719-llvm-99f54799d1e44ae06a5851ec15cb43b1ac841c9f.tar.gz bcm5719-llvm-99f54799d1e44ae06a5851ec15cb43b1ac841c9f.zip |
PR35697: look at the first declaration when determining whether a function or
variable is extern "C" in linkage calculations.
llvm-svn: 321686
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 4c1d591b41e..918466236bf 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -779,7 +779,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D, // unique-external linkage, it's not legally usable from outside // this translation unit. However, we should use the C linkage // rules instead for extern "C" declarations. - if (Context.getLangOpts().CPlusPlus && !Function->isInExternCContext()) { + if (Context.getLangOpts().CPlusPlus && !isFirstInExternCContext(Function)) { // Only look at the type-as-written. Otherwise, deducing the return type // of a function could change its linkage. QualType TypeAsWritten = Function->getType(); @@ -1165,7 +1165,7 @@ LinkageInfo LinkageComputer::getLVForLocalDecl(const NamedDecl *D, LVComputationKind computation) { if (const auto *Function = dyn_cast<FunctionDecl>(D)) { if (Function->isInAnonymousNamespace() && - !Function->isInExternCContext()) + !isFirstInExternCContext(Function)) return getInternalLinkageFor(Function); // This is a "void f();" which got merged with a file static. @@ -1188,7 +1188,7 @@ LinkageInfo LinkageComputer::getLVForLocalDecl(const NamedDecl *D, if (const auto *Var = dyn_cast<VarDecl>(D)) { if (Var->hasExternalStorage()) { - if (Var->isInAnonymousNamespace() && !Var->isInExternCContext()) + if (Var->isInAnonymousNamespace() && !isFirstInExternCContext(Var)) return getInternalLinkageFor(Var); LinkageInfo LV; |