diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-08 00:35:25 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-08 00:35:25 +0000 |
commit | 1680a15795363624f5e7c9e3469a52dca48dcc7e (patch) | |
tree | a8a43b8c28826e6bf3f11898a216f14fc98ddf75 /test/CXX/temp/temp.deduct.guide/p1.cpp | |
parent | 68ad3a8b8c36008f95df1b61304fe2540c7592bb (diff) |
P0091R3: Improved syntactic checking of deduction-guides.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294395 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/temp/temp.deduct.guide/p1.cpp')
-rw-r--r-- | test/CXX/temp/temp.deduct.guide/p1.cpp | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/test/CXX/temp/temp.deduct.guide/p1.cpp b/test/CXX/temp/temp.deduct.guide/p1.cpp index 08c4c93619..5c27cfe96c 100644 --- a/test/CXX/temp/temp.deduct.guide/p1.cpp +++ b/test/CXX/temp/temp.deduct.guide/p1.cpp @@ -16,11 +16,19 @@ explicit A(int(&)[2]) -> A<int>; &A(int(&)[4]) -> A<int>; // expected-error {{cannot specify any part of a return type in the declaration of a deduction guide}} A(int(&)[5])[3] -> A<int>; #ifdef CLASS // FIXME: These diagnostics are both pretty bad. -// expected-error@-2 {{deduction guide declaration without trailing return type}} expected-error@-2 {{array of 'auto'}} expected-error@-2 {{';'}} +// expected-error@-2 {{function cannot return array type}} expected-error@-2 {{';'}} #else // expected-error@-4 {{expected function body after function declarator}} #endif +(A[3])(int(&)[5][1]) -> A<int>; // expected-error {{'<deduction guide for A>' cannot be the name of a variable}} +#ifndef CLASS +// expected-error@-2 {{declared as array of functions}} +#endif +(*A)(int(&)[5][2]) -> A<int>; // expected-error {{'<deduction guide for A>' cannot be the name of a variable}} +(&A)(int(&)[5][3]) -> A<int>; // expected-error {{'<deduction guide for A>' cannot be the name of a variable}} +(*A(int))(int(&)[5][4]) -> A<int>; // expected-error {{cannot specify any part of a return type in the declaration of a deduction guide}} + // (Pending DR) attributes and parens around the declarator-id are OK. [[deprecated]] A(int(&)[6]) [[]] -> A<int> [[]]; A [[]] (int(&)[7]) -> A<int>; // FIXME: expected-error 2{{expected}} expected-note {{to match}} @@ -43,30 +51,37 @@ int A(int) -> A<int>; // expected-error {{function with trailing return type mus template<typename T> struct B {}; // expected-note {{here}} auto B(int) -> B<int>; // expected-error {{redefinition of 'B' as different kind of symbol}} -// FIXME: No storage class specifier, function specifier, ... +// No storage class specifier, function specifier, ... friend A(int(&)[20]) -> A<int>; #ifdef CLASS // expected-error@-2 {{cannot declare a deduction guide as a friend}} #else // expected-error@-4 {{'friend' used outside of class}} #endif -typedef A(int(&)[21]) -> A<int>; // FIXME: Bad diagnostic: expected-error {{typedef name must be an identifier}} -constexpr A(int(&)[22]) -> A<int>; -inline A(int(&)[23]) -> A<int>; -static A(int(&)[24]) -> A<int>; +typedef A(int(&)[21]) -> A<int>; // expected-error {{deduction guide cannot be declared 'typedef'}} +constexpr A(int(&)[22]) -> A<int>; // expected-error {{deduction guide cannot be declared 'constexpr'}} +inline A(int(&)[23]) -> A<int>; // expected-error {{deduction guide cannot be declared 'inline'}} +static A(int(&)[24]) -> A<int>; // expected-error {{deduction guide cannot be declared 'static'}} thread_local A(int(&)[25]) -> A<int>; // expected-error {{'thread_local' is only allowed on variable declarations}} extern A(int(&)[26]) -> A<int>; #ifdef CLASS // expected-error@-2 {{storage class specified for a member}} +#else +// expected-error@-4 {{deduction guide cannot be declared 'extern'}} #endif mutable A(int(&)[27]) -> A<int>; // expected-error-re {{{{'mutable' cannot be applied to|illegal storage class on}} function}} virtual A(int(&)[28]) -> A<int>; // expected-error {{'virtual' can only appear on non-static member functions}} +const A(int(&)[28]) -> A<int>; // expected-error {{deduction guide cannot be declared 'const'}} + +const volatile static constexpr inline A(int(&)[29]) -> A<int>; // expected-error {{deduction guide cannot be declared 'static inline constexpr const volatile'}} + +A(int(&)[30]) const -> A<int>; // expected-error {{deduction guide cannot have 'const' qualifier}} // FIXME: No definition is allowed. -A(int(&)[30]) -> A<int> {} -A(int(&)[31]) -> A<int> = default; // expected-error {{only special member functions may be defaulted}} -A(int(&)[32]) -> A<int> = delete; -A(int(&)[33]) -> A<int> try {} catch (...) {} +A(int(&)[40]) -> A<int> {} +A(int(&)[41]) -> A<int> = default; // expected-error {{only special member functions may be defaulted}} +A(int(&)[42]) -> A<int> = delete; +A(int(&)[43]) -> A<int> try {} catch (...) {} #ifdef CLASS }; |