forked from OSchip/llvm-project
[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:
parent
57a6e1321f
commit
90717ad731
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
typedef struct { int x; } TypedefStructHidden_t;
|
|
@ -0,0 +1 @@
|
|||
typedef struct { int x; } TypedefStructVisible_t;
|
|
@ -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}}
|
Loading…
Reference in New Issue