Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaTemplate / concepts-inherited-ctor.cpp
blob6ac5a1618784e89ceda4190280cc3ace9345e51e
1 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
3 namespace 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 };
9 template <typename U> struct B<void, U> : B<int, U> {
10 using B<int, U>::B;
13 template<typename T>
14 void g(B<T>); // expected-note {{cannot convert}}
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>();
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>();
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}}
50 namespace no_early_substitution {
51 template <typename T> concept X = true;
53 struct A {};
55 template <typename T> struct B {
56 B() requires X<T*>;
57 B();
60 template <typename U = int, typename V = A>
61 struct C : public B<V&> {
62 using B<V&>::B;
65 void foo() {
66 // OK, we only substitute T ~> V& into X<T*> in a SFINAE context,
67 // during satisfaction checks.
68 C();
72 namespace GH62362 {
73 template<typename T>
74 concept C = true;
75 template <typename T> struct Test {
76 Test()
77 requires(C<T>);
79 struct Bar : public Test<int> {
80 using Test<int>::Test;
82 template <>
83 struct Test<void> : public Test<int> {
84 using Test<int>::Test;
87 void foo() {
88 Bar();
89 Test<void>();