Hubert Tong | ec3cb57 | 2015-06-25 00:23:39 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ %s -verify |
| 2 | |
| 3 | // Test parsing of constraint-expressions in cases where the grammar is |
| 4 | // ambiguous with the expectation that the longest token sequence which matches |
| 5 | // the syntax is consumed without backtracking. |
| 6 | |
| 7 | // type-specifier-seq in conversion-type-id |
| 8 | template <typename T> requires (bool)&T::operator short |
| 9 | unsigned int foo(); // expected-error {{C++ requires a type specifier for all declarations}} |
| 10 | |
| 11 | // type-specifier-seq in new-type-id |
| 12 | template <typename T> requires (bool)sizeof new (T::f()) short |
| 13 | unsigned int bar(); // expected-error {{C++ requires a type specifier for all declarations}} |
| 14 | |
| 15 | template<typename T> requires (bool)sizeof new (T::f()) unsigned // expected-error {{'struct' cannot be signed or unsigned}} |
| 16 | struct X { }; // expected-error {{'X' cannot be defined in a type specifier}} |
| 17 | |
| 18 | // C-style cast |
| 19 | // of function call on function-style cast |
| 20 | template <typename T> requires (bool(T())) |
| 21 | T (*fp)(); // expected-error {{use of undeclared identifier 'fp'}} |
| 22 | |
| 23 | // function-style cast |
| 24 | // as the callee in a function call |
| 25 | struct A { |
| 26 | static int t; |
| 27 | template <typename T> requires bool(T()) |
| 28 | (A(T (&t))) { } // expected-error {{called object type 'bool' is not a function or function pointer}} |
| 29 | }; |