[clang] [clang][ASTImporter] Fix import of variable template redeclarations. (PR #72841)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 9 03:41:53 PST 2024
=?utf-8?q?Balázs_Kéri?= <balazs.keri at ericsson.com>,
=?utf-8?q?Balázs_Kéri?= <balazs.keri at ericsson.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/72841 at github.com>
================
@@ -6245,17 +6245,21 @@ ExpectedDecl ASTNodeImporter::VisitVarTemplateDecl(VarTemplateDecl *D) {
D->getTemplatedDecl()))
continue;
if (IsStructuralMatch(D, FoundTemplate)) {
- // The Decl in the "From" context has a definition, but in the
- // "To" context we already have a definition.
+ // FIXME Check for ODR error if the two definitions have
+ // different initializers?
VarTemplateDecl *FoundDef = getTemplateDefinition(FoundTemplate);
- if (D->isThisDeclarationADefinition() && FoundDef)
- // FIXME Check for ODR error if the two definitions have
- // different initializers?
- return Importer.MapImported(D, FoundDef);
- if (FoundTemplate->getDeclContext()->isRecord() &&
- D->getDeclContext()->isRecord())
- return Importer.MapImported(D, FoundTemplate);
-
+ if (D->getDeclContext()->isRecord()) {
+ assert(FoundTemplate->getDeclContext()->isRecord() &&
+ "Member variable template imported as non-member, "
+ "inconsistent imported AST?");
----------------
NagyDonat wrote:
Why is this assert always valid? I thought about this for some time and I couldn't rule out that this would crash on some tricky code.
https://github.com/llvm/llvm-project/pull/72841
More information about the cfe-commits
mailing list