aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/c-c++-common/analyzer/invalid-shift-1.c4
-rw-r--r--gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c11
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-decompose-2.c3
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr100400-1-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr100400-1-3.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-3.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-4.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104132-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104133-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104774-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/mdc-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/vla-1.c2
-rw-r--r--gcc/testsuite/c-c++-common/uninit-17.c4
-rw-r--r--gcc/testsuite/g++.dg/analyzer/exception-value-2.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template18.C11
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C5
-rw-r--r--gcc/testsuite/g++.dg/cpp26/attr-indeterminate1.C154
-rw-r--r--gcc/testsuite/g++.dg/cpp26/attr-indeterminate2.C39
-rw-r--r--gcc/testsuite/g++.dg/cpp26/attr-indeterminate3.C21
-rw-r--r--gcc/testsuite/g++.dg/cpp26/attr-indeterminate4.C36
-rw-r--r--gcc/testsuite/g++.dg/cpp26/erroneous1.C61
-rw-r--r--gcc/testsuite/g++.dg/cpp26/erroneous2.C234
-rw-r--r--gcc/testsuite/g++.dg/cpp26/erroneous3.C158
-rw-r--r--gcc/testsuite/g++.dg/cpp26/erroneous4.C37
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/constexpr-new28.C45
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/constexpr-new29.C30
-rw-r--r--gcc/testsuite/g++.dg/modules/adl-6_c.C5
-rw-r--r--gcc/testsuite/g++.dg/modules/internal-14_c.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/internal-15_a.C28
-rw-r--r--gcc/testsuite/g++.dg/modules/internal-15_b.C13
-rw-r--r--gcc/testsuite/g++.dg/opt/store-merging-1.C2
-rw-r--r--gcc/testsuite/g++.dg/parse/auto-struct-param.C4
-rw-r--r--gcc/testsuite/g++.dg/uninit-pred-loop-1_b.C2
-rw-r--r--gcc/testsuite/g++.dg/warn/Warray-bounds-20.C12
-rw-r--r--gcc/testsuite/g++.dg/warn/Wuninitialized-13.C4
-rw-r--r--gcc/testsuite/gnat.dg/use_type1.adb16
-rw-r--r--gcc/testsuite/gnat.dg/use_type2.adb15
38 files changed, 942 insertions, 27 deletions
diff --git a/gcc/testsuite/c-c++-common/analyzer/invalid-shift-1.c b/gcc/testsuite/c-c++-common/analyzer/invalid-shift-1.c
index 08e5272..1b67c07 100644
--- a/gcc/testsuite/c-c++-common/analyzer/invalid-shift-1.c
+++ b/gcc/testsuite/c-c++-common/analyzer/invalid-shift-1.c
@@ -12,10 +12,10 @@ _dl_hwcaps_subdirs_build_bitmask (int subdirs, int active)
uint32_t mask;
if (subdirs != 32)
- mask = (1 << subdirs) - 1; /* { dg-message "shift by count \\('33'\\) >= precision of type \\('\[0-9\]+'\\)" } */
+ mask = (1 << subdirs) - 1; /* { dg-message "shift by count \\('33'\\) >= precision of type \\('\[0-9\]+'\\)" "" { xfail c++26 } } */
else
mask = -1;
- return mask ^ ((1U << inactive) - 1); /* { dg-message "shift by negative count \\('-1'\\)" } */
+ return mask ^ ((1U << inactive) - 1); /* { dg-message "shift by negative count \\('-1'\\)" "" { xfail c++26 } } */
}
void f1 (int);
diff --git a/gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c b/gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c
index 9ef154e..929dfca 100644
--- a/gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c
+++ b/gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c
@@ -1,10 +1,9 @@
-/* { dg-additional-options "--param=openacc-kernels=decompose" }
-
+/* { dg-additional-options "--param=openacc-kernels=decompose" } */
/* { dg-additional-options "-fopt-info-omp-note" } */
-
-/* { dg-additional-options "--param=openacc-privatization=noisy" }
- Prune a few: uninteresting, and potentially varying depending on GCC configuration (data types):
- { dg-prune-output {note: variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} } */
+/* { dg-additional-options "--param=openacc-privatization=noisy" } */
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
+/* Prune a few: uninteresting, and potentially varying depending on GCC configuration (data types): */
+/* { dg-prune-output {note: variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} } */
void
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-2.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-2.c
index 3ce9490..5aac40c 100644
--- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-2.c
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-2.c
@@ -1,10 +1,13 @@
/* Test OpenACC 'kernels' construct decomposition. */
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
/* { dg-additional-options "-fopt-info-omp-all" } */
/* { dg-additional-options "--param=openacc-kernels=decompose" }
/* { dg-additional-options "-O2" } for 'parloops'. */
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
+
/* { dg-additional-options "--param=openacc-privatization=noisy" }
Prune a few: uninteresting, and potentially varying depending on GCC configuration (data types):
{ dg-prune-output {note: variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr100400-1-1.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr100400-1-1.c
index 57cb1a8..97fcaf7 100644
--- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr100400-1-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr100400-1-1.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
/* { dg-additional-options "--param openacc-kernels=decompose" } */
/* { dg-additional-options "-g0" } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr100400-1-3.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr100400-1-3.c
index 9779f10..f7c8069 100644
--- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr100400-1-3.c
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr100400-1-3.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
/* { dg-additional-options "--param openacc-kernels=decompose" } */
/* { dg-additional-options "-fchecking" }
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-1.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-1.c
index aa0fca7..5bb68c1 100644
--- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-1.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
/* { dg-additional-options "--param openacc-kernels=decompose" } */
/* { dg-additional-options "-g0" } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-3.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-3.c
index 70c2ac5..43e1cca 100644
--- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-3.c
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-3.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
/* { dg-additional-options "--param openacc-kernels=decompose" } */
/* { dg-additional-options "-fcompare-debug" } -- w/o debug compiled first.
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-4.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-4.c
index d1cc1a9..97d7bed 100644
--- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-4.c
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104061-1-4.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
/* { dg-additional-options "--param openacc-kernels=decompose" } */
/* { dg-additional-options "-g -fcompare-debug" } -- w/ debug compiled first.
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104132-1.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104132-1.c
index 2a663e0..9094a57 100644
--- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104132-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104132-1.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
/* { dg-additional-options "--param openacc-kernels=decompose" } */
/* { dg-additional-options "-fopt-info-all-omp" } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104133-1.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104133-1.c
index 2724e22..aa5dd34 100644
--- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104133-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104133-1.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
/* { dg-additional-options "--param openacc-kernels=decompose" } */
/* { dg-additional-options "-fopt-info-all-omp" } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104774-1.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104774-1.c
index 3ef0c897..e6d4c55 100644
--- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104774-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-pr104774-1.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
/* { dg-additional-options "--param openacc-kernels=decompose" } */
/* { dg-additional-options "-fopt-info-all-omp" } */
diff --git a/gcc/testsuite/c-c++-common/goacc/mdc-1.c b/gcc/testsuite/c-c++-common/goacc/mdc-1.c
index 923a4ea..8d3e7bf 100644
--- a/gcc/testsuite/c-c++-common/goacc/mdc-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/mdc-1.c
@@ -3,6 +3,7 @@
/* TODO The tree dump scanning has certain expectations.
{ dg-do compile { target { lp64 || llp64 } } } */
+/* { dg-skip-if "PR121975" { c++26 } { "*" } { "" } } */
/* { dg-additional-options "-fdump-tree-omplower" } */
/* { dg-additional-options -Wuninitialized } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/vla-1.c b/gcc/testsuite/c-c++-common/ubsan/vla-1.c
index b29d904..0073514 100644
--- a/gcc/testsuite/c-c++-common/ubsan/vla-1.c
+++ b/gcc/testsuite/c-c++-common/ubsan/vla-1.c
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-options "-fsanitize=vla-bound -Wall -Wno-unused-variable -fno-stack-clash-protection" } */
+/* { dg-options "-fsanitize=vla-bound -Wall -Wno-unused-variable -fno-stack-clash-protection -ftrivial-auto-var-init=uninitialized" } */
typedef long int V;
int x = -1;
diff --git a/gcc/testsuite/c-c++-common/uninit-17.c b/gcc/testsuite/c-c++-common/uninit-17.c
index b549536..5dd49a9 100644
--- a/gcc/testsuite/c-c++-common/uninit-17.c
+++ b/gcc/testsuite/c-c++-common/uninit-17.c
@@ -10,10 +10,10 @@ static void bar(int a, int *ptr)
do
{
int b;
- if (b < 40) {
+ if (b < 40) { /* { dg-warning "is used uninitialized" "" { target c++26 } } */
ptr[0] = b;
}
- b += 1; /* { dg-warning "is used uninitialized" } */
+ b += 1; /* { dg-warning "is used uninitialized" "" { target { c || c++23_down } } } */
ptr++;
}
while (--a != 0);
diff --git a/gcc/testsuite/g++.dg/analyzer/exception-value-2.C b/gcc/testsuite/g++.dg/analyzer/exception-value-2.C
index ef9dd46..5173f538 100644
--- a/gcc/testsuite/g++.dg/analyzer/exception-value-2.C
+++ b/gcc/testsuite/g++.dg/analyzer/exception-value-2.C
@@ -1,3 +1,5 @@
+// { dg-skip-if "PR122044" { c++26 } { "*" } { "" } }
+
#include "../../gcc.dg/analyzer/analyzer-decls.h"
struct foo {};
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template18.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template18.C
new file mode 100644
index 0000000..e5e6e6a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template18.C
@@ -0,0 +1,11 @@
+// PR c++/122127
+// { dg-do compile { target c++11 } }
+
+template <int> struct resize;
+template <int _Np> using resize_t = resize<_Np>;
+template <class _Ap> struct basic_mask {
+ void _M_chunk() {
+ constexpr int __rem = 1;
+ [&] { resize_t<__rem>(); }();
+ }
+};
diff --git a/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C b/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C
index ba485df..ce35c90 100644
--- a/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C
+++ b/gcc/testsuite/g++.dg/cpp1y/vla-initlist1.C
@@ -1,5 +1,4 @@
// { dg-do run { target c++11 } }
-// { dg-skip-if "power overwrites two slots of array i" { "power*-*-*" } }
// { dg-options "-Wno-vla" }
#include <initializer_list>
@@ -7,7 +6,7 @@
struct A
{
int i;
- A(std::initializer_list<int>) { }
+ A(std::initializer_list<int>) : i{43} { }
A(int i): i{i} { }
~A() {}
};
@@ -18,7 +17,7 @@ int main(int argc, char **argv)
{ int i[x] = { 42, 42, 42, 42 }; }
{
A a[x] = { argc };
- if (a[1].i != 42)
+ if (a[1].i != 43)
__builtin_abort ();
}
}
diff --git a/gcc/testsuite/g++.dg/cpp26/attr-indeterminate1.C b/gcc/testsuite/g++.dg/cpp26/attr-indeterminate1.C
new file mode 100644
index 0000000..58f6dc5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/attr-indeterminate1.C
@@ -0,0 +1,154 @@
+// C++ 26 P2795R5 - Erroneous behaviour for uninitialized reads
+// { dg-do compile { target c++11 } }
+
+int arr[2];
+struct S { int a, b; };
+S arr2[2];
+
+void
+foo ([[indeterminate]] int n, int n2 [[indeterminate]], int n3 [[indeterminate]] [2])
+{
+ [[indeterminate]] int x1, x11, x12, x13;
+ int x14, x15 [[indeterminate]];
+ [[indeterminate ("foobar")]] int x2; // { dg-error "'indeterminate' attribute does not take any arguments" }
+ // { dg-error "expected primary-expression before 'int'" "" { target *-*-* } .-1 }
+ [[indeterminate (0)]] int x3; // { dg-error "'indeterminate' attribute does not take any arguments" }
+ // { dg-error "expected primary-expression before 'int'" "" { target *-*-* } .-1 }
+ [[indeterminate ("foo", "bar", "baz")]] int x4;// { dg-error "'indeterminate' attribute does not take any arguments" }
+ // { dg-error "expected primary-expression before 'int'" "" { target *-*-* } .-1 }
+ [[indeterminate (0, 1, 2)]] int x5; // { dg-error "'indeterminate' attribute does not take any arguments" }
+ // { dg-error "expected primary-expression before 'int'" "" { target *-*-* } .-1 }
+
+ auto a = [] [[indeterminate]] () {}; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ auto b = [] constexpr [[indeterminate]] {}; // { dg-warning "'indeterminate' attribute does not apply to types" }
+ // { dg-error "parameter declaration before lambda declaration specifiers only optional with" "" { target c++20_down } .-1 }
+ // { dg-error "'constexpr' lambda only available with" "" { target c++14_down } .-2 }
+ auto c = [] noexcept [[indeterminate]] {}; // { dg-warning "'indeterminate' attribute does not apply to types" }
+ // { dg-error "parameter declaration before lambda exception specification only optional with" "" { target c++20_down } .-1 }
+ auto d = [] () [[indeterminate]] {}; // { dg-warning "'indeterminate' attribute does not apply to types" }
+ auto e = new int [n] [[indeterminate]]; // { dg-warning "attributes ignored on outermost array type in new expression" }
+ auto e2 = new int [n] [[indeterminate]] [42]; // { dg-warning "attributes ignored on outermost array type in new expression" }
+ auto f = new int [n][42] [[indeterminate]]; // { dg-warning "'indeterminate' attribute does not apply to types" }
+ [[indeterminate]]; // { dg-warning "attributes at the beginning of statement are ignored" }
+ [[indeterminate]] {} // { dg-warning "attributes at the beginning of statement are ignored" }
+ [[indeterminate]] if (true) {} // { dg-warning "attributes at the beginning of statement are ignored" }
+ [[indeterminate]] while (false) {} // { dg-warning "attributes at the beginning of statement are ignored" }
+ [[indeterminate]] goto lab; // { dg-warning "attributes at the beginning of statement are ignored" }
+ [[indeterminate]] lab:; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ [[indeterminate]] try {} catch (int) {} // { dg-warning "attributes at the beginning of statement are ignored" }
+ if ([[indeterminate]] int x = 0) {}
+ switch (n)
+ {
+ [[indeterminate]] case 1: // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ [[indeterminate]] break; // { dg-warning "attributes at the beginning of statement are ignored" }
+ [[indeterminate]] default: // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ break;
+ }
+ for ([[indeterminate]] auto a : arr) {}
+ for ([[indeterminate]] auto [a, b] : arr2) {} // { dg-error "structured bindings only available with" "" { target c++14_down } }
+ [[indeterminate]] asm (""); // { dg-warning "attributes ignored on 'asm' declaration" }
+ try {} catch ([[indeterminate]] int x) {}
+ try {} catch ([[indeterminate]] int) {}
+ try {} catch (int [[indeterminate]] x) {} // { dg-warning "attribute ignored" }
+ try {} catch (int [[indeterminate]]) {} // { dg-warning "attribute ignored" }
+ try {} catch (int x [[indeterminate]]) {}
+}
+
+[[indeterminate]] int bar (); // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+using foobar [[indeterminate]] = int; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+[[indeterminate]] int a; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+[[indeterminate]] auto [b, c] = arr; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ // { dg-error "structured bindings only available with" "" { target c++14_down } .-1 }
+[[indeterminate]]; // { dg-warning "attribute ignored" }
+inline [[indeterminate]] void baz () {} // { dg-warning "attribute ignored" }
+ // { dg-error "standard attributes in middle of decl-specifiers" "" { target *-*-* } .-1 }
+constexpr [[indeterminate]] int qux () { return 0; } // { dg-warning "attribute ignored" }
+ // { dg-error "standard attributes in middle of decl-specifiers" "" { target *-*-* } .-1 }
+int [[indeterminate]] d; // { dg-warning "attribute ignored" }
+int const [[indeterminate]] e = 1; // { dg-warning "attribute ignored" }
+struct A {} [[indeterminate]]; // { dg-warning "attribute ignored in declaration of 'struct A'" }
+struct A [[indeterminate]]; // { dg-warning "attribute ignored" }
+struct A [[indeterminate]] a1; // { dg-warning "attribute ignored" }
+A [[indeterminate]] a2; // { dg-warning "attribute ignored" }
+enum B { B0 } [[indeterminate]]; // { dg-warning "attribute ignored in declaration of 'enum B'" }
+enum B [[indeterminate]]; // { dg-warning "attribute ignored" }
+enum B [[indeterminate]] b1; // { dg-warning "attribute ignored" }
+B [[indeterminate]] b2; // { dg-warning "attribute ignored" }
+struct [[indeterminate]] C {}; // { dg-warning "'indeterminate' attribute does not apply to types" }
+int f [[indeterminate]]; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+int g[2] [[indeterminate]]; // { dg-warning "'indeterminate' attribute does not apply to types" }
+int g2 [[indeterminate]] [2]; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+int corge () [[indeterminate]]; // { dg-warning "'indeterminate' attribute does not apply to types" }
+int *[[indeterminate]] h; // { dg-warning "'indeterminate' attribute does not apply to types" }
+int & [[indeterminate]] i = f; // { dg-warning "'indeterminate' attribute does not apply to types" }
+int && [[indeterminate]] j = 0; // { dg-warning "'indeterminate' attribute does not apply to types" }
+int S::* [[indeterminate]] k; // { dg-warning "'indeterminate' attribute does not apply to types" }
+auto l = sizeof (int [2] [[indeterminate]]); // { dg-warning "'indeterminate' attribute does not apply to types" }
+int freddy ([[indeterminate]] int a,
+ [[indeterminate]] int,
+ [[indeterminate]] int c = 0,
+ [[indeterminate]] int = 0);
+void
+corge ([[indeterminate]] int a,
+ [[indeterminate]] int,
+ [[indeterminate]] int c = 0,
+ [[indeterminate]] int = 0)
+{
+}
+[[indeterminate]] void
+garply () // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+{
+}
+int grault (int [[indeterminate]] a, // { dg-warning "attribute ignored" }
+ int [[indeterminate]], // { dg-warning "attribute ignored" }
+ int [[indeterminate]] c = 0, // { dg-warning "attribute ignored" }
+ int [[indeterminate]] = 0); // { dg-warning "attribute ignored" }
+void
+waldo (int [[indeterminate]] a, // { dg-warning "attribute ignored" }
+ int [[indeterminate]], // { dg-warning "attribute ignored" }
+ int [[indeterminate]] c = 0, // { dg-warning "attribute ignored" }
+ int [[indeterminate]] = 0) // { dg-warning "attribute ignored" }
+{
+}
+int plugh (int a [[indeterminate]],
+ int b [[indeterminate]] = 0);
+void
+thud (int a [[indeterminate]],
+ int b [[indeterminate]] = 0)
+{
+}
+enum [[indeterminate]] D { D0 }; // { dg-warning "'indeterminate' attribute does not apply to types" }
+enum class [[indeterminate]] E { E0 }; // { dg-warning "'indeterminate' attribute does not apply to types" }
+enum F {};
+enum [[indeterminate]] F; // { dg-warning "'indeterminate' attribute does not apply to types" }
+enum G {
+ G0 [[indeterminate]], // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ G1 [[indeterminate]] = 2 // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+};
+namespace [[indeterminate]] H { using H0 = int; }// { dg-warning "'indeterminate' attribute directive ignored" }
+namespace [[indeterminate]] {} // { dg-warning "'indeterminate' attribute directive ignored" }
+[[indeterminate]] using namespace H; // { dg-warning "'indeterminate' attribute directive ignored" }
+struct [[indeterminate]] I // { dg-warning "'indeterminate' attribute does not apply to types" }
+{
+ [[indeterminate]]; // { dg-error "declaration does not declare anything" }
+ [[indeterminate]] int i; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ [[indeterminate]] int foo (); // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ [[indeterminate]] int bar () { return 1; } // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ [[indeterminate]] int : 0; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ [[indeterminate]] int i2 : 5; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ [[indeterminate]] static int i3; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+ static int i4;
+};
+[[indeterminate]] int I::i4 = 0; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+struct J : [[indeterminate]] C {}; // { dg-warning "attributes on base specifiers are ignored" }
+#if __cpp_concepts >= 201907L
+template <typename T>
+concept K [[indeterminate]] = requires { true; };// { dg-error "'indeterminate' on declaration other than parameter or automatic variable" "" { target c++20 } }
+#endif
+typedef int L [[indeterminate]]; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
+template <typename T>
+struct M {};
+template <>
+struct [[indeterminate]] M<int> { int m; }; // { dg-warning "'indeterminate' attribute does not apply to types" }
+typedef int N[2] [[indeterminate]]; // { dg-warning "'indeterminate' attribute does not apply to types" }
+typedef int O [[indeterminate]] [2]; // { dg-error "'indeterminate' on declaration other than parameter or automatic variable" }
diff --git a/gcc/testsuite/g++.dg/cpp26/attr-indeterminate2.C b/gcc/testsuite/g++.dg/cpp26/attr-indeterminate2.C
new file mode 100644
index 0000000..a2704c6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/attr-indeterminate2.C
@@ -0,0 +1,39 @@
+// C++ 26 P2795R5 - Erroneous behaviour for uninitialized reads
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-fdump-tree-gimple" }
+// { dg-skip-if "" { c++26 } { "-ftrivial-auto-var-init=*" } { "" } }
+// Expect .DEFERRED_INIT calls for the h, r and s variables (3) and
+// temporaries for the second arguments to foo and baz calls (4).
+// { dg-final { scan-tree-dump-times " = \\.DEFERRED_INIT \\\(" 7 "gimple" { target c++26 } } }
+
+struct S { S (); S (const S &); ~S (); int s; };
+void foo (S a [[indeterminate]], S b, S c [[indeterminate]] = S ());
+void foo (S d, S e, S f [[indeterminate]]);
+
+void
+bar ()
+{
+ S g [[indeterminate]], h;
+ foo (g, h, S ());
+ foo (g, h);
+}
+
+void
+foo (S i [[indeterminate]], S j, S k)
+{
+}
+
+void
+baz ([[indeterminate]] S l, S m, [[indeterminate]] S n = S ())
+{
+}
+
+void baz (S o, S p, S q);
+
+void
+qux ()
+{
+ S r, s;
+ baz (r, s, s);
+ baz (r, s);
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/attr-indeterminate3.C b/gcc/testsuite/g++.dg/cpp26/attr-indeterminate3.C
new file mode 100644
index 0000000..8f13390
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/attr-indeterminate3.C
@@ -0,0 +1,21 @@
+// C++ 26 P2795R5 - Erroneous behaviour for uninitialized reads
+// { dg-do compile { target c++11 } }
+// { dg-skip-if "" { c++26 } { "-ftrivial-auto-var-init=*" } { "" } }
+
+struct S { S (); S (const S &); ~S (); int s; };
+void foo (S u, S v [[indeterminate]], int);
+void foo (S a, S b, S c = S ()); // { dg-message "earlier declaration" }
+void foo (S d, S e, S f [[indeterminate]]); // { dg-error "'indeterminate' attribute not specified for parameter 'f' on the first declaration of its function" }
+
+void
+foo (S i [[indeterminate]], S j, S k) // { dg-error "'indeterminate' attribute not specified for parameter 'i' on the first declaration of its function" }
+{
+}
+
+void
+bar (S l, S m, S n = S ()) // { dg-message "earlier declaration" }
+{
+}
+
+void bar (S o [[indeterminate]], S p, [[indeterminate]]S q); // { dg-error "'indeterminate' attribute not specified for parameter 'o' on the first declaration of its function" }
+ // { dg-error "'indeterminate' attribute not specified for parameter 'q' on the first declaration of its function" "" { target *-*-* } .-1 }
diff --git a/gcc/testsuite/g++.dg/cpp26/attr-indeterminate4.C b/gcc/testsuite/g++.dg/cpp26/attr-indeterminate4.C
new file mode 100644
index 0000000..946e019
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/attr-indeterminate4.C
@@ -0,0 +1,36 @@
+// C++ 26 P2795R5 - Erroneous behaviour for uninitialized reads
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-ftrivial-auto-var-init=uninitialized -fdump-tree-gimple" }
+// { dg-final { scan-tree-dump-not " = \\.DEFERRED_INIT \\\(" "gimple" } }
+
+struct S { S (); S (const S &); ~S (); int s; };
+void foo (S a [[indeterminate]], S b, S c [[indeterminate]] = S ());
+void foo (S d, S e, S f [[indeterminate]]);
+
+void
+bar ()
+{
+ S g [[indeterminate]], h;
+ foo (g, h, S ());
+ foo (g, h);
+}
+
+void
+foo (S i [[indeterminate]], S j, S k)
+{
+}
+
+void
+baz ([[indeterminate]] S l, S m, [[indeterminate]] S n = S ())
+{
+}
+
+void baz (S o, S p, S q);
+
+void
+qux ()
+{
+ S r, s;
+ baz (r, s, s);
+ baz (r, s);
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/erroneous1.C b/gcc/testsuite/g++.dg/cpp26/erroneous1.C
new file mode 100644
index 0000000..78769e6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/erroneous1.C
@@ -0,0 +1,61 @@
+// C++ 26 P2795R5 - Erroneous behaviour for uninitialized reads
+// { dg-do run { target c++26 } }
+// { dg-skip-if "" { *-*-* } { "-ftrivial-auto-var-init=*" } { "" } }
+// { dg-options "-O2 -Wuninitialized" }
+
+#define assert(x) if (!(x)) __builtin_abort ()
+
+template <typename T>
+[[gnu::noipa]] T
+baz (T &x)
+{
+ return x;
+}
+
+[[gnu::noipa]] int
+foo (bool b)
+{
+ unsigned char c;
+ unsigned char d = c; // no erroneous behavior, but d has an erroneous value
+ // { dg-warning "'c' is used uninitialized" "" { target *-*-* } .-1 }
+
+ assert (c == d); // holds, both integral promotions have erroneous behavior
+
+ unsigned char f = c;
+ unsigned char g = baz (f);
+
+ assert (g == c);
+
+ int e = d; // erroneous behavior
+ baz (e);
+ return b ? d : 0; // erroneous behavior if b is true
+}
+
+[[gnu::noipa]] void
+bar ()
+{
+ int d1, d2;
+
+ int e1 = d1; // erroneous behavior
+ int e2 = d1; // erroneous behavior
+
+ assert (e1 == e2); // holds
+ assert (e1 == d1); // holds, erroneous behavior
+ assert (e2 == d1); // holds, erroneous behavior
+
+ int f = d1; // { dg-warning "'d1' is used uninitialized" }
+ int g = baz (f);
+ assert (g == d1);
+
+ __builtin_memcpy (&d2, &d1, sizeof (int)); // no erroneous behavior, but d2 has an erroneous value
+ assert (e1 == d2); // holds, erroneous behavior
+ assert (e2 == d2); // holds, erroneous behavior
+}
+
+int
+main ()
+{
+ foo (false);
+ foo (true);
+ bar ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/erroneous2.C b/gcc/testsuite/g++.dg/cpp26/erroneous2.C
new file mode 100644
index 0000000..e8c66f4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/erroneous2.C
@@ -0,0 +1,234 @@
+// C++ 26 P2795R5 - Erroneous behaviour for uninitialized reads
+// { dg-do compile }
+// { dg-skip-if "" { *-*-* } { "-ftrivial-auto-var-init=*" } { "" } }
+// { dg-options "-O2 -fdump-tree-gimple" }
+// All the s1..s24 variables and i1 need .DEFERRED_INIT call on their
+// declarations.
+// Plus, forward gotos to l1 & l2 labels need up to s1-s4 and s6-s9 vars to
+// be .DEFERRED_INITed (and backward gotos up to that minus the first two).
+// switch to case 15 skips over s12, switch to case 16/17 skip
+// over s12 and s13 but the adjacent l3 label needs to also skip over s3-s4
+// and s6-s9 and s11. switch to case 18 skips over s12-s14 and switch to
+// default in the same switch skips over s12-s15.
+// goto l4; skips over s19 initialization.
+// goto l5; skips over s20-s22 initialization.
+// switch to case 32/33 skips over s23 but goto to adjacent l6 skips also
+// over s20-s22. switch to default in that switch skips over s23-s24.
+// { dg-final { scan-tree-dump-times " s1 = \.DEFERRED_INIT \\\(" 2 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s2 = \.DEFERRED_INIT \\\(" 2 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s3 = \.DEFERRED_INIT \\\(" 3 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s4 = \.DEFERRED_INIT \\\(" 3 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s5 = \.DEFERRED_INIT \\\(" 1 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s6 = \.DEFERRED_INIT \\\(" 3 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s7 = \.DEFERRED_INIT \\\(" 3 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s8 = \.DEFERRED_INIT \\\(" 3 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s9 = \.DEFERRED_INIT \\\(" 3 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s10 = \.DEFERRED_INIT \\\(" 1 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s11 = \.DEFERRED_INIT \\\(" 2 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s12 = \.DEFERRED_INIT \\\(" 5 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s13 = \.DEFERRED_INIT \\\(" 4 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s14 = \.DEFERRED_INIT \\\(" 3 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s15 = \.DEFERRED_INIT \\\(" 2 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s16 = \.DEFERRED_INIT \\\(" 1 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s17 = \.DEFERRED_INIT \\\(" 1 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s18 = \.DEFERRED_INIT \\\(" 1 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s19 = \.DEFERRED_INIT \\\(" 2 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s20 = \.DEFERRED_INIT \\\(" 3 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s21 = \.DEFERRED_INIT \\\(" 3 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s22 = \.DEFERRED_INIT \\\(" 3 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s23 = \.DEFERRED_INIT \\\(" 3 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " s24 = \.DEFERRED_INIT \\\(" 2 "gimple" { target c++26 } } }
+// { dg-final { scan-tree-dump-times " i1 = \.DEFERRED_INIT \\\(" 1 "gimple" { target c++26 } } }
+
+struct S { int a, b, c; };
+
+int
+foo (int x)
+{
+ int r = 0;
+ if (x == 1)
+ goto l1;
+ S s1;
+ if (x == 2)
+ goto l1;
+ S s2;
+ {
+ S s10;
+ if (x == 12)
+ goto l1;
+ s10.a = 1;
+ r += s10.a;
+ int i1;
+ if (x == 13)
+ goto l1;
+ i1 = 2;
+ r += i1;
+ }
+ if (x == 3)
+ goto l2;
+ if (x == 4)
+ goto l1;
+ {
+ S s3;
+ if (x == 5)
+ goto l2;
+ S s4;
+ if (x == 6)
+ goto l1;
+ {
+ S s5;
+ if (x == 7)
+ goto l1;
+ s5.a = 5;
+ r += s5.a;
+ }
+ S s6;
+ {
+ S s7;
+ S s8;
+ if (x == 8)
+ goto l1;
+ S s9;
+ if (x == 9)
+ goto l2;
+ if (x == 10)
+ goto l2;
+ if (x == 11)
+ goto l2;
+ l1:
+ l2:
+ s1.a = 1;
+ s2.b = 2;
+ s3.c = 3;
+ s4.a = 4;
+ s6.b = 6;
+ s7.c = 7;
+ s8.a = 8;
+ s9.b = 9;
+ r += s1.a + s2.b + s3.c;
+ r += s4.a + s6.b + s7.c;
+ r += s8.a + s9.b;
+ if (x == 14)
+ goto l3;
+ S s11;
+ switch (x)
+ {
+ S s12;
+ case 15:
+ S s13;
+ // FALLTHRU
+ l3:
+ case 16:
+ case 17:
+ S s14;
+ s11.a = 1;
+ s12.b = 2;
+ s13.c = 3;
+ s14.a = 4;
+ r += s11.a + s12.b + s13.c;
+ r += s14.a;
+ return r;
+ case 18:
+ S s15;
+ s11.a = 1;
+ s12.b = 2;
+ s13.c = 3;
+ s14.a = 4;
+ s15.b = 5;
+ r += s11.a + s12.b + s13.c;
+ r += s14.a + s15.b;
+ return r;
+ default:
+ if (x != 19 && x != 20)
+ break;
+ S s16;
+ s11.a = 1;
+ s12.b = 2;
+ s13.c = 3;
+ s14.a = 4;
+ s15.b = 5;
+ s16.c = 6;
+ r += s11.a + s12.b + s13.c;
+ r += s14.a + s15.b + s16.c;
+ return r;
+ }
+ if (x == 21)
+ goto l3;
+ }
+ S s17;
+ if (x == 22)
+ goto l3;
+ if (x == 23)
+ goto l1;
+ if (x == 24)
+ goto l2;
+ s17.a = 1;
+ r += s17.a;
+ }
+ S s18;
+ if (x == 25)
+ {
+ S s19;
+ s19.c = 2;
+ r += s19.c;
+ if (x == 29)
+ l4:;
+ goto l3;
+ }
+ if (x == 26)
+ goto l1;
+ if (x == 27)
+ goto l2;
+ s18.b = 1;
+ r += s18.b;
+ if (x == 28)
+ goto l4;
+ {
+ S s20;
+ {
+ S s21;
+ if (x == 29)
+ goto l1;
+ S s22;
+ if (x == 30)
+ goto l2;
+ l5:
+ s20.a = 1;
+ s21.b = 2;
+ s22.c = 3;
+ r += s20.a + s21.b + s22.c;
+ switch (x)
+ {
+ case 31:
+ S s23;
+ // FALLTHRU
+ l6:
+ case 32:
+ case 33:
+ S s24;
+ s23.a = 1;
+ s24.b = 2;
+ r += s23.a + s24.b;
+ return r;
+ default:
+ if (x >= 34 && x <= 35)
+ return r;
+ break;
+ }
+ if (x == 34)
+ goto l5;
+ if (x == 35)
+ goto l6;
+ return r;
+ }
+ if (x == 36)
+ goto l5;
+ if (x == 37)
+ goto l6;
+ }
+ if (x == 38)
+ goto l5;
+ if (x == 39)
+ goto l6;
+ return r;
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/erroneous3.C b/gcc/testsuite/g++.dg/cpp26/erroneous3.C
new file mode 100644
index 0000000..d48a08e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/erroneous3.C
@@ -0,0 +1,158 @@
+// C++ 26 P2795R5 - Erroneous behaviour for uninitialized reads
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wimplicit-fallthrough -Wswitch-unreachable" }
+// Make sure -Wimplicit-fallthrough and -Wswitch-unreachable
+// are consistent between -std=c++23 and -std=c++26 even when
+// the latter instruments jumps across vacuous initializations.
+
+int i;
+
+void
+foo (int x)
+{
+ switch (x)
+ {
+ case 1:
+ int j;
+ ++i; // { dg-warning "this statement may fall through" }
+ case 2: // { dg-message "here" }
+ int k;
+ ++i;
+ // FALLTHRU
+ case 3:
+ int l;
+ ++i;
+ [[fallthrough]];
+ default:
+ int m;
+ ++i;
+ j = 42;
+ k = 42;
+ l = 42;
+ m = 42;
+ i += (j - k) + (l - m);
+ break;
+ }
+}
+
+void
+bar (int x)
+{
+ if (x == 6)
+ goto l1;
+ if (x == 7)
+ goto l2;
+ if (x == 8)
+ goto l3;
+ if (x == 9)
+ goto l4;
+ if (x == 10)
+ goto l5;
+ if (x == 11)
+ goto l6;
+ int j;
+ j = 5;
+ i += j;
+ switch (x)
+ {
+ case 1:
+ l1:
+ ++i; // { dg-warning "this statement may fall through" }
+ case 2: // { dg-message "here" }
+ l2:
+ ++i;
+ // FALLTHRU
+ case 3:
+ l3:
+ ++i;
+ [[fallthrough]];
+ default:
+ l4:
+ ++i;
+ break;
+ case 4:
+ ++i; // { dg-warning "this statement may fall through" }
+ case 5: // { dg-message "here" }
+ l5:;
+ ++i; // { dg-warning "this statement may fall through" }
+ case 6: // { dg-message "here" }
+ ++i;
+ case 7:
+ l6:;
+ }
+}
+
+void
+baz (int x)
+{
+ switch (x)
+ {
+ case 1:
+ int j [[indeterminate]];
+ ++i; // { dg-warning "this statement may fall through" }
+ case 2: // { dg-message "here" }
+ int k [[indeterminate]];
+ ++i;
+ // FALLTHRU
+ case 3:
+ int l [[indeterminate]];
+ ++i;
+ [[fallthrough]];
+ default:
+ int m [[indeterminate]];
+ ++i;
+ j = 42;
+ k = 42;
+ l = 42;
+ m = 42;
+ i += (j - k) + (l - m);
+ break;
+ }
+}
+
+void
+qux (int x)
+{
+ if (x == 6)
+ goto l1;
+ if (x == 7)
+ goto l2;
+ if (x == 8)
+ goto l3;
+ if (x == 9)
+ goto l4;
+ if (x == 10)
+ goto l5;
+ if (x == 11)
+ goto l6;
+ int j [[indeterminate]];
+ j = 5;
+ i += j;
+ switch (x)
+ {
+ case 1:
+ l1:
+ ++i; // { dg-warning "this statement may fall through" }
+ case 2: // { dg-message "here" }
+ l2:
+ ++i;
+ // FALLTHRU
+ case 3:
+ l3:
+ ++i;
+ [[fallthrough]];
+ default:
+ l4:
+ ++i;
+ break;
+ case 4:
+ ++i; // { dg-warning "this statement may fall through" }
+ case 5: // { dg-message "here" }
+ l5:;
+ ++i; // { dg-warning "this statement may fall through" }
+ case 6: // { dg-message "here" }
+ ++i;
+ case 7:
+ l6:;
+ }
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/erroneous4.C b/gcc/testsuite/g++.dg/cpp26/erroneous4.C
new file mode 100644
index 0000000..0863480
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/erroneous4.C
@@ -0,0 +1,37 @@
+// C++ 26 P2795R5 - Erroneous behaviour for uninitialized reads
+// { dg-do compile { target c++23 } }
+// Make sure we don't reject this in C++26 because of
+// .DEFERRED_INIT calls.
+
+constexpr int
+foo (int x)
+{
+ if (x == 6)
+ goto l1;
+ if (x == 7)
+ goto l2;
+ int i;
+ switch (x)
+ {
+ int j;
+ case 1:
+ i = 6;
+ return i;
+ case 2:
+ i = 4;
+ l1:
+ i = 5;
+ return i;
+ case 3:
+ l2:
+ i = 7;
+ return i;
+ default:
+ return 42;
+ }
+}
+
+static_assert (foo (1) == 6);
+static_assert (foo (2) == 5);
+static_assert (foo (3) == 7);
+static_assert (foo (4) == 42);
diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-new28.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-new28.C
new file mode 100644
index 0000000..7828f30
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-new28.C
@@ -0,0 +1,45 @@
+// PR c++/115645
+// { dg-do compile { target c++20 } }
+
+using size_t = decltype(sizeof(0));
+
+void* operator new(size_t, void* p) { return p; }
+void* operator new[](size_t, void* p) { return p; }
+
+#define VERIFY(C) if (!(C)) throw
+
+namespace std {
+ template<typename T>
+ constexpr T* construct_at(T* p)
+ {
+ if constexpr (__is_array(T))
+ return ::new((void*)p) T[1]();
+ else
+ return ::new((void*)p) T();
+ }
+}
+
+struct S {
+ constexpr S () : s (0) {}
+ constexpr S (int x) : s (x) {}
+ constexpr bool operator== (int x) const { return s == x; }
+ int s;
+};
+
+constexpr void
+test_array()
+{
+ S arr[1] { 99 };
+ std::construct_at(&arr);
+ VERIFY( arr[0] == 0 );
+
+ union U {
+ long long x = -1;
+ S arr[4];
+ } u;
+
+ auto p = std::construct_at(&u.arr);
+ VERIFY( (*p)[0] == 0 );
+}
+
+static_assert( [] { test_array(); return true; }() );
diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-new29.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-new29.C
new file mode 100644
index 0000000..368018d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-new29.C
@@ -0,0 +1,30 @@
+// P0784R7
+// { dg-do compile { target c++20 } }
+// { dg-additional-options "-fdelete-null-pointer-checks" }
+
+struct S
+{
+ constexpr S () : s (0) { s++; }
+ constexpr S (int x) : s (x) { s += 2; }
+ constexpr ~S () { if (s != 35) asm (""); s = 5; }
+ int s;
+};
+
+constexpr bool
+foo (int n)
+{
+ S *p = new S (7);
+ if (p->s != 9) return false;
+ p->s = 35;
+ delete p;
+ p = new S[n] { 11, 13, 15 };
+ if (p[0].s != 13 || p[1].s != 15 || p[2].s != 17) return false;
+ p[0].s = 35;
+ p[2].s = 35;
+ p[1].s = 35;
+ delete[] p;
+ return true;
+}
+
+constexpr bool a = foo (3);
+static_assert (a);
diff --git a/gcc/testsuite/g++.dg/modules/adl-6_c.C b/gcc/testsuite/g++.dg/modules/adl-6_c.C
index 99b6c4c..2c675f5 100644
--- a/gcc/testsuite/g++.dg/modules/adl-6_c.C
+++ b/gcc/testsuite/g++.dg/modules/adl-6_c.C
@@ -1,5 +1,5 @@
// PR c++/117658
-// { dg-additional-options "-fmodules" }
+// { dg-additional-options "-fmodules -Wno-error=external-tu-local" }
import N;
@@ -22,7 +22,8 @@ void test() {
apply_err(x); // error: R::g has internal linkage and cannot be used outside N
// { dg-message "here" "" { target *-*-* } .-1 }
- // { dg-error "'g'" "" { target *-*-* } 0 }
+ // { dg-warning "lookup of 'R::g'" "" { target *-*-* } 0 }
+ // { dg-error "'g' was not declared" "" { target *-*-* } 0 }
auto y = make_Y();
f(y); // OK, I::B::f and I::A::Y have matching innermost non-inline namespace
diff --git a/gcc/testsuite/g++.dg/modules/internal-14_c.C b/gcc/testsuite/g++.dg/modules/internal-14_c.C
index 4f8e785c..50fb8e6 100644
--- a/gcc/testsuite/g++.dg/modules/internal-14_c.C
+++ b/gcc/testsuite/g++.dg/modules/internal-14_c.C
@@ -4,6 +4,6 @@
import m;
int main() {
- // { dg-error "instantiation exposes TU-local entity '(fun1|Dodgy)'" "" { target *-*-* } 0 }
+ // { dg-error "instantiation exposes TU-local entity '\[^']*(fun1|Dodgy)\[^']*'" "" { target *-*-* } 0 }
fun2(123); // { dg-message "required from here" }
}
diff --git a/gcc/testsuite/g++.dg/modules/internal-15_a.C b/gcc/testsuite/g++.dg/modules/internal-15_a.C
new file mode 100644
index 0000000..03fec2a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/internal-15_a.C
@@ -0,0 +1,28 @@
+// { dg-additional-options "-fmodules -fdump-lang-module-graph -Wno-global-module" }
+// { dg-module-cmi A }
+
+export module A;
+
+namespace N {
+ struct A {};
+ void adl(A);
+ inline namespace inner {
+ static void adl(int);
+ }
+}
+namespace G {
+ struct B {};
+ void adl(B);
+ namespace {
+ extern "C++" void adl(int);
+ }
+}
+void adl(double);
+
+template <typename T>
+inline void h(T t) {
+ adl(t);
+}
+
+// { dg-final { scan-lang-dump {Binding on tu-local function_decl:'::N::inner::adl' found} module } }
+// { dg-final { scan-lang-dump-not {'G::_GLOBAL__N_1::adl'} module } }
diff --git a/gcc/testsuite/g++.dg/modules/internal-15_b.C b/gcc/testsuite/g++.dg/modules/internal-15_b.C
new file mode 100644
index 0000000..003d948
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/internal-15_b.C
@@ -0,0 +1,13 @@
+// { dg-additional-options "-fmodules -pedantic-errors" }
+
+module A;
+
+void other() {
+ adl(N::A{}); // OK, lookup occurs from here
+ h(0); // OK, doesn't consider N::inner::adl
+
+ h(N::A{}); // { dg-message "required from here" }
+ // { dg-error "TU-local" "" { target *-*-* } 0 }
+
+ h(G::B{}); // OK, G::adl is not attached to A
+}
diff --git a/gcc/testsuite/g++.dg/opt/store-merging-1.C b/gcc/testsuite/g++.dg/opt/store-merging-1.C
index c7f294e..8c46252 100644
--- a/gcc/testsuite/g++.dg/opt/store-merging-1.C
+++ b/gcc/testsuite/g++.dg/opt/store-merging-1.C
@@ -1,7 +1,7 @@
// PR target/92038
// { dg-do compile { target int32 } }
// { dg-require-effective-target store_merge }
-// { dg-options "-O2 -flifetime-dse=2 -fdump-tree-store-merging-details" }
+// { dg-options "-O2 -flifetime-dse=2 -fdump-tree-store-merging-details -ftrivial-auto-var-init=uninitialized" }
// { dg-final { scan-tree-dump "New sequence of \[12] stores to replace old one of 2 stores" "store-merging" } }
struct S { S () : a (0), b (0) {} int a; char b; char c[3]; };
diff --git a/gcc/testsuite/g++.dg/parse/auto-struct-param.C b/gcc/testsuite/g++.dg/parse/auto-struct-param.C
new file mode 100644
index 0000000..78573c6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/auto-struct-param.C
@@ -0,0 +1,4 @@
+// PR c++/122112
+// { dg-do compile { target c++20 } }
+
+void func(struct { auto x; }); // { dg-error "" }
diff --git a/gcc/testsuite/g++.dg/uninit-pred-loop-1_b.C b/gcc/testsuite/g++.dg/uninit-pred-loop-1_b.C
index b17b936..55b15b7 100644
--- a/gcc/testsuite/g++.dg/uninit-pred-loop-1_b.C
+++ b/gcc/testsuite/g++.dg/uninit-pred-loop-1_b.C
@@ -13,7 +13,7 @@ int foo(int n)
_err;
});
- if (err == 0) return 17;
+ if (err == 0) return 17; /* { dg-warning "'_err' may be used uninitialized" "" { target c++26 } } */
}
return 18;
diff --git a/gcc/testsuite/g++.dg/warn/Warray-bounds-20.C b/gcc/testsuite/g++.dg/warn/Warray-bounds-20.C
index 36f8046..643e801 100644
--- a/gcc/testsuite/g++.dg/warn/Warray-bounds-20.C
+++ b/gcc/testsuite/g++.dg/warn/Warray-bounds-20.C
@@ -26,7 +26,7 @@ struct D1: virtual B, virtual C
/* The warning would ideally point to the assignment but instead points
to the opening brace. */
D1 ()
- { // { dg-warning "\\\[-Warray-bounds" "brace" }
+ {
ci = 0; // { dg-warning "\\\[-Warray-bounds" "assign" { xfail lp64 } }
}
};
@@ -35,11 +35,11 @@ void sink (void*);
void warn_derived_ctor_access_new_decl ()
{
- char a[sizeof (D1)]; // { dg-message "at offset 1 into object 'a' of size 40" "LP64 note" { target lp64} }
- // { dg-message "at offset 1 into object 'a' of size 20" "LP64 note" { target ilp32} .-1 }
+ char a[sizeof (D1)]; // { dg-message "at offset 1 into object 'a' of size 40" "LP64 note" { target lp64 } }
+ // { dg-message "at offset 1 into object 'a' of size 20" "LP32 note" { target ilp32 } .-1 }
char *p = a;
++p;
- D1 *q = new (p) D1; // { dg-warning "-Warray-bounds" }
+ D1 *q = new (p) D1; // { dg-warning "\\\[-Warray-bounds" }
sink (q);
}
@@ -47,14 +47,14 @@ void warn_derived_ctor_access_new_alloc ()
{
char *p = (char*)operator new (sizeof (D1)); // { dg-message "at offset 1 into object of size \\d+ allocated by '\[^\n\r]*operator new\[^\n\r]*'" "note" }
++p;
- D1 *q = new (p) D1; // { dg-warning "-Warray-bounds" }
+ D1 *q = new (p) D1; // { dg-warning "\\\[-Warray-bounds" }
sink (q);
}
void warn_derived_ctor_access_new_array_decl ()
{
char b[sizeof (D1) * 2]; // { dg-message "at offset \\d+ into object 'b' of size 80" "LP64 note" { target { lp64 } xfail { lp64 } } }
- // { dg-message "at offset \\d+ into object 'b' of size 40" "LP64 note" { target { ilp32 } xfail { ilp32 } } .-1 }
+ // { dg-message "at offset \\d+ into object 'b' of size 40" "LP32 note" { target { ilp32 } xfail { ilp32 } } .-1 }
char *p = b;
++p;
D1 *q = new (p) D1[2];
diff --git a/gcc/testsuite/g++.dg/warn/Wuninitialized-13.C b/gcc/testsuite/g++.dg/warn/Wuninitialized-13.C
index b74a2fa..47a7545 100644
--- a/gcc/testsuite/g++.dg/warn/Wuninitialized-13.C
+++ b/gcc/testsuite/g++.dg/warn/Wuninitialized-13.C
@@ -8,12 +8,12 @@
struct shared_count {
shared_count () { }
shared_count (shared_count &r)
- : pi (r.pi) { } // { dg-warning "\\\[-Wuninitialized" }
+ : pi (r.pi) { }
int pi;
};
// There's another (redundant) -Wuninitialized on the line below.
-struct shared_ptr {
+struct shared_ptr { // { dg-warning "\\\[-Wuninitialized" }
int ptr;
shared_count refcount;
};
diff --git a/gcc/testsuite/gnat.dg/use_type1.adb b/gcc/testsuite/gnat.dg/use_type1.adb
new file mode 100644
index 0000000..a324610
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/use_type1.adb
@@ -0,0 +1,16 @@
+-- { dg-do compile }
+
+procedure Use_Type1 is
+
+ package Nested is
+ type T is (X, Y, Z);
+ procedure Proc (Obj : T) is null;
+ end Nested;
+
+ use all type Nested.T;
+
+ Obj : Nested.T := X;
+
+begin
+ Proc (Obj);
+end;
diff --git a/gcc/testsuite/gnat.dg/use_type2.adb b/gcc/testsuite/gnat.dg/use_type2.adb
new file mode 100644
index 0000000..8299636
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/use_type2.adb
@@ -0,0 +1,15 @@
+-- { dg-do compile }
+
+with Ada.Containers.Vectors;
+
+procedure Use_Type2 is
+
+ package Vectors is new Ada.Containers.Vectors (Positive, Character);
+
+ use all type Vectors.Vector;
+
+ X : Vectors.Vector := To_Vector (0);
+
+begin
+ Append (X, 'A');
+end;