44 lines · cpp
1// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t2// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s3 4// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch -fpch-instantiate-templates %s -o %t5// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s6 7#ifndef HEADER_INCLUDED8 9#define HEADER_INCLUDED10 11struct B {12 B();13 constexpr B(char) {}14};15 16struct C {17 B b;18 double d = 0.0;19};20 21struct D : B {22 constexpr D(int n) : B('x'), k(2*n+1) {}23 int k;24};25 26constexpr int value = 7;27 28template<typename T>29constexpr T plus_seven(T other) {30 return value + other;31}32 33#else34 35static_assert(D(4).k == 9, "");36constexpr int f(C c) { return 0; } // expected-error {{not a literal type}}37// expected-note@16 {{not an aggregate and has no constexpr constructors}}38constexpr B b; // expected-error {{constant expression}} expected-note {{non-constexpr}}39 // expected-note@12 {{here}}40 41static_assert(plus_seven(3) == 10, "");42 43#endif44