Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x |
Anders Carlsson | fb31176 | 2009-03-14 00:25:26 +0000 | [diff] [blame] | 2 | |
| 3 | int f(); |
| 4 | |
| 5 | static_assert(f(), "f"); // expected-error {{static_assert expression is not an integral constant expression}} |
| 6 | static_assert(true, "true is not false"); |
| 7 | static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}} |
| 8 | |
| 9 | void g() { |
| 10 | static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}} |
| 11 | } |
| 12 | |
| 13 | class C { |
| 14 | static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}} |
| 15 | }; |
Anders Carlsson | c308241 | 2009-03-14 00:33:21 +0000 | [diff] [blame] | 16 | |
| 17 | template<int N> struct T { |
Anders Carlsson | 94b15fb | 2009-03-15 18:44:04 +0000 | [diff] [blame] | 18 | static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed "N is not 2!"}} |
Anders Carlsson | c308241 | 2009-03-14 00:33:21 +0000 | [diff] [blame] | 19 | }; |
| 20 | |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 21 | T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}} |
Anders Carlsson | 94b15fb | 2009-03-15 18:44:04 +0000 | [diff] [blame] | 22 | T<2> t2; |
| 23 | |
Anders Carlsson | c308241 | 2009-03-14 00:33:21 +0000 | [diff] [blame] | 24 | template<typename T> struct S { |
Anders Carlsson | 94b15fb | 2009-03-15 18:44:04 +0000 | [diff] [blame] | 25 | static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static_assert failed "Type not big enough!"}} |
Anders Carlsson | c308241 | 2009-03-14 00:33:21 +0000 | [diff] [blame] | 26 | }; |
| 27 | |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 28 | S<char> s1; // expected-note {{in instantiation of template class 'S<char>' requested here}} |
Anders Carlsson | 94b15fb | 2009-03-15 18:44:04 +0000 | [diff] [blame] | 29 | S<int> s2; |
| 30 | |