-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Revert "[clang] Fix CTAD for aggregates for nested template classes" #78541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-clang Author: None (antangelo) ChangesReverts llvm/llvm-project#78387 The added tests are failing on several build bots. Full diff: https://github.com/llvm/llvm-project/pull/78541.diff 4 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d70d6dfd5df9fe3..cf52c1e66b91b42 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -972,9 +972,6 @@ Bug Fixes to C++ Support
(`#57410 <https://github.com/llvm/llvm-project/issues/57410>`_) and
(`#76604 <https://github.com/llvm/llvm-project/issues/57410>`_)
-- Fixes CTAD for aggregates on nested template classes. Fixes:
- (`#77599 <https://github.com/llvm/llvm-project/issues/77599>`_)
-
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 48235941f62aa23..408ee5f775804b6 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10718,14 +10718,7 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
bool HasAnyDeductionGuide = false;
auto SynthesizeAggrGuide = [&](InitListExpr *ListInit) {
- auto *Pattern = Template;
- while (Pattern->getInstantiatedFromMemberTemplate()) {
- if (Pattern->isMemberSpecialization())
- break;
- Pattern = Pattern->getInstantiatedFromMemberTemplate();
- }
-
- auto *RD = cast<CXXRecordDecl>(Pattern->getTemplatedDecl());
+ auto *RD = cast<CXXRecordDecl>(Template->getTemplatedDecl());
if (!(RD->getDefinition() && RD->isAggregate()))
return;
QualType Ty = Context.getRecordType(RD);
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 839d508b911f063..0655d3633520676 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2418,9 +2418,6 @@ struct ConvertConstructorToDeductionGuideTransform {
QualType Result = SemaRef.BuildFunctionType(DeducedType, ParamTypes, Loc,
DeductionGuideName, EPI);
TypeSourceInfo *TSI = SemaRef.Context.getTrivialTypeSourceInfo(Result, Loc);
- if (NestedPattern)
- TSI = SemaRef.SubstType(TSI, OuterInstantiationArgs, Loc,
- DeductionGuideName);
FunctionProtoTypeLoc FPTL =
TSI->getTypeLoc().castAs<FunctionProtoTypeLoc>();
@@ -2428,13 +2425,9 @@ struct ConvertConstructorToDeductionGuideTransform {
// Build the parameters, needed during deduction / substitution.
SmallVector<ParmVarDecl*, 4> Params;
for (auto T : ParamTypes) {
- auto *TSI = SemaRef.Context.getTrivialTypeSourceInfo(T, Loc);
- if (NestedPattern)
- TSI = SemaRef.SubstType(TSI, OuterInstantiationArgs, Loc,
- DeclarationName());
- ParmVarDecl *NewParam =
- ParmVarDecl::Create(SemaRef.Context, DC, Loc, Loc, nullptr,
- TSI->getType(), TSI, SC_None, nullptr);
+ ParmVarDecl *NewParam = ParmVarDecl::Create(
+ SemaRef.Context, DC, Loc, Loc, nullptr, T,
+ SemaRef.Context.getTrivialTypeSourceInfo(T, Loc), SC_None, nullptr);
NewParam->setScopeInfo(0, Params.size());
FPTL.setParam(Params.size(), NewParam);
Params.push_back(NewParam);
@@ -2677,14 +2670,8 @@ FunctionTemplateDecl *Sema::DeclareImplicitDeductionGuideFromInitList(
if (BuildingDeductionGuides.isInvalid())
return nullptr;
- ClassTemplateDecl *Pattern =
- Transform.NestedPattern ? Transform.NestedPattern : Transform.Template;
- ContextRAII SavedContext(*this, Pattern->getTemplatedDecl());
-
- auto *DG = cast<FunctionTemplateDecl>(
+ return cast<FunctionTemplateDecl>(
Transform.buildSimpleDeductionGuide(ParamTypes));
- SavedContext.pop();
- return DG;
}
void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
diff --git a/clang/test/SemaTemplate/nested-implicit-deduction-guides.cpp b/clang/test/SemaTemplate/nested-implicit-deduction-guides.cpp
index f3af6e8d6c17da0..c44ec6918c7afb1 100644
--- a/clang/test/SemaTemplate/nested-implicit-deduction-guides.cpp
+++ b/clang/test/SemaTemplate/nested-implicit-deduction-guides.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -std=c++20 -verify %s
+// expected-no-diagnostics
template<class T> struct S {
template<class U> struct N {
@@ -57,21 +58,3 @@ template<class X> struct requires_clause {
requires_clause<int>::B req(1, 2);
using RC = decltype(req);
using RC = requires_clause<int>::B<int>;
-
-template<typename X> struct nested_init_list {
- template<C<X> Y>
- struct B { // #INIT_LIST_INNER
- X x;
- Y y;
- };
-};
-
-nested_init_list<int>::B nil {1, 2};
-using NIL = decltype(nil);
-using NIL = nested_init_list<int>::B<int>;
-
-// expected-error@+1 {{no viable constructor or deduction guide for deduction of template arguments of 'B'}}
-nested_init_list<int>::B nil_invalid {1, ""};
-// expected-note@#INIT_LIST_INNER {{candidate template ignored: substitution failure [with Y = const char *]: constraints not satisfied for class template 'B' [with Y = const char *]}}
-// expected-note@#INIT_LIST_INNER {{candidate function template not viable: requires 1 argument, but 2 were provided}}
-// expected-note@#INIT_LIST_INNER {{candidate function template not viable: requires 0 arguments, but 2 were provided}}
|
ampandey-1995
pushed a commit
to ampandey-1995/llvm-project
that referenced
this pull request
Jan 19, 2024
…lvm#78541) Reverts llvm#78387 The added tests are failing on several build bots.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reverts #78387
The added tests are failing on several build bots.