summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/expr/expr.const/p2-0x.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX/expr/expr.const/p2-0x.cpp')
-rw-r--r--clang/test/CXX/expr/expr.const/p2-0x.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp b/clang/test/CXX/expr/expr.const/p2-0x.cpp
index 091ef097255..63e30175b9f 100644
--- a/clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -pedantic -verify -fcxx-exceptions %s -fconstexpr-depth 128 -triple i686-pc-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -pedantic -verify=expected,cxx11 -fcxx-exceptions %s -fconstexpr-depth 128 -triple i686-pc-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -std=c++2a -pedantic -verify=expected,cxx20 -fcxx-exceptions %s -fconstexpr-depth 128 -triple i686-pc-linux-gnu
// A conditional-expression is a core constant expression unless it involves one
// of the following as a potentially evaluated subexpression [...]:
@@ -157,13 +158,13 @@ namespace UndefinedBehavior {
constexpr int shl_unsigned_negative = unsigned(-3) << 1; // ok
constexpr int shl_unsigned_into_sign = 1u << 31; // ok
constexpr int shl_unsigned_overflow = 1024u << 31; // ok
- constexpr int shl_signed_negative = (-3) << 1; // expected-error {{constant expression}} expected-note {{left shift of negative value -3}}
+ constexpr int shl_signed_negative = (-3) << 1; // cxx11-error {{constant expression}} cxx11-note {{left shift of negative value -3}}
constexpr int shl_signed_ok = 1 << 30; // ok
constexpr int shl_signed_into_sign = 1 << 31; // ok (DR1457)
constexpr int shl_signed_into_sign_2 = 0x7fffffff << 1; // ok (DR1457)
- constexpr int shl_signed_off_end = 2 << 31; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x100000000) requires 34 bits to represent, but 'int' only has 32 bits}}
- constexpr int shl_signed_off_end_2 = 0x7fffffff << 2; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x1FFFFFFFC) requires 34 bits to represent, but 'int' only has 32 bits}}
- constexpr int shl_signed_overflow = 1024 << 31; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{requires 43 bits to represent}}
+ constexpr int shl_signed_off_end = 2 << 31; // cxx11-error {{constant expression}} cxx11-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x100000000) requires 34 bits to represent, but 'int' only has 32 bits}}
+ constexpr int shl_signed_off_end_2 = 0x7fffffff << 2; // cxx11-error {{constant expression}} cxx11-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x1FFFFFFFC) requires 34 bits to represent, but 'int' only has 32 bits}}
+ constexpr int shl_signed_overflow = 1024 << 31; // cxx11-error {{constant expression}} cxx11-note {{signed left shift discards bits}} expected-warning {{requires 43 bits to represent}}
constexpr int shl_signed_ok2 = 1024 << 20; // ok
constexpr int shr_m1 = 0 >> -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}}
@@ -291,7 +292,7 @@ namespace UndefinedBehavior {
// - a lambda-expression (5.1.2);
struct Lambda {
- int n : []{ return 1; }(); // expected-error {{constant expression}} expected-error {{integral constant expression}} expected-note {{non-literal type}}
+ int n : []{ return 1; }(); // cxx11-error {{constant expression}} cxx11-error {{integral constant expression}} cxx11-note {{non-literal type}}
};
// - an lvalue-to-rvalue conversion (4.1) unless it is applied to
@@ -360,7 +361,7 @@ namespace LValueToRValueUnion {
extern const U pu;
constexpr const int *pua = &pu.a;
constexpr const int *pub = &pu.b;
- constexpr U pu = { .b = 1 }; // expected-warning {{C++20 extension}}
+ constexpr U pu = { .b = 1 }; // cxx11-warning {{C++20 extension}}
constexpr const int a2 = *pua; // expected-error {{constant expression}} expected-note {{read of member 'a' of union with active member 'b'}}
constexpr const int b2 = *pub; // ok
}
@@ -402,7 +403,7 @@ namespace DynamicCast {
struct S { int n; };
constexpr S s { 16 };
struct T {
- int n : dynamic_cast<const S*>(&s)->n; // expected-warning {{constant expression}} expected-note {{dynamic_cast}}
+ int n : dynamic_cast<const S*>(&s)->n; // cxx11-warning {{constant expression}} cxx11-note {{dynamic_cast}}
};
}
@@ -431,8 +432,8 @@ namespace PseudoDtor {
namespace IncDec {
int k = 2;
struct T {
- int n : ++k; // expected-error {{constant expression}}
- int m : --k; // expected-error {{constant expression}}
+ int n : ++k; // expected-error {{constant expression}} cxx20-note {{visible outside}}
+ int m : --k; // expected-error {{constant expression}} cxx20-note {{visible outside}}
};
}
@@ -446,7 +447,7 @@ namespace std {
namespace TypeId {
struct S { virtual void f(); };
constexpr S *p = 0;
- constexpr const std::type_info &ti1 = typeid(*p); // expected-error {{must be initialized by a constant expression}} expected-note {{typeid applied to expression of polymorphic type 'TypeId::S'}}
+ constexpr const std::type_info &ti1 = typeid(*p); // expected-error {{must be initialized by a constant expression}} cxx11-note {{typeid applied to expression of polymorphic type 'TypeId::S'}} cxx20-note {{dereferenced null pointer}}
struct T {} t;
constexpr const std::type_info &ti2 = typeid(t);
@@ -455,10 +456,10 @@ namespace TypeId {
// - a new-expression (5.3.4);
// - a delete-expression (5.3.5);
namespace NewDelete {
- int *p = 0;
+ constexpr int *p = 0;
struct T {
- int n : *new int(4); // expected-error {{constant expression}}
- int m : (delete p, 2); // expected-error {{constant expression}}
+ int n : *new int(4); // expected-warning {{constant expression}} cxx11-note {{until C++20}} cxx20-note {{was not deallocated}}
+ int m : (delete p, 2); // cxx11-warning {{constant expression}} cxx11-note {{until C++20}}
};
}
@@ -550,8 +551,8 @@ namespace UnspecifiedRelations {
namespace Assignment {
int k;
struct T {
- int n : (k = 9); // expected-error {{constant expression}}
- int m : (k *= 2); // expected-error {{constant expression}}
+ int n : (k = 9); // expected-error {{constant expression}} cxx20-note {{visible outside}}
+ int m : (k *= 2); // expected-error {{constant expression}} cxx20-note {{visible outside}}
};
struct Literal {
OpenPOWER on IntegriCloud