[flang][cuda] Update CompilerGeneratedNames pass to work on gpu module (#120660)
[llvm-project.git] / clang / test / CXX / over / over.match / over.match.viable / p3.cpp
blobe207c4b8dc73696ef5ffed08bc6e917456c14051
1 // RUN: %clang_cc1 -std=c++2a -verify %s
3 struct S2 {};
4 // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'S1<int>' to 'const S2' for 1st argument}}
5 // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'S1<int>' to 'S2' for 1st argument}}
6 // expected-note@-3 {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
8 template<typename T>
9 struct S1 {
10 void foo() const requires true {}
11 void foo() const requires false {}
12 void bar() const requires false {}
13 // expected-note@-1 {{because 'false' evaluated to false}}
14 operator bool() const requires true { return true; }
15 explicit operator bool() const requires false;
16 explicit operator S2() const requires false;
17 // expected-note@-1 {{candidate function not viable: constraints not satisfied}}
18 // expected-note@-2 {{because 'false' evaluated to false}}
21 void foo() {
22 S1<int>().foo();
23 S1<int>().bar();
24 // expected-error@-1 {{invalid reference to function 'bar': constraints not satisfied}}
25 (void) static_cast<bool>(S1<int>());
26 (void) static_cast<S2>(S1<int>());
27 // expected-error@-1 {{no matching conversion for static_cast from 'S1<int>' to 'S2'}}
30 // Test that constraints are checked before implicit conversions are formed.
32 template<typename T>
33 struct invalid_template { using X = typename T::non_existant; };
34 struct A {
35 template<typename T, bool=invalid_template<T>::aadasas>
36 operator T() {}
39 template<typename>
40 struct WrapsStatics {
41 static void foo(int) requires false;
42 static void foo(A) requires true;
45 template<typename T>
46 struct S {
47 void foo(int) requires false;
48 void foo(A) requires true;
49 S(A) requires false;
50 S(double) requires true;
51 ~S() requires false;
52 ~S() requires true;
53 operator int() requires true;
54 operator int() requires false;
57 void bar() {
58 WrapsStatics<int>::foo(A{});
59 S<int>{1.}.foo(A{});
61 S<int> s = 1;
62 int a = s;