aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog39
-rw-r--r--gcc/testsuite/g++.dg/modules/convop-2_a.H10
-rw-r--r--gcc/testsuite/g++.dg/modules/convop-2_b.C5
-rw-r--r--gcc/testsuite/gcc.dg/fold-vecperm-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/gnu-compoundlit-1.c26
-rw-r--r--gcc/testsuite/gcc.dg/gnu-compoundlit-2.c20
-rw-r--r--gcc/testsuite/gcc.dg/pr68090.c7
-rw-r--r--gcc/testsuite/gcc.dg/pr97986-1.c27
-rw-r--r--gcc/testsuite/gcc.dg/pr97986-2.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr122502.c21
-rw-r--r--gcc/testsuite/gcc.dg/vla-init-4.c2
-rw-r--r--gcc/testsuite/gcc.dg/vla-init-5.c2
-rw-r--r--gcc/testsuite/gcc.target/aarch64/pr121853_1.c64
-rw-r--r--gcc/testsuite/gcc.target/aarch64/pr121853_2.c14
-rw-r--r--gcc/testsuite/gcc.target/riscv/rvv/autovec/pr122321.c150
-rw-r--r--gcc/testsuite/gfortran.dg/pdt_65.f03135
-rw-r--r--gcc/testsuite/gfortran.dg/pure_result.f9049
17 files changed, 585 insertions, 5 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index daf99d1..013121d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,42 @@
+2025-10-31 Tamar Christina <tamar.christina@arm.com>
+
+ PR target/121853
+ * gcc.target/aarch64/pr121853_1.c: New test.
+ * gcc.target/aarch64/pr121853_2.c: New test.
+
+2025-10-31 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/122452
+ * gfortran.dg/pdt_65.f03: New test.
+
+2025-10-31 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/122502
+ * gcc.dg/torture/pr122502.c: New testcase.
+
+2025-10-31 Andrew Pinski <andrew.pinski@oss.qualcomm.com>
+
+ * gcc.dg/tree-ssa/pr122478.c: Swap `1` and `"optimized"`.
+
+2025-10-31 Andrew Pinski <andrew.pinski@oss.qualcomm.com>
+
+ PR tree-optimization/122497
+ * gcc.dg/torture/pr122497-1.c: New test.
+
+2025-10-31 Lulu Cheng <chenglulu@loongson.cn>
+
+ * gcc.dg/vect/slp-widen-mult-half.c: Remove '-mlasx'.
+ * gcc.dg/vect/tree-vect.h: Check whether the runtime
+ environment supports LSX instructions.
+ * gcc.dg/vect/vect-widen-mult-const-s16.c: Dito.
+ * gcc.dg/vect/vect-widen-mult-const-u16.c: Dito.
+ * gcc.dg/vect/vect-widen-mult-half-u8.c: Dito.
+ * gcc.dg/vect/vect-widen-mult-half.c: Dito.
+ * gcc.dg/vect/vect-widen-mult-u16.c: Dito.
+ * gcc.dg/vect/vect-widen-mult-u8-s16-s32.c: Dito.
+ * gcc.dg/vect/vect-widen-mult-u8-u32.c: Dito.
+ * gcc.dg/vect/vect-widen-mult-u8.c: Dito.
+
2025-10-30 Yap Zhi Heng <yapzhhg@gmail.com>
* rust/compile/tuplepattern-restpattern-typecheck-err.rs: New file.
diff --git a/gcc/testsuite/g++.dg/modules/convop-2_a.H b/gcc/testsuite/g++.dg/modules/convop-2_a.H
new file mode 100644
index 0000000..62bb210
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/convop-2_a.H
@@ -0,0 +1,10 @@
+// PR c++/122381
+// { dg-additional-options "-fmodule-header" }
+// { dg-module-cmi {} }
+
+template <typename T> struct color_ref {
+ operator int() const { return 0; }
+ int foo(color_ref x) {
+ return x.operator int();
+ }
+};
diff --git a/gcc/testsuite/g++.dg/modules/convop-2_b.C b/gcc/testsuite/g++.dg/modules/convop-2_b.C
new file mode 100644
index 0000000..d1e829e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/convop-2_b.C
@@ -0,0 +1,5 @@
+// PR c++/122381
+// { dg-additional-options "-fmodules" }
+
+import "convop-2_a.H";
+template struct color_ref<int>;
diff --git a/gcc/testsuite/gcc.dg/fold-vecperm-1.c b/gcc/testsuite/gcc.dg/fold-vecperm-1.c
index 5d4456b..878d392 100644
--- a/gcc/testsuite/gcc.dg/fold-vecperm-1.c
+++ b/gcc/testsuite/gcc.dg/fold-vecperm-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-forwprop3" } */
typedef int v4si __attribute__((vector_size(16)));
typedef short v8hi __attribute__((vector_size(16)));
@@ -20,4 +20,4 @@ int128 concat (int128 a, int128 b) {
return res;
}
-/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 1 "forwprop3" } } */
diff --git a/gcc/testsuite/gcc.dg/gnu-compoundlit-1.c b/gcc/testsuite/gcc.dg/gnu-compoundlit-1.c
new file mode 100644
index 0000000..a7f3496
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gnu-compoundlit-1.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu23" } */
+
+int g(int n, int (*p)[n]);
+int f(int n)
+{
+ return g(n, &(int[n]){ });
+}
+
+void h(int n)
+{
+ (int[n]){ 1 }; /* { dg-error "empty initializer" } */
+}
+
+void i(int n)
+{
+ (static int[3]){ };
+ (static int[n]){ }; /* { dg-error "storage size" } */
+ (constexpr int[3]){ };
+ (constexpr int[n]){ }; /* { dg-error "storage size" } */
+ (register int[3]){ }; /* { dg-error "register" } */
+ (register int[n]){ }; /* { dg-error "register" } */
+ (_Thread_local int[3]){ }; /* { dg-error "_Thread_local" } */
+ (_Thread_local int[n]){ }; /* { dg-error "_Thread_local" } */
+}
+
diff --git a/gcc/testsuite/gcc.dg/gnu-compoundlit-2.c b/gcc/testsuite/gcc.dg/gnu-compoundlit-2.c
new file mode 100644
index 0000000..dcc5775
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gnu-compoundlit-2.c
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu23 -Wall" } */
+
+[[gnu::noinline,gnu::noipa]]
+static bool f(int n)
+{
+ struct foo { char a[n]; };
+ struct foo x = { };
+
+ return 0 == __builtin_memcmp(&x, &(struct foo){ }, sizeof x);
+}
+
+int main()
+{
+ if (!f(7))
+ __builtin_abort();
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/pr68090.c b/gcc/testsuite/gcc.dg/pr68090.c
index 87b3b93..84e0ca4 100644
--- a/gcc/testsuite/gcc.dg/pr68090.c
+++ b/gcc/testsuite/gcc.dg/pr68090.c
@@ -1,13 +1,18 @@
/* PR c/68090 */
/* { dg-do compile } */
-/* { dg-options "" } */
+/* { dg-options "--pedantic-error" } */
void
fn (int i)
{
(int[(0, 1)]) { 0 }; /* { dg-error "compound literal has variable size" } */
+ /* { dg-error "variable-size" "" { target *-*-* } .-1 } */
(int[i]) { 0 }; /* { dg-error "compound literal has variable size" } */
+ /* { dg-error "variable-size" "" { target *-*-* } .-1 } */
(int[(0, i)]) { 0 }; /* { dg-error "compound literal has variable size" } */
+ /* { dg-error "variable-size" "" { target *-*-* } .-1 } */
(int [][i]){ 0 }; /* { dg-error "compound literal has variable size" } */
+ /* { dg-error "variable-size" "" { target *-*-* } .-1 } */
(int [][(1, 2)]){ 0 }; /* { dg-error "compound literal has variable size" } */
+ /* { dg-error "variable-size" "" { target *-*-* } .-1 } */
}
diff --git a/gcc/testsuite/gcc.dg/pr97986-1.c b/gcc/testsuite/gcc.dg/pr97986-1.c
new file mode 100644
index 0000000..87ee3d8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr97986-1.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu23" } */
+
+#include <stdarg.h>
+
+int f(int n, ...)
+{
+ __label__ b, d;
+ va_list ap;
+ va_start(ap, n);
+ _Static_assert(5 == sizeof(va_arg(ap, char[5]))); /* { dg-warning "array type" } */
+ void g(void) { n++; goto b; }
+ int *a = va_arg((g(), ap), int[n]); /* { dg-warning "array type" } */
+b:
+ void h(void) { n++; goto d; }
+ typeof(va_arg(ap, int[(h(), n)])) c; /* { dg-warning "array type" } */
+d:
+ return n;
+}
+
+int main()
+{
+ if (9 != f(7))
+ __builtin_abort();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/pr97986-2.c b/gcc/testsuite/gcc.dg/pr97986-2.c
new file mode 100644
index 0000000..fc23a57
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr97986-2.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c90" } */
+
+#include <stdarg.h>
+
+
+int f(int n, ...)
+{
+ va_list ap;
+ va_start(ap, n);
+ _Static_assert(5 == sizeof(va_arg(ap, char[5])));
+ va_arg(ap, int[n]); /* { dg-error "array type" } */
+ int * a = va_arg(ap, int[3]); /* { dg-error "invalid use of non-lvalue array" } */
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr122502.c b/gcc/testsuite/gcc.dg/torture/pr122502.c
new file mode 100644
index 0000000..5e2cb2e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr122502.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+short int *ts;
+
+void
+c2 (unsigned long long int s4, int ns)
+{
+ short int *b2 = (short int *)&ns;
+
+ while (ns != 0)
+ {
+ int xn;
+
+ for (xn = 0; xn < 3; ++xn)
+ for (*b2 = 0; *b2 < 2; ++*b2)
+ s4 += xn;
+ if (s4 != 0)
+ b2 = ts;
+ ++ns;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/vla-init-4.c b/gcc/testsuite/gcc.dg/vla-init-4.c
index 06351d0..7d1aa5b 100644
--- a/gcc/testsuite/gcc.dg/vla-init-4.c
+++ b/gcc/testsuite/gcc.dg/vla-init-4.c
@@ -4,4 +4,4 @@
/* { dg-options "" } */
const int i = 1;
-void foo() { char *p = (char [i]){ "" }; } /* { dg-error "compound literal has variable size" } */
+void foo() { char *p = (char [i]){ "" }; } /* { dg-error "variable-sized object" } */
diff --git a/gcc/testsuite/gcc.dg/vla-init-5.c b/gcc/testsuite/gcc.dg/vla-init-5.c
index aa9f491..2c249ec 100644
--- a/gcc/testsuite/gcc.dg/vla-init-5.c
+++ b/gcc/testsuite/gcc.dg/vla-init-5.c
@@ -4,4 +4,4 @@
/* { dg-options "" } */
const int i = 1;
-void foo() { void *p = (char [][i]){ "" }; } /* { dg-error "compound literal has variable size" } */
+void foo() { void *p = (char [][i]){ "" }; } /* { dg-error "variable-sized object" } */
diff --git a/gcc/testsuite/gcc.target/aarch64/pr121853_1.c b/gcc/testsuite/gcc.target/aarch64/pr121853_1.c
new file mode 100644
index 0000000..24b2fdc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr121853_1.c
@@ -0,0 +1,64 @@
+/* { dg-do run } */
+/* { dg-additional-options "-O2 -std=c99" } */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+__attribute__ ((noipa))
+float convert(__bf16 value) {
+ return (float)value;
+}
+
+static inline uint32_t f32_bits(float f) {
+ uint32_t u; memcpy(&u, &f, sizeof u); return u;
+}
+static inline __bf16 bf16_from_bits(uint16_t u) {
+ __bf16 b; memcpy(&b, &u, sizeof b); return b;
+}
+
+/* Fixed bf16 inputs (as raw 16-bit payloads) covering edge cases. */
+static const uint16_t inputs[] = {
+ 0x0000, // +0
+ 0x8000, // -0
+ 0x7F80, // +inf
+ 0xFF80, // -inf
+ 0x7FC0, // qNaN (+) (quiet bit set in bf16)
+ 0xFFC0, // qNaN (-)
+ 0x7F01, // sNaN (+) (will be quieted by conversion)
+ 0xFF01, // sNaN (-)
+ 0x0001, // smallest +subnormal
+ 0x007F, // largest +subnormal
+ 0x8001, // smallest -subnormal
+ 0x807F, // largest -subnormal
+ 0x0080, // smallest +normal
+ 0x3F80, // +1.0
+ 0xBF80, // -1.0
+ 0x3F00, // +0.5
+ 0xBF00, // -0.5
+ 0x3FC0, // +1.5
+ 0x7F7F, // max finite +
+ 0xFF7F, // max finite -
+};
+
+int main(void) {
+ const size_t N = sizeof(inputs)/sizeof(inputs[0]);
+ size_t fails = 0;
+
+ for (size_t i = 0; i < N; ++i) {
+ __bf16 in = bf16_from_bits(inputs[i]);
+ float out = convert(in);
+ uint32_t got = f32_bits(out);
+ uint32_t exp = inputs[i] << 16;
+
+ if (got != exp) {
+ printf("FAIL[%zu]: in_bf16=0x%04X exp_f32=0x%08X got_f32=0x%08X\n",
+ i, inputs[i], exp, got);
+ ++fails;
+ }
+ }
+
+ if (fails != 0)
+ __builtin_abort ();
+}
+
diff --git a/gcc/testsuite/gcc.target/aarch64/pr121853_2.c b/gcc/testsuite/gcc.target/aarch64/pr121853_2.c
new file mode 100644
index 0000000..e9fb401
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr121853_2.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O1" } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+float convert(__bf16 value) {
+ return (float)value;
+}
+
+/*
+** convert:
+** movi v[0-9]+.4s, 0
+** ext v[0-9]+.16b, v[0-9]+.16b, v[0-9]+.16b, #14
+** ret
+*/
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr122321.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr122321.c
new file mode 100644
index 0000000..0e34bc1f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr122321.c
@@ -0,0 +1,150 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -w -O0" { target rv64 } } */
+/* { dg-options "-march=rv32gcv -mabi=ilp32 -w -O0" { target rv32 } } */
+
+
+typedef int a;
+typedef signed char b;
+typedef char c;
+typedef short d;
+typedef unsigned short e;
+typedef a f;
+typedef unsigned g;
+typedef long h;
+h j, k, l, m, n, o;
+int p, q, r, s;
+short t;
+volatile a u;
+a v[];
+char w, x;
+a *y, *z;
+a **aa;
+__attribute__((always_inline)) b __attribute__((vector_size(16)))
+ab(f __attribute__((vector_size(8 * sizeof(f)))), d ac,
+ d __attribute__((vector_size(2 * sizeof(d)))), d) {
+ return __builtin_shufflevector(
+ (b __attribute__((vector_size(16)))) __builtin_convertvector(
+ (d __attribute__((vector_size(16 *sizeof(d))))){
+ ac, ac, ac, ac, ac, ac, ac, ac, ac, ac, ac, ac, ac},
+ c __attribute__((vector_size(16)))) |
+ __builtin_convertvector(
+ (d __attribute__((vector_size(16 *sizeof(d))))){
+ ac, ac, ac, ac, ac, ac, ac, ac, ac, ac, ac, ac, ac},
+ c __attribute__((vector_size(16)))),
+ __builtin_convertvector(
+ (d __attribute__((vector_size(16 *sizeof(d))))){
+ ac, ac, ac, ac, ac, ac, ac, ac, ac, ac, ac, ac, ac},
+ b __attribute__((vector_size(16)))),
+ 3, 21, 0, 2, 2, 7, 1, 8, 4, 0, 8, 0, 8, 9, 5, 6);
+}
+__attribute__((always_inline)) g
+ad(d ae, h __attribute__((vector_size(32 * sizeof(h))))) {
+ g f = 6318;
+ return (8 ? ae / 786856318u : 0) & ae;
+}
+a(af)(a, int);
+void(ag)(long);
+char(ah)(char, char);
+char(ai)(char);
+short(aj)(short, short);
+int ak(long, int *, int *, char, int);
+void al(signed, a *, int *, long);
+char am(int *, short, short);
+void an(int *, long, int);
+void ao(int, int *, a *);
+a ap() {
+ int *aq, *ar, *as;
+ short at;
+ char au, av, aw = 2;
+ long ax, ay, az = j;
+ int ba, i;
+ g __attribute__((vector_size(16 * sizeof(g)))) bb = {80};
+ b __attribute__((vector_size(4))) bc = {6};
+ int bd[1];
+ char *be = &w;
+ int bf, bg = q;
+ a **bh[] = {
+ &y, &z, &z, &y, &y, &y, &y, &y, &z, &z, &y, &z, &y, &y, &y, &y, &z, &y,
+ &z, &y, &y, &y, &z, &z, &z, &y, &z, &z, &z, &y, &z, &z, &y, &z, &z, &y,
+ &z, &z, &z, &y, 0, &z, 0, &y, 0, &y, &y, &z, &z, &y, &y, 0, &z, 0,
+ &z, 0, &y, &z, &z, 0, &z, 0, &z, &z, &z, &y, &z, &z, &y, &z, &z, &y,
+ 0, &z, 0, &z, &z, &y, 0, &z, 0, &y, 0, &y, &y, &z, &z, &y, &y, 0,
+ &z, 0, &z, 0, &y, &z, &z, 0, &z, 0, &z, &z, &z, &y, &z, &z, &y, &z,
+ &z, &y, 0, &z, 0, &z, &z, &y, 0, &z, 0, &y, 0, &y, &y, &z, &z, &y,
+ &y, 0, &z, 0, &z, 0, &y, &z, &z, 0, &z, 0, &z, &z, &z, &y, &z, &z,
+ &y, &z, &z, &y, 0, &z, 0, &z, &z, &y, 0, &z, 0, &y, 0, &y, &y, &z,
+ &z, &y, &y, 0, &z, 0, &z, 0, &y, &z, &z, 0, 0, &z, 0, &z, &z, &z,
+ &y, &z, &z, &y, &z, &z, &y, 0, &z, 0, 0, &z, &z};
+ for (; i; i++)
+ bd[i] = p;
+ h __attribute__((vector_size(32 * sizeof(h))))
+ bi = {2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681,
+ 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681,
+ 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681},
+ bj = __builtin_convertvector(
+ (c __attribute__((vector_size(32)))){
+ aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw,
+ aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw, aw},
+ h __attribute__((vector_size(32 * sizeof(h))))),
+ bk = __builtin_convertvector(
+ __builtin_shufflevector(bb, bb, 4, 8, 7, 9, 1, 10, 4, 7, 0, 4, 3, 5, 6, 7,
+ 6, 2, 2, 20, 6, 4, 7, 7, 9, 7, 4, 9, 8, 6, 1, 0,
+ 6, 9),
+ h __attribute__((vector_size(32 * sizeof(h)))));
+ bb = __builtin_convertvector(
+ ab(__builtin_shufflevector(
+ __builtin_shufflevector(
+ __builtin_convertvector(
+ __builtin_shufflevector(bb, bb, 1, 31, 8, 2, 3, 7, 4, 0, 7,
+ 3, 4, 6, 7, 1, 9, 3, 8, 7, 1, 8, 5,
+ 3, 9, 9, 0, 3, 2, 8, 5, 2, 5, 3),
+ f __attribute__((vector_size(32 * sizeof(f))))),
+ (f __attribute__((vector_size(32 * sizeof(f))))){
+ 800761418310502961587690471176286910032020044212442466872080013589354162852207417903424527024812447907811618435019152886919380169872910001752451018659493155196043018716516518746289614523948734758456011127254301274351182132760058399143431214610613191313926994549901191890929084305862034120561651877003645},
+ 32, 44),
+ (f __attribute__((vector_size(2 * sizeof(f))))){o}, 1, 0, 3, 0, 2,
+ 1, 3, 3),
+ ad(__builtin_clzg((g)aw, (f)bb[9]),
+ (h __attribute__((vector_size(32 * sizeof(h))))){
+ bi[0] ?: bk[0], bi[1] ? 1 : bk[1], bi[2] ? 2 : bk[2],
+ bi[3] ? 3 : bk[3], bi[4] ? 4 : bk[4], bi[5] ? 5 : bk[5],
+ bi[6] ? 6 : bk[6], bi[7] ? 7 : bk[7], bi[8] ? 8 : bk[8],
+ bi[9] ? 9 : bk[9], bi[0] ? 10 : bk[0], bi[1] ? 1 : bk[1],
+ bi[2] ? 2 : bk[2], bi[3] ? 3 : bk[3], bi[4] ? 4 : bk[4],
+ bi[5] ? 5 : bk[5], bi[6] ? 6 : bk[6], bi[7] ? 7 : bk[7],
+ bi[8] ? 8 : bk[8], bi[9] ? 9 : bk[9], bi[0] ? 20 : bk[0],
+ bi[1] ? 1 : bk[1], bi[2] ? 2 : bk[2], bi[3] ? 3 : bk[3],
+ bi[4] ? bj[4] : 4, bi[5] ?: 5, bi[6] ?: 6,
+ bi[7] ? 0 : 7, bi[8] ?: 8, bi[9] ? 0 : 9,
+ bi[0] ? 0 : 30, bi[1] ?: 1}),
+ (d __attribute__((vector_size(2 * sizeof(d)))))
+ __builtin_shufflevector(
+ __builtin_convertvector(
+ __builtin_shufflevector(bb, bb, 2, 7, 21, 6),
+ e __attribute__((vector_size(4 * sizeof(e))))),
+ __builtin_convertvector(
+ (c __attribute__((vector_size(4)))){aw, aw},
+ e __attribute__((vector_size(4 * sizeof(e))))),
+ 5, 1) +
+ (__builtin_convertvector(
+ __builtin_shufflevector(bb, bb, 4, 5),
+ e __attribute__((vector_size(2 * sizeof(e))))) <=
+ __builtin_convertvector(
+ (c __attribute__((vector_size(2)))){aw},
+ e __attribute__((vector_size(2 * sizeof(e)))))),
+ n ? bb[5] << n : aw),
+ g __attribute__((vector_size(16 * sizeof(g)))));
+ ag(aw & t);
+ at = aj(aw, v[1]);
+ au = ah(at, aw);
+ ba = af((1 == ax != aw) <= aw <= au, aw);
+ ao(0, &bd[0], &r);
+ o = ay;
+ an(aq, aw, k);
+ av = am(ar, l, k);
+ *be = ai(*be);
+ al(x, as, &bd[0], aw);
+ bg = ak(u, &s, &bf, aw, aw);
+ as = *aa;
+ return m;
+}
diff --git a/gcc/testsuite/gfortran.dg/pdt_65.f03 b/gcc/testsuite/gfortran.dg/pdt_65.f03
new file mode 100644
index 0000000..d5e45c2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pdt_65.f03
@@ -0,0 +1,135 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Test fix for PR122452
+!
+! Contributed by Damian Rouson <damian@archaeologic.codes>
+!
+module kind_parameters_m
+ integer, parameter :: default_real = kind(1e0)
+ integer, parameter :: double_precision = kind(1d0)
+end module
+
+module tensor_m
+ use kind_parameters_m, only : default_real, double_precision
+ implicit none
+
+ private
+ public :: tensor_t
+
+ type tensor_t(k)
+ integer, kind :: k = default_real
+ real(k), allocatable, private :: values_(:)
+ contains
+ generic :: values => default_real_values, double_precision_values
+ procedure, private, non_overridable :: default_real_values, double_precision_values
+ generic :: num_components => default_real_num_components, double_precision_num_components
+ procedure, private :: default_real_num_components, double_precision_num_components
+ end type
+
+ interface tensor_t
+
+ pure module function construct_default_real(values) result(tensor)
+ implicit none
+ real, intent(in) :: values(:)
+ type(tensor_t) tensor
+ end function
+
+ pure module function construct_double_precision(values) result(tensor)
+ implicit none
+ double precision, intent(in) :: values(:)
+ type(tensor_t(double_precision)) tensor
+ end function
+
+ end interface
+
+ interface
+
+ pure module function default_real_values(self) result(tensor_values)
+ implicit none
+ class(tensor_t), intent(in) :: self
+ real, allocatable :: tensor_values(:)
+ end function
+
+ pure module function double_precision_values(self) result(tensor_values)
+ implicit none
+ class(tensor_t(double_precision)), intent(in) :: self
+ double precision, allocatable :: tensor_values(:)
+ end function
+
+ pure module function default_real_num_components(self) result(n)
+ implicit none
+ class(tensor_t), intent(in) :: self
+ integer n
+ end function
+
+ pure module function double_precision_num_components(self) result(n)
+ implicit none
+ class(tensor_t(double_precision)), intent(in) :: self
+ integer n
+ end function
+
+ end interface
+
+end module tensor_m
+
+submodule(tensor_m) tensor_s
+contains
+
+ pure module function construct_default_real(values) result(tensor)
+ implicit none
+ real, intent(in) :: values(:)
+ type(tensor_t) tensor
+ tensor = tensor_t ()(values)
+ end function
+
+ pure module function construct_double_precision(values) result(tensor)
+ implicit none
+ double precision, intent(in) :: values(:)
+ type(tensor_t(double_precision)) tensor
+ tensor = tensor_t (double_precision)(values)
+ end function
+
+ pure module function default_real_values(self) result(tensor_values)
+ implicit none
+ class(tensor_t), intent(in) :: self
+ real, allocatable :: tensor_values(:)
+ tensor_values = self%values_
+ end function
+
+ pure module function double_precision_values(self) result(tensor_values)
+ implicit none
+ class(tensor_t(double_precision)), intent(in) :: self
+ double precision, allocatable :: tensor_values(:)
+ tensor_values = self%values_
+ end function
+
+
+ pure module function default_real_num_components(self) result(n)
+ implicit none
+ class(tensor_t), intent(in) :: self
+ integer n
+ n = default_real
+ end function
+
+ pure module function double_precision_num_components(self) result(n)
+ implicit none
+ class(tensor_t(double_precision)), intent(in) :: self
+ integer n
+ n = double_precision
+ end function
+
+end submodule tensor_s
+
+
+ use tensor_m
+ type(tensor_t(kind(0e0))) :: a
+ type(tensor_t(kind(0D0))) :: b
+ a = tensor_t ([1e0,2e0])
+ print *, a%num_components (), a%values ()
+ b = tensor_t ([3d0,4d0])
+ print *, b%num_components (), b%values ()
+end
+! { dg-final { scan-tree-dump-times "construct_" 4 "original" } }
+! { dg-final { scan-tree-dump-times "_components" 4 "original" } }
+! { dg-final { scan-tree-dump-times "_values" 4 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/pure_result.f90 b/gcc/testsuite/gfortran.dg/pure_result.f90
new file mode 100644
index 0000000..a4d30aa
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pure_result.f90
@@ -0,0 +1,49 @@
+! { dg-do compile }
+! PR fortran/78640 - constraints on pure function results
+!
+! F2018:C1585, F2023:C1594:
+! "The function result of a pure function shall not be both polymorphic and
+! allocatable, or have a polymorphic allocatable ultimate component."
+
+program pr78640
+ implicit none
+
+ type foo_t
+ end type
+
+ type bar_t
+ integer, allocatable :: dummy
+ class(*), allocatable :: c
+ end type bar_t
+
+contains
+
+ pure function f() result(foo) ! { dg-error "is polymorphic allocatable" }
+ class(foo_t), allocatable :: foo
+ foo = foo_t()
+ end function
+
+ pure function f2() ! { dg-error "is polymorphic allocatable" }
+ class(foo_t), allocatable :: f2
+ f2 = foo_t()
+ end function
+
+ pure function g() result(foo) ! { dg-error "is polymorphic allocatable" }
+ class(*), allocatable :: foo
+ foo = foo_t()
+ end function
+
+ pure function g2() ! { dg-error "is polymorphic allocatable" }
+ class(*), allocatable :: g2
+ g2 = foo_t()
+ end function
+
+ pure function h() result(bar) ! { dg-error "polymorphic allocatable component" }
+ type(bar_t) :: bar
+ end function
+
+ pure function h2() ! { dg-error "polymorphic allocatable component" }
+ type(bar_t) :: h2
+ end function
+
+end