blob: caf76033af704fe80052e565acb570de63fed81f [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x
Anders Carlssonfb311762009-03-14 00:25:26 +00002
3int f();
4
5static_assert(f(), "f"); // expected-error {{static_assert expression is not an integral constant expression}}
6static_assert(true, "true is not false");
7static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
8
9void g() {
10 static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
11}
12
13class C {
14 static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
15};
Anders Carlssonc3082412009-03-14 00:33:21 +000016
17template<int N> struct T {
Anders Carlsson94b15fb2009-03-15 18:44:04 +000018 static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed "N is not 2!"}}
Anders Carlssonc3082412009-03-14 00:33:21 +000019};
20
Anders Carlsson94b15fb2009-03-15 18:44:04 +000021T<1> t1; // expected-note {{in instantiation of template class 'struct T<1>' requested here}}
22T<2> t2;
23
Anders Carlssonc3082412009-03-14 00:33:21 +000024template<typename T> struct S {
Anders Carlsson94b15fb2009-03-15 18:44:04 +000025 static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static_assert failed "Type not big enough!"}}
Anders Carlssonc3082412009-03-14 00:33:21 +000026};
27
Anders Carlsson94b15fb2009-03-15 18:44:04 +000028S<char> s1; // expected-note {{in instantiation of template class 'struct S<char>' requested here}}
29S<int> s2;
30