summaryrefslogtreecommitdiffstats
path: root/test/CXX/expr/expr.unary
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/expr/expr.unary')
-rw-r--r--test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp2
-rw-r--r--test/CXX/expr/expr.unary/expr.sizeof/p1.cpp28
-rw-r--r--test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp9
-rw-r--r--test/CXX/expr/expr.unary/expr.unary.op/p4.cpp4
4 files changed, 40 insertions, 3 deletions
diff --git a/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp b/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
index 4ebbfce..2e99b52 100644
--- a/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
+++ b/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
@@ -11,7 +11,7 @@ void f() {
only<double*> q = new (auto) (0.0);
new auto; // expected-error{{new expression for type 'auto' requires a constructor argument}}
- new (const auto)(); // expected-error{{new expression for type 'auto const' requires a constructor argument}}
+ new (const auto)(); // expected-error{{new expression for type 'const auto' requires a constructor argument}}
new (auto) (1,2,3); // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
}
diff --git a/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp b/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp
index 6a59e3d..aa76b3a 100644
--- a/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp
+++ b/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp
@@ -18,3 +18,31 @@ void test(A *a) {
x = sizeof(a->bitX = 3); // expected-error {{invalid application of 'sizeof' to bit-field}}
x = sizeof(a->bitY += 3); // expected-error {{invalid application of 'sizeof' to bit-field}}
}
+
+void test2() {
+ int x;
+ x = sizeof(void); // expected-error {{invalid application of 'sizeof' to an incomplete type 'void'}}
+ x = sizeof(int()); // expected-error {{invalid application of 'sizeof' to a function type}}
+ x = sizeof(test2()); // expected-error {{invalid application of 'sizeof' to an incomplete type 'void'}}
+ x = sizeof(test2); // expected-error {{invalid application of 'sizeof' to a function type}}
+}
+
+namespace pr16992 {
+
+template<typename T> struct ABC {
+ int func () {
+ return sizeof T; // expected-error {{expected parentheses around type name in sizeof expression}}
+ }
+};
+
+ABC<int> qq;
+
+template<typename T> struct ABC2 {
+ int func () {
+ return sizeof T::A;
+ }
+};
+
+struct QQ { int A; };
+ABC2<QQ> qq2;
+}
diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp
index 1f5969d..427e8c5 100644
--- a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp
+++ b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -fms-extensions %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -fms-extensions -Wno-delete-incomplete %s
// expected-no-diagnostics
#define P(e) static_assert(noexcept(e), "expected nothrow")
@@ -39,6 +39,9 @@ void (*pallspec)() throw(...);
void (*pintspec)() throw(int);
void (*pemptyspec)() throw();
+typedef void (*funcptr)();
+funcptr returnsptr() throw();
+
void callptr() {
N(pnospec());
N((*pnospec)());
@@ -48,6 +51,7 @@ void callptr() {
N((*pintspec)());
P(pemptyspec());
P((*pemptyspec)());
+ N(returnsptr()());
}
struct S1 {
@@ -91,6 +95,8 @@ struct S2 {
void *operator new(__typeof__(sizeof(int)) sz, int) throw();
+struct IncompleteStruct;
+
struct Bad1 {
~Bad1() throw(int);
};
@@ -104,6 +110,7 @@ void implicits() {
N(new int);
P(new (0) int);
P(delete (int*)0);
+ P(delete (IncompleteStruct*)0);
N(delete (Bad1*)0);
N(delete (Bad2*)0);
N(S2());
diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp
index 06cc610..cd55cc2 100644
--- a/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp
+++ b/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp
@@ -38,6 +38,8 @@ namespace test2 {
};
void A::test() {
- int (A::*ptr)(int) = &(A::foo); // expected-error {{can't form member pointer of type 'int (test2::A::*)(int)' without '&' and class name}}
+ // FIXME: The error message in this case is less than clear, we can do
+ // better.
+ int (A::*ptr)(int) = &(A::foo); // expected-error {{cannot create a non-constant pointer to member function}}
}
}
OpenPOWER on IntegriCloud