summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp1z')
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/aligned-new1.C17
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/aligned-new2.C31
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/aligned-new3.C23
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/aligned-new4.C13
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/aligned-new4a.C13
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/aligned-new5.C14
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/bool-increment1.C14
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C6
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/gen-attrs1.C43
9 files changed, 174 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new1.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new1.C
new file mode 100644
index 00000000000..735296fd8fa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new1.C
@@ -0,0 +1,17 @@
+// { dg-options -std=c++1z }
+// { dg-do run }
+
+#ifndef __STDCPP_DEFAULT_NEW_ALIGNMENT__
+#error __STDCPP_DEFAULT_NEW_ALIGNMENT__ not defined
+#endif
+
+#include <cstdint>
+
+struct alignas(64) A { int i; };
+
+int main()
+{
+ A *p = new A;
+ if (std::intptr_t(p) % 64 != 0)
+ __builtin_abort();
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new2.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new2.C
new file mode 100644
index 00000000000..fe159692b3b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new2.C
@@ -0,0 +1,31 @@
+// { dg-options -std=c++1z }
+// { dg-do run }
+
+#include <new>
+
+struct alignas(64) A {
+ int i;
+ A() { throw 42; }
+};
+struct B { int i; } b;
+
+void *operator new (std::size_t s, std::align_val_t a, B b)
+{
+ return operator new (s, a);
+}
+
+bool deleted = false;
+void operator delete (void *p, std::align_val_t, B)
+{
+ deleted = true;
+}
+
+int main()
+{
+ try {
+ A *p = new (b) A;
+ __builtin_abort ();
+ } catch (...) {}
+ if (!deleted)
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new3.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new3.C
new file mode 100644
index 00000000000..73e33432542
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new3.C
@@ -0,0 +1,23 @@
+// { dg-options -std=c++1z }
+// { dg-do run }
+
+#include <new>
+
+struct alignas(64) A {
+ int i;
+};
+
+bool deleted = false;
+void operator delete (void *p, std::size_t, std::align_val_t)
+{
+ deleted = true;
+ operator delete (p);
+}
+
+int main()
+{
+ A *p = new A;
+ delete p;
+ if (!deleted)
+ __builtin_abort();
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new4.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new4.C
new file mode 100644
index 00000000000..cc63a145589
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new4.C
@@ -0,0 +1,13 @@
+// { dg-options "-std=c++14 -Waligned-new" }
+
+struct alignas(64) A { int i; };
+struct alignas(64) B {
+ int i;
+ void *operator new(__SIZE_TYPE__);
+};
+
+int main()
+{
+ A* ap = new A; // { dg-warning "-Waligned-new" }
+ B* bp = new B;
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new4a.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new4a.C
new file mode 100644
index 00000000000..eb178d46dff
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new4a.C
@@ -0,0 +1,13 @@
+// { dg-options "-std=c++14 -Waligned-new=all" }
+
+struct alignas(64) A { int i; };
+struct alignas(64) B {
+ int i;
+ void *operator new(__SIZE_TYPE__);
+};
+
+int main()
+{
+ A* ap = new A; // { dg-warning "-Waligned-new" }
+ B* bp = new B; // { dg-warning "-Waligned-new" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new5.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new5.C
new file mode 100644
index 00000000000..525129e4c40
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new5.C
@@ -0,0 +1,14 @@
+// { dg-options -faligned-new }
+// { dg-do run }
+
+#include <new>
+#include <stdint.h>
+
+struct A { int i; };
+
+int main()
+{
+ A* ap = new (std::align_val_t(64)) A;
+ if (intptr_t(ap) % 64 != 0)
+ __builtin_abort();
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/bool-increment1.C b/gcc/testsuite/g++.dg/cpp1z/bool-increment1.C
new file mode 100644
index 00000000000..ae2dcf9f391
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/bool-increment1.C
@@ -0,0 +1,14 @@
+// { dg-options -std=c++1z }
+
+int
+fn (bool b)
+{
+ int r = 0;
+
+ r += b++; // { dg-error "use of an operand of type .bool. in .operator\\+\\+. is forbidden in" }
+ r += ++b; // { dg-error "use of an operand of type .bool. in .operator\\+\\+. is forbidden in" }
+ r += b--; // { dg-error "use of an operand of type .bool. in .operator--. is forbidden" }
+ r += --b; // { dg-error "use of an operand of type .bool. in .operator--. is forbidden" }
+
+ return r;
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C
index 41b61114537..982572e65cc 100644
--- a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C
+++ b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C
@@ -350,6 +350,12 @@
# error "__cpp_if_constexpr != 201606"
#endif
+#ifndef __cpp_aligned_new
+# error "__cpp_aligned_new"
+#elif __cpp_aligned_new != 201606
+# error "__cpp_aligned_new != 201606"
+#endif
+
#ifdef __has_cpp_attribute
# if ! __has_cpp_attribute(maybe_unused)
diff --git a/gcc/testsuite/g++.dg/cpp1z/gen-attrs1.C b/gcc/testsuite/g++.dg/cpp1z/gen-attrs1.C
new file mode 100644
index 00000000000..fe1ebb29a1d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/gen-attrs1.C
@@ -0,0 +1,43 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+int
+foo ()
+{
+ static int a [[using gnu: unused, used]]; // { dg-warning "attribute using prefix only available" "" { target c++14_down } }
+ int b [[ using foo : bar (2), baz ]]; // { dg-warning "'foo::bar' scoped attribute directive ignored" }
+ // { dg-warning "'foo::baz' scoped attribute directive ignored" "" { target *-*-* } 8 }
+ // { dg-warning "attribute using prefix only available" "" { target c++14_down } 8 }
+ int c [[ using foo : using ("foo")]]; // { dg-warning "'foo::using' scoped attribute directive ignored" }
+ // { dg-warning "attribute using prefix only available" "" { target c++14_down } 11 }
+ b = 0;
+ c = 0;
+ return b + c;
+}
+
+int
+bar ()
+{
+ int a [[ using BAR: foo::bar]]; // { dg-error "attribute using prefix used together with scoped attribute token" }
+ // { dg-warning "ignored" "" { target *-*-* } 21 }
+ // { dg-warning "attribute using prefix only available" "" { target c++14_down } 21 }
+ int b [[ using BAZ: bar(2), bar::bar(3, 4) ]];// { dg-error "attribute using prefix used together with scoped attribute token" }
+ // { dg-warning "ignored" "" { target *-*-* } 24 }
+ // { dg-warning "attribute using prefix only available" "" { target c++14_down } 24 }
+ a = 0;
+ b = 0;
+ return a + b;
+}
+
+int
+baz ()
+{
+ int a [[ using using: using]]; // { dg-warning "attribute using prefix only available" "" { target c++14_down } }
+ // { dg-warning "'using::using' scoped attribute directive ignored" "" { target *-*-* } 35 }
+ int b [[ using bitand: bitor, xor]]; // { dg-warning "attribute using prefix only available" "" { target c++14_down } }
+ // { dg-warning "'bitand::bitor' scoped attribute directive ignored" "" { target *-*-* } 37 }
+ // { dg-warning "'bitand::xor' scoped attribute directive ignored" "" { target *-*-* } 37 }
+ a = 0;
+ b = 0;
+ return a + b;
+}