92 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s2 3namespace GH62361 {4 template <typename T, typename U = void*> struct B { // expected-note 14{{candidate}}5 B() // expected-note 7{{not viable}}6 requires __is_same(T, int); // expected-note 7{{because '__is_same(char, int)' evaluated to false}}7 };8 9 template <typename U> struct B<void, U> : B<int, U> {10 using B<int, U>::B;11 };12 13 template<typename T>14 void g(B<T>); // expected-note {{cannot convert}}15 16 void f1() {17 B<void> b1;18 B<void> b2{};19 B<void> b3 = {};20 new B<void>{};21 new B<void>();22 g<void>({});23 B<void>{};24 B<void>();25 }26 27 void f2() {28 B<int> b1;29 B<int> b2{};30 B<int> b3 = {};31 new B<int>{};32 new B<int>();33 g<int>({});34 B<int>{};35 B<int>();36 }37 38 void f3() {39 B<char> b1; // expected-error {{no matching constructor}}40 B<char> b2{}; // expected-error {{no matching constructor}}41 B<char> b3 = {}; // expected-error {{no matching constructor}}42 new B<char>{}; // expected-error {{no matching constructor}}43 new B<char>(); // expected-error {{no matching constructor}}44 g<char>({}); // expected-error {{no matching function}}45 B<char>{}; // expected-error {{no matching constructor}}46 B<char>(); // expected-error {{no matching constructor}}47 }48}49 50namespace no_early_substitution {51 template <typename T> concept X = true;52 53 struct A {};54 55 template <typename T> struct B {56 B() requires X<T*>;57 B();58 };59 60 template <typename U = int, typename V = A>61 struct C : public B<V&> {62 using B<V&>::B;63 };64 65 void foo() {66 // OK, we only substitute T ~> V& into X<T*> in a SFINAE context,67 // during satisfaction checks.68 C();69 }70}71 72namespace GH62362 {73 template<typename T>74 concept C = true;75 template <typename T> struct Test {76 Test()77 requires(C<T>);78 };79 struct Bar : public Test<int> {80 using Test<int>::Test;81 };82 template <>83 struct Test<void> : public Test<int> {84 using Test<int>::Test;85 };86 87 void foo() {88 Bar();89 Test<void>();90 }91}92