aboutsummaryrefslogtreecommitdiff
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.cpp6
-rw-r--r--test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp10
-rw-r--r--test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp11
3 files changed, 25 insertions, 2 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 7305bd1f53e2..a3a2f712c800 100644
--- a/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
+++ b/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
@@ -9,12 +9,14 @@ struct only {
void f() {
only<const int*> p = new const auto (0);
only<double*> q = new (auto) (0.0);
+ only<char*> r = new auto {'a'};
new auto; // expected-error{{new expression for type 'auto' 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}}
- new auto {1,2,3}; // expected-error{{new expression for type 'auto' cannot use list-initialization}}
- new auto ({1,2,3}); // expected-error{{new expression for type 'auto' cannot use list-initialization}}
+ new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}}
+ new auto {1,2,3}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
+ new auto ({1,2,3}); // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
}
void p2example() {
diff --git a/test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp b/test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp
new file mode 100644
index 000000000000..70bbc4805c43
--- /dev/null
+++ b/test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -pedantic
+
+void f() {
+ new auto('a');
+ new auto {2}; // expected-warning {{ISO C++ standards before C++17 do not allow new expression for type 'auto' to use list-initialization}}
+ new auto {1, 2}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
+ new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}}
+ new decltype(auto)({1}); // expected-warning {{ISO C++ standards before C++17 do not allow new expression for type 'decltype(auto)' to use list-initialization}}
+ new decltype(auto)({1, 2}); // expected-error{{new expression for type 'decltype(auto)' contains multiple constructor arguments}}
+}
diff --git a/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp b/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
new file mode 100644
index 000000000000..6e76075ab16f
--- /dev/null
+++ b/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 -pedantic
+
+void f() {
+ new auto('a');
+ new auto {2};
+ new auto {1, 2}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
+ new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}}
+ new decltype(auto)({1});
+ new decltype(auto)({1, 2}); // expected-error{{new expression for type 'decltype(auto)' contains multiple constructor arguments}}
+}