1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t 2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc #ifndef HEADER_INCLUDED 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc #define HEADER_INCLUDED 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc struct B { 9*f4a2713aSLionel Sambuc B(); BB10*f4a2713aSLionel Sambuc constexpr B(char) {} 11*f4a2713aSLionel Sambuc }; 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc struct C { 14*f4a2713aSLionel Sambuc B b; 15*f4a2713aSLionel Sambuc double d = 0.0; 16*f4a2713aSLionel Sambuc }; 17*f4a2713aSLionel Sambuc 18*f4a2713aSLionel Sambuc struct D : B { DD19*f4a2713aSLionel Sambuc constexpr D(int n) : B('x'), k(2*n+1) {} 20*f4a2713aSLionel Sambuc int k; 21*f4a2713aSLionel Sambuc }; 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc constexpr int value = 7; 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc template<typename T> plus_seven(T other)26*f4a2713aSLionel Sambucconstexpr T plus_seven(T other) { 27*f4a2713aSLionel Sambuc return value + other; 28*f4a2713aSLionel Sambuc } 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc #else 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambuc static_assert(D(4).k == 9, ""); f(C c)33*f4a2713aSLionel Sambucconstexpr int f(C c) { return 0; } // expected-error {{not a literal type}} 34*f4a2713aSLionel Sambuc // expected-note@13 {{not an aggregate and has no constexpr constructors}} 35*f4a2713aSLionel Sambuc constexpr B b; // expected-error {{constant expression}} expected-note {{non-constexpr}} 36*f4a2713aSLionel Sambuc // expected-note@9 {{here}} 37*f4a2713aSLionel Sambuc 38*f4a2713aSLionel Sambuc static_assert(plus_seven(3) == 10, ""); 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc #endif 41