aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/i-c-e-cxx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/i-c-e-cxx.cpp')
-rw-r--r--test/SemaCXX/i-c-e-cxx.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/test/SemaCXX/i-c-e-cxx.cpp b/test/SemaCXX/i-c-e-cxx.cpp
index 4d02ca8f174e..5631577e0fa9 100644
--- a/test/SemaCXX/i-c-e-cxx.cpp
+++ b/test/SemaCXX/i-c-e-cxx.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
// C++-specific tests for integral constant expressions.
@@ -16,9 +16,9 @@ void f() {
}
int a() {
- const int t=t;
+ const int t=t; // expected-note {{declared here}}
switch(1) { // expected-warning {{no case matching constant switch condition '1'}}
- case t:; // expected-error {{not an integer constant expression}}
+ case t:; // expected-error {{not an integral constant expression}} expected-note {{initializer of 't' is not a constant expression}}
}
}
@@ -48,7 +48,7 @@ void pr6373(const unsigned x = 0) {
namespace rdar9204520 {
struct A {
- static const int B = int(0.75 * 1000 * 1000);
+ static const int B = int(0.75 * 1000 * 1000); // expected-warning {{not a constant expression; folding it to a constant is a GNU extension}}
};
int foo() { return A::B; }
@@ -59,5 +59,10 @@ const int x = 10;
int* y = reinterpret_cast<const char&>(x); // expected-error {{cannot initialize}}
// This isn't an integral constant expression, but make sure it folds anyway.
-struct PR8836 { char _; long long a; };
-int PR8836test[(__typeof(sizeof(int)))&reinterpret_cast<const volatile char&>((((PR8836*)0)->a))];
+struct PR8836 { char _; long long a; }; // expected-warning {{long long}}
+int PR8836test[(__typeof(sizeof(int)))&reinterpret_cast<const volatile char&>((((PR8836*)0)->a))]; // expected-warning {{folded to constant array as an extension}} expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
+
+const int nonconst = 1.0; // expected-note {{declared here}}
+int arr[nonconst]; // expected-warning {{folded to constant array as an extension}} expected-note {{initializer of 'nonconst' is not a constant expression}}
+const int castfloat = static_cast<int>(1.0);
+int arr2[castfloat]; // ok