[modules] Allow "redefinition" of typedef of anon tag from unimported submodule

r233345 started being stricter about typedef names for linkage purposes
in non-visible modules, but broke languages without the ODR.

rdar://23527954

llvm-svn: 253123
This commit is contained in:
Ben Langmuir 2015-11-14 03:26:14 +00:00
parent 57a6e1321f
commit 90717ad731
7 changed files with 22 additions and 3 deletions

View File

@ -1256,7 +1256,8 @@ static LinkageInfo computeLVForDecl(const NamedDecl *D,
case Decl::TypeAlias:
// A typedef declaration has linkage if it gives a type a name for
// linkage purposes.
if (!cast<TypedefNameDecl>(D)
if (!D->getASTContext().getLangOpts().CPlusPlus ||
!cast<TypedefNameDecl>(D)
->getAnonDeclWithTypedefName(/*AnyRedecl*/true))
return LinkageInfo::none();
break;

View File

@ -1829,7 +1829,8 @@ static void filterNonConflictingPreviousTypedefDecls(Sema &S,
// If both declarations give a tag declaration a typedef name for linkage
// purposes, then they declare the same entity.
if (OldTD->getAnonDeclWithTypedefName(/*AnyRedecl*/true) &&
if (S.getLangOpts().CPlusPlus &&
OldTD->getAnonDeclWithTypedefName(/*AnyRedecl*/true) &&
Decl->getAnonDeclWithTypedefName())
continue;
}

View File

@ -119,7 +119,7 @@ int test_multi_declaration(void) {
// CHECK: usrs.m c:@SA@MyStruct Extent=[15:9 - 18:2]
// CHECK: usrs.m c:@SA@MyStruct@FI@wa Extent=[16:3 - 16:9]
// CHECK: usrs.m c:@SA@MyStruct@FI@moo Extent=[17:3 - 17:10]
// CHECK: usrs.m c:@T@MyStruct Extent=[15:1 - 18:11]
// CHECK: usrs.m c:usrs.m@T@MyStruct Extent=[15:1 - 18:11]
// CHECK: usrs.m c:@E@Pizza Extent=[20:1 - 23:2]
// CHECK: usrs.m c:@E@Pizza@CHEESE Extent=[21:3 - 21:9]
// CHECK: usrs.m c:@E@Pizza@MUSHROOMS Extent=[22:3 - 22:12]

View File

@ -379,3 +379,10 @@ module DebugSubmodules {
module ExtensionTestA {
header "ExtensionTestA.h"
}
module TypedefTag {
header "typedef-tag.h"
explicit module Hidden {
header "typedef-tag-hidden.h"
}
}

View File

@ -0,0 +1 @@
typedef struct { int x; } TypedefStructHidden_t;

View File

@ -0,0 +1 @@
typedef struct { int x; } TypedefStructVisible_t;

View File

@ -0,0 +1,8 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify
@import TypedefTag;
typedef struct { int x; } TypedefStructHidden_t;
typedef struct { int x; } TypedefStructVisible_t; // expected-error{{typedef redefinition}}
// expected-note@typedef-tag.h:1 {{here}}