From: Richard Smith Date: Fri, 10 Oct 2014 22:37:41 +0000 (+0000) Subject: [modules] Delay loading the field declared with an anonymous tag declaration X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=105139cb4f5d7f2f38a99e8e6d7126f7e3325053;p=clang [modules] Delay loading the field declared with an anonymous tag declaration until after we've had a chance to merge that tag. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219539 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 93cd932a61..51d930073d 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -535,7 +535,7 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitTagDecl(TagDecl *TD) { TypedefNameForLinkage = Reader.GetIdentifierInfo(F, Record, Idx); break; case 3: // DeclaratorForAnonDecl - TD->NamedDeclOrQualifier = ReadDeclAs(Record, Idx); + NamedDeclForTagDecl = ReadDeclID(Record, Idx); break; default: llvm_unreachable("unexpected tag info kind"); diff --git a/test/Modules/Inputs/cxx-templates-a.h b/test/Modules/Inputs/cxx-templates-a.h index c2ce74d195..92333b377a 100644 --- a/test/Modules/Inputs/cxx-templates-a.h +++ b/test/Modules/Inputs/cxx-templates-a.h @@ -89,3 +89,11 @@ typedef PartiallyInstantiatePartialSpec PartiallyInstantiatePartialSpecHel void InstantiateWithAliasTemplate(WithAliasTemplate::X); inline int InstantiateWithAnonymousDeclsA(WithAnonymousDecls x) { return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e; } inline int InstantiateWithAnonymousDeclsB2(WithAnonymousDecls x); + + +template +struct MergeAnonUnionMember { + MergeAnonUnionMember() { (void)values.t1; } + union { int t1; } values; +}; +inline MergeAnonUnionMember<> maum_a() { return {}; } diff --git a/test/Modules/Inputs/cxx-templates-c.h b/test/Modules/Inputs/cxx-templates-c.h index 6daffadc6c..6b4c506670 100644 --- a/test/Modules/Inputs/cxx-templates-c.h +++ b/test/Modules/Inputs/cxx-templates-c.h @@ -11,3 +11,10 @@ template struct MergeTemplateDefinitions { static constexpr int g(); }; template constexpr int MergeTemplateDefinitions::g() { return 2; } + +template +struct MergeAnonUnionMember { + MergeAnonUnionMember() { (void)values.t1; } + union { int t1; } values; +}; +inline MergeAnonUnionMember<> maum_c() { return {}; } diff --git a/test/Modules/cxx-templates.cpp b/test/Modules/cxx-templates.cpp index 3833e995c5..b299233665 100644 --- a/test/Modules/cxx-templates.cpp +++ b/test/Modules/cxx-templates.cpp @@ -144,6 +144,8 @@ MergeSpecializations::explicitly_specialized_in_b spec_in_b_2; MergeSpecializations::explicitly_specialized_in_c spec_in_c_2; #endif +MergeAnonUnionMember<> maum_main; + using AliasTemplateMergingTest = WithAliasTemplate::X; int AnonymousDeclsMergingTest(WithAnonymousDecls WAD, WithAnonymousDecls WADC) {