aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2025-09-02 15:58:26 -0700
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2025-09-02 15:58:26 -0700
commit071b4126c613881f4cb25b4e5c39032964827f88 (patch)
tree7ed805786566918630d1d617b1ed8f7310f5fd8e /gcc/testsuite/gcc.dg
parent845d23f3ea08ba873197c275a8857eee7edad996 (diff)
parentcaa1c2f42691d68af4d894a5c3e700ecd2dba080 (diff)
downloadgcc-devel/gfortran-test.zip
gcc-devel/gfortran-test.tar.gz
gcc-devel/gfortran-test.tar.bz2
Merge branch 'master' into gfortran-testdevel/gfortran-test
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/Warray-parameter-11.c4
-rw-r--r--gcc/testsuite/gcc.dg/Warray-parameter.c3
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-1.c62
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-3.c62
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-4.c4
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-5.c47
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-6.c4
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-7.c47
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-8.c4
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-9.c15
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-1.c9
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-4.c9
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-6.c10
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-error-3.c4
-rw-r--r--gcc/testsuite/gcc.dg/bitint-125.c15
-rw-r--r--gcc/testsuite/gcc.dg/bitintext.h46
-rw-r--r--gcc/testsuite/gcc.dg/c23-attr-syntax-6.c4
-rw-r--r--gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c44
-rw-r--r--gcc/testsuite/gcc.dg/cpp/paste12-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/paste12.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/paste14-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/cpp/paste14.c4
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-array-7.c24
-rw-r--r--gcc/testsuite/gcc.dg/flex-array-counted-by-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/flex-array-counted-by.c2
-rw-r--r--gcc/testsuite/gcc.dg/gomp/adjust-args-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/gomp/append-args-1.c28
-rw-r--r--gcc/testsuite/gcc.dg/gomp/declare-variant-3.c18
-rw-r--r--gcc/testsuite/gcc.dg/gomp/pr121453.c18
-rw-r--r--gcc/testsuite/gcc.dg/gomp/unprototyped-variant.c30
-rw-r--r--gcc/testsuite/gcc.dg/graphite/id-30.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-graphs-html.py2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-html.c13
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-html.py69
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c9
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c24
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/must-tail-call-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/plugin.exp3
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-1.c34
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-2.c10
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-3.c127
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c6
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c6
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c10
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c10
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-4.c77
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-5.c56
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-6.c56
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-7.c32
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-8.c29
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-9.c85
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by.c111
-rw-r--r--gcc/testsuite/gcc.dg/pr109071.c43
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_1.c36
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_10.c85
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_11.c89
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_12.c44
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_2.c50
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_3.c42
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_4.c41
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_5.c33
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_6.c49
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_7.c44
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_8.c51
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_9.c61
-rw-r--r--gcc/testsuite/gcc.dg/pr116906-1.c1
-rw-r--r--gcc/testsuite/gcc.dg/pr116906-2.c1
-rw-r--r--gcc/testsuite/gcc.dg/pr117375.c13
-rw-r--r--gcc/testsuite/gcc.dg/pr118946-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/pr120660.c19
-rw-r--r--gcc/testsuite/gcc.dg/pr120929.c49
-rw-r--r--gcc/testsuite/gcc.dg/pr121217.c19
-rw-r--r--gcc/testsuite/gcc.dg/pr121322.c14
-rw-r--r--gcc/testsuite/gcc.dg/pr121619.c33
-rw-r--r--gcc/testsuite/gcc.dg/pr121663.c9
-rw-r--r--gcc/testsuite/gcc.dg/pr78185.c1
-rw-r--r--gcc/testsuite/gcc.dg/pr89828.c49
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-2.c88
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-4.c84
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-5.c80
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-6.c166
-rw-r--r--gcc/testsuite/gcc.dg/torture/bitint-83.c48
-rw-r--r--gcc/testsuite/gcc.dg/torture/bitint-84.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/bitint-85.c34
-rw-r--r--gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-1.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-2.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c8
-rw-r--r--gcc/testsuite/gcc.dg/torture/hardbool-ai.c8
-rw-r--r--gcc/testsuite/gcc.dg/torture/hardbool-vi.c5
-rw-r--r--gcc/testsuite/gcc.dg/torture/hardbool.c68
-rw-r--r--gcc/testsuite/gcc.dg/torture/malloc-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/malloc-2.c12
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121236-1.c20
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121279-1.c49
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121295-1.c13
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121370.c25
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121382.c23
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121422-1.c35
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121422-2.c36
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121478-1.c32
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121514.c20
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121656.c30
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121695-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-1.c21
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-1.c28
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-2.c25
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-3.c25
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/cswtch-6.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/cswtch-7.c48
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr121264.c12
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-105.c33
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-106.c33
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-107.c29
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-108.c30
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-109.c23
-rw-r--r--gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c53
-rw-r--r--gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c42
-rw-r--r--gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c42
-rw-r--r--gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c40
-rw-r--r--gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c46
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr112325.c1
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr117888-1.c1
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr120687-1.c16
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr120687-2.c17
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr120687-3.c16
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121509.c42
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121638.c74
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121659.c11
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121686.c32
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121744-1.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121754.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr59984.c4
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c62
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c54
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-early-break_52.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-gather-1.c6
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-recurr-pr121256-2.c49
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-recurr-pr121256.c54
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-simd-pr121130.c11
-rw-r--r--gcc/testsuite/gcc.dg/vla-tert-1.c293
146 files changed, 4338 insertions, 167 deletions
diff --git a/gcc/testsuite/gcc.dg/Warray-parameter-11.c b/gcc/testsuite/gcc.dg/Warray-parameter-11.c
index 8ca1b55..e05835c 100644
--- a/gcc/testsuite/gcc.dg/Warray-parameter-11.c
+++ b/gcc/testsuite/gcc.dg/Warray-parameter-11.c
@@ -9,7 +9,7 @@ typedef __INTPTR_TYPE__ intptr_t;
void f0 (double[!copysign (~2, 3)]);
void f1 (double[!copysign (~2, 3)]);
-void f1 (double[1]); // { dg-warning "-Warray-parameter" }
+void f1 (double[1]); // { dg-warning "-Wvla-parameter" }
void f2 (int[(int)+1.0]);
void f2 (int[(int)+1.1]);
@@ -21,4 +21,4 @@ extern struct S *sp;
void f3 (int[(intptr_t)((char*)sp->a - (char*)sp)]);
void f3 (int[(intptr_t)((char*)&sp->a[0] - (char*)sp)]);
-void f3 (int[(intptr_t)((char*)&sp->a[1] - (char*)sp)]); // { dg-warning "-Warray-parameter" }
+void f3 (int[(intptr_t)((char*)&sp->a[1] - (char*)sp)]); // { dg-warning "-Wvla-parameter" }
diff --git a/gcc/testsuite/gcc.dg/Warray-parameter.c b/gcc/testsuite/gcc.dg/Warray-parameter.c
index 6c5195a..31879a8 100644
--- a/gcc/testsuite/gcc.dg/Warray-parameter.c
+++ b/gcc/testsuite/gcc.dg/Warray-parameter.c
@@ -118,8 +118,7 @@ typedef int IA2[2];
typedef int IA3[3];
// The message should differentiate between the [] form and *.
-void f1IAx_A1 (IAx); // { dg-message "previously declared as 'int\\\[]'" "pr?????" { xfail *-*-* } }
- // { dg-message "previously declared as 'int *\\\*'" "note" { target *-*-* } .-1 }
+void f1IAx_A1 (IAx); // { dg-message "previously declared as 'int\\\[]'" }
void f1IAx_A1 (IA1); // { dg-message "argument 1 of type 'int\\\[1]' with mismatched bound" }
void f1IA1_A2 (IA1); // { dg-message "previously declared as 'int\\\[1]'" }
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-1.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-1.c
new file mode 100644
index 0000000..0b2d78f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-1.c
@@ -0,0 +1,62 @@
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro -std=c23" }
+
+#define _Alignas 1 // { dg-warning "keyword '_Alignas' defined as macro" }
+#define _Alignof 1 // { dg-warning "keyword '_Alignof' defined as macro" }
+#define _Atomic 1 // { dg-warning "keyword '_Atomic' defined as macro" }
+#define _BitInt 1 // { dg-warning "keyword '_BitInt' defined as macro" }
+#define _Bool 1 // { dg-warning "keyword '_Bool' defined as macro" }
+#define _Complex 1 // { dg-warning "keyword '_Complex' defined as macro" }
+#define _Decimal128 1 // { dg-warning "keyword '_Decimal128' defined as macro" }
+#define _Decimal32 1 // { dg-warning "keyword '_Decimal32' defined as macro" }
+#define _Decimal64 1 // { dg-warning "keyword '_Decimal64' defined as macro" }
+#define _Generic 1 // { dg-warning "keyword '_Generic' defined as macro" }
+#define _Imaginary 1 // { dg-warning "keyword '_Imaginary' defined as macro" }
+#define _Noreturn 1 // { dg-warning "keyword '_Noreturn' defined as macro" }
+#define _Static_assert 1 // { dg-warning "keyword '_Static_assert' defined as macro" }
+#define _Thread_local 1 // { dg-warning "keyword '_Thread_local' defined as macro" }
+#define alignas 1 // { dg-warning "keyword 'alignas' defined as macro" }
+#define alignof 1 // { dg-warning "keyword 'alignof' defined as macro" }
+#define auto 1 // { dg-warning "keyword 'auto' defined as macro" }
+#define bool 1 // { dg-warning "keyword 'bool' defined as macro" }
+#define break 1 // { dg-warning "keyword 'break' defined as macro" }
+#define case 1 // { dg-warning "keyword 'case' defined as macro" }
+#define char 1 // { dg-warning "keyword 'char' defined as macro" }
+#define const 1 // { dg-warning "keyword 'const' defined as macro" }
+#define constexpr 1 // { dg-warning "keyword 'constexpr' defined as macro" }
+#define continue 1 // { dg-warning "keyword 'continue' defined as macro" }
+#define default 1 // { dg-warning "keyword 'default' defined as macro" }
+#define do 1 // { dg-warning "keyword 'do' defined as macro" }
+#define double 1 // { dg-warning "keyword 'double' defined as macro" }
+#define else 1 // { dg-warning "keyword 'else' defined as macro" }
+#define enum 1 // { dg-warning "keyword 'enum' defined as macro" }
+#define extern 1 // { dg-warning "keyword 'extern' defined as macro" }
+#define false 1 // { dg-warning "keyword 'false' defined as macro" }
+#define float 1 // { dg-warning "keyword 'float' defined as macro" }
+#define for 1 // { dg-warning "keyword 'for' defined as macro" }
+#define goto 1 // { dg-warning "keyword 'goto' defined as macro" }
+#define if 1 // { dg-warning "keyword 'if' defined as macro" }
+#define inline 1 // { dg-warning "keyword 'inline' defined as macro" }
+#define int 1 // { dg-warning "keyword 'int' defined as macro" }
+#define long 1 // { dg-warning "keyword 'long' defined as macro" }
+#define nullptr 1 // { dg-warning "keyword 'nullptr' defined as macro" }
+#define register 1 // { dg-warning "keyword 'register' defined as macro" }
+#define restrict 1 // { dg-warning "keyword 'restrict' defined as macro" }
+#define return 1 // { dg-warning "keyword 'return' defined as macro" }
+#define short 1 // { dg-warning "keyword 'short' defined as macro" }
+#define signed 1 // { dg-warning "keyword 'signed' defined as macro" }
+#define sizeof 1 // { dg-warning "keyword 'sizeof' defined as macro" }
+#define static 1 // { dg-warning "keyword 'static' defined as macro" }
+#define static_assert 1 // { dg-warning "keyword 'static_assert' defined as macro" }
+#define struct 1 // { dg-warning "keyword 'struct' defined as macro" }
+#define switch 1 // { dg-warning "keyword 'switch' defined as macro" }
+#define thread_local 1 // { dg-warning "keyword 'thread_local' defined as macro" }
+#define true 1 // { dg-warning "keyword 'true' defined as macro" }
+#define typedef 1 // { dg-warning "keyword 'typedef' defined as macro" }
+#define typeof 1 // { dg-warning "keyword 'typeof' defined as macro" }
+#define typeof_unqual 1 // { dg-warning "keyword 'typeof_unqual' defined as macro" }
+#define union 1 // { dg-warning "keyword 'union' defined as macro" }
+#define unsigned 1 // { dg-warning "keyword 'unsigned' defined as macro" }
+#define void 1 // { dg-warning "keyword 'void' defined as macro" }
+#define volatile 1 // { dg-warning "keyword 'volatile' defined as macro" }
+#define while 1 // { dg-warning "keyword 'while' defined as macro" }
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-2.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-2.c
new file mode 100644
index 0000000..329a55a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-2.c
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=c23" }
+
+#include "Wkeyword-macro-1.c"
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-3.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-3.c
new file mode 100644
index 0000000..f631b8e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-3.c
@@ -0,0 +1,62 @@
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro -std=c23" }
+
+#undef _Alignas // { dg-warning "undefining keyword '_Alignas'" }
+#undef _Alignof // { dg-warning "undefining keyword '_Alignof'" }
+#undef _Atomic // { dg-warning "undefining keyword '_Atomic'" }
+#undef _BitInt // { dg-warning "undefining keyword '_BitInt'" }
+#undef _Bool // { dg-warning "undefining keyword '_Bool'" }
+#undef _Complex // { dg-warning "undefining keyword '_Complex'" }
+#undef _Decimal128 // { dg-warning "undefining keyword '_Decimal128'" }
+#undef _Decimal32 // { dg-warning "undefining keyword '_Decimal32'" }
+#undef _Decimal64 // { dg-warning "undefining keyword '_Decimal64'" }
+#undef _Generic // { dg-warning "undefining keyword '_Generic'" }
+#undef _Imaginary // { dg-warning "undefining keyword '_Imaginary'" }
+#undef _Noreturn // { dg-warning "undefining keyword '_Noreturn'" }
+#undef _Static_assert // { dg-warning "undefining keyword '_Static_assert'" }
+#undef _Thread_local // { dg-warning "undefining keyword '_Thread_local'" }
+#undef alignas // { dg-warning "undefining keyword 'alignas'" }
+#undef alignof // { dg-warning "undefining keyword 'alignof'" }
+#undef auto // { dg-warning "undefining keyword 'auto'" }
+#undef bool // { dg-warning "undefining keyword 'bool'" }
+#undef break // { dg-warning "undefining keyword 'break'" }
+#undef case // { dg-warning "undefining keyword 'case'" }
+#undef char // { dg-warning "undefining keyword 'char'" }
+#undef const // { dg-warning "undefining keyword 'const'" }
+#undef constexpr // { dg-warning "undefining keyword 'constexpr'" }
+#undef continue // { dg-warning "undefining keyword 'continue'" }
+#undef default // { dg-warning "undefining keyword 'default'" }
+#undef do // { dg-warning "undefining keyword 'do'" }
+#undef double // { dg-warning "undefining keyword 'double'" }
+#undef else // { dg-warning "undefining keyword 'else'" }
+#undef enum // { dg-warning "undefining keyword 'enum'" }
+#undef extern // { dg-warning "undefining keyword 'extern'" }
+#undef false // { dg-warning "undefining keyword 'false'" }
+#undef float // { dg-warning "undefining keyword 'float'" }
+#undef for // { dg-warning "undefining keyword 'for'" }
+#undef goto // { dg-warning "undefining keyword 'goto'" }
+#undef if // { dg-warning "undefining keyword 'if'" }
+#undef inline // { dg-warning "undefining keyword 'inline'" }
+#undef int // { dg-warning "undefining keyword 'int'" }
+#undef long // { dg-warning "undefining keyword 'long'" }
+#undef nullptr // { dg-warning "undefining keyword 'nullptr'" }
+#undef register // { dg-warning "undefining keyword 'register'" }
+#undef restrict // { dg-warning "undefining keyword 'restrict'" }
+#undef return // { dg-warning "undefining keyword 'return'" }
+#undef short // { dg-warning "undefining keyword 'short'" }
+#undef signed // { dg-warning "undefining keyword 'signed'" }
+#undef sizeof // { dg-warning "undefining keyword 'sizeof'" }
+#undef static // { dg-warning "undefining keyword 'static'" }
+#undef static_assert // { dg-warning "undefining keyword 'static_assert'" }
+#undef struct // { dg-warning "undefining keyword 'struct'" }
+#undef switch // { dg-warning "undefining keyword 'switch'" }
+#undef thread_local // { dg-warning "undefining keyword 'thread_local'" }
+#undef true // { dg-warning "undefining keyword 'true'" }
+#undef typedef // { dg-warning "undefining keyword 'typedef'" }
+#undef typeof // { dg-warning "undefining keyword 'typeof'" }
+#undef typeof_unqual // { dg-warning "undefining keyword 'typeof_unqual'" }
+#undef union // { dg-warning "undefining keyword 'union'" }
+#undef unsigned // { dg-warning "undefining keyword 'unsigned'" }
+#undef void // { dg-warning "undefining keyword 'void'" }
+#undef volatile // { dg-warning "undefining keyword 'volatile'" }
+#undef while // { dg-warning "undefining keyword 'while'" }
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-4.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-4.c
new file mode 100644
index 0000000..796d654
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-4.c
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=c23" }
+
+#include "Wkeyword-macro-3.c"
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-5.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-5.c
new file mode 100644
index 0000000..c61a1ce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-5.c
@@ -0,0 +1,47 @@
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro -std=c17" }
+
+#define _Alignas 1 // { dg-warning "keyword '_Alignas' defined as macro" }
+#define _Alignof 1 // { dg-warning "keyword '_Alignof' defined as macro" }
+#define _Atomic 1 // { dg-warning "keyword '_Atomic' defined as macro" }
+#define _Bool 1 // { dg-warning "keyword '_Bool' defined as macro" }
+#define _Complex 1 // { dg-warning "keyword '_Complex' defined as macro" }
+#define _Generic 1 // { dg-warning "keyword '_Generic' defined as macro" }
+#define _Imaginary 1 // { dg-warning "keyword '_Imaginary' defined as macro" }
+#define _Noreturn 1 // { dg-warning "keyword '_Noreturn' defined as macro" }
+#define _Static_assert 1 // { dg-warning "keyword '_Static_assert' defined as macro" }
+#define _Thread_local 1 // { dg-warning "keyword '_Thread_local' defined as macro" }
+#define auto 1 // { dg-warning "keyword 'auto' defined as macro" }
+#define break 1 // { dg-warning "keyword 'break' defined as macro" }
+#define case 1 // { dg-warning "keyword 'case' defined as macro" }
+#define char 1 // { dg-warning "keyword 'char' defined as macro" }
+#define const 1 // { dg-warning "keyword 'const' defined as macro" }
+#define continue 1 // { dg-warning "keyword 'continue' defined as macro" }
+#define default 1 // { dg-warning "keyword 'default' defined as macro" }
+#define do 1 // { dg-warning "keyword 'do' defined as macro" }
+#define double 1 // { dg-warning "keyword 'double' defined as macro" }
+#define else 1 // { dg-warning "keyword 'else' defined as macro" }
+#define enum 1 // { dg-warning "keyword 'enum' defined as macro" }
+#define extern 1 // { dg-warning "keyword 'extern' defined as macro" }
+#define float 1 // { dg-warning "keyword 'float' defined as macro" }
+#define for 1 // { dg-warning "keyword 'for' defined as macro" }
+#define goto 1 // { dg-warning "keyword 'goto' defined as macro" }
+#define if 1 // { dg-warning "keyword 'if' defined as macro" }
+#define inline 1 // { dg-warning "keyword 'inline' defined as macro" }
+#define int 1 // { dg-warning "keyword 'int' defined as macro" }
+#define long 1 // { dg-warning "keyword 'long' defined as macro" }
+#define register 1 // { dg-warning "keyword 'register' defined as macro" }
+#define restrict 1 // { dg-warning "keyword 'restrict' defined as macro" }
+#define return 1 // { dg-warning "keyword 'return' defined as macro" }
+#define short 1 // { dg-warning "keyword 'short' defined as macro" }
+#define signed 1 // { dg-warning "keyword 'signed' defined as macro" }
+#define sizeof 1 // { dg-warning "keyword 'sizeof' defined as macro" }
+#define static 1 // { dg-warning "keyword 'static' defined as macro" }
+#define struct 1 // { dg-warning "keyword 'struct' defined as macro" }
+#define switch 1 // { dg-warning "keyword 'switch' defined as macro" }
+#define typedef 1 // { dg-warning "keyword 'typedef' defined as macro" }
+#define union 1 // { dg-warning "keyword 'union' defined as macro" }
+#define unsigned 1 // { dg-warning "keyword 'unsigned' defined as macro" }
+#define void 1 // { dg-warning "keyword 'void' defined as macro" }
+#define volatile 1 // { dg-warning "keyword 'volatile' defined as macro" }
+#define while 1 // { dg-warning "keyword 'while' defined as macro" }
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-6.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-6.c
new file mode 100644
index 0000000..760ece6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-6.c
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=c17" }
+
+#include "Wkeyword-macro-5.c"
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-7.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-7.c
new file mode 100644
index 0000000..dc146d4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-7.c
@@ -0,0 +1,47 @@
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro -std=c17" }
+
+#undef _Alignas // { dg-warning "undefining keyword '_Alignas'" }
+#undef _Alignof // { dg-warning "undefining keyword '_Alignof'" }
+#undef _Atomic // { dg-warning "undefining keyword '_Atomic'" }
+#undef _Bool // { dg-warning "undefining keyword '_Bool'" }
+#undef _Complex // { dg-warning "undefining keyword '_Complex'" }
+#undef _Generic // { dg-warning "undefining keyword '_Generic'" }
+#undef _Imaginary // { dg-warning "undefining keyword '_Imaginary'" }
+#undef _Noreturn // { dg-warning "undefining keyword '_Noreturn'" }
+#undef _Static_assert // { dg-warning "undefining keyword '_Static_assert'" }
+#undef _Thread_local // { dg-warning "undefining keyword '_Thread_local'" }
+#undef auto // { dg-warning "undefining keyword 'auto'" }
+#undef break // { dg-warning "undefining keyword 'break'" }
+#undef case // { dg-warning "undefining keyword 'case'" }
+#undef char // { dg-warning "undefining keyword 'char'" }
+#undef const // { dg-warning "undefining keyword 'const'" }
+#undef continue // { dg-warning "undefining keyword 'continue'" }
+#undef default // { dg-warning "undefining keyword 'default'" }
+#undef do // { dg-warning "undefining keyword 'do'" }
+#undef double // { dg-warning "undefining keyword 'double'" }
+#undef else // { dg-warning "undefining keyword 'else'" }
+#undef enum // { dg-warning "undefining keyword 'enum'" }
+#undef extern // { dg-warning "undefining keyword 'extern'" }
+#undef float // { dg-warning "undefining keyword 'float'" }
+#undef for // { dg-warning "undefining keyword 'for'" }
+#undef goto // { dg-warning "undefining keyword 'goto'" }
+#undef if // { dg-warning "undefining keyword 'if'" }
+#undef inline // { dg-warning "undefining keyword 'inline'" }
+#undef int // { dg-warning "undefining keyword 'int'" }
+#undef long // { dg-warning "undefining keyword 'long'" }
+#undef register // { dg-warning "undefining keyword 'register'" }
+#undef restrict // { dg-warning "undefining keyword 'restrict'" }
+#undef return // { dg-warning "undefining keyword 'return'" }
+#undef short // { dg-warning "undefining keyword 'short'" }
+#undef signed // { dg-warning "undefining keyword 'signed'" }
+#undef sizeof // { dg-warning "undefining keyword 'sizeof'" }
+#undef static // { dg-warning "undefining keyword 'static'" }
+#undef struct // { dg-warning "undefining keyword 'struct'" }
+#undef switch // { dg-warning "undefining keyword 'switch'" }
+#undef typedef // { dg-warning "undefining keyword 'typedef'" }
+#undef union // { dg-warning "undefining keyword 'union'" }
+#undef unsigned // { dg-warning "undefining keyword 'unsigned'" }
+#undef void // { dg-warning "undefining keyword 'void'" }
+#undef volatile // { dg-warning "undefining keyword 'volatile'" }
+#undef while // { dg-warning "undefining keyword 'while'" }
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-8.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-8.c
new file mode 100644
index 0000000..b209f40
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-8.c
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=c17" }
+
+#include "Wkeyword-macro-7.c"
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-9.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-9.c
new file mode 100644
index 0000000..5d6b650
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-9.c
@@ -0,0 +1,15 @@
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro" }
+
+#undef for // { dg-warning "undefining keyword 'for'" }
+#define for for // { dg-warning "keyword 'for' defined as macro" }
+#undef for // { dg-warning "undefining keyword 'for'" }
+#define while do // { dg-warning "keyword 'while' defined as macro" }
+#define while do // { dg-warning "keyword 'while' defined as macro" }
+#define while for // { dg-warning "keyword 'while' defined as macro" }
+ // { dg-warning "'while' redefined" "" { target *-*-* } .-1 }
+#undef while // { dg-warning "undefining keyword 'while'" }
+#define while while // { dg-warning "keyword 'while' defined as macro" }
+#define inline // { dg-warning "keyword 'inline' defined as macro" }
+#undef inline // { dg-warning "undefining keyword 'inline'" }
+#define inline __inline__ __attribute__((__always_inline__)) // { dg-warning "keyword 'inline' defined as macro" }
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-1.c b/gcc/testsuite/gcc.dg/asm-hard-reg-1.c
index 6a5a9ad..8cefb6e 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-1.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-1.c
@@ -22,10 +22,11 @@
/* { dg-final { scan-assembler-times "foo\t%r4" 8 { target { s390*-*-* } } } } */
#elif defined (__x86_64__)
# define GPR "{rcx}"
-/* { dg-final { scan-assembler-times "foo\t%cl" 2 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "foo\t%cx" 2 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "foo\t%ecx" 2 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%cl" 2 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%cx" 2 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%ecx" 2 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "foo\t%ecx" 4 { target { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } */
#endif
char
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-2.c b/gcc/testsuite/gcc.dg/asm-hard-reg-2.c
index 7dabf96..5a60f9b 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-2.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-2.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-do compile { target { { aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* } || { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } } */
/* { dg-options "-std=c99" } we need long long */
#if defined (__aarch64__)
@@ -15,7 +15,7 @@
/* { dg-final { scan-assembler-times "foo\t%r4" 2 { target { s390*-*-* } } } } */
#elif defined (__x86_64__)
# define GPR "{rcx}"
-/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { i?86-*-* x86_64-*-* } } } } */
#endif
long long
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-4.c b/gcc/testsuite/gcc.dg/asm-hard-reg-4.c
index 0134bf0..01ae3ad 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-4.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-4.c
@@ -1,11 +1,12 @@
-/* { dg-do compile { target aarch64*-*-* arm*-*-* powerpc*-*-* riscv*-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* powerpc*-*-* riscv*-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-additional-options "-msse2" { target i?86-*-* x86_64-*-* } } */
#if defined (__aarch64__)
# define FPR "{d5}"
/* { dg-final { scan-assembler-times "foo\tv5" 4 { target { aarch64*-*-* } } } } */
#elif defined (__arm__)
# define FPR "{d5}"
-/* { dg-additional-options "-march=armv7-a+fp -mfloat-abi=hard" { target arm*-*-* } } */
+/* { dg-additional-options "-mcpu=unset -march=armv7-a+fp -mfloat-abi=hard" { target arm*-*-* } } */
/* { dg-final { scan-assembler-times "foo\ts10" 4 { target { arm*-*-* } } } } */
#elif defined (__powerpc__) || defined (__POWERPC__)
# define FPR "{5}"
@@ -16,9 +17,9 @@
#elif defined (__s390__)
# define FPR "{f5}"
/* { dg-final { scan-assembler-times "foo\t%f5" 4 { target { s390*-*-* } } } } */
-#elif defined (__x86_64__)
+#elif defined (__i386__) || defined (__x86_64__)
# define FPR "{xmm5}"
-/* { dg-final { scan-assembler-times "foo\t%xmm5" 4 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%xmm5" 4 { target { i?86-*-* x86_64-*-* } } } } */
#endif
float
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-5.c b/gcc/testsuite/gcc.dg/asm-hard-reg-5.c
index a9e25ce..ea7907a 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-5.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-5.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-do compile { target { { aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* } || { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } } */
typedef int V __attribute__ ((vector_size (4 * sizeof (int))));
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-6.c b/gcc/testsuite/gcc.dg/asm-hard-reg-6.c
index d9b7fae..c87a811 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-6.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-6.c
@@ -19,8 +19,8 @@
# define GPR1 "{eax}"
# define GPR2 "{ebx}"
# define GPR3 "{ecx}"
-/* { dg-final { scan-assembler-times "foo\t4\\(%esp\\),%ecx" 1 { target { i?86-*-* } } } } */
-/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%eax\\)" 1 { target { i?86-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t4\\(%esp\\),%ecx" 1 { target { { i?86-*-* x86_64-*-* } && { ia32 } } } } } */
+/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%eax\\)" 1 { target { { i?86-*-* x86_64-*-* } && { ia32 } } } } } */
#elif defined (__powerpc__) || defined (__POWERPC__)
# define GPR1 "{r4}"
# define GPR2 "{r5}"
@@ -43,8 +43,10 @@
# define GPR1 "{eax}"
# define GPR2 "{ebx}"
# define GPR3 "{rcx}"
-/* { dg-final { scan-assembler-times "foo\t%eax,%rcx" 1 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%rsi\\)" 1 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%eax,%rcx" 1 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%rsi\\)" 1 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "foo\t%eax,%ecx" 1 { target { { i?86-*-* x86_64-*-* } && x32 } } } } */
+/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%esi\\)" 1 { target { { i?86-*-* x86_64-*-* } && x32 } } } } */
#endif
void
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-error-3.c b/gcc/testsuite/gcc.dg/asm-hard-reg-error-3.c
index 17b2317..d3962bd 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-error-3.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-error-3.c
@@ -1,6 +1,6 @@
-/* { dg-do compile { target arm-*-* s390-*-* } } */
+/* { dg-do compile { target arm*-*-* s390-*-* } } */
/* { dg-options "-std=c99" } we need long long */
-/* { dg-additional-options "-march=armv7-a" { target arm-*-* } } */
+/* { dg-additional-options "-mcpu=unset -march=armv7-a+fp -marm" { target arm*-*-* } } */
/* Test register pairs. */
diff --git a/gcc/testsuite/gcc.dg/bitint-125.c b/gcc/testsuite/gcc.dg/bitint-125.c
new file mode 100644
index 0000000..5ef0e32
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-125.c
@@ -0,0 +1,15 @@
+/* PR tree-optimization/121127 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O2 -w" } */
+
+#if __BITINT_MAXWIDTH__ >= 576
+_BitInt(575)
+foo (void)
+{
+ _BitInt(576) d;
+ _BitInt(575) e = d * 42wb;
+ return e;
+}
+#else
+int i;
+#endif
diff --git a/gcc/testsuite/gcc.dg/bitintext.h b/gcc/testsuite/gcc.dg/bitintext.h
index 99fedb3..f61cf9a 100644
--- a/gcc/testsuite/gcc.dg/bitintext.h
+++ b/gcc/testsuite/gcc.dg/bitintext.h
@@ -4,25 +4,41 @@ do_copy (void *p, const void *q, __SIZE_TYPE__ r)
__builtin_memcpy (p, q, r);
}
+/* Obtain the value of N from a _BitInt(N)-typed expression X
+ at compile time. */
+#define S(x) \
+ ((typeof (x)) -1 < 0 \
+ ? __builtin_clrsbg (__builtin_choose_expr ((typeof (x)) -1 < 0, \
+ (typeof (x)) -1, -1)) + 1 \
+ : __builtin_popcountg (__builtin_choose_expr ((typeof (x)) -1 < 0, \
+ 0U, (typeof (x)) -1)))
+
+#define CEIL(x,y) (((x) + (y) - 1) / (y))
+
+/* Promote a _BitInt type to include its padding bits. */
+#if defined (__s390x__) || defined(__arm__)
+#define PROMOTED_SIZE(x) sizeof (x)
+#elif defined(__loongarch__)
+#define PROMOTED_SIZE(x) (sizeof (x) > 8 ? CEIL (S (x), 64) * 8 : sizeof (x))
+#endif
+
/* Macro to test whether (on targets where psABI requires it) _BitInt
with padding bits have those filled with sign or zero extension. */
#if defined(__s390x__) || defined(__arm__) || defined(__loongarch__)
+#define BEXTC1(x, uns) \
+ do { \
+ uns _BitInt(PROMOTED_SIZE (x) * __CHAR_BIT__) __x; \
+ do_copy (&__x, &(x), sizeof (__x)); \
+ if (__x != (typeof (x)) __x) \
+ __builtin_abort (); \
+ } while (0)
+
#define BEXTC(x) \
- do { \
- if ((typeof (x)) -1 < 0) \
- { \
- _BitInt(sizeof (x) * __CHAR_BIT__) __x; \
- do_copy (&__x, &(x), sizeof (__x)); \
- if (__x != (x)) \
- __builtin_abort (); \
- } \
- else \
- { \
- unsigned _BitInt(sizeof (x) * __CHAR_BIT__) __x; \
- do_copy (&__x, &(x), sizeof (__x)); \
- if (__x != (x)) \
- __builtin_abort (); \
- } \
+ do { \
+ if ((typeof (x)) -1 < 0) \
+ BEXTC1 ((x), signed); \
+ else \
+ BEXTC1 ((x), unsigned); \
} while (0)
#else
#define BEXTC(x) do { (void) (x); } while (0)
diff --git a/gcc/testsuite/gcc.dg/c23-attr-syntax-6.c b/gcc/testsuite/gcc.dg/c23-attr-syntax-6.c
index f8c5b0f..4e6b80b 100644
--- a/gcc/testsuite/gcc.dg/c23-attr-syntax-6.c
+++ b/gcc/testsuite/gcc.dg/c23-attr-syntax-6.c
@@ -45,7 +45,7 @@ typedef int [[__extension__ __extension__]] b2; /* { dg-error {'extension' attri
typedef int [[__extension__ unknown_attribute]] b3; /* { dg-error {'unknown_attribute' attribute ignored} } */
typedef int [[__extension__ gnu:vector_size(4)]] b4; /* { dg-error {expected '\]' before ':'} } */
/* { dg-error {'gnu' attribute ignored} "" { target *-*-* } .-1 } */
-typedef int [[__extension__ gnu JOIN2(:,:) vector_size (4)]] b5; /* { dg-error {pasting ":" and ":" does not give a valid preprocessing token} } */
+typedef int [[__extension__ gnu JOIN2(:,:) vector_size (4)]] b5; /* { dg-error {pasting ':' and ':' does not give a valid preprocessing token} } */
/* { dg-error {expected '\]' before ':'} "" { target *-*-* } .-1 } */
/* { dg-error {'gnu' attribute ignored} "" { target *-*-* } .-2 } */
typedef int [[__extension__ gnu : : vector_size (4)]] b6; /* { dg-error {expected '\]' before ':'} } */
@@ -81,7 +81,7 @@ typedef int [[gnu :: vector_size (4)]] b18; /* { dg-error {attributes before C23
typedef int [[gnu FOO vector_size (4)]] b19; /* { dg-error {attributes before C23} } */
typedef int [[gnu :: vector_size (sizeof (void (*)(...)))]] b20; /* { dg-error {attributes before C23} } */
/* { dg-error {requires a named argument before} "" { target *-*-* } .-1 } */
-typedef int [[gnu JOIN2(:,:) vector_size (4)]] b21; /* { dg-error {pasting ":" and ":" does not give a valid preprocessing token} } */
+typedef int [[gnu JOIN2(:,:) vector_size (4)]] b21; /* { dg-error {pasting ':' and ':' does not give a valid preprocessing token} } */
/* { dg-error {expected '\]' before ':'} "" { target *-*-* } .-1 } */
/* { dg-error {'gnu' attribute ignored} "" { target *-*-* } .-2 } */
/* { dg-error {attributes before C23} "" { target *-*-* } .-3 } */
diff --git a/gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c b/gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c
new file mode 100644
index 0000000..47d4b23
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c
@@ -0,0 +1,44 @@
+/* N3457 - The __COUNTER__ predefined macro */
+/* { dg-do run } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+#ifndef __COUNTER__
+#error "__COUNTER__ not defined"
+#endif
+
+#define A(X) X + X
+static_assert (A(__COUNTER__) == 0);
+#define B(X)
+B(__COUNTER__)
+static_assert (__COUNTER__ == 1);
+#define C(...) __VA_OPT__()
+C(__COUNTER__)
+static_assert (__COUNTER__ == 3);
+#define D(...) __VA_OPT__(a)
+int D(__COUNTER__) = 1;
+static_assert (__COUNTER__ == 5);
+#define E(X) #X
+const char *b = E(__COUNTER__);
+#define F(X) a##X
+int F(__COUNTER__) = 2;
+static_assert (__COUNTER__ == 6);
+#define G(X) b##X = X
+int G(__COUNTER__);
+static_assert (__COUNTER__ == 8);
+#if !defined(__COUNTER__) || (__COUNTER__ + 1 != __COUNTER__ + 0)
+#error "Unexpected __COUNTER__ behavior")
+#endif
+static_assert (__COUNTER__ == 11);
+
+extern int strcmp (const char *, const char *);
+extern void abort ();
+
+int
+main ()
+{
+ if (a != 1
+ || strcmp (b, "__COUNTER__")
+ || a__COUNTER__ != 2
+ || b__COUNTER__ != 7)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/paste12-2.c b/gcc/testsuite/gcc.dg/cpp/paste12-2.c
index 6e2e4f1..f46645a 100644
--- a/gcc/testsuite/gcc.dg/cpp/paste12-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/paste12-2.c
@@ -6,6 +6,6 @@
/* Test correct diagnostics when pasting in #include.
Source: PR preprocessor/6780. */
-#define inc2(a,b) <##a.b> /* { dg-error "pasting \"<\" and \"stdio\" does not" } */
+#define inc2(a,b) <##a.b> /* { dg-error "pasting '<' and 'stdio' does not" } */
#define INC(X) inc2(X,h)
#include INC(stdio)
diff --git a/gcc/testsuite/gcc.dg/cpp/paste12.c b/gcc/testsuite/gcc.dg/cpp/paste12.c
index 3e0f7b9..f6b3696 100644
--- a/gcc/testsuite/gcc.dg/cpp/paste12.c
+++ b/gcc/testsuite/gcc.dg/cpp/paste12.c
@@ -8,4 +8,4 @@
#define inc2(a,b) <##a.b>
#define INC(X) inc2(X,h)
-#include INC(stdio) /* { dg-error "pasting \"<\" and \"stdio\" does not" } */
+#include INC(stdio) /* { dg-error "pasting '<' and 'stdio' does not" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/paste14-2.c b/gcc/testsuite/gcc.dg/cpp/paste14-2.c
index 3b23ada..bb51999 100644
--- a/gcc/testsuite/gcc.dg/cpp/paste14-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/paste14-2.c
@@ -4,8 +4,8 @@
{ dg-do preprocess }
*/
-#define foo - ## >> /* { dg-error "pasting \"-\" and \">>\"" } */
+#define foo - ## >> /* { dg-error "pasting '-' and '>>'" } */
foo
-#define bar = ## == /* { dg-error "pasting \"=\" and \"==\"" } */
+#define bar = ## == /* { dg-error "pasting '=' and '=='" } */
bar
diff --git a/gcc/testsuite/gcc.dg/cpp/paste14.c b/gcc/testsuite/gcc.dg/cpp/paste14.c
index 043d5e5..d60b328 100644
--- a/gcc/testsuite/gcc.dg/cpp/paste14.c
+++ b/gcc/testsuite/gcc.dg/cpp/paste14.c
@@ -5,6 +5,6 @@
*/
#define foo - ## >>
-foo /* { dg-error "pasting \"-\" and \">>\"" } */
+foo /* { dg-error "pasting '-' and '>>'" } */
#define bar = ## ==
-bar /* { dg-error "pasting \"=\" and \"==\"" } */
+bar /* { dg-error "pasting '=' and '=='" } */
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-7.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-7.c
new file mode 100644
index 0000000..f064f6f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-7.c
@@ -0,0 +1,24 @@
+/* PR debug/121411
+ CTF generation for array which cannot be encoded in CTF.
+
+ CTF encoding uses a uint32 for number of elements in an array which
+ means there is a hard upper limit on sizes of arrays which can be
+ represented. Arrays with too many elements are encoded with
+ CTF_K_UNKNOWN to indicate that they cannot be represented. */
+
+/* { dg-do compile { target { lp64 || llp64 } } } */
+/* { dg-options "-O0 -gctf -dA" } */
+
+int rep[0xffffffff];
+int unrep[0x100000000];
+
+/* One dimension can be represented, other cannot.
+ Result is a (representable) array with unknown element type. */
+int unrepdim [0xab][0x100000007];
+
+/* Two CTF_K_ARRAY, one (shared) CTF_K_UNKNOWN. */
+/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
+/* { dg-final { scan-assembler-times "0x2000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]+0xffffffff\[\t \]+\[^\n\]*cta_nelems" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]+0xab\[\t \]+\[^\n\]*cta_nelems" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c b/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
index 42d6436..a9bec2d 100644
--- a/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
+++ b/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
@@ -111,4 +111,4 @@ int main(int argc, char *argv[])
return 0;
}
-/* { dg-final { scan-tree-dump-times "ACCESS_WITH_SIZE" 8 "original" } } */
+/* { dg-final { scan-tree-dump-times "ACCESS_WITH_SIZE" 6 "original" } } */
diff --git a/gcc/testsuite/gcc.dg/flex-array-counted-by.c b/gcc/testsuite/gcc.dg/flex-array-counted-by.c
index 16eb2c6..4fa91ff 100644
--- a/gcc/testsuite/gcc.dg/flex-array-counted-by.c
+++ b/gcc/testsuite/gcc.dg/flex-array-counted-by.c
@@ -10,7 +10,7 @@ int x __attribute ((counted_by (size))); /* { dg-error "attribute is not allowed
struct trailing {
int count;
- int field __attribute ((counted_by (count))); /* { dg-error "attribute is not allowed for a non-array field" } */
+ int field __attribute ((counted_by (count))); /* { dg-error "attribute is not allowed for a non-array or non-pointer field" } */
};
struct trailing_1 {
diff --git a/gcc/testsuite/gcc.dg/gomp/adjust-args-1.c b/gcc/testsuite/gcc.dg/gomp/adjust-args-1.c
index 90787ef..d67db5e 100644
--- a/gcc/testsuite/gcc.dg/gomp/adjust-args-1.c
+++ b/gcc/testsuite/gcc.dg/gomp/adjust-args-1.c
@@ -11,7 +11,7 @@ int f1 (int);
int f2 (void *a);
#pragma omp declare variant (f1) match (construct={dispatch}) adjust_args (other: a) /* { dg-error "expected 'nothing' or 'need_device_ptr'" } */
int f3 (int a);
-#pragma omp declare variant (f0) adjust_args (nothing: a) /* { dg-error "an 'adjust_args' clause requires a 'match' clause" } */
+#pragma omp declare variant (f0) adjust_args (nothing: a) /* { dg-error "expected 'match' clause" } */
int f4 (void *a);
#pragma omp declare variant (f1) match (construct={dispatch}) adjust_args () /* { dg-error "expected 'nothing' or 'need_device_ptr' followed by ':'" } */
int f5 (int a);
diff --git a/gcc/testsuite/gcc.dg/gomp/append-args-1.c b/gcc/testsuite/gcc.dg/gomp/append-args-1.c
index 81dd106..15fc752 100644
--- a/gcc/testsuite/gcc.dg/gomp/append-args-1.c
+++ b/gcc/testsuite/gcc.dg/gomp/append-args-1.c
@@ -15,56 +15,60 @@ typedef enum omp_interop_t
} omp_interop_t;
-/* (A) No prototype for the variant but for the base function. */
+/* (A) No prototype for the variant but for the base function.
+ This is OK, the unprototyped decl is compatible with the modified
+ argument list. */
void variant_fn1();
#pragma omp declare variant(variant_fn1) match(construct={dispatch}) append_args(interop(target)) \
adjust_args(need_device_ptr: x,y)
void bar1(int *x, int *y);
-/* { dg-error "variant 'variant_fn1' and base 'bar1' have incompatible types" "" { target *-*-* } .-3 } */
void variant_fn2();
#pragma omp declare variant(variant_fn2) match(construct={dispatch}) append_args(interop(target))
void bar2(int *x, int *y);
-/* { dg-error "variant 'variant_fn2' and base 'bar2' have incompatible types" "" { target *-*-* } .-2 } */
-/* (B) No prototype for the variant nor for the base function. */
+/* (B) No prototype for the variant nor for the base function.
+ The declarations are compatible, but adjust_args requires a prototyped
+ base function so that we know where in the arglist to insert the additional
+ omp_interop_t arguments. */
-void variant_fn3(); /* { dg-error "argument 1 of 'variant_fn3' must be of 'omp_interop_t'" } */
+void variant_fn3();
#pragma omp declare variant(variant_fn3) match(construct={dispatch}) append_args(interop(target)) \
adjust_args(need_device_ptr: x,y)
void bar3();
/* { dg-error "'x' undeclared here \\(not in a function\\)" "" { target *-*-* } .-2 } */
/* { dg-error "'y' undeclared here \\(not in a function\\)" "" { target *-*-* } .-3 } */
-/* { dg-note "'append_args' specified here" "" { target *-*-* } .-5 } */
+/* { dg-message "'append_args' with unprototyped base function" "" { target *-*-* } .-5 } */
-void variant_fn4(); /* { dg-error "argument 1 of 'variant_fn4' must be of 'omp_interop_t'" } */
+void variant_fn4();
#pragma omp declare variant(variant_fn4) match(construct={dispatch}) append_args(interop(target))
void bar4();
-/* { dg-note "'append_args' specified here" "" { target *-*-* } .-2 } */
+/* { dg-message "'append_args' with unprototyped base function" "" { target *-*-* } .-2 } */
-/* (C) Only a prototype on the variant-function side. */
+/* (C) Only a prototype on the variant-function side. Again, the base
+ function requires a prototype with append_args. */
void variant_fn5(omp_interop_t, omp_interop_t);
#pragma omp declare variant(variant_fn5) match(construct={dispatch}) append_args(interop(target)) \
adjust_args(need_device_ptr: x,y)
void bar5();
-/* { dg-error "variant 'variant_fn5' and base 'bar5' have incompatible types" "" { target *-*-* } .-3 } */
+/* { dg-message "'append_args' with unprototyped base function" "" { target *-*-* } .-3 } */
void variant_fn6(omp_interop_t, omp_interop_t);
#pragma omp declare variant(variant_fn6) match(construct={dispatch}) append_args(interop(target))
void bar6();
-/* { dg-error "variant 'variant_fn6' and base 'bar6' have incompatible types" "" { target *-*-* } .-2 } */
+/* { dg-message "'append_args' with unprototyped base function" "" { target *-*-* } .-2 } */
void variant_fn7(int *, int, omp_interop_t, omp_interop_t);
#pragma omp declare variant(variant_fn7) match(construct={dispatch}) append_args(interop(target))
void bar7();
-/* { dg-error "variant 'variant_fn7' and base 'bar7' have incompatible types" "" { target *-*-* } .-2 } */
+/* { dg-message "'append_args' with unprototyped base function" "" { target *-*-* } .-2 } */
diff --git a/gcc/testsuite/gcc.dg/gomp/declare-variant-3.c b/gcc/testsuite/gcc.dg/gomp/declare-variant-3.c
new file mode 100644
index 0000000..92b71fe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/declare-variant-3.c
@@ -0,0 +1,18 @@
+/* PR118839: Check that error is diagnosed when the variant is the same as
+ the base function. */
+
+/* No previous declaration. */
+#pragma omp declare variant(f) match(user={condition(1)}) /* { dg-error "variant 'f' is the same as base function" } */
+void f(int *x);
+
+/* Previous declaration. */
+void g(int *x)
+{
+ *x = 42;
+}
+
+#pragma omp declare variant(g) match(user={condition(1)}) /* { dg-error "variant 'g' is the same as base function" } */
+void g(int *x);
+
+
+
diff --git a/gcc/testsuite/gcc.dg/gomp/pr121453.c b/gcc/testsuite/gcc.dg/gomp/pr121453.c
new file mode 100644
index 0000000..74014e6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/pr121453.c
@@ -0,0 +1,18 @@
+/* PR middle-end/121453 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -O2 -Wuninitialized" } */
+
+void bar (int, int, int);
+int v[40][40][40];
+
+void
+foo (int x, int y, int z)
+{
+ int i, j, k;
+#pragma omp parallel for simd collapse(3)
+ for (k = 1; k <= z; ++k)
+ for (j = 2; j <= y - 1; ++j)
+ for (i = 1; i <= x; ++i)
+ v[i][j][k] = 0;
+ bar (i, j, k);
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/unprototyped-variant.c b/gcc/testsuite/gcc.dg/gomp/unprototyped-variant.c
new file mode 100644
index 0000000..ca84775
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/unprototyped-variant.c
@@ -0,0 +1,30 @@
+/* { dg-additional-options "-std=gnu90" } */
+
+/* This test case used to ICE in the gimplifier after issuing a
+ different diagnostic message. */
+
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+ omp_interop_none = 0,
+ __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+
+void g2();
+#pragma omp declare variant(g2) match(construct={dispatch}) append_args(interop(target,targetsync)) /* { dg-message "'append_args' with unprototyped base function" } */
+void f2();
+
+void foo()
+{
+ omp_interop_t obj6 = omp_interop_none;
+ const char *cp = 0L;
+
+ #pragma omp dispatch interop(obj6)
+ f2(5, cp);
+}
diff --git a/gcc/testsuite/gcc.dg/graphite/id-30.c b/gcc/testsuite/gcc.dg/graphite/id-30.c
index f8144ce..91838ed 100644
--- a/gcc/testsuite/gcc.dg/graphite/id-30.c
+++ b/gcc/testsuite/gcc.dg/graphite/id-30.c
@@ -1,5 +1,5 @@
/* The modulo constraints we generate for the niter expression
- (unsinged long)ubound - (unsigned long)lbound
+ (unsigned long)ubound - (unsigned long)lbound
end up with a modulo that we cannot represent in the expression
type we are using (int64_t), so we run into the codegen error
where ISL generates a modulo/divide by sth that doesn't fit the
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-graphs-html.py b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-graphs-html.py
index 11e5fd1..9ff4645 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-graphs-html.py
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-graphs-html.py
@@ -26,7 +26,7 @@ def test_result_graph(html_tree):
assert message.attrib['id'] == 'gcc-diag-0-message'
assert message[0].tag == make_tag('strong')
- assert message[0].tail == ' this is a placeholder error, with graphs '
+ assert message[0].tail == ' this is a placeholder error, with graphs'
graph = diag.find("./xhtml:div[@class='gcc-directed-graph']", ns)
assert graph is not None
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-html.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-html.c
new file mode 100644
index 0000000..8ff7b35
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-html.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-fdiagnostics-add-output=experimental-html:javascript=no" } */
+
+extern void foo (void);
+
+void test_nesting (void)
+{
+ foo (); /* { dg-error "top-level error" } */
+}
+
+/* Use a Python script to verify various properties about the generated
+ .html file:
+ { dg-final { run-html-pytest diagnostic-test-nesting-html.c "diagnostic-test-nesting-html.py" } } */
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-html.py b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-html.py
new file mode 100644
index 0000000..3899ba5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-html.py
@@ -0,0 +1,69 @@
+# Verify that nesting works in HTML output.
+
+from htmltest import *
+
+import pytest
+
+@pytest.fixture(scope='function', autouse=True)
+def html_tree():
+ return html_tree_from_env()
+
+def test_nesting(html_tree):
+ root = html_tree.getroot ()
+ assert root.tag == make_tag('html')
+
+ body = root.find('xhtml:body', ns)
+ assert body is not None
+
+ diag_list = body.find('xhtml:div', ns)
+ assert diag_list is not None
+ assert diag_list.attrib['class'] == 'gcc-diagnostic-list'
+
+ diag = diag_list.find('xhtml:div', ns)
+ assert diag is not None
+
+ message = diag.find("./xhtml:div[@class='gcc-message']", ns)
+ assert message.attrib['id'] == 'gcc-diag-0-message'
+
+ assert message[0].tag == make_tag('strong')
+ assert message[0].tail == ' top-level error'
+
+ # We expect 12 messages, with the given IDs and text:
+ for i in range(12):
+ child = diag.find(".//xhtml:div[@id='gcc-diag-%i']" % (i + 1),
+ ns)
+ assert child is not None
+
+ message = child.find("./xhtml:div[@class='gcc-message']", ns)
+ assert message.attrib['id'] == 'gcc-diag-%i-message' % (i + 1)
+
+ if i % 4 == 0:
+ assert message.text == 'child %i' % (i / 4)
+ else:
+ assert message.text == 'grandchild %i %i' % ((i / 4), (i % 4) - 1)
+
+ # We expect the messages to be organized into nested <ul> with
+ # "nesting-level" set, all below a <ul>
+ child_ul = diag.find("./xhtml:ul[@nesting-level='1']", ns)
+ assert child_ul is not None
+ msg_id = 1
+ for i in range(3):
+ child_li = child_ul.find("./xhtml:li[@nesting-level='1'][%i]" % (i + 1), ns)
+ assert child_li is not None
+ child = child_li.find("./xhtml:div[@id='gcc-diag-%i']" % msg_id, ns)
+ assert child is not None
+ message = child.find("./xhtml:div[@class='gcc-message']", ns)
+ assert message.attrib['id'] == 'gcc-diag-%i-message' % msg_id
+ assert message.text == 'child %i' % i
+ msg_id += 1
+ grandchild_ul = child_ul.find("./xhtml:ul[@nesting-level='2'][%i]" % (i + 1), ns)
+ assert grandchild_ul is not None
+ for j in range(3):
+ grandchild_li = grandchild_ul.find("./xhtml:li[@nesting-level='2'][%i]" % (j + 1), ns)
+ assert grandchild_li is not None
+ grandchild = grandchild_li.find("./xhtml:div[@id='gcc-diag-%i']" % msg_id, ns)
+ assert grandchild is not None
+ message = grandchild.find("./xhtml:div[@class='gcc-message']", ns)
+ assert message.attrib['id'] == 'gcc-diag-%i-message' % msg_id
+ assert message.text == 'grandchild %i %i' % (i, j)
+ msg_id += 1
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c
new file mode 100644
index 0000000..3492899
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-diagnostics-show-nesting" } */
+
+extern void foo (void);
+
+void test_nesting (void)
+{
+ foo (); /* { dg-error "top-level error" } */
+}
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c
new file mode 100644
index 0000000..8fc2edb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-fdiagnostics-show-nesting" } */
+
+extern void foo (void);
+
+void test_nesting (void)
+{
+ foo (); /* { dg-error "top-level error" } */
+}
+
+/* { dg-begin-multiline-output "" }
+ * child 0
+ * grandchild 0 0
+ * grandchild 0 1
+ * grandchild 0 2
+ * child 1
+ * grandchild 1 0
+ * grandchild 1 1
+ * grandchild 1 2
+ * child 2
+ * grandchild 2 0
+ * grandchild 2 1
+ * grandchild 2 2
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c
index f44c8eb..4be52fe 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-levels=yes" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes,show-nesting-levels=yes" } */
extern void foo (void);
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c
index 39e29f7..c069c3f 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes -fdiagnostics-text-art-charset=unicode" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes -fdiagnostics-text-art-charset=unicode" } */
extern void foo (void);
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c
index e103429..a35254d 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes" } */
extern void foo (void);
diff --git a/gcc/testsuite/gcc.dg/plugin/must-tail-call-2.c b/gcc/testsuite/gcc.dg/plugin/must-tail-call-2.c
index d51d15c..6f65f4a 100644
--- a/gcc/testsuite/gcc.dg/plugin/must-tail-call-2.c
+++ b/gcc/testsuite/gcc.dg/plugin/must-tail-call-2.c
@@ -55,5 +55,5 @@ volatile fn_ptr_t fn_ptr;
void
test_5 (void)
{
- fn_ptr (); /* { dg-error "cannot tail-call: " } */
+ fn_ptr ();
}
diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp
index ce25c0a..c7cc36c 100644
--- a/gcc/testsuite/gcc.dg/plugin/plugin.exp
+++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp
@@ -112,10 +112,13 @@ set plugin_test_list [list \
diagnostic-test-graphs-html.c \
diagnostic-test-graphs-sarif.c } \
{ diagnostic_plugin_test_nesting.cc \
+ diagnostic-test-nesting-show-nesting.c \
+ diagnostic-test-nesting-no-show-nesting.c \
diagnostic-test-nesting-text-plain.c \
diagnostic-test-nesting-text-indented.c \
diagnostic-test-nesting-text-indented-show-levels.c \
diagnostic-test-nesting-text-indented-unicode.c \
+ diagnostic-test-nesting-html.c \
diagnostic-test-nesting-sarif.c } \
{ diagnostic_plugin_test_paths.cc \
diagnostic-test-paths-1.c \
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-1.c b/gcc/testsuite/gcc.dg/pointer-counted-by-1.c
new file mode 100644
index 0000000..395af34
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-1.c
@@ -0,0 +1,34 @@
+/* More testing the correct usage of attribute counted_by for pointer field. */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+typedef struct item1 Item1;
+typedef union item2 Item2;
+
+struct pointer_array {
+ int count1;
+ Item1 *array_1 __attribute__ ((counted_by (count1)));
+ Item2 *array_2 __attribute__ ((counted_by (count2)));
+ int count2;
+} *pointer_data;
+
+struct item1 {
+ int a;
+ float b[];
+};
+
+union item2 {
+ int c;
+ float d[];
+};
+
+void foo ()
+{
+ pointer_data
+ = (struct pointer_array *) __builtin_malloc (sizeof (struct pointer_array));
+ pointer_data->array_1 /* { dg-error "attribute is not allowed for a pointer to structure or union with flexible array member" } */
+ = (Item1 *) __builtin_malloc (sizeof (Item1) + 3 * sizeof (float));
+ pointer_data->array_2 /* { dg-error "attribute is not allowed for a pointer to structure or union with flexible array member" } */
+ = (Item2 *) __builtin_malloc (sizeof (Item2) + 3 * sizeof (float));
+ return;
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-2.c b/gcc/testsuite/gcc.dg/pointer-counted-by-2.c
new file mode 100644
index 0000000..1f4a278
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-2.c
@@ -0,0 +1,10 @@
+/* Testing the correct usage of attribute counted_by for pointer: _BitInt */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O2 -std=c23" } */
+
+struct pointer_array {
+ _BitInt(24) count;
+ int *array __attribute__ ((counted_by (count)));
+ int *array1 __attribute__ ((counted_by (count1)));
+ _BitInt(24) count1;
+};
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-3.c b/gcc/testsuite/gcc.dg/pointer-counted-by-3.c
new file mode 100644
index 0000000..7005609
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-3.c
@@ -0,0 +1,127 @@
+ /* Testing the correct usage of attribute counted_by for pointer in c23,
+ multiple definitions of the same tag in same or different scopes.
+ { dg-do compile }
+ { dg-options "-std=c23" }
+ */
+
+/* Allowed redefinitions of the same struct in the same scope, with the
+ same counted_by attribute. */
+struct f {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (b))); };
+struct f {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (b))); };
+struct f {
+ int b;
+ int c;
+ int *a; }; /* { dg-error "redefinition of struct or union" } */
+
+/* Error when the counted_by attribute is defined differently. */
+struct f {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (c))); }; /* { dg-error "redefinition of struct or union" } */
+
+struct h {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (b))); } p;
+
+void test (void)
+{
+ struct h {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (b))); } x;
+
+ p = x;
+}
+
+void test1 (void)
+{
+ struct h {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (c))); } y;
+
+ p = y; /* { dg-error "incompatible types when assigning to type" } */
+}
+
+struct nested_f {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (b)));
+};
+
+struct nested_f {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (b)));
+};
+
+struct nested_f {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (n)));
+}; /* { dg-error "redefinition of struct or union" } */
+
+struct nested_h {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (b)));
+} nested_p;
+
+void test_2 (void)
+{
+struct nested_h {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (b)));
+} nested_x;
+
+ nested_p = nested_x;
+}
+
+void test_3 (void)
+{
+struct nested_h {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (n)));
+} nested_y;
+
+ nested_p = nested_y; /* { dg-error "incompatible types when assigning to type" } */
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c
new file mode 100644
index 0000000..c404e5b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c
@@ -0,0 +1,6 @@
+/* Test the attribute counted_by for pointer field and its usage in
+ * __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+#define PTR_TYPE char
+#include "pointer-counted-by-4.c"
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c
new file mode 100644
index 0000000..383d8fb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c
@@ -0,0 +1,6 @@
+/* Test the attribute counted_by for pointer field and its usage in
+ * __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+#define PTR_TYPE float
+#include "pointer-counted-by-4.c"
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c
new file mode 100644
index 0000000..50246d2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c
@@ -0,0 +1,10 @@
+/* Test the attribute counted_by for pointer field and its usage in
+ * __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+struct A {
+ int a;
+ char *b;
+};
+#define PTR_TYPE struct A
+#include "pointer-counted-by-4.c"
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c
new file mode 100644
index 0000000..e786d99
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c
@@ -0,0 +1,10 @@
+/* Test the attribute counted_by for pointer field and its usage in
+ * __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+union A {
+ int a;
+ float b;
+};
+#define PTR_TYPE union A
+#include "pointer-counted-by-4.c"
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4.c
new file mode 100644
index 0000000..c4b3631
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-4.c
@@ -0,0 +1,77 @@
+/* Test the attribute counted_by for pointer field and its usage in
+ * __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "builtin-object-size-common.h"
+#ifndef PTR_TYPE
+#define PTR_TYPE int
+#endif
+struct pointer_array {
+ int b;
+ PTR_TYPE *c;
+} *p_array;
+
+struct annotated {
+ PTR_TYPE *c __attribute__ ((counted_by (b)));
+ int b;
+} *p_array_annotated;
+
+struct nested_annotated {
+ PTR_TYPE *c __attribute__ ((counted_by (b)));
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+} *p_array_nested_annotated;
+
+void __attribute__((__noinline__)) setup (int normal_count, int attr_count)
+{
+ p_array
+ = (struct pointer_array *) malloc (sizeof (struct pointer_array));
+ p_array->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * normal_count);
+ p_array->b = normal_count;
+
+ p_array_annotated
+ = (struct annotated *) malloc (sizeof (struct annotated));
+ p_array_annotated->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * attr_count);
+ p_array_annotated->b = attr_count;
+
+ p_array_nested_annotated
+ = (struct nested_annotated *) malloc (sizeof (struct nested_annotated));
+ p_array_nested_annotated->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * attr_count);
+ p_array_nested_annotated->b = attr_count;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test ()
+{
+ EXPECT(__builtin_dynamic_object_size(p_array->c, 1), -1);
+ EXPECT(__builtin_dynamic_object_size(p_array_annotated->c, 1),
+ p_array_annotated->b * sizeof (PTR_TYPE));
+ EXPECT(__builtin_dynamic_object_size(p_array_nested_annotated->c, 1),
+ p_array_nested_annotated->b * sizeof (PTR_TYPE));
+}
+
+void cleanup ()
+{
+ free (p_array->c);
+ free (p_array);
+ free (p_array_annotated->c);
+ free (p_array_annotated);
+ free (p_array_nested_annotated->c);
+ free (p_array_nested_annotated);
+}
+
+int main(int argc, char *argv[])
+{
+ setup (10,10);
+ test ();
+ DONE ();
+ cleanup ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-5.c b/gcc/testsuite/gcc.dg/pointer-counted-by-5.c
new file mode 100644
index 0000000..b43ffdf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-5.c
@@ -0,0 +1,56 @@
+/* Test the attribute counted_by for pointer fields and its usage in
+ * __builtin_dynamic_object_size: when the counted_by field is negative. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "builtin-object-size-common.h"
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+} *array_annotated;
+
+struct nested_annotated {
+ int *c __attribute__ ((counted_by (b)));
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+} *array_nested_annotated;
+
+void __attribute__((__noinline__)) setup (int attr_count)
+{
+ array_annotated
+ = (struct annotated *)malloc (sizeof (struct annotated));
+ array_annotated->b = attr_count;
+
+ array_nested_annotated
+ = (struct nested_annotated *)malloc (sizeof (struct nested_annotated));
+ array_nested_annotated->b = attr_count - 1;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test ()
+{
+ EXPECT(__builtin_dynamic_object_size(array_annotated->c, 1), 0);
+ EXPECT(__builtin_dynamic_object_size(array_nested_annotated->c, 1), 0);
+}
+
+void cleanup ()
+{
+ free (array_annotated);
+ free (array_nested_annotated);
+}
+
+int main(int argc, char *argv[])
+{
+ setup (-10);
+ test ();
+ DONE ();
+ cleanup ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-6.c b/gcc/testsuite/gcc.dg/pointer-counted-by-6.c
new file mode 100644
index 0000000..355558c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-6.c
@@ -0,0 +1,56 @@
+/* Test the attribute counted_by for pointer fields and its usage in
+ * __builtin_dynamic_object_size: when the type of the pointer
+ * is casting to another type. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "builtin-object-size-common.h"
+
+typedef unsigned short u16;
+
+struct info {
+ u16 data_len;
+ char *data __attribute__((counted_by(data_len)));
+};
+
+struct foo {
+ int a;
+ int b;
+};
+
+static __attribute__((__noinline__))
+struct info *setup ()
+{
+ struct info *p;
+ size_t bytes = 3 * sizeof(struct foo);
+
+ p = (struct info *) malloc (sizeof (struct info));
+ p->data = (char *) malloc (bytes);
+ p->data_len = bytes;
+
+ return p;
+}
+
+static void
+__attribute__((__noinline__)) report (struct info *p)
+{
+ struct foo *bar = (struct foo *)p->data;
+ EXPECT(__builtin_dynamic_object_size((char *)(bar + 1), 1),
+ sizeof (struct foo) * 2);
+ EXPECT(__builtin_dynamic_object_size((char *)(bar + 2), 1),
+ sizeof (struct foo));
+}
+
+void cleanup (struct info *p)
+{
+ free (p->data);
+ free (p);
+}
+
+int main(int argc, char *argv[])
+{
+ struct info *p = setup();
+ report(p);
+ cleanup (p);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-7.c b/gcc/testsuite/gcc.dg/pointer-counted-by-7.c
new file mode 100644
index 0000000..af1ab27
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-7.c
@@ -0,0 +1,32 @@
+/* Additional test of the attribute counted_by for pointer field and its usage
+ in __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "builtin-object-size-common.h"
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+};
+
+struct annotated __attribute__((__noinline__)) setup (int attr_count)
+{
+ struct annotated p_array_annotated;
+ p_array_annotated.c = (int *) malloc (sizeof (int) * attr_count);
+ p_array_annotated.b = attr_count;
+
+ return p_array_annotated;
+}
+
+int main(int argc, char *argv[])
+{
+ struct annotated x = setup (10);
+ int *p = x.c;
+ x = setup (20);
+ EXPECT(__builtin_dynamic_object_size (p, 1), 10 * sizeof (int));
+ EXPECT(__builtin_dynamic_object_size (x.c, 1), 20 * sizeof (int));
+ free (p);
+ free (x.c);
+ DONE ();
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-8.c b/gcc/testsuite/gcc.dg/pointer-counted-by-8.c
new file mode 100644
index 0000000..96bb83f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-8.c
@@ -0,0 +1,29 @@
+/* Additional test of the attribute counted_by for pointer field and its usage
+ in __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "builtin-object-size-common.h"
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+};
+
+
+void __attribute__((__noinline__)) setup (int **ptr, int attr_count)
+{
+ *ptr = (int *) malloc (sizeof (int) * attr_count);
+}
+
+int main(int argc, char *argv[])
+{
+ struct annotated *f
+ = (struct annotated *) __builtin_malloc (sizeof (struct annotated));
+ setup (&f->c, 10);
+ f->b = 10;
+ EXPECT(__builtin_dynamic_object_size (f->c, 1), 10 * sizeof (int));
+ free (f->c);
+ free (f);
+ DONE ();
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-9.c b/gcc/testsuite/gcc.dg/pointer-counted-by-9.c
new file mode 100644
index 0000000..a0ca0a2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-9.c
@@ -0,0 +1,85 @@
+/* Test the code generation for the new attribute counted_by.
+ And also the offsetof operator on such array. */
+/* { dg-do run } */
+/* { dg-options "-O2 -fdump-tree-original" } */
+
+#include <stdlib.h>
+
+typedef __UINTPTR_TYPE__ uintptr_t;
+
+struct annotated {
+ int b;
+ char *c __attribute__ ((counted_by (b)));
+} *p_annotated;
+
+struct flex {
+ int b;
+ char *c;
+};
+
+struct nested_annotated {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (b)));
+} *p_nested_annotated;
+
+struct nested_flex {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c;
+};
+
+void __attribute__((__noinline__)) setup (int normal_count, int attr_count)
+{
+ p_annotated
+ = (struct annotated *)malloc (sizeof (struct annotated));
+
+ p_annotated->c = (char *) malloc (sizeof (char) * attr_count);
+ p_annotated->b = attr_count;
+
+ p_nested_annotated
+ = (struct nested_annotated *)malloc (sizeof (struct nested_annotated));
+ p_nested_annotated->c = (char *) malloc (attr_count * sizeof (char));
+ p_nested_annotated->b = attr_count;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test (char a, char b)
+{
+ if (__builtin_offsetof (struct annotated, c)
+ != __builtin_offsetof (struct flex, c))
+ abort ();
+ if (__builtin_offsetof (struct nested_annotated, c)
+ != __builtin_offsetof (struct nested_flex, c))
+ abort ();
+
+ if (__alignof (*p_annotated->c) != __alignof (char))
+ abort ();
+ if (__alignof (*p_nested_annotated->c) != __alignof (char))
+ abort ();
+
+ p_annotated->c[2] = a;
+ p_nested_annotated->c[3] = b;
+}
+
+int main(int argc, char *argv[])
+{
+ setup (10,10);
+ test ('A', 'B');
+ if (p_annotated->c[2] != 'A') abort ();
+ if (p_nested_annotated->c[3] != 'B') abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "ACCESS_WITH_SIZE" 4 "original" } } */
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by.c b/gcc/testsuite/gcc.dg/pointer-counted-by.c
new file mode 100644
index 0000000..0f18828
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by.c
@@ -0,0 +1,111 @@
+/* Testing the correct usage of attribute counted_by for pointer field.
+ and also mixed pointer field and FMA field in the same structure. */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+int size;
+int *x __attribute__ ((counted_by (size))); /* { dg-error "attribute is not allowed for a non-field declaration" } */
+
+struct pointer_array_0 {
+ int count;
+ int array __attribute__ ((counted_by (count))); /* { dg-error "attribute is not allowed for a non-array or non-pointer field" } */
+ int other;
+};
+
+int count;
+struct pointer_array_1 {
+ int other;
+ int *array_1 __attribute__ ((counted_by (count))); /* { dg-error "attribute is not a field declaration in the same structure as" } */
+ int array_fam[] __attribute__ ((counted_by (count))); /* { dg-error "attribute is not a field declaration in the same structure as" } */
+};
+
+struct pointer_array_2 {
+ float count1;
+ float count2;
+ int *array_2 __attribute__ ((counted_by (count1))); /* { dg-error "attribute is not a field declaration with an integer type" } */
+ int array_fam[] __attribute__ ((counted_by (count2))); /* { dg-error "attribute is not a field declaration with an integer type" } */
+};
+
+struct pointer_array_3 {
+ int count;
+ int *array_3 __attribute__ ((counted_by (count))) __attribute__ ((counted_by (count)));
+};
+
+struct pointer_array_4 {
+ int count1;
+ int count2;
+ int *array_4 __attribute__ ((counted_by (count1))) __attribute__ ((counted_by (count2))); /* { dg-error "conflicts with previous declaration" } */
+ float array_fam[] __attribute__ ((counted_by (count2))) __attribute__ ((counted_by (count1))); /* { dg-error "conflicts with previous declaration" } */
+};
+
+struct pointer_array_5 {
+ _Bool count;
+ int *array_5 __attribute__ ((counted_by (count)));
+};
+
+enum week {Mon, Tue, Wed};
+struct pointer_array_6 {
+ enum week days;
+ int *array_6 __attribute__ ((counted_by (days)));
+};
+
+struct pointer_array_7 {
+ int count;
+ void *array_7 __attribute__ ((counted_by (count))); /* { dg-error "attribute is not allowed for a pointer to void" } */
+};
+
+struct pointer_array_8 {
+ int count;
+ int (*fpr)(int,int) __attribute__ ((counted_by (count))); /* { dg-error "attribute is not allowed for a pointer to function" } */
+};
+
+struct item1 {
+ int a;
+ float b;
+};
+
+union item2 {
+ char *a;
+ int *b;
+};
+
+typedef struct item3 Item3;
+typedef union item4 Item4;
+
+struct item5 {
+ int a;
+ float b[];
+};
+
+/* Incomplete structure and union are allowed. */
+struct pointer_array_9 {
+ int count1;
+ int count2;
+ int count3;
+ struct item1 *array_1 __attribute__ ((counted_by (count1)));
+ union item2 *array_2 __attribute__ ((counted_by (count2)));
+ Item3 *array_3 __attribute__ ((counted_by (count3)));
+ Item4 *array_4 __attribute__ ((counted_by (count4)));
+ int count4;
+ int count5;
+ /* structure with flexible array member is not allowed. */
+ struct item5 *array_5 __attribute__ ((counted_by (count5))); /* { dg-error "attribute is not allowed for a pointer to structure or union with flexible array member" } */
+};
+
+struct mixed_array {
+ int count1;
+ float *array_1 __attribute__ ((counted_by (count1)));
+ float *array_2 __attribute__ ((counted_by (count1)));
+ int count2;
+ long *array_3 __attribute__ ((counted_by (count2)));
+ long array_4[] __attribute__ ((counted_by (count2)));
+};
+
+struct mixed_array_2 {
+ float *array_1 __attribute__ ((counted_by (count1)));
+ int count1;
+ float *array_2 __attribute__ ((counted_by (count1)));
+ long *array_3 __attribute__ ((counted_by (count2)));
+ int count2;
+ long array_4[] __attribute__ ((counted_by (count2)));
+};
diff --git a/gcc/testsuite/gcc.dg/pr109071.c b/gcc/testsuite/gcc.dg/pr109071.c
new file mode 100644
index 0000000..74b7b46
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071.c
@@ -0,0 +1,43 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading. */
+/* { dg-options "-O2 -Wall -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+
+extern void warn(void);
+static inline void assign(int val, int *regs, int index)
+{
+ if (index >= 4)
+ warn();
+ *regs = val;
+}
+struct nums {int vals[4];};
+
+void sparx5_set (int *ptr, struct nums *sg, int index)
+{
+ int *val = &sg->vals[index]; /* { dg-warning "is above array bounds" } */
+
+ assign(0, ptr, index);
+ assign(*val, ptr, index);
+}
+/* { dg-begin-multiline-output "" }
+ NN | int *val = &sg->vals[index];
+ | ~~~~~~~~^~~~~~~
+ 'sparx5_set': events 1-2
+ NN | if (index >= 4)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ | ~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | struct nums {int vals[4];};
+ | ^~~~
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_1.c b/gcc/testsuite/gcc.dg/pr109071_1.c
new file mode 100644
index 0000000..592a998
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_1.c
@@ -0,0 +1,36 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR88771, which is a duplication of PR109071. */
+/* { dg-options "-O2 -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+typedef struct {
+ int a;
+} * b;
+
+char *c, *x;
+int f;
+
+void d() {
+ b e;
+ char a = f + 1 ?: f;
+ __builtin_strncpy(c, x, f); /* { dg-warning "exceeds maximum object size" } */
+ if (a)
+ e->a = 0;
+}
+/* { dg-begin-multiline-output "" }
+ NN | __builtin_strncpy(c, x, f);
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~
+ 'd': events 1-2
+ NN | char a = f + 1 ?: f;
+ | ^
+ | |
+ | (1) when the condition is evaluated to false
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | __builtin_strncpy(c, x, f);
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_10.c b/gcc/testsuite/gcc.dg/pr109071_10.c
new file mode 100644
index 0000000..1fe7edc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_10.c
@@ -0,0 +1,85 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to compiler optimization. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=3" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#define MAX_LENGTH 10
+int a[MAX_LENGTH];
+
+void __attribute__ ((noinline)) foo (int i, bool is_dollar)
+{
+ if (i < MAX_LENGTH)
+ {
+ if (i == -1)
+ {
+ if (is_dollar)
+ __builtin_printf ("dollar");
+ else
+ __builtin_printf ("euro");
+ a[i] = -1; /* { dg-warning "is below array bounds of" } */
+ }
+ else
+ a[i] = i;
+ }
+ else
+ a[i] = i + 1; /* { dg-warning "is above array bounds of" } */
+}
+
+int main ()
+{
+ for (int i = 0; i < MAX_LENGTH; i++)
+ foo (i, true);
+ return 0;
+}
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = i + 1;
+ | ~^~~
+ 'foo': events 1-2
+ NN | if (i < MAX_LENGTH)
+ | ^
+ | |
+ | (1) when the condition is evaluated to false
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = i + 1;
+ | ~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~^~~
+ 'foo': events 1-3
+ NN | if (i < MAX_LENGTH)
+ | ~
+ | |
+ | (2) when the condition is evaluated to true
+ NN | {
+ NN | if (i == -1)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~~~~
+ | |
+ | (3) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
+
diff --git a/gcc/testsuite/gcc.dg/pr109071_11.c b/gcc/testsuite/gcc.dg/pr109071_11.c
new file mode 100644
index 0000000..b9973bd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_11.c
@@ -0,0 +1,89 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to compiler optimization. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=3" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#define MAX_LENGTH 10
+int a[MAX_LENGTH];
+
+void __attribute__ ((noinline)) foo (int i, bool is_day, bool is_dollar)
+{
+ if (i < MAX_LENGTH)
+ {
+ if (is_day)
+ __builtin_printf ("day");
+ else
+ __builtin_printf ("night");
+ if (i == -1)
+ {
+ if (is_dollar)
+ __builtin_printf ("dollar");
+ else
+ __builtin_printf ("euro");
+ a[i] = -1; /* { dg-warning "is below array bounds of" } */
+ }
+ else
+ a[i] = i;
+ }
+ else
+ a[i] = i + 1; /* { dg-warning "is above array bounds of" } */
+}
+
+int main ()
+{
+ for (int i = 0; i < MAX_LENGTH; i++)
+ foo (i, false, true);
+ return 0;
+}
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = i + 1;
+ | ~^~~
+ 'foo': events 1-2
+ NN | if (i < MAX_LENGTH)
+ | ^
+ | |
+ | (1) when the condition is evaluated to false
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = i + 1;
+ | ~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~^~~
+ 'foo': events 1-3
+ NN | if (i < MAX_LENGTH)
+ | ~
+ | |
+ | (2) when the condition is evaluated to true
+......
+ NN | if (i == -1)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~~~~
+ | |
+ | (3) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
+
diff --git a/gcc/testsuite/gcc.dg/pr109071_12.c b/gcc/testsuite/gcc.dg/pr109071_12.c
new file mode 100644
index 0000000..a77ae88
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_12.c
@@ -0,0 +1,44 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ to test the alias option -fdiagnostics-show-context. */
+/* { dg-options "-O2 -Wall -fdiagnostics-show-context" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+
+extern void warn(void);
+static inline void assign(int val, int *regs, int index)
+{
+ if (index >= 4)
+ warn();
+ *regs = val;
+}
+struct nums {int vals[4];};
+
+void sparx5_set (int *ptr, struct nums *sg, int index)
+{
+ int *val = &sg->vals[index]; /* { dg-warning "is above array bounds" } */
+
+ assign(0, ptr, index);
+ assign(*val, ptr, index);
+}
+/* { dg-begin-multiline-output "" }
+ NN | int *val = &sg->vals[index];
+ | ~~~~~~~~^~~~~~~
+ 'sparx5_set': events 1-2
+ NN | if (index >= 4)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ | ~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | struct nums {int vals[4];};
+ | ^~~~
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_2.c b/gcc/testsuite/gcc.dg/pr109071_2.c
new file mode 100644
index 0000000..549a8c4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_2.c
@@ -0,0 +1,50 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR85788, which is a duplication of PR109071. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+int b=10;
+int *d = &b, *e;
+void a(void *k, long l) {
+ long f = __builtin_object_size(k, 0);
+ __builtin___memset_chk(k, b, l, f); /* { dg-warning "is out of the bounds" } */
+}
+typedef struct {
+ int g;
+ int h;
+ char i[8000 * 8];
+} j;
+static void make_str_raster(j *k) {
+ int *c = d;
+ for (; c; c = e)
+ k->g = k->h = 32767;
+
+ a(k->i, k->g / 8 * k->h);
+ for (; d;)
+ ;
+}
+j m;
+void n() { make_str_raster(&m); }
+/* { dg-begin-multiline-output "" }
+ NN | __builtin___memset_chk(k, b, l, f);
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ 'n': events 1-2
+ NN | __builtin___memset_chk(k, b, l, f);
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | for (; c; c = e)
+ | ^
+ | |
+ | (1) when the condition is evaluated to false
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | j m;
+ | ^
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_3.c b/gcc/testsuite/gcc.dg/pr109071_3.c
new file mode 100644
index 0000000..c7b86eb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_3.c
@@ -0,0 +1,42 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR108770, which is a duplication of PR109071. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+extern void put(int i);
+int check_idx(int i) {
+ if (i > 1)
+ put(i);
+ return i;
+}
+const char *arr[] = {"A", 0};
+void init() {
+ int i = 0;
+ while (arr[check_idx(i)] != 0) { /* { dg-warning "is above array bounds of" } */
+ if (arr[check_idx(i)]) {}
+ i++;
+ }
+}
+/* { dg-begin-multiline-output "" }
+ NN | while (arr[check_idx(i)] != 0) {
+ | ~~~^~~~~~~~~~~~~~
+ 'init': events 1-2
+ NN | if (i > 1)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | while (arr[check_idx(i)] != 0) {
+ | ~~~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | const char *arr[] = {"A", 0};
+ | ^~~
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_4.c b/gcc/testsuite/gcc.dg/pr109071_4.c
new file mode 100644
index 0000000..308249e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_4.c
@@ -0,0 +1,41 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR106762, which is a duplication of PR109071. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+typedef long unsigned int size_t;
+
+struct obj_t { size_t field0; size_t field1; };
+struct obj_array_t { size_t objcnt; struct obj_t* objary; };
+
+extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__(1)));
+
+void bug(struct obj_array_t* ary)
+{
+ size_t idx = 0;
+ struct obj_t* obj;
+ if (idx < ary->objcnt)
+ obj = &ary->objary[idx];
+ else
+ obj = 0;
+ memset(&obj->field1, 0xff, sizeof(obj->field1)); /* { dg-warning "is out of the bounds" } */
+ obj->field0 = 0;
+}
+/* { dg-begin-multiline-output "" }
+ NN | memset(&obj->field1, 0xff, sizeof(obj->field1));
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ 'bug': events 1-2
+ NN | if (idx < ary->objcnt)
+ | ^
+ | |
+ | (1) when the condition is evaluated to false
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | memset(&obj->field1, 0xff, sizeof(obj->field1));
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_5.c b/gcc/testsuite/gcc.dg/pr109071_5.c
new file mode 100644
index 0000000..466d518
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_5.c
@@ -0,0 +1,33 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR115274, which is a duplication of PR109071. */
+/* { dg-options "-O2 -Wstringop-overread -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#include <string.h>
+char *c;
+void a(long);
+int b(char *d) { return strlen(d); } /* { dg-warning "or more bytes from a region of size 0" } */
+void e() {
+ long f = 1;
+ f = b(c + f);
+ if (c == 0)
+ a(f);
+}
+/* { dg-begin-multiline-output "" }
+ NN | int b(char *d) { return strlen(d); }
+ | ^~~~~~~~~
+ 'e': events 1-2
+ NN | int b(char *d) { return strlen(d); }
+ | ~~~~~~~~~
+ | |
+ | (2) warning happens here
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | if (c == 0)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_6.c b/gcc/testsuite/gcc.dg/pr109071_6.c
new file mode 100644
index 0000000..eddf15b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_6.c
@@ -0,0 +1,49 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR117179, which is a duplication of PR109071. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+const char* commands[] = {"a", "b"};
+
+int setval_internal(int comind)
+{
+ if (comind > sizeof(commands)/sizeof(commands[0])) {
+ return 0;
+ }
+
+ return 1;
+}
+
+_Bool setval_internal_tilde(int comind, const char *com,
+ const char *val)
+{
+ int ret = setval_internal(comind);
+ if (commands[comind] == "b" && /* { dg-warning "is outside array bounds of" } */
+
+ ret)
+ return 1;
+ return 0;
+}
+/* { dg-begin-multiline-output "" }
+ NN | if (commands[comind] == "b" &&
+ | ~~~~~~~~^~~~~~~~
+ 'setval_internal_tilde': events 1-2
+ NN | if (comind > sizeof(commands)/sizeof(commands[0])) {
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | if (commands[comind] == "b" &&
+ | ~~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | const char* commands[] = {"a", "b"};
+ | ^~~~~~~~
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_7.c b/gcc/testsuite/gcc.dg/pr109071_7.c
new file mode 100644
index 0000000..a54a9f5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_7.c
@@ -0,0 +1,44 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to compiler optimization. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#define MAX_LENGTH 10
+int a[MAX_LENGTH];
+
+void __attribute__ ((noinline)) foo (int i)
+{
+ if (i == 12)
+ a[i] = -1; /* { dg-warning "is above array bounds of" } */
+ else
+ a[i] = i;
+}
+
+int main ()
+{
+ for (int i = 0; i < MAX_LENGTH; i++)
+ foo (i);
+ return 0;
+}
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~^~~
+ 'foo': events 1-2
+ NN | if (i == 12)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_8.c b/gcc/testsuite/gcc.dg/pr109071_8.c
new file mode 100644
index 0000000..13af458
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_8.c
@@ -0,0 +1,51 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to compiler optimization. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#define MAX_LENGTH 10
+int a[MAX_LENGTH];
+
+void __attribute__ ((noinline)) foo (int i, bool is_dollar)
+{
+ if (i == -1)
+ {
+ if (is_dollar)
+ __builtin_printf ("dollar");
+ else
+ __builtin_printf ("euro");
+ a[i] = -1; /* { dg-warning "is below array bounds of" } */
+ }
+ else
+ a[i] = i;
+}
+
+int main ()
+{
+ for (int i = 0; i < MAX_LENGTH; i++)
+ foo (i, true);
+ return 0;
+}
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~^~~
+ 'foo': events 1-2
+ NN | if (i == -1)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_9.c b/gcc/testsuite/gcc.dg/pr109071_9.c
new file mode 100644
index 0000000..4892571
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_9.c
@@ -0,0 +1,61 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to compiler optimization. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#define MAX_LENGTH 10
+int a[MAX_LENGTH];
+
+void __attribute__ ((noinline)) foo (int i, bool is_dollar,
+ bool is_hour, bool is_color)
+{
+ if (i == -1)
+ {
+ if (is_dollar)
+ __builtin_printf ("dollar");
+ else
+ __builtin_printf ("euro");
+ if (is_hour)
+ __builtin_printf ("hour");
+ else
+ {
+ if (is_color)
+ __builtin_printf ("color minute");
+ else
+ __builtin_printf ("non minute");
+ }
+ a[i] = -1; /* { dg-warning "is below array bounds of" } */
+ }
+ else
+ a[i] = i;
+}
+
+int main ()
+{
+ for (int i = 0; i < MAX_LENGTH; i++)
+ foo (i, true, false, true);
+ return 0;
+}
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~^~~
+ 'foo': events 1-2
+ NN | if (i == -1)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr116906-1.c b/gcc/testsuite/gcc.dg/pr116906-1.c
index 7187507..ee60ad6 100644
--- a/gcc/testsuite/gcc.dg/pr116906-1.c
+++ b/gcc/testsuite/gcc.dg/pr116906-1.c
@@ -1,3 +1,4 @@
+/* { dg-do run } */
/* { dg-require-effective-target alarm } */
/* { dg-require-effective-target signal } */
/* { dg-options "-O2" } */
diff --git a/gcc/testsuite/gcc.dg/pr116906-2.c b/gcc/testsuite/gcc.dg/pr116906-2.c
index 41a352b..4172ec3 100644
--- a/gcc/testsuite/gcc.dg/pr116906-2.c
+++ b/gcc/testsuite/gcc.dg/pr116906-2.c
@@ -1,3 +1,4 @@
+/* { dg-do run } */
/* { dg-require-effective-target alarm } */
/* { dg-require-effective-target signal } */
/* { dg-options "-O2 -fno-tree-ch" } */
diff --git a/gcc/testsuite/gcc.dg/pr117375.c b/gcc/testsuite/gcc.dg/pr117375.c
new file mode 100644
index 0000000..9679a03
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr117375.c
@@ -0,0 +1,13 @@
+/* PR middle-end/117375 ICE with -fdiagnostics-show-context=1 patch in sink pass. */
+/* { dg-do compile }
+ { dg-options "-O2 -Wall -fdiagnostics-show-context=1" } */
+
+int st, st_0;
+int nbFilledBytes, max;
+void ec_enc_shrink();
+void max_allowed() {
+ int nbAvailableBytes = nbFilledBytes;
+ if (st && st_0)
+ if (max < nbAvailableBytes)
+ ec_enc_shrink();
+}
diff --git a/gcc/testsuite/gcc.dg/pr118946-1.c b/gcc/testsuite/gcc.dg/pr118946-1.c
new file mode 100644
index 0000000..6cf2661
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr118946-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-tree-forwprop1-details" } */
+
+/* PR tree-optimization/118946 */
+
+void f(char *a)
+{
+ char t[1024] = {};
+ __builtin_memcpy(a, t, 10);
+}
+
+/* We should be able to optimize the memcpy into a memset here. */
+/* { dg-final { scan-tree-dump-times "after previous" 1 "forwprop1"} } */
+/* { dg-final { scan-tree-dump-times "memset " 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "memcpy " "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/pr120660.c b/gcc/testsuite/gcc.dg/pr120660.c
new file mode 100644
index 0000000..6e8c5e8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr120660.c
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+/* { dg-options "-O -favoid-store-forwarding" } */
+
+int c;
+
+short
+foo (short s)
+{
+ __builtin_memset (&s, c, 1);
+ return s;
+}
+
+int
+main ()
+{
+ short x = foo (0x1111);
+ if (x != 0x1100 && x != 0x0011)
+ __builtin_abort();
+}
diff --git a/gcc/testsuite/gcc.dg/pr120929.c b/gcc/testsuite/gcc.dg/pr120929.c
new file mode 100644
index 0000000..8bb6d5c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr120929.c
@@ -0,0 +1,49 @@
+/* PR120929, pointee's size should not be propagated to pointer for
+ __builtin_dynamic_object_size. */
+
+/* { dg-do compile} */
+/* { dg-options "-O2" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+extern void pin_pointer(void *);
+extern int some_value(void);
+
+struct magic_ {
+ char unused[9]; // at least 9
+};
+
+struct magic_map {
+ struct magic_ *magic;
+};
+
+static int
+coalesce_entries(struct magic_ **ma)
+{
+ size_t slen;
+
+ slen = sizeof (**ma);
+ *ma = __builtin_malloc (slen);
+
+ for (unsigned i = 0; i < 1; i++)
+ {
+ char b[1024] = {};
+ struct magic_ *ptr = *ma;
+ (void) __builtin___memcpy_chk (ptr, b, sizeof (*ptr), /* { dg-bogus "overflows the destination" } */
+ __builtin_dynamic_object_size (ptr, 0));
+ }
+ return 0;
+}
+
+struct magic_map *
+apprentice_load(void)
+{
+ char buf[128]; // did not shrink, but needs to be more than 100
+ struct magic_map *map2;
+
+ map2 = __builtin_malloc (sizeof (*map2));
+
+ pin_pointer(&buf);
+ coalesce_entries(&map2->magic);
+ pin_pointer(map2);
+}
diff --git a/gcc/testsuite/gcc.dg/pr121217.c b/gcc/testsuite/gcc.dg/pr121217.c
new file mode 100644
index 0000000..313f1e3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr121217.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu17" } */
+
+typedef union{
+ char *nordic_ref;
+ unsigned long long int bit_number;
+ enum PinMode mode : 2; /* { dg-warning "narrower" } */
+ /* { dg-error "field 'mode'" "" { target *-*-* } .-1 } */
+ unsigned char value;
+ } s; typedef struct{
+ union{
+ char *nordic_ref;
+ unsigned long long int bit_number;
+ enum PinMode mode : 2; /* { dg-warning "narrower" } */
+ /* { dg-error "field 'mode'" "" { target *-*-* } .-1 } */
+ unsigned char value;
+ } s;
+} /* { dg-error "expected identifier" } */
+
diff --git a/gcc/testsuite/gcc.dg/pr121322.c b/gcc/testsuite/gcc.dg/pr121322.c
new file mode 100644
index 0000000..2fad5b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr121322.c
@@ -0,0 +1,14 @@
+/* PR middle-end/121322 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+unsigned long long
+foo (unsigned long long *p)
+{
+ unsigned long long a = *p;
+ unsigned long long b = __builtin_bswap64 (a);
+ return ((b << 32)
+ | ((b >> 8) & 0xff000000ULL)
+ | ((b >> 24) & 0xff0000ULL)
+ | ((b >> 40) & 0xff00ULL));
+}
diff --git a/gcc/testsuite/gcc.dg/pr121619.c b/gcc/testsuite/gcc.dg/pr121619.c
new file mode 100644
index 0000000..a63896d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr121619.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-gcse -fno-tree-ter -fno-guess-branch-probability -fno-forward-propagate" } */
+
+int printf(const char *, ...);
+long a, c, d;
+char b;
+int main() {
+f : {
+ short g = 100;
+ int h = 1;
+ while (1) {
+ char i = 0;
+ if (a)
+ i = h = -b;
+ short j = g;
+ c = h ^ g;
+ g = ~(-h / c + 1);
+ if (b > 6) {
+ a = g && -1;
+ goto f;
+ }
+ if (j < 100)
+ printf("%ld\n", d);
+ if (g - 1)
+ break;
+ b = i;
+ }
+ int k = 2L % g;
+ if (k)
+ goto f;
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr121663.c b/gcc/testsuite/gcc.dg/pr121663.c
new file mode 100644
index 0000000..b1dfa30
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr121663.c
@@ -0,0 +1,9 @@
+/* PR middle-end/121663 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+foo (void)
+{
+#line 4294967295
+}
diff --git a/gcc/testsuite/gcc.dg/pr78185.c b/gcc/testsuite/gcc.dg/pr78185.c
index ada8b1b..4c3af4f 100644
--- a/gcc/testsuite/gcc.dg/pr78185.c
+++ b/gcc/testsuite/gcc.dg/pr78185.c
@@ -1,3 +1,4 @@
+/* { dg-do run } */
/* { dg-require-effective-target alarm } */
/* { dg-require-effective-target signal } */
/* { dg-options "-O" } */
diff --git a/gcc/testsuite/gcc.dg/pr89828.c b/gcc/testsuite/gcc.dg/pr89828.c
new file mode 100644
index 0000000..d41fbae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr89828.c
@@ -0,0 +1,49 @@
+/* { dg-do compile { target rx-*-* } } */
+/* { dg-options "-O2 -g -fno-omit-frame-pointer" } */
+struct baz;
+struct foo {
+ struct baz *c;
+ unsigned int flags;
+};
+struct bar {
+ const struct bar *b;
+ void (*func)(struct foo *a, struct baz *c, int flags);
+};
+struct baz {
+ int flag;
+ const struct bar *b;
+};
+static inline
+__attribute__((always_inline))
+__attribute__((no_instrument_function)) void inline1(struct foo *a)
+{
+ a->flags |= 1;
+}
+static inline
+__attribute__((always_inline))
+__attribute__((no_instrument_function)) int inline2(struct baz *c)
+{
+ return c->flag == 1;
+}
+extern const struct bar _bar;
+extern void func(struct foo *a);
+void pr89828(struct foo *a, struct baz *c, int flags)
+{
+ const struct bar *b;
+
+ if (c->b == a->c->b) {
+ a->c->b->func(a, c, flags);
+ } else {
+ for (b = (&_bar); b; b = b->b) {
+ if (b == a->c->b)
+ break;
+ if (b == c->b) {
+ func(a);
+ break;
+ }
+ }
+ }
+
+ if (inline2(a->c))
+ inline1(a);
+}
diff --git a/gcc/testsuite/gcc.dg/pr94589-2.c b/gcc/testsuite/gcc.dg/pr94589-2.c
index 9481b76..b20cccd 100644
--- a/gcc/testsuite/gcc.dg/pr94589-2.c
+++ b/gcc/testsuite/gcc.dg/pr94589-2.c
@@ -1,35 +1,63 @@
/* PR tree-optimization/94589 */
/* { dg-do compile } */
/* { dg-options "-O2 -g0 -ffast-math -fdump-tree-optimized" } */
-/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 14 "optimized" } } */
-/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) 5\\.0" 14 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 28 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) 5\\.0" 28 "optimized" } } */
#define A __attribute__((noipa))
-A int f1 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 0; }
-A int f2 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 0; }
-A int f3 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > 0; }
-A int f4 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 0; }
-A int f5 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 0; }
-A int f6 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= 0; }
-A int f7 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == -1; }
-A int f8 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != -1; }
-A int f9 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > -1; }
-A int f10 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= -1; }
-A int f11 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 1; }
-A int f12 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 1; }
-A int f13 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 1; }
-A int f14 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 1; }
-A int f15 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 0; }
-A int f16 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 0; }
-A int f17 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > 0; }
-A int f18 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 0; }
-A int f19 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 0; }
-A int f20 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= 0; }
-A int f21 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == -1; }
-A int f22 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != -1; }
-A int f23 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > -1; }
-A int f24 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= -1; }
-A int f25 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 1; }
-A int f26 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 1; }
-A int f27 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 1; }
-A int f28 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 1; }
+A int f1 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == 0; }
+A int f2 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != 0; }
+A int f3 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c > 0; }
+A int f4 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c < 0; }
+A int f5 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c >= 0; }
+A int f6 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c <= 0; }
+A int f7 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == -1; }
+A int f8 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != -1; }
+A int f9 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c > -1; }
+A int f10 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c <= -1; }
+A int f11 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == 1; }
+A int f12 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != 1; }
+A int f13 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c < 1; }
+A int f14 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c >= 1; }
+A int f15 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == 0; }
+A int f16 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != 0; }
+A int f17 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c > 0; }
+A int f18 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c < 0; }
+A int f19 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c >= 0; }
+A int f20 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c <= 0; }
+A int f21 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == -1; }
+A int f22 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != -1; }
+A int f23 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c > -1; }
+A int f24 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c <= -1; }
+A int f25 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == 1; }
+A int f26 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != 1; }
+A int f27 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c < 1; }
+A int f28 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c >= 1; }
+A int f29 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 0; }
+A signed char f30 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 0; }
+A signed char f31 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 0; }
+A signed char f32 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > 0; }
+A signed char f33 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= 0; }
+A signed char f34 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 0; }
+A signed char f35 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 1; }
+A signed char f36 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 1; }
+A signed char f37 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 1; }
+A signed char f38 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 1; }
+A signed char f39 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == -1; }
+A signed char f40 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != -1; }
+A signed char f41 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > -1; }
+A signed char f42 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= -1; }
+A signed char f43 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 0; }
+A signed char f44 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 0; }
+A signed char f45 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 0; }
+A signed char f46 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > 0; }
+A signed char f47 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= 0; }
+A signed char f48 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 0; }
+A signed char f49 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 1; }
+A signed char f50 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 1; }
+A signed char f51 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 1; }
+A signed char f52 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 1; }
+A signed char f53 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == -1; }
+A signed char f54 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != -1; }
+A signed char f55 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > -1; }
+A signed char f56 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= -1; }
diff --git a/gcc/testsuite/gcc.dg/pr94589-4.c b/gcc/testsuite/gcc.dg/pr94589-4.c
index b2557fb..f277b6c 100644
--- a/gcc/testsuite/gcc.dg/pr94589-4.c
+++ b/gcc/testsuite/gcc.dg/pr94589-4.c
@@ -93,5 +93,89 @@ main ()
D (f28, 4.0, 0);
D (f28, 5.0, 0);
D (f28, 6.0, 1);
+ C (f29, 7.0, 8.0, 0);
+ C (f29, 8.0, 8.0, 1);
+ C (f29, 9.0, 8.0, 0);
+ C (f30, 7.0, 8.0, 1);
+ C (f30, 8.0, 8.0, 0);
+ C (f30, 9.0, 8.0, 1);
+ C (f31, 7.0, 8.0, 0);
+ C (f31, 8.0, 8.0, 0);
+ C (f31, 9.0, 8.0, 1);
+ C (f32, 7.0, 8.0, 1);
+ C (f32, 8.0, 8.0, 0);
+ C (f32, 9.0, 8.0, 0);
+ C (f33, 7.0, 8.0, 0);
+ C (f33, 8.0, 8.0, 1);
+ C (f33, 9.0, 8.0, 1);
+ C (f34, 7.0, 8.0, 1);
+ C (f34, 8.0, 8.0, 1);
+ C (f34, 9.0, 8.0, 0);
+ C (f35, 7.0, 8.0, 1);
+ C (f35, 8.0, 8.0, 0);
+ C (f35, 9.0, 8.0, 0);
+ C (f36, 7.0, 8.0, 0);
+ C (f36, 8.0, 8.0, 1);
+ C (f36, 9.0, 8.0, 1);
+ C (f37, 7.0, 8.0, 0);
+ C (f37, 8.0, 8.0, 1);
+ C (f37, 9.0, 8.0, 1);
+ C (f38, 7.0, 8.0, 1);
+ C (f38, 8.0, 8.0, 0);
+ C (f38, 9.0, 8.0, 0);
+ C (f39, 7.0, 8.0, 0);
+ C (f39, 8.0, 8.0, 0);
+ C (f39, 9.0, 8.0, 1);
+ C (f40, 7.0, 8.0, 1);
+ C (f40, 8.0, 8.0, 1);
+ C (f40, 9.0, 8.0, 0);
+ C (f41, 7.0, 8.0, 1);
+ C (f41, 8.0, 8.0, 1);
+ C (f41, 9.0, 8.0, 0);
+ C (f42, 7.0, 8.0, 0);
+ C (f42, 8.0, 8.0, 0);
+ C (f42, 9.0, 8.0, 1);
+ D (f43, 4.0, 0);
+ D (f43, 5.0, 1);
+ D (f43, 6.0, 0);
+ D (f44, 4.0, 1);
+ D (f44, 5.0, 0);
+ D (f44, 6.0, 1);
+ D (f45, 4.0, 0);
+ D (f45, 5.0, 0);
+ D (f45, 6.0, 1);
+ D (f46, 4.0, 1);
+ D (f46, 5.0, 0);
+ D (f46, 6.0, 0);
+ D (f47, 4.0, 0);
+ D (f47, 5.0, 1);
+ D (f47, 6.0, 1);
+ D (f48, 4.0, 1);
+ D (f48, 5.0, 1);
+ D (f48, 6.0, 0);
+ D (f49, 4.0, 1);
+ D (f49, 5.0, 0);
+ D (f49, 6.0, 0);
+ D (f50, 4.0, 0);
+ D (f50, 5.0, 1);
+ D (f50, 6.0, 1);
+ D (f51, 4.0, 0);
+ D (f51, 5.0, 1);
+ D (f51, 6.0, 1);
+ D (f52, 4.0, 1);
+ D (f52, 5.0, 0);
+ D (f52, 6.0, 0);
+ D (f53, 4.0, 0);
+ D (f53, 5.0, 0);
+ D (f53, 6.0, 1);
+ D (f54, 4.0, 1);
+ D (f54, 5.0, 1);
+ D (f54, 6.0, 0);
+ D (f55, 4.0, 1);
+ D (f55, 5.0, 1);
+ D (f55, 6.0, 0);
+ D (f56, 4.0, 0);
+ D (f56, 5.0, 0);
+ D (f56, 6.0, 1);
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/pr94589-5.c b/gcc/testsuite/gcc.dg/pr94589-5.c
index 8777fa4..65dfd05 100644
--- a/gcc/testsuite/gcc.dg/pr94589-5.c
+++ b/gcc/testsuite/gcc.dg/pr94589-5.c
@@ -1,35 +1,55 @@
/* PR tree-optimization/94589 */
/* { dg-do compile { target inf } } */
/* { dg-options "-O2 -g0 -fdump-tree-optimized" } */
-/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|>|>=) \[ij]_\[0-9]+\\(D\\)" 14 "optimized" } } */
-/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|>|>=) 5\\.0" 14 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|>|>=) \[ij]_\[0-9]+\\(D\\)" 24 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|>|>=) 5\\.0" 24 "optimized" } } */
#define A __attribute__((noipa))
-A int f3 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > 0; }
-A int f4 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 0; }
-A int f5 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 0; }
-A int f6 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= 0; }
-A int f7 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == -1; }
-A int f8 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != -1; }
-A int f9 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > -1; }
-A int f10 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= -1; }
-A int f11 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 1; }
-A int f12 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 1; }
-A int f13 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 1; }
-A int f14 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 1; }
-A int f17 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > 0; }
-A int f18 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 0; }
-A int f19 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 0; }
-A int f20 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= 0; }
-A int f21 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == -1; }
-A int f22 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != -1; }
-A int f23 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > -1; }
-A int f24 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= -1; }
-A int f25 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 1; }
-A int f26 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 1; }
-A int f27 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 1; }
-A int f28 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 1; }
-A int f29 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return (c & ~1) == 0; }
-A int f30 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return (c & ~1) != 0; }
-A int f31 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return (c & ~1) == 0; }
-A int f32 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return (c & ~1) != 0; }
+A int f3 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c > 0; }
+A int f4 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c < 0; }
+A int f5 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c >= 0; }
+A int f6 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c <= 0; }
+A int f7 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == -1; }
+A int f8 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != -1; }
+A int f9 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c > -1; }
+A int f10 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c <= -1; }
+A int f11 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == 1; }
+A int f12 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != 1; }
+A int f13 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c < 1; }
+A int f14 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c >= 1; }
+A int f17 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c > 0; }
+A int f18 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c < 0; }
+A int f19 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c >= 0; }
+A int f20 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c <= 0; }
+A int f21 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == -1; }
+A int f22 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != -1; }
+A int f23 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c > -1; }
+A int f24 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c <= -1; }
+A int f25 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == 1; }
+A int f26 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != 1; }
+A int f27 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c < 1; }
+A int f28 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c >= 1; }
+A signed char f31 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 0; }
+A signed char f32 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > 0; }
+A signed char f33 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= 0; }
+A signed char f34 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 0; }
+A signed char f35 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 1; }
+A signed char f36 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 1; }
+A signed char f37 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 1; }
+A signed char f38 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 1; }
+A signed char f39 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == -1; }
+A signed char f40 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != -1; }
+A signed char f41 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > -1; }
+A signed char f42 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= -1; }
+A signed char f45 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 0; }
+A signed char f46 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > 0; }
+A signed char f47 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= 0; }
+A signed char f48 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 0; }
+A signed char f49 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 1; }
+A signed char f50 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 1; }
+A signed char f51 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 1; }
+A signed char f52 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 1; }
+A signed char f53 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == -1; }
+A signed char f54 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != -1; }
+A signed char f55 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > -1; }
+A signed char f56 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= -1; }
diff --git a/gcc/testsuite/gcc.dg/pr94589-6.c b/gcc/testsuite/gcc.dg/pr94589-6.c
index 2014c1c..3131ab4 100644
--- a/gcc/testsuite/gcc.dg/pr94589-6.c
+++ b/gcc/testsuite/gcc.dg/pr94589-6.c
@@ -3,13 +3,19 @@
#include "pr94589-5.c"
-A int f1 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 0; }
-A int f2 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 0; }
-A int f15 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 0; }
-A int f16 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 0; }
+A int f1 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == 0; }
+A int f2 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != 0; }
+A int f15 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == 0; }
+A int f16 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != 0; }
+A int f29 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 0; }
+A int f30 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 0; }
+A int f43 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 0; }
+A int f44 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 0; }
-#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort ()
-#define D(fn, i, r) if (fn (i) != r) __builtin_abort ()
+//#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort ()
+//#define D(fn, i, r) if (fn (i) != r) __builtin_abort ()
+#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_printf ("%d\n", __LINE__)
+#define D(fn, i, r) if (fn (i) != r) __builtin_printf ("%d\n", __LINE__)
int
main ()
@@ -25,19 +31,19 @@ main ()
C (f3, 7.0, 8.0, 0);
C (f3, 8.0, 8.0, 0);
C (f3, 9.0, 8.0, 1);
- C (f3, __builtin_nan (""), 8.0, 1);
+ C (f3, __builtin_nan (""), 8.0, 0);
C (f4, 7.0, 8.0, 1);
C (f4, 8.0, 8.0, 0);
C (f4, 9.0, 8.0, 0);
- C (f4, __builtin_nan (""), 8.0, 0);
+ C (f4, __builtin_nan (""), 8.0, 1);
C (f5, 7.0, 8.0, 0);
C (f5, 8.0, 8.0, 1);
C (f5, 9.0, 8.0, 1);
- C (f5, __builtin_nan (""), 8.0, 1);
+ C (f5, __builtin_nan (""), 8.0, 0);
C (f6, 7.0, 8.0, 1);
C (f6, 8.0, 8.0, 1);
C (f6, 9.0, 8.0, 0);
- C (f6, __builtin_nan (""), 8.0, 0);
+ C (f6, __builtin_nan (""), 8.0, 1);
C (f7, 7.0, 8.0, 1);
C (f7, 8.0, 8.0, 0);
C (f7, 9.0, 8.0, 0);
@@ -49,11 +55,11 @@ main ()
C (f9, 7.0, 8.0, 0);
C (f9, 8.0, 8.0, 1);
C (f9, 9.0, 8.0, 1);
- C (f9, __builtin_nan (""), 8.0, 1);
+ C (f9, __builtin_nan (""), 8.0, 0);
C (f10, 7.0, 8.0, 1);
C (f10, 8.0, 8.0, 0);
C (f10, 9.0, 8.0, 0);
- C (f10, __builtin_nan (""), 8.0, 0);
+ C (f10, __builtin_nan (""), 8.0, 1);
C (f11, 7.0, 8.0, 0);
C (f11, 8.0, 8.0, 0);
C (f11, 9.0, 8.0, 1);
@@ -65,11 +71,11 @@ main ()
C (f13, 7.0, 8.0, 1);
C (f13, 8.0, 8.0, 1);
C (f13, 9.0, 8.0, 0);
- C (f13, __builtin_nan (""), 8.0, 0);
+ C (f13, __builtin_nan (""), 8.0, 1);
C (f14, 7.0, 8.0, 0);
C (f14, 8.0, 8.0, 0);
C (f14, 9.0, 8.0, 1);
- C (f14, __builtin_nan (""), 8.0, 1);
+ C (f14, __builtin_nan (""), 8.0, 0);
D (f15, 4.0, 0);
D (f15, 5.0, 1);
D (f15, 6.0, 0);
@@ -81,19 +87,19 @@ main ()
D (f17, 4.0, 0);
D (f17, 5.0, 0);
D (f17, 6.0, 1);
- D (f17, __builtin_nan (""), 1);
+ D (f17, __builtin_nan (""), 0);
D (f18, 4.0, 1);
D (f18, 5.0, 0);
D (f18, 6.0, 0);
- D (f18, __builtin_nan (""), 0);
+ D (f18, __builtin_nan (""), 1);
D (f19, 4.0, 0);
D (f19, 5.0, 1);
D (f19, 6.0, 1);
- D (f19, __builtin_nan (""), 1);
+ D (f19, __builtin_nan (""), 0);
D (f20, 4.0, 1);
D (f20, 5.0, 1);
D (f20, 6.0, 0);
- D (f20, __builtin_nan (""), 0);
+ D (f20, __builtin_nan (""), 1);
D (f21, 4.0, 1);
D (f21, 5.0, 0);
D (f21, 6.0, 0);
@@ -105,11 +111,11 @@ main ()
D (f23, 4.0, 0);
D (f23, 5.0, 1);
D (f23, 6.0, 1);
- D (f23, __builtin_nan (""), 1);
+ D (f23, __builtin_nan (""), 0);
D (f24, 4.0, 1);
D (f24, 5.0, 0);
D (f24, 6.0, 0);
- D (f24, __builtin_nan (""), 0);
+ D (f24, __builtin_nan (""), 1);
D (f25, 4.0, 0);
D (f25, 5.0, 0);
D (f25, 6.0, 1);
@@ -121,26 +127,122 @@ main ()
D (f27, 4.0, 1);
D (f27, 5.0, 1);
D (f27, 6.0, 0);
- D (f27, __builtin_nan (""), 0);
+ D (f27, __builtin_nan (""), 1);
D (f28, 4.0, 0);
D (f28, 5.0, 0);
D (f28, 6.0, 1);
- D (f28, __builtin_nan (""), 1);
+ D (f28, __builtin_nan (""), 0);
C (f29, 7.0, 8.0, 0);
C (f29, 8.0, 8.0, 1);
- C (f29, 9.0, 8.0, 1);
+ C (f29, 9.0, 8.0, 0);
C (f29, __builtin_nan (""), 8.0, 0);
C (f30, 7.0, 8.0, 1);
C (f30, 8.0, 8.0, 0);
- C (f30, 9.0, 8.0, 0);
+ C (f30, 9.0, 8.0, 1);
C (f30, __builtin_nan (""), 8.0, 1);
- D (f31, 4.0, 0);
- D (f31, 5.0, 1);
- D (f31, 6.0, 1);
- D (f31, __builtin_nan (""), 0);
- D (f32, 4.0, 1);
- D (f32, 5.0, 0);
- D (f32, 6.0, 0);
- D (f32, __builtin_nan (""), 1);
+ C (f31, 7.0, 8.0, 0);
+ C (f31, 8.0, 8.0, 0);
+ C (f31, 9.0, 8.0, 1);
+ C (f31, __builtin_nan (""), 8.0, 1);
+ C (f32, 7.0, 8.0, 1);
+ C (f32, 8.0, 8.0, 0);
+ C (f32, 9.0, 8.0, 0);
+ C (f32, __builtin_nan (""), 8.0, 0);
+ C (f33, 7.0, 8.0, 0);
+ C (f33, 8.0, 8.0, 1);
+ C (f33, 9.0, 8.0, 1);
+ C (f33, __builtin_nan (""), 8.0, 1);
+ C (f34, 7.0, 8.0, 1);
+ C (f34, 8.0, 8.0, 1);
+ C (f34, 9.0, 8.0, 0);
+ C (f34, __builtin_nan (""), 8.0, 0);
+ C (f35, 7.0, 8.0, 1);
+ C (f35, 8.0, 8.0, 0);
+ C (f35, 9.0, 8.0, 0);
+ C (f35, __builtin_nan (""), 8.0, 0);
+ C (f36, 7.0, 8.0, 0);
+ C (f36, 8.0, 8.0, 1);
+ C (f36, 9.0, 8.0, 1);
+ C (f36, __builtin_nan (""), 8.0, 1);
+ C (f37, 7.0, 8.0, 0);
+ C (f37, 8.0, 8.0, 1);
+ C (f37, 9.0, 8.0, 1);
+ C (f37, __builtin_nan (""), 8.0, 1);
+ C (f38, 7.0, 8.0, 1);
+ C (f38, 8.0, 8.0, 0);
+ C (f38, 9.0, 8.0, 0);
+ C (f38, __builtin_nan (""), 8.0, 0);
+ C (f39, 7.0, 8.0, 0);
+ C (f39, 8.0, 8.0, 0);
+ C (f39, 9.0, 8.0, 1);
+ C (f39, __builtin_nan (""), 8.0, 0);
+ C (f40, 7.0, 8.0, 1);
+ C (f40, 8.0, 8.0, 1);
+ C (f40, 9.0, 8.0, 0);
+ C (f40, __builtin_nan (""), 8.0, 1);
+ C (f41, 7.0, 8.0, 1);
+ C (f41, 8.0, 8.0, 1);
+ C (f41, 9.0, 8.0, 0);
+ C (f41, __builtin_nan (""), 8.0, 0);
+ C (f42, 7.0, 8.0, 0);
+ C (f42, 8.0, 8.0, 0);
+ C (f42, 9.0, 8.0, 1);
+ C (f42, __builtin_nan (""), 8.0, 1);
+ D (f43, 4.0, 0);
+ D (f43, 5.0, 1);
+ D (f43, 6.0, 0);
+ D (f43, __builtin_nan (""), 0);
+ D (f44, 4.0, 1);
+ D (f44, 5.0, 0);
+ D (f44, 6.0, 1);
+ D (f44, __builtin_nan (""), 1);
+ D (f45, 4.0, 0);
+ D (f45, 5.0, 0);
+ D (f45, 6.0, 1);
+ D (f45, __builtin_nan (""), 1);
+ D (f46, 4.0, 1);
+ D (f46, 5.0, 0);
+ D (f46, 6.0, 0);
+ D (f46, __builtin_nan (""), 0);
+ D (f47, 4.0, 0);
+ D (f47, 5.0, 1);
+ D (f47, 6.0, 1);
+ D (f47, __builtin_nan (""), 1);
+ D (f48, 4.0, 1);
+ D (f48, 5.0, 1);
+ D (f48, 6.0, 0);
+ D (f48, __builtin_nan (""), 0);
+ D (f49, 4.0, 1);
+ D (f49, 5.0, 0);
+ D (f49, 6.0, 0);
+ D (f49, __builtin_nan (""), 0);
+ D (f50, 4.0, 0);
+ D (f50, 5.0, 1);
+ D (f50, 6.0, 1);
+ D (f50, __builtin_nan (""), 1);
+ D (f51, 4.0, 0);
+ D (f51, 5.0, 1);
+ D (f51, 6.0, 1);
+ D (f51, __builtin_nan (""), 1);
+ D (f52, 4.0, 1);
+ D (f52, 5.0, 0);
+ D (f52, 6.0, 0);
+ D (f52, __builtin_nan (""), 0);
+ D (f53, 4.0, 0);
+ D (f53, 5.0, 0);
+ D (f53, 6.0, 1);
+ D (f53, __builtin_nan (""), 0);
+ D (f54, 4.0, 1);
+ D (f54, 5.0, 1);
+ D (f54, 6.0, 0);
+ D (f54, __builtin_nan (""), 1);
+ D (f55, 4.0, 1);
+ D (f55, 5.0, 1);
+ D (f55, 6.0, 0);
+ D (f55, __builtin_nan (""), 0);
+ D (f56, 4.0, 0);
+ D (f56, 5.0, 0);
+ D (f56, 6.0, 1);
+ D (f56, __builtin_nan (""), 1);
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/torture/bitint-83.c b/gcc/testsuite/gcc.dg/torture/bitint-83.c
new file mode 100644
index 0000000..8a9df44
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/bitint-83.c
@@ -0,0 +1,48 @@
+/* Derived from a test in gcc.dg/torture/bitint-16.c */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c23 -pedantic-errors" } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#include "../bitintext.h"
+
+#define BASIC_TESTS \
+ TEST(8) \
+ TEST(16) \
+ TEST(32)
+
+#if __BITINT_MAXWIDTH__ >= 519
+#define ALL_TESTS \
+ BASIC_TESTS \
+ TEST(64) \
+ TEST(128) \
+ TEST(256) \
+ TEST(512)
+#else
+#define ALL_TESTS BASIC_TESTS
+#endif
+
+#define TEST(N) \
+void \
+test##N (unsigned _BitInt(N + 7) *t, _BitInt(N) x) \
+{ \
+ *t = -x; \
+}
+ALL_TESTS
+#undef TEST
+
+volatile int y = 0;
+
+int
+main (void)
+{
+#define TEST(N) \
+ { \
+ unsigned _BitInt(N + 7) t; \
+ _BitInt(N) x = y + N; \
+ test##N (&t, x); \
+ BEXTC (t); \
+ }
+ ALL_TESTS
+#undef TEST
+}
diff --git a/gcc/testsuite/gcc.dg/torture/bitint-84.c b/gcc/testsuite/gcc.dg/torture/bitint-84.c
new file mode 100644
index 0000000..b3ecbef
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/bitint-84.c
@@ -0,0 +1,18 @@
+/* A simple variant of gcc.dg/torture/bitint-64.c */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c23" } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#include "../bitintext.h"
+
+enum E : char { E22 = 22 } e = E22;
+
+int
+main ()
+{
+ _Atomic _BitInt (5) b = 0;
+ b += e;
+ BEXTC (b);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/bitint-85.c b/gcc/testsuite/gcc.dg/torture/bitint-85.c
new file mode 100644
index 0000000..43eb6ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/bitint-85.c
@@ -0,0 +1,34 @@
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c23 -pedantic-errors" } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 1024
+constexpr _BitInt(1024) d = -541140097068598424394740839221562143161511518875518765552323978870598341733206554363735813878577506997168480201818027232521wb;
+int c;
+
+static inline void
+foo (_BitInt(1024) b, _BitInt(1024) *r)
+{
+ if (c)
+ b = 0;
+ *r = b;
+}
+
+[[gnu::noipa]] void
+bar (_BitInt(1024) y)
+{
+ if (y != d)
+ __builtin_abort ();
+}
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 1024
+ _BitInt(1024) x;
+ foo (d, &x);
+ bar (x);
+#endif
+}
diff --git a/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-1.c b/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-1.c
new file mode 100644
index 0000000..5c457b9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-1.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+/* Make sure a bit-field store of 0 cause the whole assignment become 0. */
+
+struct s1
+{
+ unsigned char c:1;
+ unsigned char d:7;
+};
+
+__attribute__((noinline))
+struct s1 f(struct s1 a)
+{
+ a.c = 0;
+ struct s1 t = a;
+ return t;
+}
+
+int main()
+{
+ struct s1 a = {1, 2};
+ struct s1 b = f(a);
+ if (b.c != 0)
+ __builtin_abort();
+ if (b.d != 2)
+ __builtin_abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-2.c b/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-2.c
new file mode 100644
index 0000000..f1da161
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-2.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+/* Make sure a bit-field store of 0 cause the whole assignment become 0. */
+
+struct s1
+{
+ unsigned char d:7;
+ unsigned char c:1;
+};
+
+__attribute__((noinline))
+struct s1 f(struct s1 a)
+{
+ a.c = 0;
+ struct s1 t = a;
+ return t;
+}
+
+int main()
+{
+ struct s1 a = {2, 1};
+ struct s1 b = f(a);
+ if (b.c != 0)
+ __builtin_abort();
+ if (b.d != 2)
+ __builtin_abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c b/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
index ee4b385..4be3a25 100644
--- a/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
+++ b/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
@@ -24,7 +24,7 @@ void foo(void) {
s0 = s1;
}
-/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+\[lL\]C.*\n\[ \\t\]*\\.long\[ \\t\]+4\n" { target { *-*-darwin* && { ! lp64 } } } } } */
-/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+\[lL\]C.*\n\[ \\t\]*\\.long\[ \\t\]+10\n" { target { *-*-darwin* && { ! lp64 } } } } } */
-/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t4\n" { target { *-*-darwin* && { lp64 } } } } } */
-/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t10\n" { target { *-*-darwin* && { lp64 } } } } } */
+/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+L\.str\..*\n\[ \\t\]*\\.long\[ \\t\]+4\n" { target { *-*-darwin* && { ! lp64 } } } } } */
+/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+L\.str\..*\n\[ \\t\]*\\.long\[ \\t\]+10\n" { target { *-*-darwin* && { ! lp64 } } } } } */
+/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\tL\.str\..*\n\t.quad\t4\n" { target { *-*-darwin* && { lp64 } } } } } */
+/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\tL\.str\..*\n\t.quad\t10\n" { target { *-*-darwin* && { lp64 } } } } } */
diff --git a/gcc/testsuite/gcc.dg/torture/hardbool-ai.c b/gcc/testsuite/gcc.dg/torture/hardbool-ai.c
new file mode 100644
index 0000000..af4e0e1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/hardbool-ai.c
@@ -0,0 +1,8 @@
+/* { dg-do run } */
+/* { dg-require-effective-target sync_int_long } */
+
+#define basetype _Atomic int
+
+#define NO_BITFIELDS 1
+
+#include "hardbool.c"
diff --git a/gcc/testsuite/gcc.dg/torture/hardbool-vi.c b/gcc/testsuite/gcc.dg/torture/hardbool-vi.c
new file mode 100644
index 0000000..898d395
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/hardbool-vi.c
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+
+#define basetype volatile int
+
+#include "hardbool.c"
diff --git a/gcc/testsuite/gcc.dg/torture/hardbool.c b/gcc/testsuite/gcc.dg/torture/hardbool.c
index 0168495..ed0c598 100644
--- a/gcc/testsuite/gcc.dg/torture/hardbool.c
+++ b/gcc/testsuite/gcc.dg/torture/hardbool.c
@@ -21,8 +21,12 @@ typedef unsigned char __attribute__ ((__hardbool__ (1, 0))) zbool;
struct hs {
hbool a[2];
+#ifndef NO_BITFIELDS
hbool x:2;
hbool y:5;
+#else
+ hbool x, y;
+#endif
zbool z:1;
};
@@ -57,6 +61,30 @@ int ghs(hbool s) {
int t = (hbool)2;
+hbool add1(hbool *s) {
+ return *s += 1;
+}
+
+hbool preinc(hbool *s) {
+ return ++*s;
+}
+
+hbool postinc(hbool *s) {
+ return (*s)++;
+}
+
+hbool sub1(hbool *s) {
+ return *s -= 1;
+}
+
+hbool predec(hbool *s) {
+ return --*s;
+}
+
+hbool postdec(hbool *s) {
+ return (*s)--;
+}
+
void check_pfalse (hbool *p)
{
assert (!*p);
@@ -114,5 +142,43 @@ int main () {
check_vtrue (h2 (2));
check_vtrue (h2 (1));
check_vfalse (h2 (0));
-}
+ hbool v;
+ v = 0;
+ check_vtrue (add1 (&v));
+ assert (v);
+ v = 0;
+ check_vtrue (preinc (&v));
+ assert (v);
+ v = 0;
+ check_vfalse (postinc (&v));
+ assert (v);
+ v = 0;
+ check_vtrue (sub1 (&v));
+ assert (v);
+ v = 0;
+ check_vtrue (predec (&v));
+ assert (v);
+ v = 0;
+ check_vfalse (postdec (&v));
+ assert (v);
+
+ v = 1;
+ check_vtrue (add1 (&v));
+ assert (v);
+ v = 1;
+ check_vtrue (preinc (&v));
+ assert (v);
+ v = 1;
+ check_vtrue (postinc (&v));
+ assert (v);
+ v = 1;
+ check_vfalse (sub1 (&v));
+ assert (!v);
+ v = 1;
+ check_vfalse (predec (&v));
+ assert (!v);
+ v = 1;
+ check_vtrue (postdec (&v));
+ assert (!v);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/malloc-1.c b/gcc/testsuite/gcc.dg/torture/malloc-1.c
new file mode 100644
index 0000000..ba24153
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/malloc-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* PR middle-end/120024 */
+
+void *f(unsigned) __attribute__((malloc));
+void g()
+{
+ void *(*g)(unsigned) = f;
+ void (*h)(unsigned) = (void (*)(unsigned))g;
+ h(1);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/malloc-2.c b/gcc/testsuite/gcc.dg/torture/malloc-2.c
new file mode 100644
index 0000000..8eeca9d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/malloc-2.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* PR middle-end/120024 */
+
+void *f(unsigned) __attribute__((malloc));
+void h1(void);
+void g(void)
+{
+ void *(*g)(unsigned) = f;
+ void (*h)(unsigned) = (void (*)(unsigned))g;
+ h(1);
+ h1();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121236-1.c b/gcc/testsuite/gcc.dg/torture/pr121236-1.c
new file mode 100644
index 0000000..2b397e3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121236-1.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* PR tree-optimization/121236 */
+
+
+unsigned func_26(short *p_27, int gg, int p) {
+ unsigned l_184 = 0;
+ unsigned m = 0;
+ for (int g_59 = 0; g_59 < 10; g_59++)
+ {
+ if (gg)
+ l_184--;
+ else
+ {
+ m |= l_184 |= p;
+ (l_184)--;
+ }
+ }
+ return m;
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr121279-1.c b/gcc/testsuite/gcc.dg/torture/pr121279-1.c
new file mode 100644
index 0000000..516b887
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121279-1.c
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+/* PR tree-optimization/121279 */
+
+#include <stdbool.h>
+
+struct Value {
+ int type;
+ union {
+ bool boolean;
+ long long t;
+ };
+};
+
+static struct Value s_item_mem;
+
+/* truthy was being miscompiled for the value.type==2 case,
+ because the bool load from the union is pulled out of the
+ loop but that was conditional before and now it is not,
+ so turns it into `s_item_mem.type == 1 | bool` which is
+ not valid if `s_item_mem.type == 2` . */
+static bool truthy(void) __attribute__((noipa));
+static bool
+truthy(void)
+{
+ bool tt = false;
+ for(int i = 0; i < 10; i++)
+ {
+ if (s_item_mem.type == 0)
+ tt = tt | 0;
+ else if (s_item_mem.type == 1)
+ tt = tt | s_item_mem.boolean;
+ else
+ tt = tt | 1;
+ }
+ return tt;
+}
+
+int
+main(void)
+{
+ s_item_mem.type = 2;
+ s_item_mem.t = -1;
+ bool b1 = !truthy();
+ s_item_mem.type = 1;
+ s_item_mem.boolean = b1;
+ bool b = truthy();
+ if (b1 != b) __builtin_abort();
+ if (b) __builtin_abort();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121295-1.c b/gcc/testsuite/gcc.dg/torture/pr121295-1.c
new file mode 100644
index 0000000..7825c6e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121295-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options " -fno-tree-copy-prop -fno-tree-pre -fno-code-hoisting" */
+
+/* PR tree-optimization/121295 */
+
+
+int a, b, c;
+int main() {
+ int *d = &a;
+ while (b)
+ b = (*d &= 10) <= 0 || (*d = c);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121370.c b/gcc/testsuite/gcc.dg/torture/pr121370.c
new file mode 100644
index 0000000..d40f3b2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121370.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+int a;
+int main()
+{
+ int c = -2147483647;
+ int d = -2147483647;
+ int e = 2147483647;
+ if (0)
+ f:
+ e = d + e - 2;
+g:
+ if (d - c - e > 0) {
+ a = -c;
+ if (a + d) {
+ d = 1;
+ goto g;
+ }
+ return 0;
+ }
+ if (e)
+ goto f;
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121382.c b/gcc/testsuite/gcc.dg/torture/pr121382.c
new file mode 100644
index 0000000..20b49b1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121382.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+int a, b, c;
+__attribute__((noipa))
+static void d(int e, int f)
+{
+ if (e != 5 && e != 2147483647)
+ __builtin_abort();
+ f = 2147483647;
+ do {
+ f = f - e;
+ if (c - 9 * f) {
+ __builtin_abort();
+ }
+ } while (c);
+}
+__attribute__((noipa))
+int main(void)
+{
+ d(2147483647, 2147483647);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121422-1.c b/gcc/testsuite/gcc.dg/torture/pr121422-1.c
new file mode 100644
index 0000000..136f80d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121422-1.c
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+/* PR tree-optimization/121422 */
+
+struct s1
+{
+ char a[4];
+};
+struct s1 b;
+char t[4];
+
+/* if both t and b startout zero initialized before this function,
+ t should end up being:
+ {0, 0, 1, 0}
+ while b.a should end up being:
+ {0, 0, 0, 1}
+*/
+__attribute__((noipa,noinline))
+void f(void)
+{
+ b = (struct s1){};
+ b.a[3] = 1;
+ /* This memcpy should stay a memcpy and not become memset. */
+ __builtin_memcpy(&t[0], &b.a[1], 3*sizeof(t[0]));
+}
+
+
+int main()
+{
+ f();
+ for(int i = 0; i < 4; i++)
+ {
+ if (t[i] != (i == 2 ? 1 : 0))
+ __builtin_abort();
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121422-2.c b/gcc/testsuite/gcc.dg/torture/pr121422-2.c
new file mode 100644
index 0000000..570559c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121422-2.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* PR tree-optimization/121422 */
+
+struct s1
+{
+ char a[4];
+};
+struct s1 b;
+char t[4];
+
+/* if both t and b startout zero initialized before this function,
+ t should end up being:
+ {0, 0, 1, 0}
+ while b.a should end up being:
+ {0, 0, 0, 1}
+*/
+__attribute__((noipa,noinline))
+void f(void)
+{
+ __builtin_memset(&b.a[1], 0, 2);
+ b.a[3] = 1;
+ /* This memcpy should stay a memcpy and not become memset. */
+ __builtin_memcpy(&t[0], &b.a[1], 3);
+}
+
+
+int main()
+{
+ f();
+ for(int i = 0; i < 4; i++)
+ {
+ if (t[i] != (i == 2 ? 1 : 0))
+ __builtin_abort();
+ }
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr121478-1.c b/gcc/testsuite/gcc.dg/torture/pr121478-1.c
new file mode 100644
index 0000000..1dda01c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121478-1.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu23" } */
+
+#include <stddef.h>
+#include <stdlib.h>
+typedef struct {
+ int data[5];
+ nullptr_t np;
+} container_t;
+void process_array(int *arr, size_t len, nullptr_t nullp) {
+ for (size_t i = 0; i < len; ++i) {
+ switch (arr[i] % 4) {
+ case 1:
+ if (nullp == nullptr) {
+ arr[i] *= -1;
+ [[fallthrough]];
+ }
+ case 2:
+ arr[i] = abs(arr[i]);
+ break;
+ default:
+ arr[i] = 0;
+ }
+ }
+}
+int main(void) {
+ container_t c = {
+ .data = { -3, 1, 4, 2, 7 },
+ .np = nullptr
+ };
+ process_array(c.data, 5, c.np);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121514.c b/gcc/testsuite/gcc.dg/torture/pr121514.c
new file mode 100644
index 0000000..95b7a0b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121514.c
@@ -0,0 +1,20 @@
+/* { dg-do compile { target int128 } } */
+/* { dg-additional-options "-Wno-psabi" } */
+
+typedef unsigned U __attribute__((__vector_size__(64)));
+typedef char V __attribute__((vector_size(64)));
+typedef __int128 W __attribute__((vector_size(64)));
+char c;
+int i;
+U u;
+V v;
+W w;
+
+W
+foo()
+{
+ u = 0 <= u;
+ __builtin_mul_overflow(i, c, &u[7]);
+ v ^= (V)u;
+ return (W)u + w;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121656.c b/gcc/testsuite/gcc.dg/torture/pr121656.c
new file mode 100644
index 0000000..343d414
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121656.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+
+/* This test fails to run at -O1 and above. This is caused by
+
+ ebbeaf490c5 [PR rtl-optimization/120553] Improve selecting between constants based on sign bit test
+
+ and has been fixed by
+
+ 56ca14c4c4f Fix invalid right shift count with recent ifcvt changes
+
+ */
+
+__attribute__ ((noipa))
+void
+foo (int b)
+{
+ if (b != 3)
+ __builtin_abort ();
+}
+
+int a;
+int
+main ()
+{
+ int b = 0;
+ if (a >= 0)
+ b += 3;
+ foo (b);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121695-1.c b/gcc/testsuite/gcc.dg/torture/pr121695-1.c
new file mode 100644
index 0000000..877c9c9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121695-1.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* PR tree-optimization/121695 */
+
+int ac;
+char p;
+int *r;
+static unsigned t = 7;
+int q() {
+ int v;
+af: {
+ int ag[3];
+ int *ah = &ag[1];
+ for (; ac;) {
+ int ai = 3971866093;
+ if (0 >= *ah && (*r = 1))
+ *ah &= ai;
+ else {
+ if (p)
+ goto af;
+ *ah &= t;
+ }
+ }
+}
+ return v;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-1.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-1.c
new file mode 100644
index 0000000..2ce6891
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-1.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized -fdump-tree-forwprop1-details" } */
+
+struct s1
+{
+ int t[1024];
+};
+
+void f(struct s1);
+
+void g(struct s1 a)
+{
+ struct s1 temp_struct0 = a;
+ f(temp_struct0);
+}
+
+/* There should be no references to any of "temp_struct*"
+ temporaries. */
+/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" } } */
+/* Also check that forwprop pass did the copy prop. */
+/* { dg-final { scan-tree-dump-times "after previous" 1 "forwprop1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-1.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-1.c
new file mode 100644
index 0000000..577a5b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-1.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-tree-sra -fdump-tree-optimized -fdump-tree-forwprop1-details" } */
+
+extern void link_error (void);
+
+/* Check for copyprop on structs with zeroing. */
+#define vector16 __attribute__((vector_size(64)))
+
+struct g
+{
+ vector16 unsigned char t;
+};
+
+struct g f(void)
+{
+ struct g temp_struct1 ;
+ temp_struct1.t = (vector16 unsigned char){};
+ struct g temp_struct2 = temp_struct1;
+ struct g temp_struct3 = temp_struct2;
+ struct g temp_struct4 = temp_struct3;
+ return temp_struct4;
+}
+
+/* There should be no references to any of "temp_struct*"
+ temporaries. */
+/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" } } */
+/* Also check that forwprop pass did the copy prop. */
+/* { dg-final { scan-tree-dump-times "after previous" 4 "forwprop1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-2.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-2.c
new file mode 100644
index 0000000..ce3c612
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-2.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-tree-sra -fdump-tree-optimized -fdump-tree-forwprop1-details" } */
+
+extern void link_error (void);
+
+struct g
+{
+ unsigned int t;
+};
+
+struct g f(void)
+{
+ struct g temp_struct1 ;
+ temp_struct1.t = 0;
+ struct g temp_struct2 = temp_struct1;
+ struct g temp_struct3 = temp_struct2;
+ struct g temp_struct4 = temp_struct3;
+ return temp_struct4;
+}
+
+/* There should be no references to any of "temp_struct*"
+ temporaries. */
+/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" } } */
+/* Also check that forwprop pass did the copy prop. */
+/* { dg-final { scan-tree-dump-times "after previous" 4 "forwprop1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-3.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-3.c
new file mode 100644
index 0000000..94ce965
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-3.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-tree-sra -fdump-tree-optimized -fdump-tree-forwprop1-details" } */
+
+extern void link_error (void);
+
+struct g
+{
+ _Complex unsigned int t;
+};
+
+struct g f(void)
+{
+ struct g temp_struct1 ;
+ temp_struct1.t = 0;
+ struct g temp_struct2 = temp_struct1;
+ struct g temp_struct3 = temp_struct2;
+ struct g temp_struct4 = temp_struct3;
+ return temp_struct4;
+}
+
+/* There should be no references to any of "temp_struct*"
+ temporaries. */
+/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" } } */
+/* Also check that forwprop pass did the copy prop. */
+/* { dg-final { scan-tree-dump-times "after previous" 4 "forwprop1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/cswtch-6.c b/gcc/testsuite/gcc.dg/tree-ssa/cswtch-6.c
index d765a03..9637681 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/cswtch-6.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/cswtch-6.c
@@ -40,4 +40,4 @@ f1 (int v, int w)
foo (i, j);
}
-/* { dg-final { scan-assembler ".rodata.cst16" } } */
+/* { dg-final { scan-assembler ".rodata.cst16" { xfail { sparc*-*-solaris2* && { ! gas } } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/cswtch-7.c b/gcc/testsuite/gcc.dg/tree-ssa/cswtch-7.c
new file mode 100644
index 0000000..5559923
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/cswtch-7.c
@@ -0,0 +1,48 @@
+/* PR tree-optimization/120523 */
+/* PR tree-optimization/120451 */
+/* { dg-do compile { target elf } } */
+/* { dg-options "-O2" } */
+
+void foo (int, int);
+
+__attribute__((noinline, noclone)) void
+f1 (int v, int w)
+{
+ int i, j;
+ if (w)
+ {
+ i = 129;
+ j = i - 1;
+ goto lab;
+ }
+ switch (v)
+ {
+ case 170:
+ j = 7;
+ i = 27;
+ break;
+ case 171:
+ i = 8;
+ j = 122;
+ break;
+ case 172:
+ i = 21;
+ j = -19;
+ break;
+ case 173:
+ i = 18;
+ j = 17;
+ break;
+ case 174:
+ i = 33;
+ j = 55;
+ break;
+ default:
+ __builtin_abort ();
+ }
+
+ lab:
+ foo (i, j);
+}
+
+/* { dg-final { scan-assembler ".rodata.cst32" { xfail { sparc*-*-solaris2* && { ! gas } } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr121264.c b/gcc/testsuite/gcc.dg/tree-ssa/pr121264.c
new file mode 100644
index 0000000..bd5acc0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr121264.c
@@ -0,0 +1,12 @@
+/* PR tree-optimization/121264 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump " \\\| " "optimized" } } */
+
+struct A { char b; char c[0x20000010]; } a;
+
+int
+foo ()
+{
+ return a.c[0x20000000] || a.c[1];
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-105.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-105.c
new file mode 100644
index 0000000..61b93c0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-105.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-sra -fdump-tree-fre1-details" } */
+
+struct s1
+{
+ int t, t1;
+};
+
+struct s3
+{
+ struct s1 t;
+};
+
+struct s2
+{
+ struct s3 t;
+};
+
+void f(int, int);
+void l();
+void g(int a, int b, int *p)
+{
+ struct s2 c;
+ {
+ struct s1 tmp = {a,b};
+ struct s3 *t = &c.t;
+ t->t = tmp;
+ }
+ f(c.t.t.t, c.t.t.t1);
+}
+
+/* { dg-final { scan-tree-dump "Replaced c.t.t.t1 with b" "fre1" } } */
+/* { dg-final { scan-tree-dump "Replaced c.t.t.t with a" "fre1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-106.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-106.c
new file mode 100644
index 0000000..6da4201
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-106.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-sra -fdump-tree-fre1-details" } */
+
+struct s1
+{
+ int t, t1;
+};
+
+struct s3
+{
+ struct s1 t;
+};
+
+struct s2
+{
+ struct s3 t;
+};
+
+void f(int, int);
+void l();
+void g(int a, int b, int *p)
+{
+ struct s2 c;
+ {
+ struct s1 tmp = {a,b};
+ c.t.t = tmp;
+ }
+ struct s1 *t = &c.t.t;
+ f(t->t, t->t1);
+}
+
+/* { dg-final { scan-tree-dump "Replaced \[^\r\n\]*.t1 with b" "fre1" } } */
+/* { dg-final { scan-tree-dump "Replaced \[^\r\n\]*.t with a" "fre1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-107.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-107.c
new file mode 100644
index 0000000..f80baf3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-107.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+struct vec_char_16
+{
+ unsigned char raw[2];
+};
+
+static inline struct vec_char_16
+Dup128VecFromValues(unsigned char t0, unsigned char t1)
+{
+ struct vec_char_16 result;
+ result.raw[0] = t0;
+ result.raw[1] = t1;
+ return result;
+}
+
+int f(unsigned char t0, unsigned char t1)
+{
+ struct vec_char_16 a = Dup128VecFromValues(t0, t1);
+ struct vec_char_16 b;
+ __builtin_memcpy(&b, &a, sizeof(a));
+ return b.raw[0] + b.raw[1];
+}
+
+/* Ideally we'd optimize this at FRE1 time but we only replace
+ the loads from b.raw[] with BIT_FIELD_REFs which get optimized
+ only later in the next FRE. */
+/* { dg-final { scan-tree-dump-not "MEM" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-108.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-108.c
new file mode 100644
index 0000000..a13e972
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-108.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wno-psabi -fdump-tree-fre1" } */
+
+#define vector16 __attribute__((vector_size(16)))
+#define vector32 __attribute__((vector_size(32)))
+
+union u1
+{
+ struct s1
+ {
+ vector16 int hi;
+ vector16 int low;
+ }hilow;
+ vector32 int v;
+};
+
+vector16 float f(vector16 int a, vector16 int b)
+{
+ union u1 c;
+ c.hilow.hi = a;
+ c.hilow.low = b;
+ vector32 int d0 = c.v;
+ vector32 float d = (vector32 float)d0;
+ vector16 float e = __builtin_shufflevector (d, d, 0, 1, 2, 3);
+ vector16 float f = __builtin_shufflevector (d, d, 4, 5, 6, 7);
+ return e/f;
+}
+
+/* { dg-final { scan-tree-dump-times "_\[0-9\]\+ = VIEW_CONVERT_EXPR" 2 "fre1" } } */
+/* { dg-final { scan-tree-dump-not "BIT_FIELD_REF" "fre1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-109.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-109.c
new file mode 100644
index 0000000..f04e033c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-109.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-sra -fdump-tree-fre1" } */
+
+struct s1
+{
+ int t;
+};
+
+struct s2
+{
+ struct s1 t;
+};
+
+int f1(int a)
+{
+ struct s1 t = (struct s1){a};
+ struct s2 tt = (struct s2){t};
+ struct s2 ttt = tt;
+ struct s1 *t0 = &ttt.t;
+ return t0->t;
+}
+
+/* { dg-final { scan-tree-dump "return a" "fre1" } } */
diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c
new file mode 100644
index 0000000..b0cf36e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c
@@ -0,0 +1,53 @@
+/* Test the attribute counted_by for pointer fields and its usage in
+ bounds sanitizer combined with VLA. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+/* { dg-output "index 11 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*index 20 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*index 11 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*index 10 out of bounds for type 'int \\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+
+
+#include <stdlib.h>
+
+void __attribute__((__noinline__)) setup_and_test_vla (const int n, int m)
+{
+ struct foo {
+ int n;
+ int (*p)[n] __attribute__((counted_by(n)));
+ } *f;
+
+ f = (struct foo *) malloc (sizeof (struct foo));
+ f->p = (int (*)[n]) malloc (m * sizeof (int[n]));
+ f->n = m;
+ f->p[m][n-1] = 1;
+ free (f->p);
+ free (f);
+ return;
+}
+
+void __attribute__((__noinline__)) setup_and_test_vla_1 (const int n1,
+ const int n2,
+ int m)
+{
+ struct foo {
+ int n;
+ int (*p)[n2][n1] __attribute__((counted_by(n)));
+ } *f;
+
+ f = (struct foo *) malloc (sizeof(struct foo));
+ f->p = (int (*)[n2][n1]) malloc (m * sizeof (int[n2][n1]));
+ f->n = m;
+ f->p[m][n2][n1] = 1;
+ free (f->p);
+ free (f);
+ return;
+}
+
+int main(int argc, char *argv[])
+{
+ setup_and_test_vla (10, 11);
+ setup_and_test_vla_1 (10, 11, 20);
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c
new file mode 100644
index 0000000..731422d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c
@@ -0,0 +1,42 @@
+/* Test the attribute counted_by for pointer fields and its usage in bounds
+ sanitizer. when counted_by field is negative value. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+
+#include <stdlib.h>
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+} *array_annotated;
+
+void __attribute__((__noinline__)) setup (int annotated_count)
+{
+ array_annotated
+ = (struct annotated *)malloc (sizeof (struct annotated));
+ array_annotated->c = (int *) malloc (sizeof (int) * 10);
+ array_annotated->b = annotated_count;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test (int annotated_index)
+{
+ array_annotated->c[annotated_index] = 2;
+}
+
+void cleanup ()
+{
+ free (array_annotated->c);
+ free (array_annotated);
+}
+
+int main(int argc, char *argv[])
+{
+ setup (-3);
+ test (2);
+ cleanup ();
+ return 0;
+}
+
+/* { dg-output "25:21: runtime error: index 2 out of bounds for type" } */
diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c
new file mode 100644
index 0000000..52f202f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c
@@ -0,0 +1,42 @@
+/* Test the attribute counted_by for pointer fields and its usage in bounds
+ sanitizer. when counted_by field is zero value. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+
+#include <stdlib.h>
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+} *array_annotated;
+
+void __attribute__((__noinline__)) setup (int annotated_count)
+{
+ array_annotated
+ = (struct annotated *)malloc (sizeof (struct annotated));
+ array_annotated->c = (int *)malloc (sizeof (int) * 10);
+ array_annotated->b = annotated_count;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test (int annotated_index)
+{
+ array_annotated->c[annotated_index] = 2;
+}
+
+void cleanup ()
+{
+ free (array_annotated->c);
+ free (array_annotated);
+}
+
+int main(int argc, char *argv[])
+{
+ setup (0);
+ test (1);
+ cleanup ();
+ return 0;
+}
+
+/* { dg-output "25:21: runtime error: index 1 out of bounds for type" } */
diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c
new file mode 100644
index 0000000..8ad7572
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c
@@ -0,0 +1,40 @@
+/* Test the attribute counted_by for pointer fields and its usage in
+ bounds sanitizer. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+
+#include <stdlib.h>
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+} *p_array_annotated;
+
+void __attribute__((__noinline__)) setup (int annotated_count)
+{
+ p_array_annotated
+ = (struct annotated *)malloc (sizeof (struct annotated));
+ p_array_annotated->c = (int *) malloc (annotated_count * sizeof (int));
+ p_array_annotated->b = annotated_count;
+
+ return;
+}
+
+void cleanup ()
+{
+ free (p_array_annotated->c);
+ free (p_array_annotated);
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+ setup (10);
+ for (i = 0; i < 11; i++)
+ p_array_annotated->c[i] = 2; // goes boom at i == 10
+ cleanup ();
+ return 0;
+}
+
+
+/* { dg-output "34:25: runtime error: index 10 out of bounds for type" } */
diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c
new file mode 100644
index 0000000..c5a1ac5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c
@@ -0,0 +1,46 @@
+/* Test the attribute counted_by for pointer fields and its usage in
+ bounds sanitizer. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+
+#include <stdlib.h>
+
+struct pointer_array {
+ int b;
+ int *c;
+} *p_array;
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+} *p_array_annotated;
+
+void __attribute__((__noinline__)) setup (int normal_count, int annotated_count)
+{
+ p_array
+ = (struct pointer_array *) malloc (sizeof (struct pointer_array));
+ p_array->c = (int *) malloc (normal_count * sizeof (int));
+ p_array->b = normal_count;
+
+ p_array_annotated
+ = (struct annotated *) malloc (sizeof (struct annotated));
+ p_array_annotated->c = (int *) malloc (annotated_count * sizeof (int));
+ p_array_annotated->b = annotated_count;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test (int normal_index, int annotated_index)
+{
+ p_array->c[normal_index] = 1;
+ p_array_annotated->c[annotated_index] = 2;
+}
+
+int main(int argc, char *argv[])
+{
+ setup (10, 10);
+ test (10, 10);
+ return 0;
+}
+
+/* { dg-output "36:23: runtime error: index 10 out of bounds for type" } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr112325.c b/gcc/testsuite/gcc.dg/vect/pr112325.c
index 8689fbf..d380595 100644
--- a/gcc/testsuite/gcc.dg/vect/pr112325.c
+++ b/gcc/testsuite/gcc.dg/vect/pr112325.c
@@ -5,6 +5,7 @@
/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */
/* { dg-additional-options "--param max-completely-peeled-insns=200" { target powerpc64*-*-* } } */
/* { dg-additional-options "-mlsx" { target loongarch64-*-* } } */
+/* { dg-additional-options "--param max-completely-peeled-insns=200 --param min-vect-loop-bound=0" { target s390*-*-* } } */
typedef unsigned short ggml_fp16_t;
static float table_f32_f16[1 << 16];
diff --git a/gcc/testsuite/gcc.dg/vect/pr117888-1.c b/gcc/testsuite/gcc.dg/vect/pr117888-1.c
index 0b31fcd..884aed2 100644
--- a/gcc/testsuite/gcc.dg/vect/pr117888-1.c
+++ b/gcc/testsuite/gcc.dg/vect/pr117888-1.c
@@ -5,6 +5,7 @@
/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */
/* { dg-additional-options "--param max-completely-peeled-insns=200" { target powerpc64*-*-* } } */
/* { dg-additional-options "-mlsx" { target loongarch64-*-* } } */
+/* { dg-additional-options "--param max-completely-peeled-insns=200 --param min-vect-loop-bound=0" { target s390*-*-* } } */
typedef unsigned short ggml_fp16_t;
static float table_f32_f16[1 << 16];
diff --git a/gcc/testsuite/gcc.dg/vect/pr120687-1.c b/gcc/testsuite/gcc.dg/vect/pr120687-1.c
new file mode 100644
index 0000000..ce9cf63
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr120687-1.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
+unsigned
+frd (unsigned *p, unsigned *lastone)
+{
+ unsigned sum = 0;
+ for (; p <= lastone; p += 16)
+ sum += p[0] + p[1] + p[2] + p[3] + p[4] + p[5] + p[6] + p[7]
+ + p[8] + p[9] + p[10] + p[11] + p[12] + p[13] + p[14] + p[15];
+ return sum;
+}
+
+/* { dg-final { scan-tree-dump "reduction: detected reduction chain" "vect" } } */
+/* { dg-final { scan-tree-dump-not "SLP discovery of reduction chain failed" "vect" } } */
+/* { dg-final { scan-tree-dump "optimized: loop vectorized" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr120687-2.c b/gcc/testsuite/gcc.dg/vect/pr120687-2.c
new file mode 100644
index 0000000..dfc6dc7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr120687-2.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+/* { dg-additional-options "-ffast-math" } */
+
+float
+frd (float *p, float *lastone)
+{
+ float sum = 0;
+ for (; p <= lastone; p += 16)
+ sum += p[0] + p[1] + p[2] + p[3] + p[4] + p[5] + p[6] + p[7]
+ + p[8] + p[9] + p[10] + p[11] + p[12] + p[13] + p[14] + p[15];
+ return sum;
+}
+
+/* { dg-final { scan-tree-dump "reduction: detected reduction chain" "vect" } } */
+/* { dg-final { scan-tree-dump-not "SLP discovery of reduction chain failed" "vect" } } */
+/* { dg-final { scan-tree-dump "optimized: loop vectorized" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr120687-3.c b/gcc/testsuite/gcc.dg/vect/pr120687-3.c
new file mode 100644
index 0000000..f20a66a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr120687-3.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_double } */
+/* { dg-additional-options "-ffast-math" } */
+
+float
+frd (float *p, float *lastone)
+{
+ float sum = 0;
+ for (; p <= lastone; p += 2)
+ sum += p[0] + p[1];
+ return sum;
+}
+
+/* { dg-final { scan-tree-dump "reduction: detected reduction chain" "vect" } } */
+/* { dg-final { scan-tree-dump-not "SLP discovery of reduction chain failed" "vect" } } */
+/* { dg-final { scan-tree-dump "optimized: loop vectorized" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr121509.c b/gcc/testsuite/gcc.dg/vect/pr121509.c
new file mode 100644
index 0000000..3a69ad3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr121509.c
@@ -0,0 +1,42 @@
+/* { dg-additional-options "-fgimple" } */
+
+#include "tree-vect.h"
+
+long g_73[2] = {6L,6L};
+int __GIMPLE (ssa,startwith("loop")) __attribute__((noipa))
+foo ()
+{
+ signed char g;
+ int l;
+ int _1;
+ unsigned char _3;
+ unsigned char _4;
+
+ __BB(2):
+ goto __BB3;
+
+ __BB(3,loop_header(1)):
+ l_5 = __PHI (__BB2: _Literal (int) -511973466, __BB3: 1);
+ g_6 = __PHI (__BB2: _Literal (signed char) 0, __BB3: g_12);
+ _1 = (int) g_6;
+ g_73[_1] = 0l;
+ _3 = (unsigned char) g_6;
+ _4 = _3 + _Literal (unsigned char) 1;
+ g_12 = (signed char) _4;
+ if (g_12 > _Literal (signed char) 1)
+ goto __BB4;
+ else
+ goto __BB3;
+
+ __BB(4):
+ l_14 = __PHI (__BB3: l_5);
+ return l_14;
+}
+
+int main()
+{
+ check_vect ();
+ if (foo () != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr121638.c b/gcc/testsuite/gcc.dg/vect/pr121638.c
new file mode 100644
index 0000000..52d5d6d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr121638.c
@@ -0,0 +1,74 @@
+/* { dg-additional-options "-fgimple -fno-tree-scev-cprop" } */
+
+#include "tree-vect.h"
+
+int a, b, f, j, i, *m, n, o, p = 1, q;
+
+int __GIMPLE (ssa,guessed_local(1073741824),startwith("loop"))
+main ()
+{
+ int D_3005;
+ int D_3003;
+ int d;
+ int * e;
+ long unsigned int _9;
+ long unsigned int _10;
+ int * _11;
+ int _15;
+ int _32;
+
+ __BB(2,guessed_local(1073741824)):
+ check_vect ();
+ e_6 = __builtin_malloc (64ul);
+ goto __BB3(precise(134217728));
+
+ __BB(3,loop_header(2),guessed_local(8687547538)):
+ d_29 = __PHI (__BB3: d_8, __BB2: 0);
+ d_8 = d_29 + 1;
+ _9 = (long unsigned int) d_29;
+ _10 = _9 * 4ul;
+ _11 = e_6 + _10;
+ __MEM <int> (_11) = d_29;
+ if (d_8 <= 15)
+ goto __BB3(guessed(119453778));
+ else
+ goto __BB4(guessed(14763950));
+
+ __BB(4,guessed_local(955630224)):
+ if (d_8 != 16)
+ goto __BB9(guessed(58814510));
+ else
+ goto __BB5(guessed(75403218));
+
+ __BB(5,guessed_local(536870912)):
+ a = 0;
+ if (d_8 > 0)
+ goto __BB6(guessed(119453778));
+ else
+ goto __BB8(guessed(14763950));
+
+ __BB(6,loop_header(1),guessed_local(4343773769)):
+ _32 = __PHI (__BB6: _15, __BB5: 0);
+ _15 = _32 + 1;
+ if (d_29 > _32)
+ goto __BB6(guessed(119453778));
+ else
+ goto __BB7(guessed(14763950));
+
+ __BB(7,guessed_local(477815112)):
+ a = _15;
+ goto __BB8(precise(134217728));
+
+ __BB(8,guessed_local(1073741824)):
+ __builtin_free (e_6);
+ f = 0;
+ return 0;
+
+ __BB(9,precise(0)):
+ a = d_8;
+ f = 1;
+ __builtin_abort ();
+
+}
+
+
diff --git a/gcc/testsuite/gcc.dg/vect/pr121659.c b/gcc/testsuite/gcc.dg/vect/pr121659.c
new file mode 100644
index 0000000..19d5f8c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr121659.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+_Bool a;
+void b(_Bool c[][3])
+{
+ for (short d = 0; d < 100; d++)
+ for (int e = 1; e < 21; e += 4)
+ a ^= !c[1][1];
+ for (;;)
+ ;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr121686.c b/gcc/testsuite/gcc.dg/vect/pr121686.c
new file mode 100644
index 0000000..5a9284c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr121686.c
@@ -0,0 +1,32 @@
+/* { dg-additional-options "-O3" } */
+
+#include "tree-vect.h"
+
+signed char a, b, c, f;
+int d, e, g, h;
+
+int main()
+{
+ int j, k;
+ signed char m;
+ check_vect ();
+ while (f < 4) {
+ k = b = 3;
+ for (; b >= 0; b--) {
+ j = a < 0 ? a : a >> h;
+ g = k;
+ e = j;
+ k = 0;
+ while (1) {
+ if (j)
+ break;
+ k = f == 0;
+ break;
+ }
+ }
+ m = g * 87;
+ if (m < 70)
+ __builtin_abort();
+ return 0;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr121744-1.c b/gcc/testsuite/gcc.dg/vect/pr121744-1.c
new file mode 100644
index 0000000..81f4996
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr121744-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mavx2" { target avx2 } } */
+
+unsigned long a[1024];
+unsigned int b[1024];
+
+void foo()
+{
+ for (int i = 0; i < 1024; ++i)
+ a[i] = 1ul << b[i];
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target vect_var_shift } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr121754.c b/gcc/testsuite/gcc.dg/vect/pr121754.c
new file mode 100644
index 0000000..775abda
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr121754.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+float a;
+void
+fn1 (int b)
+{
+ for (; b < 10; b++)
+ {
+ a = 01.;
+ for (int c = 0; c < 2000; c++)
+ a *= 0.99;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr59984.c b/gcc/testsuite/gcc.dg/vect/pr59984.c
index c00c2267..8ca446e 100644
--- a/gcc/testsuite/gcc.dg/vect/pr59984.c
+++ b/gcc/testsuite/gcc.dg/vect/pr59984.c
@@ -64,3 +64,7 @@ main ()
return 0;
}
+/* { dg-final { scan-tree-dump "31:17: optimized: loop vectorized" "vect" } } */
+/* { dg-final { scan-tree-dump "37:7: optimized: loop vectorized" "vect" } } */
+/* { dg-final { scan-tree-dump "44:17: optimized: loop vectorized" "vect" } } */
+/* { dg-final { scan-tree-dump "50:7: optimized: loop vectorized" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c
new file mode 100644
index 0000000..e6b071c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c
@@ -0,0 +1,62 @@
+/* PR tree-optimization/121190 */
+/* { dg-options "-O3" } */
+/* { dg-additional-options "-march=znver2" { target x86_64-*-* i?86-*-* } } */
+/* { dg-require-effective-target mmap } */
+/* { dg-require-effective-target vect_early_break } */
+
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include "tree-vect.h"
+
+#define MAX_COMPARE 5000
+
+__attribute__((noipa))
+int diff (uint64_t *restrict p, uint64_t *restrict q)
+{
+ int i = 0;
+ while (i < MAX_COMPARE) {
+ if (*(p + i) != *(q + i))
+ return i;
+ i++;
+ }
+ return -1;
+}
+
+int main ()
+{
+ check_vect ();
+
+ long pgsz = sysconf (_SC_PAGESIZE);
+ if (pgsz == -1) {
+ fprintf (stderr, "sysconf failed\n");
+ return 0;
+ }
+
+ /* Allocate 2 consecutive pages of memory and let p1 and p2 point to the
+ beginning of each. */
+ void *mem = mmap (NULL, pgsz * 2, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (mem == MAP_FAILED) {
+ fprintf (stderr, "mmap failed\n");
+ return 0;
+ }
+ uint64_t *p1 = (uint64_t *) mem;
+ uint64_t *p2 = (uint64_t *) mem + pgsz / sizeof (uint64_t);
+
+ /* Fill the first page with zeros, except for its last 64 bits. */
+ memset (p1, 0, pgsz);
+ *(p2 - 1) = -1;
+
+ /* Make the 2nd page not accessable. */
+ mprotect (p2, pgsz, PROT_NONE);
+
+ /* Calls to diff should not read the 2nd page. */
+ for (int i = 1; i <= 20; i++) {
+ if (diff (p2 - i, p1) != i - 1)
+ __builtin_abort ();
+ }
+}
+
diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c
new file mode 100644
index 0000000..8cb62bf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c
@@ -0,0 +1,54 @@
+/* PR tree-optimization/121020 */
+/* { dg-options "-O3 --vect-cost-model=unlimited" } */
+/* { dg-additional-options "-march=znver2" { target x86_64-*-* i?86-*-* } } */
+/* { dg-require-effective-target mmap } */
+/* { dg-require-effective-target vect_early_break } */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include "tree-vect.h"
+
+__attribute__((noipa))
+bool equal (uint64_t *restrict p, uint64_t *restrict q, int length)
+{
+ for (int i = 0; i < length; i++) {
+ if (*(p + i) != *(q + i))
+ return false;
+ }
+ return true;
+}
+
+int main ()
+{
+ check_vect ();
+
+ long pgsz = sysconf (_SC_PAGESIZE);
+ if (pgsz == -1) {
+ fprintf (stderr, "sysconf failed\n");
+ return 0;
+ }
+
+ /* Allocate a whole page of memory. */
+ void *mem = mmap (NULL, pgsz, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (mem == MAP_FAILED) {
+ fprintf (stderr, "mmap failed\n");
+ return 0;
+ }
+ uint64_t *p1 = (uint64_t *) mem;
+ uint64_t *p2 = (uint64_t *) mem + 32;
+
+ /* The first 16 elements pointed to by p1 and p2 are the same. */
+ for (int i = 0; i < 32; i++) {
+ *(p1 + i) = 0;
+ *(p2 + i) = (i < 16 ? 0 : -1);
+ }
+
+ /* All calls to equal should return true. */
+ for (int len = 0; len < 16; len++) {
+ if (!equal (p1 + 1, p2 + 1, len))
+ __builtin_abort();
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c
index 86a632f..6abfcd6 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c
@@ -18,4 +18,4 @@ int main1 (short X)
}
}
-/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */
+/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { ! "x86_64-*-* i?86-*-* arm*-*-*" } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-gather-1.c b/gcc/testsuite/gcc.dg/vect/vect-gather-1.c
index 5f6640d..6497ab4 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-gather-1.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-gather-1.c
@@ -3,9 +3,9 @@
#define N 16
void __attribute__((noipa))
-f (int *restrict y, int *restrict x, int *restrict indices)
+f (int *restrict y, int *restrict x, int *restrict indices, int n)
{
- for (int i = 0; i < N; ++i)
+ for (int i = 0; i < n; ++i)
{
y[i * 2] = x[indices[i * 2]] + 1;
y[i * 2 + 1] = x[indices[i * 2 + 1]] + 2;
@@ -49,7 +49,7 @@ main (void)
{
check_vect ();
- f (y, x, indices);
+ f (y, x, indices, N);
#pragma GCC novector
for (int i = 0; i < 32; ++i)
if (y[i] != expected[i])
diff --git a/gcc/testsuite/gcc.dg/vect/vect-recurr-pr121256-2.c b/gcc/testsuite/gcc.dg/vect/vect-recurr-pr121256-2.c
new file mode 100644
index 0000000..7350fd9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-recurr-pr121256-2.c
@@ -0,0 +1,49 @@
+/* { dg-additional-options "-mavx2" { target avx2_runtime } } */
+
+#include "tree-vect.h"
+
+#define B 0
+#define G 1
+#define R 2
+
+int red = 153;
+int green = 66;
+int blue = 187;
+
+static void __attribute__((noipa))
+sub_left_prediction_bgr32(int *restrict dst, int *restrict src)
+{
+ for (int i = 0; i < 8; i++) {
+ int rt = src[i * 3 + R];
+ int gt = src[i * 3 + G];
+ int bt = src[i * 3 + B];
+
+ dst[i * 3 + R] = rt - red;
+ dst[i * 3 + G] = gt - green;
+ dst[i * 3 + B] = bt - blue;
+
+ red = rt;
+ green = gt;
+ blue = bt;
+ }
+}
+
+int main()
+{
+ int dst[8*3];
+ int src[8*3] = { 160, 73, 194, 17, 33, 99, 0, 12, 283, 87, 73, 11,
+ 9, 7, 1, 23, 19, 13, 77, 233, 97, 78, 2, 5 };
+ int dst2[8*3] = {-27, 7, 41, -143, -40, -95, -17, -21, 184, 87, 61,
+ -272, -78, -66, -10, 14, 12, 12, 54, 214, 84, 1, -231, -92};
+
+ check_vect ();
+
+ sub_left_prediction_bgr32(dst, src);
+
+#pragma GCC novector
+ for (int i = 0; i < 8*3; ++i)
+ if (dst[i] != dst2[i])
+ __builtin_abort();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/vect-recurr-pr121256.c b/gcc/testsuite/gcc.dg/vect/vect-recurr-pr121256.c
new file mode 100644
index 0000000..c895e94
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-recurr-pr121256.c
@@ -0,0 +1,54 @@
+/* { dg-additional-options "-mavx2" { target avx2_runtime } } */
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include "tree-vect.h"
+
+#define B 0
+#define G 1
+#define R 2
+#define A 3
+
+int red = 153;
+int green = 66;
+int blue = 187;
+int alpha = 255;
+
+static void __attribute__((noipa))
+sub_left_prediction_bgr32(uint8_t *restrict dst, uint8_t *restrict src, int w)
+{
+ for (int i = 0; i < 8; i++) {
+ int rt = src[i * 4 + R];
+ int gt = src[i * 4 + G];
+ int bt = src[i * 4 + B];
+ int at = src[i * 4 + A];
+
+ dst[i * 4 + R] = rt - red;
+ dst[i * 4 + G] = gt - green;
+ dst[i * 4 + B] = bt - blue;
+ dst[i * 4 + A] = at - alpha;
+
+ red = rt;
+ green = gt;
+ blue = bt;
+ alpha = at;
+ }
+}
+
+int main()
+{
+ check_vect ();
+
+ uint8_t *dst = calloc(36, sizeof(uint8_t));
+ uint8_t *src = calloc(36, sizeof(uint8_t));
+
+ src[R] = 160;
+ src[G] = 73;
+ src[B] = 194;
+ src[A] = 255;
+
+ sub_left_prediction_bgr32(dst, src, 33);
+ if (dst[R] != 7 || dst[B] != 7 || dst[A] != 0)
+ __builtin_abort();
+}
diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-pr121130.c b/gcc/testsuite/gcc.dg/vect/vect-simd-pr121130.c
new file mode 100644
index 0000000..c882ded
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-simd-pr121130.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+int n2;
+
+__attribute__((simd)) char
+w7(void)
+{
+ short int xb = n2;
+ xb = w7() < 1;
+ return xb;
+}
diff --git a/gcc/testsuite/gcc.dg/vla-tert-1.c b/gcc/testsuite/gcc.dg/vla-tert-1.c
new file mode 100644
index 0000000..dfbb2e6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vla-tert-1.c
@@ -0,0 +1,293 @@
+/* { dg-do run }
+ * { dg-options "-std=c99" }
+ * */
+
+
+// For the conditional operator and variably modified types,
+// verify that the size expression on the selected branch
+// is evaluated and the correct result is returned.
+
+
+// keep track which side was evaluated.
+static int fc[2] = { 0 };
+
+static int f(int s, int c)
+{
+ fc[c]++;
+ return s;
+}
+
+
+int main()
+{
+ // two VLAs, constant condition
+
+ fc[0] = fc[1] = 0;
+
+ if (5 != sizeof(*(1 ? (char(*)[ f(5, 0) ])0 : (char(*)[ f(3, 1) ])0)))
+ __builtin_abort();
+
+ if ((1 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ fc[0] = fc[1] = 0;
+
+ if (3 != sizeof(*(0 ? (char(*)[ f(5, 0) ])0 : (char(*)[ f(3, 1) ])0)))
+ __builtin_abort(); // fails
+
+ if ((0 != fc[0]) || (1 != fc[1]))
+ __builtin_abort(); // fails
+
+ // two VLAs
+
+ int c = 0;
+ fc[0] = fc[1] = 0;
+
+ if (3 != sizeof(*(c ? (char(*)[ f(5, 0) ])0 : (char(*)[ f(3, 1) ])0)))
+ __builtin_abort(); // fails
+
+ if ((0 != fc[0]) || (1 != fc[1]))
+ __builtin_abort();
+
+ c = 1;
+ fc[0] = fc[1] = 0;
+
+ if (5 != sizeof(*(c ? (char(*)[ f(5, 0) ])0 : (char(*)[ f(3, 1) ])0)))
+ __builtin_abort();
+
+ if ((1 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // VLA + array of unknown size, VLA side is evaluated, defined
+
+ c = 0;
+ fc[0] = fc[1] = 0;
+
+ if (3 != sizeof(*(c ? (char(*)[ ])0 : (char(*)[ f(3, 1) ])0)))
+ __builtin_abort();
+
+ if ((0 != fc[0]) || (1 != fc[1]))
+ __builtin_abort();
+
+ c = 1;
+ fc[0] = fc[1] = 0;
+
+ if (5 != sizeof(*(c ? (char(*)[ f(5, 0) ])0 : (char(*)[ ])0)))
+ __builtin_abort();
+
+ if ((1 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // VLA + array of unknown size, VLA side is not evaluated
+
+ c = 1;
+ fc[0] = fc[1] = 0;
+
+ sizeof(*(c ? (char(*)[ ])0 : (char(*)[ f(3, 1) ])0));
+
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // without sizeof
+
+ fc[0] = fc[1] = 0;
+
+ (c ? (char(*)[ ])0 : (char(*)[ f(3, 1) ])0);
+
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ c = 0;
+ fc[0] = fc[1] = 0;
+
+ sizeof(*(c ? (char(*)[ f(5, 0) ])0 : (char(*)[ ])0));
+
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // without sizeof
+
+ fc[0] = fc[1] = 0;
+
+ (c ? (char(*)[ f(5, 0) ])0 : (char(*)[ ])0);
+
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+
+ // VLA + array of known size, VLA side is evaluated
+
+ c = 0;
+ fc[0] = fc[1] = 0;
+
+ if (3 != sizeof(*(c ? (char(*)[3])0 : (char(*)[ f(3, 1) ])0)))
+ __builtin_abort();
+
+ // sizeof is not evaluated because not a VLA
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ c = 0;
+ fc[0] = fc[1] = 0;
+
+ // without sizeof
+
+ (c ? (char(*)[3])0 : (char(*)[ f(3, 1) ])0);
+
+ if ((0 != fc[0]) || (1 != fc[1]))
+ __builtin_abort();
+
+ c = 1;
+ fc[0] = fc[1] = 0;
+
+ if (5 != sizeof(*(c ? (char(*)[ f(5, 0) ])0 : (char(*)[5])0)))
+ __builtin_abort();
+
+ // sizeof is not evaluated because not a VLA
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // without sizeof
+
+ fc[0] = fc[1] = 0;
+
+ (c ? (char(*)[ f(5, 0) ])0 : (char(*)[ 5 ])0);
+
+ if ((1 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // VLA + array of known size, VLA side is not evaluated
+
+ c = 0;
+ fc[0] = fc[1] = 0;
+
+ if (3 != sizeof(*(c ? (char(*)[ f(3, 0) ])0 : (char(*)[ 3 ])0)))
+ __builtin_abort();
+
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ c = 1;
+ fc[0] = fc[1] = 0;
+
+ if (5 != sizeof(*(c ? (char(*)[ 5 ])0 : (char(*)[ f(5, 1) ])0)))
+ __builtin_abort();
+
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // VM type on one side, null pointer on the other side
+
+ c = 0;
+ fc[0] = fc[1] = 0;
+
+ if (3 != sizeof(*(c ? (void*)0 : (char(*)[ f(3, 1) ])0)))
+ __builtin_abort();
+
+ if ((0 != fc[0]) || (1 != fc[1]))
+ __builtin_abort();
+
+ c = 1;
+ fc[0] = fc[1] = 0;
+
+ if (5 != sizeof(*(c ? (char(*)[ f(5, 0) ])0 : (void*)0)))
+ __builtin_abort();
+
+ if ((1 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+#if 0
+ // these cases are not fixable
+ // VM types on one side, null pointer on the other side
+ c = 1;
+ fc[0] = fc[1] = 0;
+
+ if (3 != sizeof(*(c ? (void*)0 : (char(*)[ f(3, 1) ])0)))
+ __builtin_abort();
+
+ if ((0 != fc[0]) || (1 != fc[1]))
+ __builtin_abort();
+
+ c = 0;
+ fc[0] = fc[1] = 0;
+
+ if (5 != sizeof(*(c ? (char(*)[ f(5, 0) ])0 : (void*)0)))
+ __builtin_abort();
+
+ if ((1 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+#endif
+
+ // VLA + void*
+ void* p = 0;
+ c = 0;
+ fc[0] = fc[1] = 0;
+
+ if (1 != sizeof(*(c ? p : (char(*)[ f(3, 1) ])0)))
+ __builtin_abort();
+
+ // not a VLA or evaluated
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // .. without sizeof
+
+ (c ? p : (char(*)[ f(3, 1) ])0);
+
+ if ((0 != fc[0]) || (1 != fc[1]))
+ __builtin_abort();
+
+ c = 1;
+ fc[0] = fc[1] = 0;
+
+ if (1 != sizeof(*(c ? (char(*)[ f(5, 0) ])0 : p)))
+ __builtin_abort();
+
+ // not a VLA
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // .. without sizeof
+
+ (c ? (char(*)[ f(5, 0) ])0 : p);
+
+ if ((1 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // VLA + void*, VLA side not evaluated
+
+ c = 1;
+ fc[0] = fc[1] = 0;
+
+ if (1 != sizeof(*(c ? p : (char(*)[ f(3, 1) ])0)))
+ __builtin_abort();
+
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // .. without sizeof
+
+ (c ? p : (char(*)[ f(3, 1) ])0);
+
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ c = 0;
+ fc[0] = fc[1] = 0;
+
+ if (1 != sizeof(*(c ? (char(*)[ f(5, 0) ])0 : p)))
+ __builtin_abort();
+
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ // .. without sizeof
+
+ (c ? (char(*)[ f(5, 0) ])0 : p);
+
+ if ((0 != fc[0]) || (0 != fc[1]))
+ __builtin_abort();
+
+ return 0;
+}
+