1561fb158SRichard Smith // RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t 2561fb158SRichard Smith // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s 3561fb158SRichard Smith 4*a45f713cSLuboš Luňák // RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch -fpch-instantiate-templates %s -o %t 5*a45f713cSLuboš Luňák // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s 6*a45f713cSLuboš Luňák 7561fb158SRichard Smith #ifndef HEADER_INCLUDED 8561fb158SRichard Smith 9561fb158SRichard Smith #define HEADER_INCLUDED 10561fb158SRichard Smith 11561fb158SRichard Smith struct B { 12b13eb8dcSJordan Rose B(); BB13561fb158SRichard Smith constexpr B(char) {} 14561fb158SRichard Smith }; 15561fb158SRichard Smith 16b13eb8dcSJordan Rose struct C { 17561fb158SRichard Smith B b; 18561fb158SRichard Smith double d = 0.0; 19561fb158SRichard Smith }; 20561fb158SRichard Smith 21561fb158SRichard Smith struct D : B { DD22561fb158SRichard Smith constexpr D(int n) : B('x'), k(2*n+1) {} 23561fb158SRichard Smith int k; 24561fb158SRichard Smith }; 25561fb158SRichard Smith 2612cda633SDouglas Gregor constexpr int value = 7; 2712cda633SDouglas Gregor 2812cda633SDouglas Gregor template<typename T> plus_seven(T other)2912cda633SDouglas Gregorconstexpr T plus_seven(T other) { 3012cda633SDouglas Gregor return value + other; 3112cda633SDouglas Gregor } 3212cda633SDouglas Gregor 33561fb158SRichard Smith #else 34561fb158SRichard Smith 35561fb158SRichard Smith static_assert(D(4).k == 9, ""); f(C c)36561fb158SRichard Smithconstexpr int f(C c) { return 0; } // expected-error {{not a literal type}} 37*a45f713cSLuboš Luňák // expected-note@16 {{not an aggregate and has no constexpr constructors}} 38561fb158SRichard Smith constexpr B b; // expected-error {{constant expression}} expected-note {{non-constexpr}} 39*a45f713cSLuboš Luňák // expected-note@12 {{here}} 40561fb158SRichard Smith 4112cda633SDouglas Gregor static_assert(plus_seven(3) == 10, ""); 4212cda633SDouglas Gregor 43561fb158SRichard Smith #endif 44