1 // { dg-do compile { target c++11 } } 2 // { dg-options "-ftrack-macro-expansion=0" } 3 4 #define SA(X) static_assert (X, #X) 5 6 struct A 7 { 8 int i; AA9 constexpr A(int _i) { i = _i; } // { dg-error "empty body|A::i" "" { target c++17_down } } 10 }; 11 12 template <class T> 13 struct B 14 { 15 T t; BB16 constexpr B(T _t): t(_t) { } 17 }; 18 19 B<int> b(1); // { dg-message "not declared .constexpr" } 20 SA(b.t==1); // { dg-error "non-constant condition|'b'" } 21 constexpr B<int> b2(1); 22 SA(b2.t==1); 23 24 template <class T> f(T a,T b)25constexpr T f(T a, T b) 26 { 27 typedef T myT; 28 return a + b; 29 } 30 31 SA(f(1,2)==3); 32