Skip to content

[Clang] Set the decl context to the instantiated constructor when instantiating the explicit specifier #78053

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,9 @@ Bug Fixes to C++ Support
completes (except deduction guides). Fixes:
(`#59827 <https://github.com/llvm/llvm-project/issues/59827>`_)

- Fixed the handling of concepts with lambda expression constraints in explicit specifiers.
Fixes: (`#67058 <https://github.com/llvm/llvm-project/issues/67058>`_)

- Fix crash when parsing nested requirement. Fixes:
(`#73112 <https://github.com/llvm/llvm-project/issues/73112>`_)

Expand Down
1 change: 1 addition & 0 deletions clang/lib/Sema/SemaTemplateDeduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3585,6 +3585,7 @@ static Sema::TemplateDeductionResult instantiateExplicitSpecifierDeferred(
if (Inst.isInvalid())
return Sema::TDK_InstantiationDepth;
Sema::SFINAETrap Trap(S);
Sema::ContextRAII InstantiatedContext(S, Specialization);
const ExplicitSpecifier InstantiatedES =
S.instantiateExplicitSpecifier(SubstArgs, ES);
if (InstantiatedES.isInvalid() || Trap.hasErrorOccurred()) {
Expand Down
18 changes: 18 additions & 0 deletions clang/test/SemaCXX/cxx2a-explicit-bool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,3 +743,21 @@ struct S {
explicit(1L) S(char, char, char);
};
} // namespace P1401

#if __cplusplus > 201703L
namespace GH67058 {
template <class T>
concept Q = requires(T t) { [](int *) {}(t); };
struct A {
template <class T> explicit(Q<T>) A(T);
};
A a = 1;

struct B { // expected-note+ {{candidate constructor}}
template <class T>
explicit(requires(T t) { [](int *) {}(t); })
B(T); // expected-note {{explicit constructor is not a candidate}}
};
B b = new int; // expected-error {{no viable conversion}}
} // namespace GH67058
#endif