1 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx2b -std=c++2b -Wpre-c++2b-compat %s
2 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx20 -std=c++20 %s
4 void looks_like_decltype_auto() {
5 decltype(auto(42)) b
= 42; // cxx20-error {{'auto' not allowed here}} \
6 cxx2b
-warning
{{'auto' as a functional
-style cast is incompatible with C
++ standards before C
++2b
}}
7 decltype(long *) a
= 42; // expected-error {{expected '(' for function-style cast or type construction}} \
8 expected
-error
{{expected expression
}}
9 decltype(auto *) a
= 42; // expected-error {{expected '(' for function-style cast or type construction}} \
10 expected
-error
{{expected expression
}}
11 decltype(auto()) c
= 42; // cxx2b-error {{initializer for functional-style cast to 'auto' is empty}} \
12 cxx20
-error
{{'auto' not allowed here
}}
15 struct looks_like_declaration
{
19 using T
= looks_like_declaration
*;
20 void f() { T(&a
)->n
= 1; }
21 // FIXME: They should be deemed expressions without breaking function pointer
22 // parameter declarations with trailing return types.
23 // void g() { auto(&a)->n = 0; }
24 // void h() { auto{&a}->n = 0; }