2011-10-14 06:29:44 +08:00
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
2009-03-14 08:25:26 +08:00
2011-12-15 07:32:26 +08:00
int f ( ) ; // expected-note {{declared here}}
2009-03-14 08:25:26 +08:00
2011-12-15 07:32:26 +08:00
static_assert ( f ( ) , " f " ) ; // expected-error {{static_assert expression is not an integral constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
2009-03-14 08:25:26 +08:00
static_assert ( true , " true is not false " ) ;
static_assert ( false , " false is false " ) ; // expected-error {{static_assert failed "false is false"}}
void g ( ) {
static_assert ( false , " false is false " ) ; // expected-error {{static_assert failed "false is false"}}
}
class C {
static_assert ( false , " false is false " ) ; // expected-error {{static_assert failed "false is false"}}
} ;
2009-03-14 08:33:21 +08:00
template < int N > struct T {
2009-03-16 02:44:04 +08:00
static_assert ( N = = 2 , " N is not 2! " ) ; // expected-error {{static_assert failed "N is not 2!"}}
2009-03-14 08:33:21 +08:00
} ;
2010-03-10 19:27:22 +08:00
T < 1 > t1 ; // expected-note {{in instantiation of template class 'T<1>' requested here}}
2009-03-16 02:44:04 +08:00
T < 2 > t2 ;
2009-03-14 08:33:21 +08:00
template < typename T > struct S {
2009-03-16 02:44:04 +08:00
static_assert ( sizeof ( T ) > sizeof ( char ) , " Type not big enough! " ) ; // expected-error {{static_assert failed "Type not big enough!"}}
2009-03-14 08:33:21 +08:00
} ;
2010-03-10 19:27:22 +08:00
S < char > s1 ; // expected-note {{in instantiation of template class 'S<char>' requested here}}
2009-03-16 02:44:04 +08:00
S < int > s2 ;