1 | // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s |
2 | |
3 | struct S { |
4 | template <typename Ty = char> |
5 | static_assert(sizeof(Ty) != 1, "Not a char"); // expected-error {{a static_assert declaration cannot be a template}} |
6 | }; |
7 | |
8 | template <typename Ty = char> |
9 | static_assert(sizeof(Ty) != 1, "Not a char"); // expected-error {{a static_assert declaration cannot be a template}} |
10 | |
11 | namespace Ellipsis { |
12 | template<typename ...T> void f(T t..., int n); // expected-error {{must immediately precede declared identifier}} |
13 | template<typename ...T> void f(int n, T t...); // expected-error {{must immediately precede declared identifier}} |
14 | template<typename ...T> void f(int n, T t, ...); // expected-error {{unexpanded parameter pack}} |
15 | template<typename ...T> void f() { |
16 | f([]{ |
17 | void g(T |
18 | t // expected-note {{place '...' immediately before declared identifier to declare a function parameter pack}} |
19 | ... // expected-warning {{'...' in this location creates a C-style varargs function, not a function parameter pack}} |
20 | // expected-note@-1 {{insert ',' before '...' to silence this warning}} |
21 | ); |
22 | void h(T (& |
23 | ) // expected-note {{place '...' here to declare a function parameter pack}} |
24 | ... // expected-warning {{'...' in this location creates a C-style varargs function, not a function parameter pack}} |
25 | // expected-note@-1 {{insert ',' before '...' to silence this warning}} |
26 | ); |
27 | void i(T (&), ...); |
28 | }...); |
29 | } |
30 | template<typename ...T> struct S { |
31 | void f(T t...); // expected-error {{must immediately precede declared identifier}} |
32 | void f(T ... // expected-note {{preceding '...' declares a function parameter pack}} |
33 | t...); // expected-warning-re {{'...' in this location creates a C-style varargs function{{$}}}} |
34 | // expected-note@-1 {{insert ',' before '...' to silence this warning}} |
35 | }; |
36 | |
37 | // FIXME: We should just issue a single error in this case pointing out where |
38 | // the '...' goes. It's tricky to recover correctly in this case, though, |
39 | // because the parameter is in scope in the default argument, so must be |
40 | // passed to Sema before we reach the ellipsis. |
41 | template<typename...T> void f(T n = 1 ...); |
42 | // expected-warning@-1 {{creates a C-style varargs}} |
43 | // expected-note@-2 {{place '...' immediately before declared identifier}} |
44 | // expected-note@-3 {{insert ','}} |
45 | // expected-error@-4 {{unexpanded parameter pack}} |
46 | } |
47 | |