diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-11-04 19:26:32 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-11-04 19:26:32 +0000 |
commit | 2dbe4043e8f54578bd21e766c99986ac464516ec (patch) | |
tree | d2ce18b29c8b6247ef8cf4c7ff3b3b38544dd933 /clang/lib/Sema/SemaLookup.cpp | |
parent | 337675b8915f51f088a49aff987715324ad44f00 (diff) | |
download | bcm5719-llvm-2dbe4043e8f54578bd21e766c99986ac464516ec.tar.gz bcm5719-llvm-2dbe4043e8f54578bd21e766c99986ac464516ec.zip |
[modules] Generalize the workaround for multiple ambiguous definitions of
internal linkage entities in different modules from r250884 to apply to all
names, not just function names.
This is really awkward: we don't want to merge internal-linkage symbols from
separate modules, because they might not actually be defining the same entity.
But we don't want to reject programs that use such an ambiguous symbol if those
internal-linkage symbols are in fact equivalent. For now, we're resolving the
ambiguity by picking one of the equivalent definitions as an extension.
llvm-svn: 252063
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 66cfada9f43..a020dcf14d6 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -463,8 +463,11 @@ void LookupResult::resolveKind() { llvm::SmallDenseMap<QualType, unsigned, 16> UniqueTypes; bool Ambiguous = false; - bool HasTag = false, HasFunction = false, HasNonFunction = false; + bool HasTag = false, HasFunction = false; bool HasFunctionTemplate = false, HasUnresolved = false; + NamedDecl *HasNonFunction = nullptr; + + llvm::SmallVector<NamedDecl*, 4> EquivalentNonFunctions; unsigned UniqueTagIndex = 0; @@ -533,9 +536,21 @@ void LookupResult::resolveKind() { } else if (isa<FunctionDecl>(D)) { HasFunction = true; } else { - if (HasNonFunction) + if (HasNonFunction) { + // If we're about to create an ambiguity between two declarations that + // are equivalent, but one is an internal linkage declaration from one + // module and the other is an internal linkage declaration from another + // module, just skip it. + if (getSema().isEquivalentInternalLinkageDeclaration(HasNonFunction, + D)) { + EquivalentNonFunctions.push_back(D); + Decls[I] = Decls[--N]; + continue; + } + Ambiguous = true; - HasNonFunction = true; + } + HasNonFunction = D; } I++; } @@ -558,6 +573,12 @@ void LookupResult::resolveKind() { Ambiguous = true; } + // FIXME: This diagnostic should really be delayed until we're done with + // the lookup result, in case the ambiguity is resolved by the caller. + if (!EquivalentNonFunctions.empty() && !Ambiguous) + getSema().diagnoseEquivalentInternalLinkageDeclarations( + getNameLoc(), HasNonFunction, EquivalentNonFunctions); + Decls.set_size(N); if (HasNonFunction && (HasFunction || HasUnresolved)) |