diff options
Diffstat (limited to 'clang/test/CXX')
-rw-r--r-- | clang/test/CXX/basic/basic.types/p10.cpp | 9 | ||||
-rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp | 21 | ||||
-rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp | 14 | ||||
-rw-r--r-- | clang/test/CXX/expr/expr.const/p2-0x.cpp | 10 |
4 files changed, 27 insertions, 27 deletions
diff --git a/clang/test/CXX/basic/basic.types/p10.cpp b/clang/test/CXX/basic/basic.types/p10.cpp index 1f66e5522df..725be09c085 100644 --- a/clang/test/CXX/basic/basic.types/p10.cpp +++ b/clang/test/CXX/basic/basic.types/p10.cpp @@ -34,13 +34,12 @@ constexpr int f(DerivedFromNonTrivDtor<NonTrivDtorBase>); // expected-error {{co struct TrivDtor { constexpr TrivDtor(); }; -// FIXME: when building DefinitionData we look at 'isUserProvided' before it's set up! -#if 0 +constexpr int f(TrivDtor); struct TrivDefaultedDtor { constexpr TrivDefaultedDtor(); ~TrivDefaultedDtor() = default; }; -#endif +constexpr int f(TrivDefaultedDtor); // - it is an aggregate type or has at least one constexpr constructor or // constexpr constructor template that is not a copy or move constructor @@ -100,6 +99,7 @@ struct ArrGood { Agg agg[24]; double d[12]; TrivDtor td[3]; + TrivDefaultedDtor tdd[3]; }; constexpr int f(ArrGood); @@ -120,8 +120,7 @@ namespace MutableMembers { // Here's one reason why allowing this would be a disaster... template<int n> struct Id { int k = n; }; int f() { - // FIXME: correctly check whether the initializer is a constant expression. - constexpr MM m = { 0 }; // desired-error {{must be a constant expression}} + constexpr MM m = { 0 }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-literal type 'const MutableMembers::MM' cannot be used in a constant expression}} ++m.n; return Id<m.n>().k; // expected-error {{not an integral constant expression}} } diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp index 3f6f160221d..0fb6f7def00 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp @@ -20,7 +20,7 @@ constexpr int s1::mi2 = 0; // not a definition of an object constexpr extern int i2; // expected-error {{constexpr variable declaration must be a definition}} // not a literal type -constexpr notlit nl1; // expected-error {{constexpr variable 'nl1' must be initialized by a constant expression}} +constexpr notlit nl1; // expected-error {{constexpr variable 'nl1' must be initialized by a constant expression}} expected-note {{non-literal type 'const notlit' cannot be used in a constant expression}} // function parameters void f2(constexpr int i) {} // expected-error {{function parameter cannot be constexpr}} // non-static member @@ -42,12 +42,13 @@ class C2 {} constexpr; // expected-error {{class cannot be marked constexpr}} struct S2 {} constexpr; // expected-error {{struct cannot be marked constexpr}} union U2 {} constexpr; // expected-error {{union cannot be marked constexpr}} enum E2 {} constexpr; // expected-error {{enum cannot be marked constexpr}} -constexpr class C3 {} c3 = C3(); -constexpr struct S3 {} s3 = S3(); +// FIXME: Mark default constructors as 'constexpr' when appropriate. +constexpr class C3 {} c3 = C3(); // unexpected-error {{must be initialized by a constant expression}} unexpected-note {{non-constexpr constructor}} unexpected-note {{here}} +constexpr struct S3 {} s3 = S3(); // unexpected-error {{must be initialized by a constant expression}} unexpected-note {{non-constexpr constructor}} unexpected-note {{here}} constexpr union U3 {} u3 = {}; constexpr enum E3 { V3 } e3 = V3; -class C4 {} constexpr c4 = C4(); -struct S4 {} constexpr s4 = S4(); +class C4 {} constexpr c4 = C4(); // unexpected-error {{must be initialized by a constant expression}} unexpected-note {{non-constexpr constructor}} unexpected-note {{here}} +struct S4 {} constexpr s4 = S4(); // unexpected-error {{must be initialized by a constant expression}} unexpected-note {{non-constexpr constructor}} unexpected-note {{here}} union U4 {} constexpr u4 = {}; enum E4 { V4 } constexpr e4 = V4; constexpr int; // expected-error {{constexpr can only be used in variable and function declarations}} @@ -67,7 +68,7 @@ struct ConstexprDtor { }; // template stuff -template <typename T> constexpr T ft(T t) { return t; } +template <typename T> constexpr T ft(T t) { return t; } // unexpected-note {{here}} template <typename T> T gt(T t) { return t; } struct S { template<typename T> constexpr T f(); @@ -89,7 +90,7 @@ template <> char S::g() { return 0; } // expected-error {{no function template m template <> double S::g() const { return 0; } // ok // FIXME: The initializer is a constant expression. -constexpr int i3 = ft(1); // unexpected-error {{must be initialized by a constant expression}} +constexpr int i3 = ft(1); // unexpected-error {{must be initialized by a constant expression}} unexpected-note {{undefined function 'ft<int>'}} void test() { // ignore constexpr when instantiating with non-literal @@ -98,7 +99,7 @@ void test() { } // Examples from the standard: -constexpr int square(int x); +constexpr int square(int x); // expected-note {{declared here}} constexpr int bufsz = 1024; constexpr struct pixel { // expected-error {{struct cannot be marked constexpr}} @@ -108,10 +109,10 @@ constexpr struct pixel { // expected-error {{struct cannot be marked constexpr}} }; constexpr pixel::pixel(int a) - : x(square(a)), y(square(a)) + : x(square(a)), y(square(a)) // expected-note {{undefined function 'square' cannot be used in a constant expression}} { } -constexpr pixel small(2); // expected-error {{must be initialized by a constant expression}} +constexpr pixel small(2); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'pixel(2)'}} constexpr int square(int x) { return x * x; diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp index fe79a0e6fc1..4145e9b2245 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp @@ -18,17 +18,17 @@ extern int (*const d)(int); // A variable declaration which uses the constexpr specifier shall have an // initializer and shall be initialized by a constant expression. constexpr int ni1; // expected-error {{default initialization of an object of const type 'const int'}} -constexpr struct C { C(); } ni2; // expected-error {{constexpr variable 'ni2' must be initialized by a constant expression}} +constexpr struct C { C(); } ni2; // expected-error {{constexpr variable 'ni2' must be initialized by a constant expression}} expected-note {{non-literal type 'const struct C' cannot be used in a constant expression}} constexpr double &ni3; // expected-error {{declaration of reference variable 'ni3' requires an initializer}} constexpr int nc1 = i; // expected-error {{constexpr variable 'nc1' must be initialized by a constant expression}} -constexpr C nc2 = C(); // expected-error {{constexpr variable 'nc2' must be initialized by a constant expression}} -int &f(); -constexpr int &nc3 = f(); // expected-error {{constexpr variable 'nc3' must be initialized by a constant expression}} +constexpr C nc2 = C(); // expected-error {{constexpr variable 'nc2' must be initialized by a constant expression}} expected-note {{non-literal type}} +int &f(); // expected-note {{declared here}} +constexpr int &nc3 = f(); // expected-error {{constexpr variable 'nc3' must be initialized by a constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}} constexpr int nc4(i); // expected-error {{constexpr variable 'nc4' must be initialized by a constant expression}} -constexpr C nc5((C())); // expected-error {{constexpr variable 'nc5' must be initialized by a constant expression}} -int &f(); -constexpr int &nc6(f()); // expected-error {{constexpr variable 'nc6' must be initialized by a constant expression}} +constexpr C nc5((C())); // expected-error {{constexpr variable 'nc5' must be initialized by a constant expression}} expected-note {{non-literal type 'const C'}} +int &f(); // expected-note {{here}} +constexpr int &nc6(f()); // expected-error {{constexpr variable 'nc6' must be initialized by a constant expression}} expected-note {{non-constexpr function 'f'}} struct pixel { int x, y; diff --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp b/clang/test/CXX/expr/expr.const/p2-0x.cpp index d02db92a263..aa83fc7fa99 100644 --- a/clang/test/CXX/expr/expr.const/p2-0x.cpp +++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp @@ -78,13 +78,13 @@ namespace NonConstExprReturn { namespace NonConstExprCtor { struct T { constexpr T(const int &r) : - r(r) { // expected-note {{reference to temporary cannot be used to initialize a member in a constant expression}} + r(r) { // expected-note 2{{reference to temporary cannot be used to initialize a member in a constant expression}} } const int &r; }; constexpr int n = 0; constexpr T t1(n); // ok - constexpr T t2(0); // expected-error {{must be initialized by a constant expression}} + constexpr T t2(0); // expected-error {{must be initialized by a constant expression}} expected-note {{temporary created here}} expected-note {{in call to 'T(0)'}} struct S { int n : T(4).r; // expected-error {{constant expression}} expected-note {{temporary created here}} expected-note {{in call to 'T(4)'}} @@ -187,8 +187,8 @@ namespace References { constexpr int e = 42; int &f = const_cast<int&>(e); extern int &g; - constexpr int &h(); // expected-note {{here}} - int &i = h(); + constexpr int &h(); // expected-note 2{{here}} + int &i = h(); // expected-note {{here}} expected-note {{undefined function 'h' cannot be used in a constant expression}} constexpr int &j() { return b; } int &k = j(); @@ -202,7 +202,7 @@ namespace References { int F : f - 11; int G : g; // expected-error {{constant expression}} int H : h(); // expected-error {{constant expression}} expected-note {{undefined function 'h'}} - int I : i; // expected-error {{constant expression}} + int I : i; // expected-error {{constant expression}} expected-note {{initializer of 'i' is not a constant expression}} int J : j(); int K : k; }; |