[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/MatzeB closed https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
yuxuanchen1997 wrote: I have made the suggested changes and this is ready for another round of review. https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/yuxuanchen1997 updated https://github.com/llvm/llvm-project/pull/72346 >From 739f1802bbfa4a7dc454e24535423b64701ac500 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 20:52:21 -0800 Subject: [PATCH 1/8] [Clang] Fix ICE caused by mishandling template specialization in instantiation lookup --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 011356e08a04297..2ef0986dd4d2235 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6211,9 +6211,8 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, ClassTemplateDecl *ClassTemplate = Record->getDescribedClassTemplate(); if (ClassTemplate) ClassTemplate = ClassTemplate->getCanonicalDecl(); -else if (ClassTemplatePartialSpecializationDecl *PartialSpec - = dyn_cast(Record)) - ClassTemplate = PartialSpec->getSpecializedTemplate()->getCanonicalDecl(); +else if (ClassTemplateSpecializationDecl *Spec = dyn_cast(Record)) + ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl(); // Walk the current context to find either the record or an instantiation of // it. >From 9f823a95f56dd743421886f348bb10451e509cf1 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 20:55:10 -0800 Subject: [PATCH 2/8] formatting --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 2ef0986dd4d2235..07b3488a21e670b 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6211,7 +6211,8 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, ClassTemplateDecl *ClassTemplate = Record->getDescribedClassTemplate(); if (ClassTemplate) ClassTemplate = ClassTemplate->getCanonicalDecl(); -else if (ClassTemplateSpecializationDecl *Spec = dyn_cast(Record)) +else if (ClassTemplateSpecializationDecl *Spec = + dyn_cast(Record)) ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl(); // Walk the current context to find either the record or an instantiation of >From 0b0c94bbce2e02d5ddebc961d991274bae03f8ef Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 21:04:00 -0800 Subject: [PATCH 3/8] Provide test case --- .../member-template-specialization.cpp| 31 +++ 1 file changed, 31 insertions(+) create mode 100644 clang/test/SemaCXX/member-template-specialization.cpp diff --git a/clang/test/SemaCXX/member-template-specialization.cpp b/clang/test/SemaCXX/member-template-specialization.cpp new file mode 100644 index 000..baf5bd6ae7bb544 --- /dev/null +++ b/clang/test/SemaCXX/member-template-specialization.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s +// Verify that the inner template specialization can be found + +template +struct S { + static void bar() { +Ty t; +t.foo(); + } + + static void take(Ty&) {} +}; + +template +struct Outer { + template + struct Inner; + + using U = S>; + + template <> + struct Inner { +void foo() { + U::take(*this); +} + }; +}; + +int main() { + Outer::U::bar(); +} >From 3cddae9a22c67e43456c5ff4e682b208c0b727b9 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 21:13:23 -0800 Subject: [PATCH 4/8] missing expected-no-diagnostics --- clang/test/SemaCXX/member-template-specialization.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/test/SemaCXX/member-template-specialization.cpp b/clang/test/SemaCXX/member-template-specialization.cpp index baf5bd6ae7bb544..29d46ec9c1e44fc 100644 --- a/clang/test/SemaCXX/member-template-specialization.cpp +++ b/clang/test/SemaCXX/member-template-specialization.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify -fsyntax-only %s +// expected-no-diagnostics + // Verify that the inner template specialization can be found template >From 52820b186c733ef52c464094395c0b1f3f7c3a00 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Wed, 15 Nov 2023 10:10:02 -0800 Subject: [PATCH 5/8] change stale comment --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 07b3488a21e670b..08f4ba00fc9f7de 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6207,7 +6207,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, return D; // Determine whether this record is
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
bcardosolopes wrote: I'm not 100% confident here but the fix makes sense and seems good (nice testcase!). https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
erichkeane wrote: > Thanks for the review, @erichkeane. I am wondering what you mean by this > needs "release note"? Ah, yes! See `docs/ReleaseNotes.rst`. For each new bug fix (and most patches!) we require an entry into our release notes document. https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
yuxuanchen1997 wrote: Thanks for the review, @erichkeane. I am wondering what you mean by this needs "release note"? https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
@@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s yuxuanchen1997 wrote: gotcha, will do. https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
@@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s erichkeane wrote: Typically we find a similar test file and put it there, just wrapped in a namespace for the github issue. https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/erichkeane commented: I don't have a great feel if this is the right fix, but if it doesn't break anything in the tests, and does fix something, this is likely acceptable for now. This DOES need a release note, and as Shafik says: this should likely be placed in an existing/related test file in a namespace GH70735. https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
@@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s yuxuanchen1997 wrote: Can it be more elaborate like `GH70735-member-template-specialization.cpp`? https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
@@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s shafik wrote: Normally we put lone tests for a specific bug report in its own file e.g. GH70735.cpp for this case or we find a test that covers a similar area and put the test in a namespace named after the issue e.g. GH70735. https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/shafik commented: This makes some sense but I am not familiar enough with this area. https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
yuxuanchen1997 wrote: @AaronBallman , mind providing some feedback on this patch? I think this can solve #70375 https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/yuxuanchen1997 updated https://github.com/llvm/llvm-project/pull/72346 >From f238608b792f69b93eb445ee596125f3e20acf39 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 20:52:21 -0800 Subject: [PATCH 1/5] [Clang] Fix ICE caused by mishandling template specialization in instantiation lookup --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 011356e08a04297..2ef0986dd4d2235 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6211,9 +6211,8 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, ClassTemplateDecl *ClassTemplate = Record->getDescribedClassTemplate(); if (ClassTemplate) ClassTemplate = ClassTemplate->getCanonicalDecl(); -else if (ClassTemplatePartialSpecializationDecl *PartialSpec - = dyn_cast(Record)) - ClassTemplate = PartialSpec->getSpecializedTemplate()->getCanonicalDecl(); +else if (ClassTemplateSpecializationDecl *Spec = dyn_cast(Record)) + ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl(); // Walk the current context to find either the record or an instantiation of // it. >From 9a79db980951299c93cc4530230717af6f4668b3 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 20:55:10 -0800 Subject: [PATCH 2/5] formatting --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 2ef0986dd4d2235..07b3488a21e670b 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6211,7 +6211,8 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, ClassTemplateDecl *ClassTemplate = Record->getDescribedClassTemplate(); if (ClassTemplate) ClassTemplate = ClassTemplate->getCanonicalDecl(); -else if (ClassTemplateSpecializationDecl *Spec = dyn_cast(Record)) +else if (ClassTemplateSpecializationDecl *Spec = + dyn_cast(Record)) ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl(); // Walk the current context to find either the record or an instantiation of >From df884c7127bb2f0956521adc479a923c62220d7c Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 21:04:00 -0800 Subject: [PATCH 3/5] Provide test case --- .../member-template-specialization.cpp| 31 +++ 1 file changed, 31 insertions(+) create mode 100644 clang/test/SemaCXX/member-template-specialization.cpp diff --git a/clang/test/SemaCXX/member-template-specialization.cpp b/clang/test/SemaCXX/member-template-specialization.cpp new file mode 100644 index 000..baf5bd6ae7bb544 --- /dev/null +++ b/clang/test/SemaCXX/member-template-specialization.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s +// Verify that the inner template specialization can be found + +template +struct S { + static void bar() { +Ty t; +t.foo(); + } + + static void take(Ty&) {} +}; + +template +struct Outer { + template + struct Inner; + + using U = S>; + + template <> + struct Inner { +void foo() { + U::take(*this); +} + }; +}; + +int main() { + Outer::U::bar(); +} >From 7cdbce7944e051aed5b1f8ab789ce1e43f3e58b3 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 21:13:23 -0800 Subject: [PATCH 4/5] missing expected-no-diagnostics --- clang/test/SemaCXX/member-template-specialization.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/test/SemaCXX/member-template-specialization.cpp b/clang/test/SemaCXX/member-template-specialization.cpp index baf5bd6ae7bb544..29d46ec9c1e44fc 100644 --- a/clang/test/SemaCXX/member-template-specialization.cpp +++ b/clang/test/SemaCXX/member-template-specialization.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify -fsyntax-only %s +// expected-no-diagnostics + // Verify that the inner template specialization can be found template >From 23e4a9457c9d4428245a9d6593b97a33ed538ce7 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Wed, 15 Nov 2023 10:10:02 -0800 Subject: [PATCH 5/5] change stale comment --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 07b3488a21e670b..08f4ba00fc9f7de 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6207,7 +6207,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, return D; // Determine whether this record is
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/yuxuanchen1997 edited https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Yuxuan Chen (yuxuanchen1997) Changes This change aims to fix https://github.com/llvm/llvm-project/issues/70375 It appears to me that the logic here should be handling specializations in general. Not just partial specialization. It also seems that both the comment before the block and the `isInstantiationOf(ClassTemplate, SpecTemplate)` below agree with my judgement. The issue might just be a mistake that someone mistaken specialization as a special case of partial specializations, while it's actually the other way around. Needs some experts to comment here if this is the right fix. The code that caused clang ICE is added as a test case. --- Full diff: https://github.com/llvm/llvm-project/pull/72346.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+3-3) - (added) clang/test/SemaCXX/member-template-specialization.cpp (+33) ``diff diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 011356e08a04297..07b3488a21e670b 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6211,9 +6211,9 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, ClassTemplateDecl *ClassTemplate = Record->getDescribedClassTemplate(); if (ClassTemplate) ClassTemplate = ClassTemplate->getCanonicalDecl(); -else if (ClassTemplatePartialSpecializationDecl *PartialSpec - = dyn_cast(Record)) - ClassTemplate = PartialSpec->getSpecializedTemplate()->getCanonicalDecl(); +else if (ClassTemplateSpecializationDecl *Spec = + dyn_cast(Record)) + ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl(); // Walk the current context to find either the record or an instantiation of // it. diff --git a/clang/test/SemaCXX/member-template-specialization.cpp b/clang/test/SemaCXX/member-template-specialization.cpp new file mode 100644 index 000..29d46ec9c1e44fc --- /dev/null +++ b/clang/test/SemaCXX/member-template-specialization.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s +// expected-no-diagnostics + +// Verify that the inner template specialization can be found + +template +struct S { + static void bar() { +Ty t; +t.foo(); + } + + static void take(Ty&) {} +}; + +template +struct Outer { + template + struct Inner; + + using U = S>; + + template <> + struct Inner { +void foo() { + U::take(*this); +} + }; +}; + +int main() { + Outer::U::bar(); +} `` https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/yuxuanchen1997 ready_for_review https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/yuxuanchen1997 created https://github.com/llvm/llvm-project/pull/72346 This change aims to fix https://github.com/llvm/llvm-project/issues/70375 It appears to me that the logic here should be handling specializations in general. Not just partial specialization. It also seems that both the comment before the block and the `isInstantiationOf(ClassTemplate, SpecTemplate)` below agree with my judgement. The issue might just be a mistake that someone mistaken specialization as a special case of partial specializations, while it's actually the other way around. Needs some experts to comment here if this is the right fix. The code that caused clang ICE is added as a test case. >From f238608b792f69b93eb445ee596125f3e20acf39 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 20:52:21 -0800 Subject: [PATCH 1/4] [Clang] Fix ICE caused by mishandling template specialization in instantiation lookup --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 011356e08a04297..2ef0986dd4d2235 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6211,9 +6211,8 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, ClassTemplateDecl *ClassTemplate = Record->getDescribedClassTemplate(); if (ClassTemplate) ClassTemplate = ClassTemplate->getCanonicalDecl(); -else if (ClassTemplatePartialSpecializationDecl *PartialSpec - = dyn_cast(Record)) - ClassTemplate = PartialSpec->getSpecializedTemplate()->getCanonicalDecl(); +else if (ClassTemplateSpecializationDecl *Spec = dyn_cast(Record)) + ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl(); // Walk the current context to find either the record or an instantiation of // it. >From 9a79db980951299c93cc4530230717af6f4668b3 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 20:55:10 -0800 Subject: [PATCH 2/4] formatting --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 2ef0986dd4d2235..07b3488a21e670b 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6211,7 +6211,8 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, ClassTemplateDecl *ClassTemplate = Record->getDescribedClassTemplate(); if (ClassTemplate) ClassTemplate = ClassTemplate->getCanonicalDecl(); -else if (ClassTemplateSpecializationDecl *Spec = dyn_cast(Record)) +else if (ClassTemplateSpecializationDecl *Spec = + dyn_cast(Record)) ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl(); // Walk the current context to find either the record or an instantiation of >From df884c7127bb2f0956521adc479a923c62220d7c Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 21:04:00 -0800 Subject: [PATCH 3/4] Provide test case --- .../member-template-specialization.cpp| 31 +++ 1 file changed, 31 insertions(+) create mode 100644 clang/test/SemaCXX/member-template-specialization.cpp diff --git a/clang/test/SemaCXX/member-template-specialization.cpp b/clang/test/SemaCXX/member-template-specialization.cpp new file mode 100644 index 000..baf5bd6ae7bb544 --- /dev/null +++ b/clang/test/SemaCXX/member-template-specialization.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s +// Verify that the inner template specialization can be found + +template +struct S { + static void bar() { +Ty t; +t.foo(); + } + + static void take(Ty&) {} +}; + +template +struct Outer { + template + struct Inner; + + using U = S>; + + template <> + struct Inner { +void foo() { + U::take(*this); +} + }; +}; + +int main() { + Outer::U::bar(); +} >From 7cdbce7944e051aed5b1f8ab789ce1e43f3e58b3 Mon Sep 17 00:00:00 2001 From: Yuxuan Chen Date: Tue, 14 Nov 2023 21:13:23 -0800 Subject: [PATCH 4/4] missing expected-no-diagnostics --- clang/test/SemaCXX/member-template-specialization.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/test/SemaCXX/member-template-specialization.cpp b/clang/test/SemaCXX/member-template-specialization.cpp index baf5bd6ae7bb544..29d46ec9c1e44fc 100644 --- a/clang/test/SemaCXX/member-template-specialization.cpp +++ b/clang/test/SemaCXX/member-template-specialization.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify -fsyntax-only %s +// expected-no-diagnostics + // Verify that the inner template specialization can be found template ___ cfe-commits mailing list