aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r--gcc/testsuite/g++.dg/concepts/diagnostic20.C13
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/constexpr-vector1.C8
-rw-r--r--gcc/testsuite/g++.dg/modules/lambda-10_a.H17
-rw-r--r--gcc/testsuite/g++.dg/modules/lambda-10_b.C7
-rw-r--r--gcc/testsuite/g++.dg/modules/lambda-8_b.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/leg-merge-4_c.C6
-rw-r--r--gcc/testsuite/g++.dg/modules/noexcept-4_a.H6
-rw-r--r--gcc/testsuite/g++.dg/modules/noexcept-4_b.C18
-rw-r--r--gcc/testsuite/g++.dg/template/friend86.C25
-rw-r--r--gcc/testsuite/g++.dg/template/friend87.C42
-rw-r--r--gcc/testsuite/g++.dg/torture/pr119778.C20
11 files changed, 160 insertions, 4 deletions
diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic20.C b/gcc/testsuite/g++.dg/concepts/diagnostic20.C
new file mode 100644
index 0000000..2bb01db
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/diagnostic20.C
@@ -0,0 +1,13 @@
+// PR c++/99214
+// { dg-do compile { target c++20 } }
+
+template <class T>
+struct A {
+ template <class U> static void f() requires requires { T::fail; };
+};
+
+int main() {
+ A<int>::f<char>(); // { dg-error "no match" }
+}
+
+// { dg-message "In substitution of '\[^\r\n\]* \\\[with U = char\\\]'" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-vector1.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-vector1.C
new file mode 100644
index 0000000..196c6ec
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-vector1.C
@@ -0,0 +1,8 @@
+// PR c++/113835
+// { dg-timeout-factor 0.05 }
+// { dg-do compile { target c++20_only } }
+
+#include <vector>
+const std::size_t N = 1'000'000;
+std::vector<int> x(N);
+int main() {}
diff --git a/gcc/testsuite/g++.dg/modules/lambda-10_a.H b/gcc/testsuite/g++.dg/modules/lambda-10_a.H
new file mode 100644
index 0000000..1ad1a80
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/lambda-10_a.H
@@ -0,0 +1,17 @@
+// PR c++/119755
+// { dg-additional-options "-fmodule-header" }
+// { dg-module-cmi {} }
+
+template <typename _Out> void format(_Out) {
+ constexpr int __term = 1;
+ [&] { __term; };
+ [&] { const int outer = __term; { __term; } };
+ [&]() noexcept { __term; };
+ [&]() noexcept { const int outer = __term; { __term; } };
+ [&](auto) { int n[__term]; }(0);
+ [&](auto) noexcept { int n[__term]; }(0);
+}
+
+inline void vformat() {
+ format(0);
+}
diff --git a/gcc/testsuite/g++.dg/modules/lambda-10_b.C b/gcc/testsuite/g++.dg/modules/lambda-10_b.C
new file mode 100644
index 0000000..3556bce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/lambda-10_b.C
@@ -0,0 +1,7 @@
+// PR c++/119755
+// { dg-additional-options "-fmodules" }
+
+import "lambda-10_a.H";
+int main() {
+ vformat();
+}
diff --git a/gcc/testsuite/g++.dg/modules/lambda-8_b.C b/gcc/testsuite/g++.dg/modules/lambda-8_b.C
index 7ace494..96578ba 100644
--- a/gcc/testsuite/g++.dg/modules/lambda-8_b.C
+++ b/gcc/testsuite/g++.dg/modules/lambda-8_b.C
@@ -4,4 +4,4 @@
#include "lambda-8.h"
import "lambda-8_a.H";
-// { dg-error "conflicting global module declaration" "" { target *-*-* } 0 }
+// { dg-error "conflicting imported declaration" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/g++.dg/modules/leg-merge-4_c.C b/gcc/testsuite/g++.dg/modules/leg-merge-4_c.C
index f1b1aeb..5756057 100644
--- a/gcc/testsuite/g++.dg/modules/leg-merge-4_c.C
+++ b/gcc/testsuite/g++.dg/modules/leg-merge-4_c.C
@@ -11,8 +11,8 @@ void foo ()
X *p;
}
-// { dg-regexp "\nIn module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:4:\[0-9]*: error: conflicting global module declaration 'float bob'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:4:\[0-9]*: note: existing declaration 'int bob'\n\[^\n]*leg-merge-4_c.C:9:\[0-9]*: note: during load of binding '::bob'$" }
+// { dg-regexp "\nIn module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:4:\[0-9]*: error: conflicting type for imported declaration 'float bob'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:4:\[0-9]*: note: existing declaration 'int bob'\n\[^\n]*leg-merge-4_c.C:9:\[0-9]*: note: during load of binding '::bob'$" }
-// { dg-regexp "\nIn module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:5:\[0-9]*: error: conflicting global module declaration 'int frob\\(\\)'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:5:\[0-9]*: note: existing declaration 'void frob\\(\\)'\n\[^\n]*leg-merge-4_c.C:10:\[0-9]*: note: during load of binding '::frob'$" }
+// { dg-regexp "\nIn module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:5:\[0-9]*: error: conflicting type for imported declaration 'int frob\\(\\)'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:5:\[0-9]*: note: existing declaration 'void frob\\(\\)'\n\[^\n]*leg-merge-4_c.C:10:\[0-9]*: note: during load of binding '::frob'$" }
-// { dg-regexp "In module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:6:\[0-9]*: error: conflicting global module declaration 'union X'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:6:\[0-9]*: note: existing declaration 'class X'\n\[^\n]*leg-merge-4_c.C:11:\[0-9]*: note: during load of binding '::X'$" }
+// { dg-regexp "In module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:6:\[0-9]*: error: conflicting type for imported declaration 'union X'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:6:\[0-9]*: note: existing declaration 'class X'\n\[^\n]*leg-merge-4_c.C:11:\[0-9]*: note: during load of binding '::X'$" }
diff --git a/gcc/testsuite/g++.dg/modules/noexcept-4_a.H b/gcc/testsuite/g++.dg/modules/noexcept-4_a.H
new file mode 100644
index 0000000..b888a1b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/noexcept-4_a.H
@@ -0,0 +1,6 @@
+// { dg-additional-options "-fmodule-header -std=c++20" }
+// { dg-module-cmi {} }
+
+struct exception_ptr {
+ friend bool operator==(const exception_ptr&, const exception_ptr&) = default;
+};
diff --git a/gcc/testsuite/g++.dg/modules/noexcept-4_b.C b/gcc/testsuite/g++.dg/modules/noexcept-4_b.C
new file mode 100644
index 0000000..7cc5531
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/noexcept-4_b.C
@@ -0,0 +1,18 @@
+// { dg-additional-options "-fmodules -std=c++20" }
+
+struct exception_ptr {
+ friend bool operator==(const exception_ptr&, const exception_ptr&) = default;
+};
+
+void enqueue() {
+ exception_ptr e;
+ e == e;
+}
+
+import "noexcept-4_a.H";
+
+int main() {
+ constexpr exception_ptr e;
+ static_assert(e == e);
+ static_assert(noexcept(e == e));
+}
diff --git a/gcc/testsuite/g++.dg/template/friend86.C b/gcc/testsuite/g++.dg/template/friend86.C
new file mode 100644
index 0000000..9e2c1af
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/friend86.C
@@ -0,0 +1,25 @@
+// PR c++/119807
+// { dg-do run }
+
+template<int N>
+struct A {
+ template<class T> friend int f(A<N>, T);
+};
+
+template struct A<0>;
+template struct A<1>;
+
+int main() {
+ A<0> x;
+ A<1> y;
+ if (f(x, true) != 0) __builtin_abort();
+ if (f(y, true) != 1) __builtin_abort();
+}
+
+template<int N>
+struct B {
+ template<class T> friend int f(A<N>, T) { return N; }
+};
+
+template struct B<0>;
+template struct B<1>;
diff --git a/gcc/testsuite/g++.dg/template/friend87.C b/gcc/testsuite/g++.dg/template/friend87.C
new file mode 100644
index 0000000..94c0dfc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/friend87.C
@@ -0,0 +1,42 @@
+// PR c++/119807
+// { dg-do compile { target c++20 } }
+
+using size_t = decltype(sizeof(0));
+
+template<auto tag, size_t current>
+struct CounterReader {
+ template<typename>
+ friend auto counterFlag(CounterReader<tag, current>) noexcept;
+};
+
+template<auto tag, size_t current>
+struct CounterWriter {
+ static constexpr size_t value = current;
+
+ template<typename>
+ friend auto counterFlag(CounterReader<tag, current>) noexcept {}
+};
+
+template<auto tag, auto unique, size_t current = 0, size_t mask = size_t(1) << (sizeof(size_t) * 8 - 1)>
+[[nodiscard]] constexpr size_t counterAdvance() noexcept {
+ if constexpr (!mask) {
+ return CounterWriter<tag, current + 1>::value;
+ } else if constexpr (requires { counterFlag<void>(CounterReader<tag, current | mask>()); }) {
+ return counterAdvance<tag, unique, current | mask, (mask >> 1)>();
+ }
+ else {
+ return counterAdvance<tag, unique, current, (mask >> 1)>();
+ }
+}
+
+constexpr auto defaultCounterTag = [] {};
+
+template<auto tag = defaultCounterTag, auto unique = [] {}>
+constexpr size_t counter() noexcept {
+ return counterAdvance<tag, unique>();
+}
+
+int main() {
+ static_assert(counter() == 1);
+ static_assert(counter() == 2);
+}
diff --git a/gcc/testsuite/g++.dg/torture/pr119778.C b/gcc/testsuite/g++.dg/torture/pr119778.C
new file mode 100644
index 0000000..4948056
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr119778.C
@@ -0,0 +1,20 @@
+// { dg-do compile }
+// { dg-additional-options "-Wall" }
+
+struct jmp_buf { long l[16]; };
+extern "C" int setjmp (jmp_buf *);
+struct S {
+ void foo () { bar (); }
+ virtual char bar () { return 0; }
+};
+void baz ();
+jmp_buf *a;
+
+void
+qux (bool x, S *y)
+{
+ if (x)
+ setjmp (a);
+ y->foo ();
+ baz ();
+}