forked from OSchip/llvm-project
[modules] If we load two declarations with typedef names for linkage purposes
on top of a local declaration of the same entity, we still need to remember that we loaded the first one or we may fail to merge the second one properly. llvm-svn: 226765
This commit is contained in:
parent
00270df517
commit
f1f4bc2176
|
@ -2554,15 +2554,21 @@ static DeclContext *getPrimaryContextForMerging(DeclContext *DC) {
|
|||
}
|
||||
|
||||
ASTDeclReader::FindExistingResult::~FindExistingResult() {
|
||||
// Record that we had a typedef name for linkage whether or not we merge
|
||||
// with that declaration.
|
||||
if (TypedefNameForLinkage) {
|
||||
DeclContext *DC = New->getDeclContext()->getRedeclContext();
|
||||
Reader.ImportedTypedefNamesForLinkage.insert(
|
||||
std::make_pair(std::make_pair(DC, TypedefNameForLinkage), New));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AddResult || Existing)
|
||||
return;
|
||||
|
||||
DeclarationName Name = New->getDeclName();
|
||||
DeclContext *DC = New->getDeclContext()->getRedeclContext();
|
||||
if (TypedefNameForLinkage) {
|
||||
Reader.ImportedTypedefNamesForLinkage.insert(
|
||||
std::make_pair(std::make_pair(DC, TypedefNameForLinkage), New));
|
||||
} else if (!Name) {
|
||||
if (!Name) {
|
||||
assert(needsAnonymousDeclarationNumber(New));
|
||||
setAnonymousDeclForMerging(Reader, New->getLexicalDeclContext(),
|
||||
AnonymousDeclNumber, New);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
typedef union {} pthread_mutex_t;
|
|
@ -0,0 +1 @@
|
|||
typedef union {} pthread_mutex_t;
|
|
@ -0,0 +1,2 @@
|
|||
module a { header "a.h" export * }
|
||||
module b { header "b.h" export * }
|
|
@ -0,0 +1,8 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-name-for-linkage -verify %s
|
||||
// expected-no-diagnostics
|
||||
typedef union {} pthread_mutex_t;
|
||||
#include "a.h"
|
||||
pthread_mutex_t x;
|
||||
#include "b.h"
|
||||
pthread_mutex_t y;
|
Loading…
Reference in New Issue