summaryrefslogtreecommitdiffstats
path: root/test/CXX/expr
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/expr')
-rw-r--r--test/CXX/expr/expr.const/p2-0x.cpp6
-rw-r--r--test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp7
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm29
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm38
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp4
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp8
-rw-r--r--test/CXX/expr/expr.unary/expr.unary.op/p6.cpp2
-rw-r--r--test/CXX/expr/p10-0x.cpp46
8 files changed, 128 insertions, 12 deletions
diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp
index 054669e..9e6716d 100644
--- a/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/test/CXX/expr/expr.const/p2-0x.cpp
@@ -131,14 +131,14 @@ namespace IncompleteClassTypeAddr {
namespace UndefinedBehavior {
void f(int n) {
switch (n) {
- case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}}
+ case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}} expected-note {{previous case defined here}}
case (int)0x80000000u: // ok
case (int)10000000000ll: // expected-note {{here}}
case (unsigned int)10000000000ll: // expected-error {{duplicate case value}}
case (int)(unsigned)(long long)4.4e9: // ok
- case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}}
+ case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}} expected-error {{duplicate case value '2147483647'}} expected-note {{previous case defined here}}
case (int)((float)1e37 / 1e30): // ok
- case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type 'half'}}
+ case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type 'half'}} expected-error {{duplicate case value '2147483647'}}
break;
}
}
diff --git a/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp b/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp
index 22892a6..212adc8 100644
--- a/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp
+++ b/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp
@@ -10,7 +10,10 @@ template<typename T> T&& xvalue();
void test_classification(char *ptr) {
int (&fr0)(int) = reinterpret_cast<int (&&)(int)>(f);
int &&ir0 = reinterpret_cast<int &&>(*ptr);
- int &&ir1 = reinterpret_cast<int &&>(0);
- int &&ir2 = reinterpret_cast<int &&>('a');
+ int &&ir1 = reinterpret_cast<int &&>(0); // expected-error {{rvalue to reference type}}
+ int &&ir2 = reinterpret_cast<int &&>('a'); // expected-error {{rvalue to reference type}}
int &&ir3 = reinterpret_cast<int &&>(xvalue<char>());
+ // Per DR1268, reinterpret_cast can convert between lvalues and xvalues.
+ int &ir4 = reinterpret_cast<int &>(xvalue<char>());
+ int &&ir5 = reinterpret_cast<int &&>(*ptr);
}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
new file mode 100644
index 0000000..9f98671
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++11 -fblocks -emit-llvm -o - -triple x86_64-apple-darwin11.3 %s | FileCheck %s
+
+namespace PR12746 {
+ // CHECK: define zeroext i1 @_ZN7PR127462f1EPi
+ bool f1(int *x) {
+ // CHECK: store i8* bitcast (i1 (i8*)* @___ZN7PR127462f1EPi_block_invoke to i8*)
+ bool (^outer)() = ^ {
+ auto inner = [&]() -> bool {
+ return x == 0;
+ };
+ return inner();
+ };
+ return outer();
+ }
+
+ // CHECK: define internal zeroext i1 @___ZN7PR127462f1EPi_block_invoke
+ // CHECK: call zeroext i1 @"_ZNK7PR127462f132___ZN7PR127462f1EPi_block_invoke3$_0clEv"
+
+ bool f2(int *x) {
+ auto outer = [&]() -> bool {
+ bool (^inner)() = ^ {
+ return x == 0;
+ };
+ return inner();
+ };
+ return outer();
+ }
+}
+
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
index 0c3fdb2..0db2bf5 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
@@ -86,3 +86,41 @@ namespace overloading {
int &ir = accept_lambda_conv([](int x) { return x + 1; });
}
}
+
+namespace PR13117 {
+ struct A {
+ template<typename ... Args> static void f(Args...);
+
+ template<typename ... Args> static void f1()
+ {
+ (void)^(Args args) { // expected-error{{block contains unexpanded parameter pack 'Args'}}
+ };
+ }
+
+ template<typename ... Args> static void f2()
+ {
+ // FIXME: Allow this.
+ f(
+ ^(Args args) // expected-error{{block contains unexpanded parameter pack 'Args'}}
+ { }
+ ... // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
+ );
+ }
+
+ template<typename ... Args> static void f3()
+ {
+ (void)[](Args args) { // expected-error{{expression contains unexpanded parameter pack 'Args'}}
+ };
+ }
+
+ template<typename ... Args> static void f4()
+ {
+ f([](Args args) { } ...);
+ }
+ };
+
+ void g() {
+ A::f1<int, int>();
+ A::f2<int, int>();
+ }
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp
index 174db25..82fc04a 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp
@@ -9,8 +9,8 @@ void print(T first, Ts... rest) {
}
template<typename... Ts>
-void unsupported(Ts ...values) {
- auto unsup = [values] {}; // expected-error{{unexpanded function parameter pack capture is unsupported}}
+void unexpanded_capture(Ts ...values) {
+ auto unexp = [values] {}; // expected-error{{initializer contains unexpanded parameter pack 'values'}}
}
template<typename... Ts>
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
index d816e17..f580e7e 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
@@ -25,7 +25,7 @@ void infer_void_return_type(int i) {
struct X { };
X infer_X_return_type(X x) {
- return [&x](int y) { // expected-warning{{omitted result type}}
+ return [&x](int y) {
if (y > 0)
return X();
else
@@ -33,11 +33,11 @@ X infer_X_return_type(X x) {
}(5);
}
-X infer_X_return_type_fail(X x) {
- return [x](int y) { // expected-warning{{omitted result type}}
+X infer_X_return_type_fail(X x) {
+ return [x](int y) {
if (y > 0)
return X();
- else
+ else
return x; // expected-error{{return type 'const X' must match previous return type 'X' when lambda expression has unspecified explicit return type}}
}(5);
}
diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp
index ac11940..2646264 100644
--- a/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp
+++ b/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp
@@ -4,7 +4,7 @@
bool b = !0;
-bool b2 = !1.2;
+bool b2 = !1.2; //expected-warning{{implicit conversion from 'double' to 'bool' changes value from 1.2 to true}}
bool b3 = !4;
diff --git a/test/CXX/expr/p10-0x.cpp b/test/CXX/expr/p10-0x.cpp
new file mode 100644
index 0000000..564df88
--- /dev/null
+++ b/test/CXX/expr/p10-0x.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-pc-linux-gnu %s -o - -std=c++11 | FileCheck %s
+
+volatile int g1;
+struct S {
+ volatile int a;
+} g2;
+
+volatile int& refcall();
+
+// CHECK: define void @_Z2f1PViPV1S
+void f1(volatile int *x, volatile S* s) {
+ // We should perform the load in these cases.
+ // CHECK: load volatile i32*
+ (*x);
+ // CHECK: load volatile i32*
+ __extension__ g1;
+ // CHECK: load volatile i32*
+ s->a;
+ // CHECK: load volatile i32*
+ g2.a;
+ // CHECK: load volatile i32*
+ s->*(&S::a);
+ // CHECK: load volatile i32*
+ // CHECK: load volatile i32*
+ x[0], 1 ? x[0] : *x;
+
+ // CHECK: load volatile i32*
+ // CHECK: load volatile i32*
+ // CHECK: load volatile i32*
+ *x ?: *x;
+
+ // CHECK: load volatile i32*
+ ({ *x; });
+
+ // CHECK-NOT: load volatile
+ // CHECK: ret
+}
+
+// CHECK: define void @_Z2f2PVi
+// CHECK-NOT: load volatile
+// CHECK: ret
+void f2(volatile int *x) {
+ // We shouldn't perform the load in these cases.
+ refcall();
+ 1 ? refcall() : *x;
+}
OpenPOWER on IntegriCloud