1 // RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast -frecovery-ast-type -o - %s -std=gnu++17 -fsyntax-only -verify
4 struct Indestructible
{
6 ~Indestructible() = delete; // expected-note 2{{deleted}}
8 Indestructible
make_indestructible();
12 int s
= sizeof(make_indestructible()); // expected-error {{deleted}}
13 constexpr int ss
= sizeof(make_indestructible()); // expected-error {{deleted}}
14 static_assert(ss
, "");
20 constexpr int foo() { return 1; } // expected-note {{candidate function not viable}}
21 // verify the "not an integral constant expression" diagnostic is suppressed.
22 static_assert(1 == foo(1), ""); // expected-error {{no matching function}}
26 void foo(); // expected-note 3{{requires 0 arguments}}
28 // verify that "field has incomplete type" diagnostic is suppressed.
29 typeof(foo(42)) var
; // expected-error {{no matching function}} \
31 // FIXME: suppress the "cannot initialize a variable" diagnostic.
32 int a
= foo(1); // expected-error {{no matching function}} \
33 // expected-error {{cannot initialize a variable of type}}
35 // FIXME: suppress the "invalid application" diagnostic.
36 int s
= sizeof(foo(42)); // expected-error {{no matching function}} \
37 // expected-error {{invalid application of 'sizeof'}}
43 constexpr int templated() __attribute__((enable_if(N
, ""))) { // expected-note {{candidate disabled}}
46 // verify that "constexpr variable must be initialized" diagnostic is suppressed.
47 constexpr int A
= templated
<0>(); // expected-error{{no matching function}}
52 static constexpr int getB() { // expected-note{{candidate template ignored}}
55 static constexpr int foo2() {
56 return AA
<T
>::getB(); // expected-error{{no matching function for call to 'getB'}}
59 // FIXME: should we suppress the "be initialized by a constant expression" diagnostic?
60 constexpr auto x2
= AA
<int>::foo2(); // expected-error {{be initialized by a constant expression}} \
61 // expected-note {{in instantiation of member function}}
64 // verify no assertion failure on violating value category.
66 int &&f(int); // expected-note {{candidate function not viable}}
67 int &&k
= f(); // expected-error {{no matching function for call}}
70 // verify that "type 'double' cannot bind to a value of unrelated type 'int'" diagnostic is suppressed.
72 template<typename T
> using U
= T
; // expected-note {{template parameter is declared here}}
73 template<typename
...Ts
> U
<Ts
...>& f(); // expected-error {{pack expansion used as argument for non-pack parameter of alias template}}
74 double &s1
= f(); // expected-error {{no matching function}}
79 T() = delete; // expected-note {{has been explicitly marked deleted here}}
83 // verify that no -Wunused-value diagnostic.
84 (T(T())); // expected-error {{call to deleted constructor}}
88 // verify the secondary diagnostic "no matching function" is emitted.
91 C() = delete; // expected-note {{has been explicitly marked deleted}}
93 void f(C
&); // expected-note {{candidate function not viable: expects an lvalue for 1st argument}}
95 f(C()); // expected-error {{call to deleted constructor}} \
96 expected
-error
{{no matching function
for call
}}
100 // verify the secondary diagnostic "cannot initialize" is emitted.
103 int v
= arr(); // expected-error {{array types cannot be value-initialized}} \
104 expected
-error
{{cannot initialize a variable of type
'int' with an rvalue of type
'test8::arr'}}
108 auto f(); // expected-note {{candidate function not viable}}
109 // verify no crash on evaluating the size of undeduced auto type.
110 static_assert(sizeof(f(1)), ""); // expected-error {{no matching function for call to 'f'}}
114 // Ensure we don't assert here.
115 int f(); // expected-note {{candidate}}
116 template<typename T
> const int k
= f(T()); // expected-error {{no matching function}}
117 static_assert(k
<int> == 1, ""); // expected-note {{instantiation of}}
121 // Verify we do not assert()-fail here.
122 template <class T
> void foo(T
&t
);
123 template <typename T
>
128 template <typename T
= void *>
129 struct S
{ // expected-note {{candidate}}
130 S(T t
); // expected-note {{candidate}}
133 template <typename T
> S(T t
) -> S
<void *>;
136 bar(S(123)); // expected-error {{no matching conversion for functional-style cast from 'int' to 'S<void *>'}}
138 } // namespace test11
141 // Verify we do not crash.
142 int fun(int *foo
= no_such_function()); // expected-error {{undeclared identifier}}
143 void crash1() { fun(); }
144 void crash2() { constexpr int s
= fun(); }
145 } // namespace test12
148 enum Circular
{ // expected-note {{not complete until the closing '}'}}
149 Circular_A
= Circular(1), // expected-error {{'test13::Circular' is an incomplete type}}
151 // Enumerators can be evaluated (they evaluate as zero, but we don't care).
152 static_assert(Circular_A
== 0 && Circular_A
!= 0, ""); // expected-error {{static_assert failed}}