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