-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass the found declaration to DiagnoseUseOfDecl.
Don't pass in the resolved declaration, because that might be an inheriting constructor declaration, which should never be used directly and for which constraint satisfaction checking doesn't work. Fixes #62361.
- Loading branch information
Showing
2 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s | ||
|
||
namespace GH62361 { | ||
template <typename T, typename U = void*> struct B { // expected-note 14{{candidate}} | ||
B() // expected-note 7{{not viable}} | ||
requires __is_same(T, int); // expected-note 7{{because '__is_same(char, int)' evaluated to false}} | ||
}; | ||
|
||
template <typename U> struct B<void, U> : B<int, U> { | ||
using B<int, U>::B; | ||
}; | ||
|
||
template<typename T> | ||
void g(B<T>); // expected-note {{cannot convert}} | ||
|
||
void f1() { | ||
B<void> b1; | ||
B<void> b2{}; | ||
B<void> b3 = {}; | ||
new B<void>{}; | ||
new B<void>(); | ||
g<void>({}); | ||
B<void>{}; | ||
B<void>(); | ||
} | ||
|
||
void f2() { | ||
B<int> b1; | ||
B<int> b2{}; | ||
B<int> b3 = {}; | ||
new B<int>{}; | ||
new B<int>(); | ||
g<int>({}); | ||
B<int>{}; | ||
B<int>(); | ||
} | ||
|
||
void f3() { | ||
B<char> b1; // expected-error {{no matching constructor}} | ||
B<char> b2{}; // expected-error {{no matching constructor}} | ||
B<char> b3 = {}; // expected-error {{no matching constructor}} | ||
new B<char>{}; // expected-error {{no matching constructor}} | ||
new B<char>(); // expected-error {{no matching constructor}} | ||
g<char>({}); // expected-error {{no matching function}} | ||
B<char>{}; // expected-error {{no matching constructor}} | ||
B<char>(); // expected-error {{no matching constructor}} | ||
} | ||
} | ||
|
||
namespace no_early_substitution { | ||
template <typename T> concept X = true; | ||
|
||
struct A {}; | ||
|
||
template <typename T> struct B { | ||
B() requires X<T*>; | ||
B(); | ||
}; | ||
|
||
template <typename U = int, typename V = A> | ||
struct C : public B<V&> { | ||
using B<V&>::B; | ||
}; | ||
|
||
void foo() { | ||
// OK, we only substitute T ~> V& into X<T*> in a SFINAE context, | ||
// during satisfaction checks. | ||
C(); | ||
} | ||
} |
1e43349
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a release note for this fix?
1e43349
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is fixing a trunk-only regression. (Looks like @erichkeane added a release note already in f539bffc; I wonder if we should remove it for that reason.)
That said, while investigating this I did find that a previous "NFC" change fixed a bug (the
no_early_substitution
test); maybe that warrants a release note.