blob: 516243ec70e1113c87d08f68adf5eefae6fae06b [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -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
John McCall7c2342d2010-03-10 11:27:22 +000021T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
Anders Carlsson94b15fb2009-03-15 18:44:04 +000022T<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
John McCall7c2342d2010-03-10 11:27:22 +000028S<char> s1; // expected-note {{in instantiation of template class 'S<char>' requested here}}
Anders Carlsson94b15fb2009-03-15 18:44:04 +000029S<int> s2;
30