aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-09-13 10:37:49 -0700
committerIan Lance Taylor <iant@golang.org>2021-09-13 10:37:49 -0700
commite252b51ccde010cbd2a146485d8045103cd99533 (patch)
treee060f101cdc32bf5e520de8e5275db9d4236b74c /gcc/testsuite/gcc.dg
parentf10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff)
parent104c05c5284b7822d770ee51a7d91946c7e56d50 (diff)
downloadgcc-e252b51ccde010cbd2a146485d8045103cd99533.zip
gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz
gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/20030612-2.c20
-rw-r--r--gcc/testsuite/gcc.dg/Walloca-larger-than-4.c18
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-29.c22
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-30.c2
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-31.c8
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-32.c26
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-39.c49
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-52.c6
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-53.c6
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-58.c2
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-63.c6
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-64.c2
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-66.c12
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-69.c2
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-71.c7
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-71.h46
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-72.c7
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-73.c7
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-74.c7
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-75.c12
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-76.c35
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-77.c135
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-78.c109
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-79.c112
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-80.c96
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-81.c302
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-82.c258
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-83.c172
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-84.c65
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-85.c30
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-87.c48
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-88.c134
-rw-r--r--gcc/testsuite/gcc.dg/Warray-parameter-9.c54
-rw-r--r--gcc/testsuite/gcc.dg/Warray-parameter.c2
-rw-r--r--gcc/testsuite/gcc.dg/Wattributes-6.c36
-rw-r--r--gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c24
-rw-r--r--gcc/testsuite/gcc.dg/Wfree-nonheap-object-5.c46
-rw-r--r--gcc/testsuite/gcc.dg/Wfree-nonheap-object-6.c49
-rw-r--r--gcc/testsuite/gcc.dg/Wnonnull-4.c36
-rw-r--r--gcc/testsuite/gcc.dg/Wnonnull-6.c93
-rw-r--r--gcc/testsuite/gcc.dg/Wnonnull-7.c15
-rw-r--r--gcc/testsuite/gcc.dg/Wobjsize-1.c12
-rw-r--r--gcc/testsuite/gcc.dg/Wrestrict-8.c4
-rw-r--r--gcc/testsuite/gcc.dg/Wreturn-type3.c54
-rw-r--r--gcc/testsuite/gcc.dg/Wstring-compare-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/Wstring-compare.c10
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-11.c8
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-12.c6
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-15.c2
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-34.c8
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-41.c3
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-42.c12
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-43.c13
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-46.c5
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-47.c25
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-55.c10
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-61.c4
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-67.c92
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-68.c104
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-69.c84
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-70.c24
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-71.c113
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-72.c13
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-73.c35
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overread-6.c574
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overread.c32
-rw-r--r--gcc/testsuite/gcc.dg/Wunused-result.c50
-rw-r--r--gcc/testsuite/gcc.dg/Wunused-var-5.c23
-rw-r--r--gcc/testsuite/gcc.dg/Wunused-var-6.c14
-rw-r--r--gcc/testsuite/gcc.dg/Wvla-larger-than-5.c38
-rw-r--r--gcc/testsuite/gcc.dg/Wvla-parameter-10.c68
-rw-r--r--gcc/testsuite/gcc.dg/Wvla-parameter-11.c70
-rw-r--r--gcc/testsuite/gcc.dg/Wvla-parameter-12.c36
-rw-r--r--gcc/testsuite/gcc.dg/Wvla-parameter-13.c18
-rw-r--r--gcc/testsuite/gcc.dg/Wvla-parameter-2.c16
-rw-r--r--gcc/testsuite/gcc.dg/Wvla-parameter-3.c12
-rw-r--r--gcc/testsuite/gcc.dg/Wvla-parameter-9.c30
-rw-r--r--gcc/testsuite/gcc.dg/alias-7.c1
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/analyzer-decls.h8
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/asm-x86-1.c69
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/asm-x86-lp64-1.c131
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/asm-x86-lp64-2.c34
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c19
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c4
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/bitfields-1.c144
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/capacity-1.c106
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/capacity-2.c55
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/capacity-3.c82
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/clobbers-1.c97
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/clobbers-2.c72
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/data-model-1.c86
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/data-model-10.c3
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/data-model-20.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/data-model-22.c101
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/data-model-23.c26
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/dump-state.c14
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/explode-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/explode-2.c18
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/explode-2a.c51
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/feasibility-3.c133
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/fgets-1.c31
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/fread-1.c13
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/function-ptr-2.c5
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/function-ptr-4.c24
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/loop-0-up-to-n-by-1-with-iter-obj.c3
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/malloc-1.c7
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/malloc-ipa-13.c3
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/malloc-ipa-13a.c38
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/memset-1.c118
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/memset-CVE-2017-18549-1.c107
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/paths-8.c17
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pattern-test-2.c10
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/phi-1.c24
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/phi-2.c27
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr100011.c16
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr100546.c17
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr100615.c53
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr101143.c18
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr101503.c11
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr101547.c11
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr101570.c5
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr101721.c8
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr101837.c10
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr101875.c16
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr101962.c51
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr93355-localealias-feasibility.c7
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr93695-1.c53
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr94047.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr94851-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr96841.c4
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr98599-a.c8
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr98599-b.c1
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr98628.c3
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99042.c53
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99044-1.c60
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99044-2.c42
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99193-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99193-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99716-1.c40
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99716-2.c34
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99716-3.c16
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99771-1.c63
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99774-1.c61
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99774-2.c144
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99886.c21
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr99906.c3
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/realloc-1.c52
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/realloc-2.c80
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/sock-1.c112
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/sock-2.c20
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/strdup-1.c19
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/strndup-1.c1
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/switch.c141
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/symbolic-1.c8
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/symbolic-7.c46
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/symbolic-8.c11
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-array_index_mask_nospec.c74
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid-paravirt-1.c81
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid-paravirt-2.c135
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid.c46
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-rdmsr-paravirt.c210
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-rdmsr.c33
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-wfx_get_ps_timeout-full.c319
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-wfx_get_ps_timeout-reduced.c77
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/pr102225.c6
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c3
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/switch-2.c42
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/switch-3.c158
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/switch-4.c27
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/switch-5.c68
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/torture/ubsan-1.c60
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-1.c44
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-2.c14
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-3.c36
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-4.c39
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-6.c29
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-6b.c29
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-pr94713.c11
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-pr94714.c12
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/use-after-free-2.c8
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/use-after-free-3.c12
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/zlib-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/zlib-6.c13
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/zlib-6a.c47
-rw-r--r--gcc/testsuite/gcc.dg/array-quals-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-2.c1
-rw-r--r--gcc/testsuite/gcc.dg/attr-alloc_size-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/attr-alloc_size-7.c45
-rw-r--r--gcc/testsuite/gcc.dg/attr-alloc_size-8.c2
-rw-r--r--gcc/testsuite/gcc.dg/attr-nonstring-2.c22
-rw-r--r--gcc/testsuite/gcc.dg/attr-nonstring-4.c4
-rw-r--r--gcc/testsuite/gcc.dg/attr-noreturn.c64
-rw-r--r--gcc/testsuite/gcc.dg/attr-returns-nonnull.c58
-rw-r--r--gcc/testsuite/gcc.dg/attr-unavailable-1.c88
-rw-r--r--gcc/testsuite/gcc.dg/attr-unavailable-2.c6
-rw-r--r--gcc/testsuite/gcc.dg/attr-unavailable-3.c10
-rw-r--r--gcc/testsuite/gcc.dg/attr-unavailable-4.c88
-rw-r--r--gcc/testsuite/gcc.dg/attr-unavailable-5.c6
-rw-r--r--gcc/testsuite/gcc.dg/attr-unavailable-6.c11
-rw-r--r--gcc/testsuite/gcc.dg/attr-vector_size.c16
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-sra-1.c24
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-sra-2.c24
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-1.c5
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-12.c4
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-13.c10
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-14.c4
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-15.c26
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-16.c25
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-17.c15
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-18.c3
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-19.c26
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-2.c5
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-20.c4
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-21.c4
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-22.c3
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-23.c27
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-24.c3
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-25.c23
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-26.c23
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-3.c5
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-34.c60
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-36.c238
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-37.c156
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-4.c10
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-5.c6
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-6.c7
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-8.c8
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-9.c8
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-A.c7
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-B.c17
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-C.c5
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-H.c5
-rw-r--r--gcc/testsuite/gcc.dg/auto-init-uninit-I.c3
-rw-r--r--gcc/testsuite/gcc.dg/builtin-bswap-13.c329
-rw-r--r--gcc/testsuite/gcc.dg/builtin-bswap-14.c302
-rw-r--r--gcc/testsuite/gcc.dg/builtin-object-size-10.c6
-rw-r--r--gcc/testsuite/gcc.dg/builtins-70.c46
-rw-r--r--gcc/testsuite/gcc.dg/c11-digit-separators-1.c7
-rw-r--r--gcc/testsuite/gcc.dg/c11-qual-1.c11
-rw-r--r--gcc/testsuite/gcc.dg/c11-unproto-1.c24
-rw-r--r--gcc/testsuite/gcc.dg/c11-unproto-2.c21
-rw-r--r--gcc/testsuite/gcc.dg/c2x-attr-maybe_unused-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/c2x-digit-separators-1.c39
-rw-r--r--gcc/testsuite/gcc.dg/c2x-digit-separators-2.c25
-rw-r--r--gcc/testsuite/gcc.dg/c2x-digit-separators-3.c12
-rw-r--r--gcc/testsuite/gcc.dg/c2x-qual-1.c30
-rw-r--r--gcc/testsuite/gcc.dg/c2x-qual-2.c30
-rw-r--r--gcc/testsuite/gcc.dg/c2x-qual-3.c30
-rw-r--r--gcc/testsuite/gcc.dg/c2x-qual-4.c105
-rw-r--r--gcc/testsuite/gcc.dg/c2x-qual-5.c101
-rw-r--r--gcc/testsuite/gcc.dg/c2x-qual-6.c114
-rw-r--r--gcc/testsuite/gcc.dg/c2x-qual-7.c16
-rw-r--r--gcc/testsuite/gcc.dg/c2x-unproto-1.c20
-rw-r--r--gcc/testsuite/gcc.dg/c2x-unproto-2.c21
-rw-r--r--gcc/testsuite/gcc.dg/compat/struct-layout-1_generate.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/c11-elifdef-1.c16
-rw-r--r--gcc/testsuite/gcc.dg/cpp/c2x-elifdef-1.c57
-rw-r--r--gcc/testsuite/gcc.dg/cpp/c2x-elifdef-2.c63
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr100392.c5
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr100392.h4
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr100646-1.c5
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr100646-2.c6
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr101638.c7
-rw-r--r--gcc/testsuite/gcc.dg/cpp/ucnid-4-utf8.c4
-rw-r--r--gcc/testsuite/gcc.dg/cpp/ucnid-4.c4
-rw-r--r--gcc/testsuite/gcc.dg/cpp/ucnid-5-utf8.c17
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-1.c6
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-2.c10
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-struct-1.c23
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-union-1.c23
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-array-1.c31
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-1.c34
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-2.c26
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-3.c38
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-4.c23
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-cvr-quals-1.c53
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c46
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c30
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-float-1.c20
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-forward-1.c24
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-function-1.c18
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-function-2.c18
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-function-3.c22
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c44
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-pointers-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-pointers-2.c13
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-struct-1.c22
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-struct-2.c19
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-typedef-1.c82
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-union-1.c16
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-variables-1.c33
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-variables-2.c27
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf-variables-3.c36
-rw-r--r--gcc/testsuite/gcc.dg/debug/btf/btf.exp48
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-1.c6
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-2.c10
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-struct-1.c23
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-union-1.c26
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-array-1.c31
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-array-2.c38
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-array-3.c17
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-array-4.c13
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-mode-1.c23
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-used-1.c22
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-1.c30
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-2.c39
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-3.c16
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-4.c19
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-complex-1.c21
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-1.c66
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-2.c30
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-3.c25
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-4.c23
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-1.c7
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-2.c7
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-1.c21
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-2.c27
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-file-scope-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-float-1.c16
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-1.c40
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-2.c16
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-func-index-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-1.c24
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-2.c22
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-3.c21
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-4.c18
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-functions-1.c34
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-int-1.c17
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-objt-index-1.c30
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-1.c26
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-2.c25
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-preamble-1.c11
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-1.c38
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-2.c18
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-3.c20
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-4.c21
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-5.c19
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-6.c18
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-7.c18
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-8.c27
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-str-table-1.c26
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-2.c32
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-1.c65
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-2.c15
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-1.c21
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-2.c22
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-1.c68
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-2.c20
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-3.c24
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-1.c14
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-2.c17
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-3.c32
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-union-1.c14
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-2.c16
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf.exp48
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/inline5.c2
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/pr100515.c20
-rw-r--r--gcc/testsuite/gcc.dg/debug/pr57351.c1
-rw-r--r--gcc/testsuite/gcc.dg/diagnostic-input-charset-1.c17
-rw-r--r--gcc/testsuite/gcc.dg/diagnostic-input-utf8-bom.c14
-rw-r--r--gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges-2.c26
-rw-r--r--gcc/testsuite/gcc.dg/fold-convlshift-1.c20
-rw-r--r--gcc/testsuite/gcc.dg/fold-convlshift-2.c20
-rw-r--r--gcc/testsuite/gcc.dg/fold-convlshift-3.c8
-rw-r--r--gcc/testsuite/gcc.dg/fold-eqbswap-1.c113
-rw-r--r--gcc/testsuite/gcc.dg/fold-eqrotate-1.c46
-rw-r--r--gcc/testsuite/gcc.dg/fold-ior-4.c61
-rw-r--r--gcc/testsuite/gcc.dg/fold-ior-5.c17
-rw-r--r--gcc/testsuite/gcc.dg/format/c90-printf-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/format/gcc_diag-10.c20
-rw-r--r--gcc/testsuite/gcc.dg/format/gcc_diag-11.c2
-rw-r--r--gcc/testsuite/gcc.dg/format/strfmon-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/gcov-info-to-gcda.c60
-rw-r--r--gcc/testsuite/gcc.dg/gimplefe-45.c19
-rw-r--r--gcc/testsuite/gcc.dg/gimplefe-error-10.c8
-rw-r--r--gcc/testsuite/gcc.dg/gimplefe-error-11.c12
-rw-r--r--gcc/testsuite/gcc.dg/gimplefe-error-9.c9
-rw-r--r--gcc/testsuite/gcc.dg/goacc/loop-processing-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/gomp/atomic-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/gomp/barrier-2.c3
-rw-r--r--gcc/testsuite/gcc.dg/gomp/clause-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/gomp/declare-simd-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/gomp/declare-variant-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/gomp/nesting-1.c99
-rw-r--r--gcc/testsuite/gcc.dg/gomp/pr100508.c14
-rw-r--r--gcc/testsuite/gcc.dg/gomp/scan-1.c51
-rw-r--r--gcc/testsuite/gcc.dg/gomp/simd-clones-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/graphite/fuse-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/guality/example.c3
-rw-r--r--gcc/testsuite/gcc.dg/guality/guality.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/inline-params.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/loop-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr101905.c15
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr36728-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr36728-2.c30
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr36728-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr41353-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr41447-1.c1
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr43077-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr49888.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr54200.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr54519-1.c8
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr54519-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr54519-3.c8
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr54519-4.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr54519-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr54519-6.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr54693-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr54970.c16
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr56154-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr59776.c16
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr68860-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr68860-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr90074.c4
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr90716.c2
-rw-r--r--gcc/testsuite/gcc.dg/guality/sra-1.c8
-rw-r--r--gcc/testsuite/gcc.dg/ipa/inline-8.c4
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-sra-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-sra-19.c2
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-sra-23.c24
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-sra-24.c20
-rw-r--r--gcc/testsuite/gcc.dg/ipa/modref-1.c8
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr100600.c22
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr101066.c20
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr93385.c27
-rw-r--r--gcc/testsuite/gcc.dg/ipa/propmalloc-4.c2
-rw-r--r--gcc/testsuite/gcc.dg/ipa/remref-3.c23
-rw-r--r--gcc/testsuite/gcc.dg/ipa/remref-4.c31
-rw-r--r--gcc/testsuite/gcc.dg/ipa/remref-5.c38
-rw-r--r--gcc/testsuite/gcc.dg/ipa/remref-6.c24
-rw-r--r--gcc/testsuite/gcc.dg/local1.c2
-rw-r--r--gcc/testsuite/gcc.dg/loop-unswitch-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr101868_0.c33
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr101868_1.c23
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr101868_2.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr101868_3.c8
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr101949_0.c20
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr101949_1.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr48622_1.c6
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr99849_0.c23
-rw-r--r--gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-2.c15
-rw-r--r--gcc/testsuite/gcc.dg/nonnull-6.c15
-rw-r--r--gcc/testsuite/gcc.dg/old-style-asm-1.c5
-rw-r--r--gcc/testsuite/gcc.dg/optimize-bswapdi-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/optimize-bswapdi-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/optimize-bswapsi-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/optimize-bswapsi-3.c4
-rw-r--r--gcc/testsuite/gcc.dg/optimize-bswapsi-5.c4
-rw-r--r--gcc/testsuite/gcc.dg/optimize-bswapsi-6.c38
-rw-r--r--gcc/testsuite/gcc.dg/pch/valid-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c21
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c4
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c2
-rw-r--r--gcc/testsuite/gcc.dg/pointer-array-quals-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/pointer-array-quals-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr100142.c8
-rw-r--r--gcc/testsuite/gcc.dg/pr100225.c15
-rw-r--r--gcc/testsuite/gcc.dg/pr100239.c12
-rw-r--r--gcc/testsuite/gcc.dg/pr100292.c11
-rw-r--r--gcc/testsuite/gcc.dg/pr100349.c16
-rw-r--r--gcc/testsuite/gcc.dg/pr100373.c11
-rw-r--r--gcc/testsuite/gcc.dg/pr100414.c9
-rw-r--r--gcc/testsuite/gcc.dg/pr100464.c16
-rw-r--r--gcc/testsuite/gcc.dg/pr100509.c9
-rw-r--r--gcc/testsuite/gcc.dg/pr100512.c25
-rw-r--r--gcc/testsuite/gcc.dg/pr100521.c8
-rw-r--r--gcc/testsuite/gcc.dg/pr100547.c35
-rw-r--r--gcc/testsuite/gcc.dg/pr100563.c9
-rw-r--r--gcc/testsuite/gcc.dg/pr100590.c13
-rw-r--r--gcc/testsuite/gcc.dg/pr100619.c24
-rw-r--r--gcc/testsuite/gcc.dg/pr100781.c25
-rw-r--r--gcc/testsuite/gcc.dg/pr100788.c13
-rw-r--r--gcc/testsuite/gcc.dg/pr100790.c4
-rw-r--r--gcc/testsuite/gcc.dg/pr100791.c9
-rw-r--r--gcc/testsuite/gcc.dg/pr100887.c14
-rw-r--r--gcc/testsuite/gcc.dg/pr101008.c18
-rw-r--r--gcc/testsuite/gcc.dg/pr101028.c34
-rw-r--r--gcc/testsuite/gcc.dg/pr101062.c29
-rw-r--r--gcc/testsuite/gcc.dg/pr101156.c8
-rw-r--r--gcc/testsuite/gcc.dg/pr101170.c37
-rw-r--r--gcc/testsuite/gcc.dg/pr101171.c13
-rw-r--r--gcc/testsuite/gcc.dg/pr101172.c20
-rw-r--r--gcc/testsuite/gcc.dg/pr101223.c44
-rw-r--r--gcc/testsuite/gcc.dg/pr101254.c27
-rw-r--r--gcc/testsuite/gcc.dg/pr101266.c8
-rw-r--r--gcc/testsuite/gcc.dg/pr101294.c15
-rw-r--r--gcc/testsuite/gcc.dg/pr101384.c39
-rw-r--r--gcc/testsuite/gcc.dg/pr101403.c17
-rw-r--r--gcc/testsuite/gcc.dg/pr101419.c62
-rw-r--r--gcc/testsuite/gcc.dg/pr101496.c22
-rw-r--r--gcc/testsuite/gcc.dg/pr101497.c13
-rw-r--r--gcc/testsuite/gcc.dg/pr101741.c16
-rw-r--r--gcc/testsuite/gcc.dg/pr101858.c9
-rw-r--r--gcc/testsuite/gcc.dg/pr101938.c28
-rw-r--r--gcc/testsuite/gcc.dg/pr102141.c11
-rw-r--r--gcc/testsuite/gcc.dg/pr102152.c14
-rw-r--r--gcc/testsuite/gcc.dg/pr102207.c24
-rw-r--r--gcc/testsuite/gcc.dg/pr102224.c49
-rw-r--r--gcc/testsuite/gcc.dg/pr102269.c4
-rw-r--r--gcc/testsuite/gcc.dg/pr102273.c11
-rw-r--r--gcc/testsuite/gcc.dg/pr20126.c10
-rw-r--r--gcc/testsuite/gcc.dg/pr43864-4.c6
-rw-r--r--gcc/testsuite/gcc.dg/pr48552-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/pr48552-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/pr56727-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr68217.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr68317.c4
-rw-r--r--gcc/testsuite/gcc.dg/pr78213.c12
-rw-r--r--gcc/testsuite/gcc.dg/pr78888.c29
-rw-r--r--gcc/testsuite/gcc.dg/pr79214.c22
-rw-r--r--gcc/testsuite/gcc.dg/pr79412.c9
-rw-r--r--gcc/testsuite/gcc.dg/pr79972.c3
-rw-r--r--gcc/testsuite/gcc.dg/pr80776-1.c14
-rw-r--r--gcc/testsuite/gcc.dg/pr81192.c4
-rw-r--r--gcc/testsuite/gcc.dg/pr84877.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr86058.c19
-rw-r--r--gcc/testsuite/gcc.dg/pr86723.c63
-rw-r--r--gcc/testsuite/gcc.dg/pr89984.c20
-rw-r--r--gcc/testsuite/gcc.dg/pr93210.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-1.c35
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-2.c35
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-3.c97
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-4.c97
-rw-r--r--gcc/testsuite/gcc.dg/pr95580.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr96392.c33
-rw-r--r--gcc/testsuite/gcc.dg/pr96542.c27
-rw-r--r--gcc/testsuite/gcc.dg/pr96573.c20
-rw-r--r--gcc/testsuite/gcc.dg/pr97567-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr98099.c5
-rw-r--r--gcc/testsuite/gcc.dg/pr99122-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr99230.c40
-rw-r--r--gcc/testsuite/gcc.dg/pr99296.c7
-rw-r--r--gcc/testsuite/gcc.dg/pr99830.c10
-rw-r--r--gcc/testsuite/gcc.dg/pr99882.c37
-rw-r--r--gcc/testsuite/gcc.dg/pr99990.c12
-rw-r--r--gcc/testsuite/gcc.dg/pragma-diag-10.c20
-rw-r--r--gcc/testsuite/gcc.dg/pragma-diag-9.c141
-rw-r--r--gcc/testsuite/gcc.dg/predict-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/predict-9.c4
-rw-r--r--gcc/testsuite/gcc.dg/sancov/attribute.c27
-rw-r--r--gcc/testsuite/gcc.dg/shrink-wrap-loop.c54
-rw-r--r--gcc/testsuite/gcc.dg/sibcall-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/sms-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/sms-10.c3
-rw-r--r--gcc/testsuite/gcc.dg/sms-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/sms-3.c3
-rw-r--r--gcc/testsuite/gcc.dg/sms-4.c3
-rw-r--r--gcc/testsuite/gcc.dg/sms-6.c2
-rw-r--r--gcc/testsuite/gcc.dg/sms-8.c4
-rw-r--r--gcc/testsuite/gcc.dg/spellcheck-options-23.c5
-rw-r--r--gcc/testsuite/gcc.dg/spellcheck-stdlib.c10
-rw-r--r--gcc/testsuite/gcc.dg/sso-12.c27
-rw-r--r--gcc/testsuite/gcc.dg/sso-13.c24
-rw-r--r--gcc/testsuite/gcc.dg/sso-14.c56
-rw-r--r--gcc/testsuite/gcc.dg/sso-15.c36
-rw-r--r--gcc/testsuite/gcc.dg/sso-16.c100
-rw-r--r--gcc/testsuite/gcc.dg/sso-9.c27
-rw-r--r--gcc/testsuite/gcc.dg/strlenopt-73.c13
-rw-r--r--gcc/testsuite/gcc.dg/strlenopt-80.c2
-rw-r--r--gcc/testsuite/gcc.dg/strlenopt-95.c65
-rw-r--r--gcc/testsuite/gcc.dg/tls/pr99466-1.c8
-rw-r--r--gcc/testsuite/gcc.dg/tls/pr99466-2.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr100053.c25
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr100329.c16
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr100398.c13
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr100492.c26
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr100519.c13
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr100566.c36
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr100672.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr100778.c31
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr100923.c25
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr100934.c21
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101009.c17
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101025.c23
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101031.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101088.c45
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101105.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101151.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101173.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101202.c33
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101229.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101230-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101278.c21
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101394.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr101512.c11
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr102124.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr102139.c43
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr102149.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr69170.c2
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr70025.c5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr79334-0.c23
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr79334-1.c1
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr93491.c24
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr94947-1.c1
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr96513.c26
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr98601.c14
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr99652-1.c8
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr99652-2.c8
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr99694.c27
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr99824.c33
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr99880.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr99947.c18
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr99954.c30
-rw-r--r--gcc/testsuite/gcc.dg/torture/vshuf-4.inc4
-rw-r--r--gcc/testsuite/gcc.dg/torture/vshuf-8.inc4
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/indir-call-prof-2.c8
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/builtin-snprintf-11.c32
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/builtin-snprintf-12.c36
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-28.c30
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-29.c40
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-3.c25
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-26.c38
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-27.c20
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/evrp-trans.c144
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/evrp1.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/evrp11.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/evrp2.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/evrp3.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/evrp30.c16
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/evrp4.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/evrp6.c3
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ldist-33.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loop-interchange-16.c22
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/modref-4.c8
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/modref-6.c37
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/modref-7.c13
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/modref-8.c25
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/modref-9.c15
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/phi-opt-15.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/phi-opt-23.c44
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/phi-opt-24.c44
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25.c83
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/popcount4l.c3
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/popcount4ll.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/popcount5ll.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr100278.c17
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr100453.c18
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr100794.c20
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr101189.c17
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr101335.c17
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr101824.c19
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr20739.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr21001.c1
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr21294.c1
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr21417.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr21563.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr49039.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr61839_1.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr61839_2.c40
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr61839_3.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr64130.c3
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr66752-3.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr68198.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr70232.c12
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr77445-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr77445.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr83403-1.c1
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr83403-2.c1
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr84512.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr88087.c18
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr89430-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr89430-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr89430-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr89430-4.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr89430-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr89430-6.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr89430-7-comp-ref.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr89430-8-mem-ref-size.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr93781-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr94589-1.c21
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr95527-2.c57
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr96789.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c51
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr96928.c7
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr97009.c66
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr98265.C348
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr99473-1.c14
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c7
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-1.c20
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-2.c39
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-3.c41
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-4.c83
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-5.c80
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/split-path-4.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-40.c11
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-41.c11
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dce-3.c9
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-11.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-12.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-14.c1
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-18.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-6.c39
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c19
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-26.c17
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c3
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-29.c3
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-41.c16
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-42.c20
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-43.c22
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-48.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-91.c17
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-92.c21
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-93.c21
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-94.c17
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-15.c18
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-16.c19
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-17.c20
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-10.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-13.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-14.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-16.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-17.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-18.c212
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-4.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-6.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-7.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-8.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-9.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-11.c1
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-12.c7
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c1
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/tailcall-10.c12
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/tailcall-11.c12
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/tailcall-12.c12
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/tailcall-13.c15
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/tailrecursion-8.c11
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp02.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp03.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp05.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp06.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp07.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp09.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp19.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp20.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp24.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp33.c2
-rw-r--r--gcc/testsuite/gcc.dg/typedef-var-2.c5
-rw-r--r--gcc/testsuite/gcc.dg/ucnid-5-utf8.c2
-rw-r--r--gcc/testsuite/gcc.dg/ucnid-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/uninit-15-O0.c4
-rw-r--r--gcc/testsuite/gcc.dg/uninit-15.c10
-rw-r--r--gcc/testsuite/gcc.dg/uninit-23.c2
-rw-r--r--gcc/testsuite/gcc.dg/uninit-38.c39
-rw-r--r--gcc/testsuite/gcc.dg/uninit-41.c121
-rw-r--r--gcc/testsuite/gcc.dg/uninit-42.c87
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr100250.c29
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr100732.c21
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr101300.c53
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr101494.c60
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr101573.c10
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr44547.c61
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr55060.c30
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr59970.c79
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr61112.c89
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr61677.c26
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr61869.c47
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr65178.c21
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr65182.c44
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr89230-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr89230-2.c54
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr93100.c75
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr98583.c31
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pred-9_b.c3
-rw-r--r--gcc/testsuite/gcc.dg/uninit-suppress_3.c98
-rw-r--r--gcc/testsuite/gcc.dg/unroll-10.c13
-rw-r--r--gcc/testsuite/gcc.dg/unroll-9.c12
-rw-r--r--gcc/testsuite/gcc.dg/unroll-and-jam.c1
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-16.c7
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-39.c3
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-43.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-71.c32
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-72.c29
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-73.c29
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-74.c31
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-pr100778-1.c18
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-pr101207.c25
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c38
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-pr101615-1.c30
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-pr101615-2.c23
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c17
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-pr54400.c43
-rw-r--r--gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/gimplefe-40.c (renamed from gcc/testsuite/gcc.dg/gimplefe-40.c)0
-rw-r--r--gcc/testsuite/gcc.dg/vect/gimplefe-41.c (renamed from gcc/testsuite/gcc.dg/gimplefe-41.c)0
-rw-r--r--gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr101145.c187
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr101145.inc65
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr101145_1.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr101145_2.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr101145_3.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr101145inf.c25
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr101145inf.inc28
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr101145inf_1.c23
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr101445.c28
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr101505.c16
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr102046.c19
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr34195.c33
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr56541.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr65947-7.c5
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr71264.c3
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr97769.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr97832-1.c17
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr97832-2.c29
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr97832-3.c50
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr97832-4.c28
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr99102.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr99540.c20
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr99856.c33
-rw-r--r--gcc/testsuite/gcc.dg/vect/slp-21.c4
-rw-r--r--gcc/testsuite/gcc.dg/vect/slp-28.c5
-rw-r--r--gcc/testsuite/gcc.dg/vect/slp-3.c8
-rw-r--r--gcc/testsuite/gcc.dg/vect/slp-50.c20
-rw-r--r--gcc/testsuite/gcc.dg/vect/slp-perm-9.c8
-rw-r--r--gcc/testsuite/gcc.dg/vect/slp-reduc-11.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-bool-cmp.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-complex-5.c3
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-10.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-11.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-12.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-13.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-14.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-15.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-16.c13
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-17.c53
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-18.c53
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-19.c52
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-20.c52
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-21.c52
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-22.c52
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-9.c53
-rw-r--r--gcc/testsuite/gcc.dg/vla-stexp-1.c18
-rw-r--r--gcc/testsuite/gcc.dg/vla-stexp-2.c33
-rw-r--r--gcc/testsuite/gcc.dg/warn-strnlen-no-nul.c39
851 files changed, 22153 insertions, 909 deletions
diff --git a/gcc/testsuite/gcc.dg/20030612-2.c b/gcc/testsuite/gcc.dg/20030612-2.c
new file mode 100644
index 0000000..f9f212c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/20030612-2.c
@@ -0,0 +1,20 @@
+/* Derived from PR middle-end/168. */
+
+/* { dg-do compile } */
+/* { dg-options "-W" } */
+
+extern void foo ();
+
+unsigned char uc;
+unsigned short int usi;
+unsigned int ui;
+
+
+void bar()
+{
+ if (uc + usi >= ui) /* { dg-bogus "between signed and unsigned" } */
+ foo ();
+ if (uc * usi >= ui) /* { dg-bogus "between signed and unsigned" } */
+ foo ();
+}
+
diff --git a/gcc/testsuite/gcc.dg/Walloca-larger-than-4.c b/gcc/testsuite/gcc.dg/Walloca-larger-than-4.c
new file mode 100644
index 0000000..9d4c4e8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Walloca-larger-than-4.c
@@ -0,0 +1,18 @@
+/* PR middle-end/100425 - missing -Walloca-larger-than with -O0
+ { dg-do compile }
+ { dg-options "-O0 -Wall -Walloca-larger-than=128" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+void* alloca (size_t);
+
+void sink (void*);
+
+void warn_alloca_too_large (void)
+{
+ sink (alloca (1));
+ sink (alloca (128));
+ sink (alloca (129)); // { dg-warning "\\\[-Walloca-larger-than" }
+ sink (alloca (128 + 2)); // { dg-warning "\\\[-Walloca-larger-than" }
+ sink (alloca (1024)); // { dg-warning "\\\[-Walloca-larger-than" }
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-29.c b/gcc/testsuite/gcc.dg/Warray-bounds-29.c
index 72c5d1c..44e5bd3 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-29.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-29.c
@@ -44,7 +44,7 @@ void test_narrow (void)
T (p1[-1]);
T (p1[ 0]);
T (p1[ 1]);
- T (p1[ 2]); /* { dg-warning "array subscript \\\[3, 4] is outside array bounds of .char\\\[3]." } */
+ T (p1[ 2]); /* { dg-warning "array subscript 3 is outside array bounds of .char\\\[3]." } */
T (p1[ 3]); /* { dg-warning "array subscript \\\[4, 5] is outside array bounds of .char\\\[3]." } */
T (&p1[-3]); /* { dg-warning "array subscript \\\[-2, -1] is outside array bounds of .char\\\[3]." "bug" { xfail *-*-* } } */
@@ -55,7 +55,7 @@ void test_narrow (void)
T (&p1[ 2]);
T (&p1[ 3]); /* { dg-warning "array subscript \\\[4, 6] is outside array bounds of .char\\\[3]." "bug" { xfail *-*-* } } */
- T (p2[-4]); /* { dg-warning "intermediate array offset 4 is outside array bounds of .char\\\[3]." } */
+ T (p2[-4]); /* { dg-warning "subscript \\\[-2, -1\\\] is outside array bounds of .char\\\[3]." } */
T (p2[-3]);
T (p2[-2]);
T (p2[-1]);
@@ -64,19 +64,19 @@ void test_narrow (void)
/* Even though the lower bound of p3's offsets is in bounds, in order
to subtract 4 from p3 and get a dereferenceable pointer its value
would have to be out-of-bounds. */
- T (p3[-4]); /* { dg-warning "intermediate array offset 4 is outside array bounds of .char\\\[3]." } */
+ T (p3[-4]); /* { dg-warning "array subscript -1 is outside array bounds of .char\\\[3]." } */
T (p3[-3]);
T (p3[-2]);
T (p3[-1]);
- T (p3[ 0]); /* { dg-warning "array subscript \\\[3, 6] is outside array bounds of .char\\\[3]." } */
+ T (p3[ 0]); /* { dg-warning "array subscript 3 is outside array bounds of .char\\\[3]." } */
T (p4[-4]); /* { dg-warning "intermediate array offset 4 is outside array bounds of .char\\\[3]." } */
T (p4[-3]); /* { dg-warning "intermediate array offset 4 is outside array bounds of .char\\\[3]." } */
T (p4[-2]); /* { dg-warning "intermediate array offset 4 is outside array bounds of .char\\\[3]." } */
/* The final subscripts below are invalid. */
- T (p4[-1]); /* { dg-warning "array subscript \\\[3, 7] is outside array bounds of .char\\\[3]." } */
- T (p4[ 0]); /* { dg-warning "array subscript \\\[4, 8] is outside array bounds of .char\\\[3]." } */
+ T (p4[-1]); /* { dg-warning "array subscript 3 is outside array bounds of .char\\\[3]." } */
+ T (p4[ 0]); /* { dg-warning "array subscript \\\[4, 5] is outside array bounds of .char\\\[3]." } */
}
@@ -114,7 +114,7 @@ void test_wide (void)
T (p1[ 0]);
T (p1[ 1]);
T (p1[ 2]);
- T (p1[ 3]); /* { dg-warning "array subscript \\\[4, 5] is outside array bounds of .\[a-z \]+\\\[4]." } */
+ T (p1[ 3]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[4]." } */
T (&p1[-1]);
T (&p1[ 0]);
@@ -133,18 +133,18 @@ void test_wide (void)
/* Even though the lower bound of p3's offsets is in bounds, in order
to subtract 5 from p3 and get a dereferenceable pointer its value
would have to be out-of-bounds. */
- T (p3[-5]); /* { dg-warning "intermediate array offset 5 is outside array bounds of .\[a-z \]+\\\[4]." } */
+ T (p3[-5]); /* { dg-warning "array subscript \\\[-2, -1\\\] is outside array bounds of .\[a-z \]+\\\[4]." } */
T (p3[-4]);
T (p3[-3]);
T (p3[-2]);
T (p3[-1]);
T (p3[ 0]);
- T (p3[ 1]); /* { dg-warning "array subscript \\\[4, 7] is outside array bounds of .\[a-z \]+\\\[4]." } */
+ T (p3[ 1]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[4]." } */
- T (p4[-5]); /* { dg-warning "intermediate array offset 5 is outside array bounds of .\[a-z \]+\\\[4]." } */
+ T (p4[-5]); /* { dg-warning "array subscript -1 is outside array bounds of .\[a-z \]+\\\[4]." } */
T (p4[-4]);
T (p4[-3]);
T (p4[-2]);
T (p4[-1]);
- T (p4[ 0]); /* { dg-warning "array subscript \\\[4, 8] is outside array bounds of .\[a-z \]+\\\[4]." } */
+ T (p4[ 0]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[4]." } */
}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-30.c b/gcc/testsuite/gcc.dg/Warray-bounds-30.c
index 048a95d..b837ad0 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-30.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-30.c
@@ -120,7 +120,7 @@ void test_global_short_2dim_array (void)
T (&p[1]);
T (&p[2]);
T (&p[3]);
- T (&p[16]); /* { dg-warning "subscript 16 is \(above|outside\) array bounds of .short int\\\[3]" } */
+ T (&p[16]); /* { dg-warning "subscript 16 is \(above|outside\) array bounds of .short int\\\[3]" "pr??????" { xfail *-*-* } } */
T (&p[MAX]); /* { dg-warning "subscript -?\[0-9\]+ is \(above|outside\) array bounds of .short int\\\[3]" } */
}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-31.c b/gcc/testsuite/gcc.dg/Warray-bounds-31.c
index 389afaf..921461a 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-31.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-31.c
@@ -174,7 +174,7 @@ void narrow_ptr_deref_range (ptrdiff_t i, size_t j)
T (*p);
p = S1 + SR (2, 3);
- T (*p); /* { dg-warning "array subscript \\\[2, 3] is outside array bounds of .char\\\[2]." } */
+ T (*p); /* { dg-warning "array subscript 2 is outside array bounds of .char\\\[2]." } */
p = S1 + SR (9, 99);
T (*p); /* { dg-warning "array subscript \\\[9, 99] is outside array bounds of .char\\\[2]." } */
@@ -198,7 +198,7 @@ void narrow_ptr_deref_range (ptrdiff_t i, size_t j)
T (*p);
p = S8 + SR (9, 123);
- T (*p); /* { dg-warning "array subscript \\\[9, 123] is outside array bounds of .char\\\[9]." } */
+ T (*p); /* { dg-warning "array subscript 9 is outside array bounds of .char\\\[9]." } */
{
const char *p1 = S3 + i;
@@ -226,7 +226,7 @@ void narrow_ptr_deref_range (ptrdiff_t i, size_t j)
T (*p1);
T (*p2);
T (*p3);
- T (*p4); /* { dg-warning "array subscript \\\[4, \[0-9\]+] is outside array bounds of .char\\\[4]." } */
+ T (*p4); /* { dg-warning "array subscript 4 is outside array bounds of .char\\\[4]." } */
T (*p5); /* { dg-warning "array subscript \\\[5, \[0-9\]+] is outside array bounds of .char\\\[4]." } */
}
}
@@ -241,7 +241,7 @@ void narrow_ptr_index_range (void)
T (p[SR (-8, 0)]);
T (p[SR (0, MAX)]);
T (p[SR (1, 9)]);
- T (p[SR (8, 9)]); /* { dg-warning "array subscript \\\[8, 9] is outside array bounds of .char\\\[8]." } */
+ T (p[SR (8, 9)]); /* { dg-warning "array subscript 8 is outside array bounds of .char\\\[8]." } */
p = S7 + SR (4, 6);
T (p[5]); /* { dg-warning "array subscript \\\[9, 11] is outside array bounds of .char\\\[8]." } */
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-32.c b/gcc/testsuite/gcc.dg/Warray-bounds-32.c
index 9b5f333..02dac65 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-32.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-32.c
@@ -87,7 +87,7 @@ void wide_ptr_deref_range (ptrdiff_t i, size_t j)
T (*p);
p = W8 + SR (9, 123);
- T (*p); /* { dg-warning "array subscript \\\[9, 123] is outside array bounds of .\[a-z \]+\\\[9]." } */
+ T (*p); /* { dg-warning "array subscript 9 is outside array bounds of .\[a-z \]+\\\[9]." } */
}
void wide_ptr_index_range (void)
@@ -99,7 +99,7 @@ void wide_ptr_index_range (void)
T (p[SR (-8, 0)]);
T (p[SR (0, MAX)]);
T (p[SR (1, 9)]);
- T (p[SR (8, 9)]); /* { dg-warning "array subscript \\\[8, 9] is outside array bounds of .\[a-z \]+\\\[8]." } */
+ T (p[SR (8, 9)]); /* { dg-warning "array subscript 8 is outside array bounds of .\[a-z \]+\\\[8]." } */
p = W7 + SR (4, 6);
T (p[5]); /* { dg-warning "array subscript \\\[9, 11] is outside array bounds of .\[a-z \]+\\\[8]." } */
@@ -123,7 +123,7 @@ void wide_ptr_index_range_1 (void)
int i = SR (1, 2);
const wchar_t *p1 = W2 + i;
- T (p1[2]); /* { dg-warning "array subscript \\\[3, 4] is outside array bounds of .\[a-z \]+\\\[3]." } */
+ T (p1[2]); /* { dg-warning "array subscript 3 is outside array bounds of .\[a-z \]+\\\[3]." } */
}
}
@@ -140,17 +140,17 @@ void wide_ptr_index_range_chain (void)
T (p1[-1]);
T (p1[0]);
T (p1[1]);
- T (p1[2]); /* { dg-warning "array subscript \\\[3, 4] is outside array bounds of .\[a-z \]+\\\[3]." } */
+ T (p1[2]); /* { dg-warning "array subscript 3 is outside array bounds of .\[a-z \]+\\\[3]." } */
- T (p2[-5]); /* { dg-warning "array subscript \\\[-3, -1] is outside array bounds of .\[a-z \]+\\\[3]." } */
- T (p2[-4]);
+ T (p2[-5]); /* { dg-warning "array subscript \\\[-3, -2] is outside array bounds of .\[a-z \]+\\\[3]." } */
+ T (p2[-4]); /* { dg-warning "array subscript \\\[-2, -1] is outside array bounds of .\[a-z \]+\\\[3]." } */
T (p2[-1]);
T (p2[0]);
- T (p2[1]); /* { dg-warning "array subscript \\\[3, 5] is outside array bounds of .\[a-z \]+\\\[3]." } */
+ T (p2[1]); /* { dg-warning "array subscript 3 is outside array bounds of .\[a-z \]+\\\[3]." } */
- T (p3[0]); /* { dg-warning "array subscript \\\[3, 6] is outside array bounds of .\[a-z \]+\\\[3]." } */
- T (p3[1]); /* { dg-warning "array subscript \\\[4, 7] is outside array bounds of .\[a-z \]+\\\[3]." } */
- T (p3[9999]); /* { dg-warning "array subscript \\\[10002, 10005] is outside array bounds of .\[a-z \]+\\\[3]." "" { target size20plus} } */
+ T (p3[0]); /* { dg-warning "array subscript 3 is outside array bounds of .\[a-z \]+\\\[3]." } */
+ T (p3[1]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[3]." } */
+ T (p3[9999]); /* { dg-warning "array subscript 10002 is outside array bounds of .\[a-z \]+\\\[3]." "" { target size20plus} } */
/* { dg-warning "array subscript \\\[-6382, -6379] is outside array bounds of .\[a-z \]+\\\[3]." "" { target { ! size20plus } } .-1 } */
/* Large offsets are indistinguishable from negative values. */
T (p3[DIFF_MAX]); /* { dg-warning "array subscript" "bug" { xfail *-*-* } } */
@@ -166,9 +166,9 @@ void wide_ptr_index_range_chain (void)
T (p1[-2]);
T (p1[1]);
T (p1[2]);
- T (p1[3]); /* { dg-warning "array subscript \\\[4, 5] is outside array bounds of .\[a-z \]+\\\[4]." } */
+ T (p1[3]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[4]." } */
- T (p3[1]); /* { dg-warning "array subscript \\\[4, 7] is outside array bounds of .\[a-z \]+\\\[4]." } */
+ T (p3[1]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[4]." } */
}
}
@@ -180,5 +180,5 @@ void wide_ptr_index_range_4 (void)
const wchar_t *p3 = p2 + i;
const wchar_t *p4 = p3 + i;
- T (p4[1]); /* { dg-warning "array subscript \\\[5, 9] is outside array bounds of .\[a-z \]+\\\[5]." } */
+ T (p4[1]); /* { dg-warning "array subscript 5 is outside array bounds of .\[a-z \]+\\\[5]." } */
}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-39.c b/gcc/testsuite/gcc.dg/Warray-bounds-39.c
index 8317656..cb00fa9 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-39.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-39.c
@@ -5,6 +5,8 @@
{ dg-do compile }
{ dg-options "-O2 -Wall" } */
+#define NOIPA __attribute__ ((noipa))
+
typedef __SIZE_TYPE__ size_t;
extern void* memcpy (void*, const void*, size_t);
@@ -19,65 +21,65 @@ const char s1_0[1][0] = { };
char d[4];
-void* test_memcpy_s0_1 (void *d)
+NOIPA void* test_memcpy_s0_1 (void *d)
{
return memcpy (d, s0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memcpy_s0_2 (void *d)
+NOIPA void* test_memcpy_s0_2 (void *d)
{
return memcpy (d, s0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memcpy_s0_0_1 (void *d)
+NOIPA void* test_memcpy_s0_0_1 (void *d)
{
return memcpy (d, s0_0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memcpy_s0_0_2 (void *d)
+NOIPA void* test_memcpy_s0_0_2 (void *d)
{
return memcpy (d, s0_0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memcpy_s0_1_1 (void *d)
+NOIPA void* test_memcpy_s0_1_1 (void *d)
{
return memcpy (d, s0_1, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memcpy_s0_1_2 (void *d)
+NOIPA void* test_memcpy_s0_1_2 (void *d)
{
return memcpy (d, s0_1, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memcpy_s1_0_1 (void *d)
+NOIPA void* test_memcpy_s1_0_1 (void *d)
{
return memcpy (d, s1_0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memcpy_s1_0_2 (void *d)
+NOIPA void* test_memcpy_s1_0_2 (void *d)
{
return memcpy (d, s1_0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memmove_s0_1 (void *d)
+NOIPA void* test_memmove_s0_1 (void *d)
{
return memmove (d, s0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memmove_s0_2 (void *d)
+NOIPA void* test_memmove_s0_2 (void *d)
{
return memmove (d, s0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memmove_s0_0_1 (void *d)
+NOIPA void* test_memmove_s0_0_1 (void *d)
{
return memmove (d, s0_0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memmove_s0_0_2 (void *d)
+NOIPA void* test_memmove_s0_0_2 (void *d)
{
return memmove (d, s0_0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
@@ -90,59 +92,60 @@ const struct Empty e0_0[0][0] = { };
const struct Empty e0_1[0][1] = { };
const struct Empty e1_0[1][0] = { };
-void* test_memcpy_e_1 (void *d)
+NOIPA void* test_memcpy_e_1 (void *d)
{
return memcpy (d, &e, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memcpy_e0_1 (void *d)
+NOIPA void* test_memcpy_e0_1 (void *d)
{
return memcpy (d, e0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memcpy_e0_0_1 (void *d)
+NOIPA void* test_memcpy_e0_0_1 (void *d)
{
return memcpy (d, e0_0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memcpy_e0_1_1 (void *d)
+NOIPA void* test_memcpy_e0_1_1 (void *d)
{
return memcpy (d, e0_1, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-void* test_memcpy_e1_0_1 (void *d)
+NOIPA void* test_memcpy_e1_0_1 (void *d)
{
return memcpy (d, e1_0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-char* test_strcpy_s0 (char *d)
+NOIPA char*
+test_strcpy_s0 (char *d) /* { dg-bogus "-Warray-bounds" "pr101679" { xfail *-*-* } } */
{
return strcpy (d, s0); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-char* test_strcpy_s0_0 (char *d)
+NOIPA char* test_strcpy_s0_0 (char *d)
{
return strcpy (d, s0_0[0]); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-char* test_strncpy_s0_1 (char *d)
+NOIPA char* test_strncpy_s0_1 (char *d)
{
return strncpy (d, s0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-char* test_strncpy_s0_2 (char *d)
+NOIPA char* test_strncpy_s0_2 (char *d)
{
return strncpy (d, s0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-char* test_strncpy_s0_0_1 (char *d)
+NOIPA char* test_strncpy_s0_0_1 (char *d)
{
return strncpy (d, s0_0[0], 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
-char* test_strncpy_s0_0_2 (char *d)
+NOIPA char* test_strncpy_s0_0_2 (char *d)
{
return strncpy (d, s0_0[0], 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */
}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-52.c b/gcc/testsuite/gcc.dg/Warray-bounds-52.c
index 729ad45..c7217ad 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-52.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-52.c
@@ -83,17 +83,17 @@ void ptr_idx_range (void)
i = SR (0, 1);
- T (i, (int[]){ }); // { dg-warning "array subscript \\\[0, 1] is outside array bounds of 'int\\\[0]'" }
+ T (i, (int[]){ }); // { dg-warning "array subscript 0 is outside array bounds of 'int\\\[0]'" }
T (i, (int[]){ 1 });
i = SR (1, 2);
- T (i, (int[]){ 1 }); // { dg-warning "array subscript \\\[1, 2] is outside array bounds of 'int\\\[1]'" }
+ T (i, (int[]){ 1 }); // { dg-warning "array subscript 1 is outside array bounds of 'int\\\[1]'" }
i = SR (2, 3);
T (i, (int[]){ 1, 2, 3 });
i = SR (3, 4);
- T (i, (int[]){ 2, 3, 4 }); // { dg-warning "array subscript \\\[3, 4] is outside array bounds of 'int\\\[3]'" }
+ T (i, (int[]){ 2, 3, 4 }); // { dg-warning "array subscript 3 is outside array bounds of 'int\\\[3]'" }
}
/* Some of the invalid accesses above also trigger -Wuninitialized.
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-53.c b/gcc/testsuite/gcc.dg/Warray-bounds-53.c
index 80db314..591cca2 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-53.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-53.c
@@ -83,17 +83,17 @@ void ptr_idx_range (void)
i = SR (0, 1);
- T (i, (int[]){ }); // { dg-warning "array subscript \\\[0, 1] is outside array bounds of 'int\\\[0]'" }
+ T (i, (int[]){ }); // { dg-warning "array subscript 0 is outside array bounds of 'int\\\[0]'" }
T (i, (int[]){ 1 });
i = SR (1, 2);
- T (i, (int[]){ 1 }); // { dg-warning "array subscript \\\[1, 2] is outside array bounds of 'int\\\[1]'" }
+ T (i, (int[]){ 1 }); // { dg-warning "array subscript 1 is outside array bounds of 'int\\\[1]'" }
i = SR (2, 3);
T (i, (int[]){ 1, 2, 3 });
i = SR (3, 4);
- T (i, (int[]){ 2, 3, 4 }); // { dg-warning "array subscript \\\[3, 4] is outside array bounds of 'int\\\[3]'" }
+ T (i, (int[]){ 2, 3, 4 }); // { dg-warning "array subscript 3 is outside array bounds of 'int\\\[3]'" }
}
/* Some of the invalid accesses above also trigger -Wuninitialized.
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-58.c b/gcc/testsuite/gcc.dg/Warray-bounds-58.c
index 849457e5..616145b 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-58.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-58.c
@@ -36,7 +36,7 @@ extern struct Ax ax;
void fax_extern (void)
{
- sink (strlen (ax.a - 2)); // { dg-warning "\\\[-Warray-bounds" "pr93514" { xfail *-*-* } }
+ sink (strlen (ax.a - 2)); // { dg-warning "\\\[-Warray-bounds" "pr93514" }
sink (strlen (ax.a - 1)); // { dg-warning "\\\[-Warray-bounds" "pr93514" { xfail *-*-* } }
sink (strlen (ax.a));
sink (strlen (ax.a + 123));
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-63.c b/gcc/testsuite/gcc.dg/Warray-bounds-63.c
index a3fc918..530e2c5 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-63.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-63.c
@@ -14,7 +14,7 @@ void sink (void*);
void byte_store_to_decl (void)
{
- struct S6 { char a[6]; } s; // { dg-message "referencing 's'" }
+ struct S6 { char a[6]; } s; // { dg-message "at offset 6 into object 's' of size 6" "note" }
char *p = (char*)&s;
@@ -27,7 +27,7 @@ void byte_store_to_decl (void)
void word_store_to_decl (void)
{
- struct S6 { char a[6]; } s; // { dg-message "referencing 's'" }
+ struct S6 { char a[6]; } s; // { dg-message "at offset 5 into object 's' of size 6" "note" }
char *p = (char*)&s;
@@ -43,7 +43,7 @@ void word_store_to_decl (void)
void word_store_to_alloc (void)
{
struct S6 { char a[6]; } *p;
- p = alloca (sizeof *p); // { dg-message "referencing an object of size 6 allocated by 'alloca'" }
+ p = alloca (sizeof *p); // { dg-message "at offset 5 into object of size 6 allocated by 'alloca'" "note" }
int16_t *q = (int16_t*)((char*)p + 1);
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-64.c b/gcc/testsuite/gcc.dg/Warray-bounds-64.c
index 88b88de..f5ebc3d 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-64.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-64.c
@@ -7,7 +7,7 @@
asks for.
{ dg-do compile }
- { dg-options "-O2 -Wall -Warray-parameter -Wno-vla-paramater" } */
+ { dg-options "-O2 -Wall -Warray-parameter -Wno-vla-parameter" } */
#define NOIPA __attribute__ ((noipa))
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-66.c b/gcc/testsuite/gcc.dg/Warray-bounds-66.c
index c61891f..6ab3398 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-66.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-66.c
@@ -117,14 +117,14 @@ void test_alloca_int16_range (unsigned n)
}
{
- p = alloca (UR (0, 1)); // { dg-message "object of size between 0 and 1 allocated by '__builtin_alloca'" }
+ p = alloca (UR (0, 1)); // { dg-message "at offset \\d+ into object of size \\\[0, 1] allocated by '__builtin_alloca'" "note" }
sink (p);
T (p[0]); // { dg-warning "subscript 'int16_t {aka short int}\\\[0\\\]' is partly outside array bounds of 'unsigned char\\\[1]'" }
T (p[1]); // { dg-warning "subscript 1 is outside array bounds of 'int16_t\\\[0]'" }
}
{
- p = alloca (UR (0, 2)); // { dg-message "object of size between 0 and 2 allocated by '__builtin_alloca'" }
+ p = alloca (UR (0, 2)); // { dg-message "at offset \\d+ into object of size \\\[0, 2] allocated by '__builtin_alloca'" "note" }
sink (p);
sink (p[0]);
sink (p[1]); // { dg-warning "subscript 1 is outside array bounds of 'int16_t\\\[1]'" }
@@ -132,7 +132,7 @@ void test_alloca_int16_range (unsigned n)
}
{
- p = alloca (UR (0, 3)); // { dg-message "object of size between 0 and 3 allocated by '__builtin_alloca'" }
+ p = alloca (UR (0, 3)); // { dg-message "at offset \\d+ into object of size \\\[0, 3] allocated by '__builtin_alloca'" "note" }
sink (p);
T (p[0]);
T (p[1]); // { dg-warning "subscript 'int16_t {aka short int}\\\[1\\\]' is partly outside array bounds of 'unsigned char\\\[3]'" }
@@ -141,7 +141,7 @@ void test_alloca_int16_range (unsigned n)
}
{
- p = alloca (UR (1, 3)); // { dg-message "object of size between 1 and 3 allocated by '__builtin_alloca'" }
+ p = alloca (UR (1, 3)); // { dg-message "at offset 1|2|3 into object of size \\\[1, 3] allocated by '__builtin_alloca'" "note" }
sink (p);
T (p[0]);
T (p[1]); // { dg-warning "subscript 'int16_t {aka short int}\\\[1\\\]' is partly outside array bounds of 'unsigned char\\\[3]'" }
@@ -150,7 +150,7 @@ void test_alloca_int16_range (unsigned n)
}
{
- p = alloca (UR (2, 3)); // { dg-message "object of size between 2 and 3 allocated by '__builtin_alloca'" }
+ p = alloca (UR (2, 3)); // { dg-message "at offset 2|4 into object of size \\\[2, 3] allocated by '__builtin_alloca'" "note" }
sink (p);
T (p[0]);
T (p[1]); // { dg-warning "subscript 'int16_t {aka short int}\\\[1\\\]' is partly outside array bounds of 'unsigned char\\\[3]'" }
@@ -159,7 +159,7 @@ void test_alloca_int16_range (unsigned n)
}
{
- p = alloca (UR (3, 4)); // { dg-message "object of size between 3 and 4 allocated by '__builtin_alloca'" }
+ p = alloca (UR (3, 4)); // { dg-message "at offset 4|6 into object of size \\\[3, 4] allocated by '__builtin_alloca'" "note" }
sink (p);
T (p[0]);
T (p[1]);
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-69.c b/gcc/testsuite/gcc.dg/Warray-bounds-69.c
index 5a95577..80503f8 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-69.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-69.c
@@ -1,6 +1,6 @@
/* Verify that storing a bigger vector into smaller space is diagnosed.
{ dg-do compile }
- { dg-options "-O2 -Warray-bounds" } */
+ { dg-options "-O2 -Warray-bounds -Wno-stringop-overflow" } */
typedef __INT16_TYPE__ int16_t;
typedef __attribute__ ((__vector_size__ (32))) char C32;
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-71.c b/gcc/testsuite/gcc.dg/Warray-bounds-71.c
new file mode 100644
index 0000000..425bb12
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-71.c
@@ -0,0 +1,7 @@
+/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic
+ works at any call site in an inlining stack
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+#define IGNORE '1'
+#include "Warray-bounds-71.h"
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-71.h b/gcc/testsuite/gcc.dg/Warray-bounds-71.h
new file mode 100644
index 0000000..89d1068
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-71.h
@@ -0,0 +1,46 @@
+/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic
+ works at any call site in an inlining stack
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+int a[4];
+
+void f1 (int *p, int i)
+{
+#pragma GCC diagnostic push
+#if IGNORE == '1'
+# pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+ p[i + 1] = 0;
+#pragma GCC diagnostic pop
+}
+
+void f2 (int *p, int i)
+{
+#pragma GCC diagnostic push
+#if IGNORE == '2'
+# pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+ f1 (p + 1, i + 1);
+#pragma GCC diagnostic pop
+}
+
+void f3 (int *p, int i)
+{
+#pragma GCC diagnostic push
+#if IGNORE == '3'
+# pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+ f2 (p + 1, i + 1);
+#pragma GCC diagnostic pop
+}
+
+void f4 (void)
+{
+#pragma GCC diagnostic push
+#if IGNORE == '4'
+# pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+ f3 (a, 1);
+#pragma GCC diagnostic pop
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-72.c b/gcc/testsuite/gcc.dg/Warray-bounds-72.c
new file mode 100644
index 0000000..eb3f664
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-72.c
@@ -0,0 +1,7 @@
+/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic
+ works at any call site in an inlining stack
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+#define IGNORE '2'
+#include "Warray-bounds-71.h"
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-73.c b/gcc/testsuite/gcc.dg/Warray-bounds-73.c
new file mode 100644
index 0000000..50e2083
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-73.c
@@ -0,0 +1,7 @@
+/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic
+ works at any call site in an inlining stack
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+#define IGNORE '3'
+#include "Warray-bounds-71.h"
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-74.c b/gcc/testsuite/gcc.dg/Warray-bounds-74.c
new file mode 100644
index 0000000..c59a876
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-74.c
@@ -0,0 +1,7 @@
+/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic
+ works at any call site in an inlining stack
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+#define IGNORE '4'
+#include "Warray-bounds-71.h"
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-75.c b/gcc/testsuite/gcc.dg/Warray-bounds-75.c
new file mode 100644
index 0000000..306b176
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-75.c
@@ -0,0 +1,12 @@
+/* Sanity test for Warray-bounds-7[1-4].c. Also verify the expected
+ inlining stack.
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+#include "Warray-bounds-71.h"
+
+// { dg-regexp "In function 'f1'," "In function f1" { target *-*-* } 0 }
+// { dg-regexp "inlined from 'f2' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f2" { target *-*-* } 0 }
+// { dg-regexp "inlined from 'f3' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f3" { target *-*-* } 0 }
+// { dg-regexp "inlined from 'f4' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f4" { target *-*-* } 0 }
+// { dg-message "Warray-bounds-71.h:\\d+:\\d+: warning: array subscript 6 is outside array bounds of 'int\\\[4]'" "warning" { target *-*-* } 0 }
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-76.c b/gcc/testsuite/gcc.dg/Warray-bounds-76.c
new file mode 100644
index 0000000..6711dc4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-76.c
@@ -0,0 +1,35 @@
+/* PR tree-optimization/86650 - -Warray-bounds missing inlining context
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+static void f0 (int *p, int i)
+{
+ p[i] = 0; // { dg-warning "\\\[-Warray-bounds" }
+}
+
+// Expect two instances of the text below:
+// { dg-regexp "In function 'f0'," "first f0 prefix" { target *-*-* } 0 }
+// { dg-regexp "In function 'f0'," "second f0 prefix" { target *-*-* } 0 }
+
+static void f1 (int *p, int i) { f0 (p + 1, i + 1); }
+static void f2 (int *p, int i) { f1 (p + 1, i + 1); }
+
+extern int a2[2]; // { dg-note "'a2'" }
+
+void foo (void)
+{
+ f1 (a2 + 1, 1);
+}
+
+// { dg-regexp " +inlined from 'foo' at \[^:\]+Warray-bounds-76.c:21:\\d+:" "inlined from foo" }
+
+extern int a3[3]; // { dg-note "'a3'" }
+
+void bar (void)
+{
+ f2 (a3 + 1, 1);
+}
+
+// { dg-regexp " +inlined from 'f1' at \[^:\]+Warray-bounds-76.c:14:\\d+," "inlined from f1" }
+// { dg-regexp " +inlined from 'f2' at \[^:\]+Warray-bounds-76.c:15:\\d+," "inlined from f2" }
+// { dg-regexp " +inlined from 'bar' at \[^:\]+Warray-bounds-76.c:30:\\d+:" "inlined from bar" }
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-77.c b/gcc/testsuite/gcc.dg/Warray-bounds-77.c
new file mode 100644
index 0000000..6487613
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-77.c
@@ -0,0 +1,135 @@
+/* PR middle-end/100137 - -Warray-bounds false positive on varying offset
+ plus negative
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+extern char ax[], a1[1], a2[2], a3[3], a4[4], a5[5];
+
+int* ptr;
+#define X (*ptr++)
+
+
+__attribute__ ((noipa)) void
+array_plus_var_minus_cstint (int i, int j)
+{
+ {
+ const char *p = ax;
+ p += i;
+ X = p[-1];
+ X = p[-123];
+ }
+
+ {
+ const char *p = a1;
+ p += i;
+ X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-2]; // { dg-warning "\\\[-Warray-bounds" }
+ X = p[-3]; // { dg-warning "\\\[-Warray-bounds" }
+ X = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *p = a2;
+ p += i;
+ X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-3]; // { dg-warning "\\\[-Warray-bounds" }
+ X = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *p = a3;
+ p += i;
+ X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ X = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *p = a4;
+ p += i;
+ X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-4]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ X = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *p = a5;
+ p += i;
+ p += j;
+ X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-4]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-5]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+}
+
+
+__attribute__ ((noipa)) void
+array_plus_var_minus_cstlong (long i, long j)
+{
+ {
+ const char *p = ax;
+ p += i;
+ X = p[-1];
+ X = p[-123];
+ }
+
+ {
+ const char *p = a1;
+ p += i;
+ X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-2]; // { dg-warning "\\\[-Warray-bounds" }
+ X = p[-3]; // { dg-warning "\\\[-Warray-bounds" }
+ X = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *p = a2;
+ p += i;
+ X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-3]; // { dg-warning "\\\[-Warray-bounds" }
+ X = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *p = a3;
+ p += i;
+ X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ X = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *p = a4;
+ p += i;
+ X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-4]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ X = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *p = a5;
+ p += i;
+ p += j;
+ X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-4]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-5]; // { dg-bogus "\\\[-Warray-bounds" }
+ X = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-78.c b/gcc/testsuite/gcc.dg/Warray-bounds-78.c
new file mode 100644
index 0000000..73c335f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-78.c
@@ -0,0 +1,109 @@
+/* PR tree-optimization/99475 - bogus -Warray-bounds accessing an array
+ element of empty structs
+ { dg-do compile }
+ { dg-options "-O2 -Wall -Wno-strict-aliasing" } */
+
+typedef _Bool bool;
+
+#define NOIPA __attribute__ ((noipa))
+
+struct S { };
+
+extern struct S sa3[3];
+extern struct S sa2_3[2][3];
+extern struct S sa3_4_5[3][4][5];
+
+void sink (void*);
+
+
+NOIPA void access_sa3 (void)
+{
+ ((bool*)sa3)[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ ((bool*)sa3)[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ ((bool*)sa3)[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ ((bool*)sa3)[3] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+}
+
+NOIPA void access_sa3_ptr (void)
+{
+ bool *p = (bool*)&sa3[0];
+
+ p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[3] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+}
+
+NOIPA void access_sa2_3_ptr (void)
+{
+ bool *p = (bool*)&sa2_3[0][0];
+
+ p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[6] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+}
+
+NOIPA void access_sa3_4_5_ptr (struct S s, int i)
+{
+ bool *p = (bool*)&sa3_4_5[0][0][0];
+
+ p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[60] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+}
+
+
+NOIPA void access_vla3 (struct S s, unsigned n)
+{
+ struct S vla3[3 < n ? 3 : n];
+
+ ((bool*)vla3)[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ ((bool*)vla3)[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ ((bool*)vla3)[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ ((bool*)vla3)[3] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+
+ sink (vla3);
+}
+
+NOIPA void access_vla3_ptr (struct S s, unsigned n)
+{
+ struct S vla3[3 < n ? 3 : n];
+ bool *p = (bool*)&vla3[0];
+
+ p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[3] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+
+ sink (vla3);
+}
+
+NOIPA void access_vla2_3_ptr (struct S s, unsigned n)
+{
+ struct S vla2_3[2 < n ? 2 : n][3 < n ? 3 : n];
+ bool *p = (bool*)&vla2_3[0][0];
+
+ p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[6] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+
+ sink (vla2_3);
+}
+
+NOIPA void access_vla3_4_5_ptr (struct S s, unsigned n)
+{
+ struct S vla3_4_5[3 < n ? 3 : n][4 < n ? 4 : n][5 < n ? 5 : n];
+ bool *p = (bool*)&vla3_4_5[0][0][0];
+
+ p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+ p[60] = __LINE__; // { dg-warning "\\\[-Warray-bounds" }
+
+ sink (vla3_4_5);
+}
+
+// { dg-prune-output "empty struct has size 0 in C" }
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-79.c b/gcc/testsuite/gcc.dg/Warray-bounds-79.c
new file mode 100644
index 0000000..b44ac9d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-79.c
@@ -0,0 +1,112 @@
+/* PR tree-optimization/99475 - bogus -Warray-bounds accessing an array
+ element of empty structs
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+struct S
+{
+#if SOME_CONFIG_MACRO
+ /* Suppose the contents are empty in the development configuration
+ but non-empty in others. Out of bounds accesses to elements of
+ the arrays below should be diagnosed in all configurations,
+ including when S is empty, even if they are folded away. */
+ int member;
+#endif
+};
+
+extern struct S sa3[3];
+extern struct S sa2_3[2][3];
+extern struct S sa3_4_5[3][4][5];
+
+void sink (void*);
+
+
+void access_sa3 (void)
+{
+ sa3[0] = (struct S){ };
+ sa3[1] = (struct S){ };
+ sa3[2] = (struct S){ };
+ sa3[3] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
+}
+
+void access_sa3_ptr (void)
+{
+ struct S *p = &sa3[0];
+
+ p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[3] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
+}
+
+void access_sa2_3_ptr (void)
+{
+ struct S *p = &sa2_3[0][0];
+
+ p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[6] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
+}
+
+void access_sa3_4_5_ptr (struct S s, int i)
+{
+ struct S *p = &sa3_4_5[0][0][0];
+
+ p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[60] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
+}
+
+
+void access_vla3 (struct S s, unsigned n)
+{
+ struct S vla3[3 < n ? 3 : n];
+
+ vla3[0] = (struct S){ };
+ vla3[1] = (struct S){ };
+ vla3[2] = (struct S){ };
+ vla3[3] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
+
+ sink (vla3);
+}
+
+void access_vla3_ptr (struct S s, unsigned n)
+{
+ struct S vla3[3 < n ? 3 : n];
+ struct S *p = &vla3[0];
+
+ p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[3] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
+
+ sink (vla3);
+}
+
+void access_vla2_3_ptr (struct S s, unsigned n)
+{
+ struct S vla2_3[2 < n ? 2 : n][3 < n ? 3 : n];
+ struct S *p = &vla2_3[0][0];
+
+ p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[6] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
+
+ sink (vla2_3);
+}
+
+void access_vla3_4_5_ptr (struct S s, unsigned n)
+{
+ struct S vla3_4_5[3 < n ? 3 : n][4 < n ? 4 : n][5 < n ? 5 : n];
+ struct S *p = &vla3_4_5[0][0][0];
+
+ p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" }
+ p[60] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } }
+
+ sink (vla3_4_5);
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-80.c b/gcc/testsuite/gcc.dg/Warray-bounds-80.c
new file mode 100644
index 0000000..4ef32fb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-80.c
@@ -0,0 +1,96 @@
+/* PR tree-optimization/101397 - spurious warning writing to the result
+ of stpcpy minus 1
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+char* stpcpy (char*, const char*);
+
+void sink (int, ...);
+
+extern char ax[], a3[3], a5[5], *s;
+
+volatile int x;
+
+void test_stpcpy (int i)
+{
+ {
+ char *p = stpcpy (ax, s);
+ x = p[-9]; // { dg-bogus "\\\[-Warray-bounds" }
+ x = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ x = p[ 0];
+ x = p[+9];
+ }
+
+ {
+ char *p = stpcpy (a3, s);
+ x = p[-2]; // { dg-bogus "\\\[-Warray-bounds" }
+ x = p[-1]; // { dg-bogus "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = stpcpy (a3, s);
+ x = p[-3]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-2], p[-1], p[0], p[1], p[2]);
+ x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ /* Stpcpy always returns a pointer to the copied nul (which must
+ exist) and never a past-the-end pointer. As a result, P below
+ is in [a5, a5 + 4]. */
+ char *p = stpcpy (a5, s);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = stpcpy (a5 + 1, s);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3]);
+ x = p[ 4]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = stpcpy (a5 + 2, s);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2]);
+ x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = stpcpy (a5 + 3, s);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1]);
+ x = p[ 2]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ /* Because strlen (a3) is at most 2, the stpcpy call must return
+ a pointer in the range [ax, ax + 2], and so -3 is necessarily
+ out of bounds. */
+ char *p = stpcpy (ax, a3);
+ p[-3] = 1; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ if (i >= 0)
+ i = -1;
+
+ char *p = stpcpy (a3, s);
+ x = p[i]; // { dg-bogus "\\\[-Warray-bounds" }
+ }
+
+ {
+ if (i >= -3)
+ i = -3;
+
+ char *p = stpcpy (a3, s);
+ p[i] = 1; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-81.c b/gcc/testsuite/gcc.dg/Warray-bounds-81.c
new file mode 100644
index 0000000..27e725d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-81.c
@@ -0,0 +1,302 @@
+/* PR tree-optimization/101397 - spurious warning writing to the result
+ of stpcpy minus 1
+ Verify warnings for indexing into a pointer returned from stpncpy.
+ The call stpncpy(S1, S2, N) returns the address of the copy of
+ the first NUL is it exists or &S1[N] otherwise.
+ { dg-do compile }
+ { dg-options "-O2 -Wall -Wno-stringop-truncation" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+void* calloc (size_t, size_t);
+char* stpncpy (char*, const char*, size_t);
+
+void sink (int, ...);
+
+extern char ax[], a3[3], a5[5], a7[7], a9[9], *s;
+
+volatile int x;
+
+/* Verify warnings for indexing into the result of stpncpy with a source
+ pointing to an array of unknown bound. */
+
+void test_stpncpy_from_ptr (int i, int n)
+{
+ {
+ // P is in [ax, ax + 5].
+ char *p = stpncpy (ax, s, 5);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-5], p[-1], p[0], p[9]);
+ }
+
+ {
+ // P is in [a5, a5 + 3].
+ char *p = stpncpy (a5, s, 3);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-3], p[-2], p[-1], p[0]);
+ sink (p[ 1], p[ 2], p[ 3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ // P is in [ax, ax + 4].
+ char *p = stpncpy (a5, s, 4);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[ 1], p[ 2], p[ 3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ // P is in [ax, ax + 5].
+ char *p = stpncpy (a5, s, n);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-5], p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[ 1], p[ 2], p[ 3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ // P is in [ax, ax + 4].
+ char *p = stpncpy (a5, s, 4);
+
+ if (i > -1) i = -1;
+ x = p[i];
+
+ if (i > -2) i = -2;
+ x = p[i];
+
+ if (i > -3) i = -3;
+ x = p[i];
+
+ if (i > -4) i = -4;
+ x = p[i];
+
+ if (i > -5) i = -5;
+ x = p[i]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+}
+
+/* Verify warnings for indexing into the result of stpncpy with a source
+ an array of size 5. */
+
+void test_stpncpy_from_a5 (int i, int n, int n3_9)
+{
+ {
+ // The returned pointer is in [ax, ax + 3].
+ char *p = stpncpy (ax, a5, 3);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-3], p[-2], p[-1], p[0], p[1], p[99]);
+ }
+
+ {
+ // The returned pointer is in [ax, ax + 5].
+ char *p = stpncpy (ax, a5, 5);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-5];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 9];
+ }
+
+ {
+ //The returned pointer is in [ax, ax + 5] even though n is not known.
+ char *p = stpncpy (ax, a5, n);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-5], p[-4], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[9], p[99]);
+ }
+
+
+ {
+ // The returned pointer is in [a3, a3 + 3].
+ char *p = stpncpy (a3, a5, 3);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-3], p[-2], p[-1], p[0]);
+ sink (p[ 1], p[ 2]);
+ x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ // The returned pointer is in [a3, a3 + 3].
+ char *p = stpncpy (a3, a5, n);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-3], p[-2], p[-1], p[0]);
+ sink (p[ 1], p[ 2]);
+ x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ if (n3_9 < 3 || 9 < n3_9)
+ n3_9 = 3;
+
+ // The returned pointer is in [a3, a3 + 3].
+ char *p = stpncpy (a3, a5, n3_9);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-3], p[-2], p[-1], p[0]);
+ sink (p[ 1], p[ 2]);
+ x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = stpncpy (a3, a5, 3);
+
+ if (i > -1) i = -1;
+ x = p[i];
+
+ if (i > -2) i = -2;
+ x = p[i];
+
+ if (i > -3) i = -3;
+ x = p[i];
+
+ if (i > -4) i = -4;
+ x = p[i]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+}
+
+
+/* Verify warnings for indexing into the result of stpncpy with a source
+ an array of size 7. */
+
+void test_stpncpy_from_a7 (int i, int n, int n3_9)
+{
+ {
+ // The returned pointer is ax + 5.
+ char *p = stpncpy (ax, a7, 5);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-5];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 9];
+ }
+
+ {
+ //The returned pointer is in [ax, ax + 7] even though n is not known.
+ char *p = stpncpy (ax, a7, n);
+ x = p[-8]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-7], p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9]);
+ }
+
+
+ {
+ // The returned pointer is in [a5, a5 + 3].
+ char *p = stpncpy (a5, a7, 3);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ // The returned pointer is a5 + 4.
+ char *p = stpncpy (a5, a7, 4);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ // The returned pointer is in [a5, a5 + 5].
+ char *p = stpncpy (a5, a7, n);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-5], p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ if (n3_9 < 3 || 9 < n3_9)
+ n3_9 = 3;
+
+ // The returned pointer is in [a5, a5 + 5].
+ char *p = stpncpy (a5, a7, n3_9);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-5], p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = stpncpy (a5, a7, 4);
+
+ if (i > -1) i = -1;
+ x = p[i];
+
+ if (i > -2) i = -2;
+ x = p[i];
+
+ if (i > -3) i = -3;
+ x = p[i];
+
+ if (i > -4) i = -4;
+ x = p[i];
+
+ if (i > -5) i = -5;
+ x = p[i]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+}
+
+
+void test_stpncpy_from_a5_to_allocated (int i, int n, int n5_7, int n3_9)
+{
+ if (n5_7 < 5 || 7 < n5_7)
+ n5_7 = 5;
+
+ {
+ char *d = calloc (n5_7, 1);
+ char *p = stpncpy (d, s, n);
+ x = p[-8]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-7], p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *d = calloc (n5_7, 1);
+ char *p = stpncpy (d, a3, n);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *d = calloc (n5_7, 1);
+ char *p = stpncpy (d, a5, n);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-5], p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *d = calloc (n5_7, 1);
+ char *p = stpncpy (d, a9, n);
+ x = p[-8]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-7], p[-6], p[-5], p[-3], p[-4], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *d = calloc (n5_7, 1);
+ char *p = stpncpy (d, a3, n3_9);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *d = calloc (n5_7, 1);
+ char *p = stpncpy (d, a9, n3_9);
+ x = p[-8]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-7], p[-6], p[-5], p[-4], p[-4], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-82.c b/gcc/testsuite/gcc.dg/Warray-bounds-82.c
new file mode 100644
index 0000000..b5dd919
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-82.c
@@ -0,0 +1,258 @@
+/* PR tree-optimization/101397 - spurious warning writing to the result
+ of stpcpy minus 1
+ Verify warnings for indexing into a pointer returned from mempcpy.
+ The call mempcpy(S1, S2, N) returns &S1[N].
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+void* mempcpy (void*, const void*, size_t);
+
+extern char ax[], a3[3], a5[5], a7[7], *s;
+
+volatile int x;
+
+/* Verify warnings for indexing into the result of mempcpy with a source
+ pointing to an array of unknown bound. */
+
+void test_mempcpy_from_ptr (int i)
+{
+ {
+ char *p = mempcpy (ax, s, 5);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-5];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 9];
+ }
+
+ {
+ char *p = mempcpy (a5, s, 3);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-3];
+ x = p[-2];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 1];
+ x = p[ 2]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = mempcpy (a5, s, 4);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-4];
+ x = p[-3];
+ x = p[-2];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 1]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = mempcpy (a5, s, 4);
+
+ if (i > -1) i = -1;
+ x = p[i];
+
+ if (i > -2) i = -2;
+ x = p[i];
+
+ if (i > -3) i = -3;
+ x = p[i];
+
+ if (i > -4) i = -4;
+ x = p[i];
+
+ if (i > -5) i = -5;
+ x = p[i]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+}
+
+/* Verify warnings for indexing into the result of mempcpy with a source
+ an array of size 5. */
+
+void test_mempcpy_from_a5 (int i, int n, int n3_9)
+{
+ {
+ // The returned pointer is ax + 3 as specified by the bound.
+ char *p = mempcpy (ax, a5, 3);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-3];
+ x = p[-2];
+ x = p[ 0];
+ x = p[ 1];
+ x = p[ 2];
+ }
+
+ {
+ // The returned pointer is ax + 5.
+ char *p = mempcpy (ax, a5, 5);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-5];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 9];
+ }
+
+ {
+ //The returned pointer is in [ax, ax + 5] even though n is not known.
+ char *p = mempcpy (ax, a5, n);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-5];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 9];
+ }
+
+
+ {
+ // The returned pointer is a3 + 3.
+ char *p = mempcpy (a3, a5, 3);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-3];
+ x = p[-1];
+ x = p[ 0]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[ 1]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ // The returned pointer is in [a3, a3 + 3].
+ char *p = mempcpy (a3, a5, n);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-3];
+ x = p[-2];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 2];
+ x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ if (n3_9 < 3 || 9 < n3_9)
+ n3_9 = 3;
+
+ // The returned pointer is a3.
+ char *p = mempcpy (a3, a5, n3_9);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-3];
+ x = p[-2];
+ x = p[-1];
+ x = p[ 0]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = mempcpy (a3, a5, 3);
+
+ if (i > -1) i = -1;
+ x = p[i];
+
+ if (i > -2) i = -2;
+ x = p[i];
+
+ if (i > -3) i = -3;
+ x = p[i];
+
+ if (i > -4) i = -4;
+ x = p[i]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+}
+
+
+/* Verify warnings for indexing into the result of mempcpy with a source
+ an array of size 7. */
+
+void test_mempcpy_from_a7 (int i, int n, int n3_9)
+{
+ {
+ // The returned pointer is ax + 5.
+ char *p = mempcpy (ax, a7, 5);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-5];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 9];
+ }
+
+ {
+ //The returned pointer is in [ax, ax + 7] even though n is not known.
+ char *p = mempcpy (ax, a7, n);
+ x = p[-8]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-7];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 9];
+ }
+
+
+ {
+ // The returned pointer is a5 + 3 as specified by the bound.
+ char *p = mempcpy (a5, a7, 3);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-3];
+ x = p[-2];
+ x = p[ 0];
+ x = p[ 1];
+ x = p[ 2]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ // The returned pointer is a5 + 4.
+ char *p = mempcpy (a5, a7, 4);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-4];
+ x = p[-3];
+ x = p[-2];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 1]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ // The returned pointer is in [a5, a5 + 5].
+ char *p = mempcpy (a5, a7, n);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-5];
+ x = p[-3];
+ x = p[-2];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 4];
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ if (n3_9 < 3 || 9 < n3_9)
+ n3_9 = 3;
+
+ // The returned pointer is in [a5 + 3, a5 + 5].
+ char *p = mempcpy (a5, a7, n3_9);
+ x = p[-6]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-5];
+ x = p[-3];
+ x = p[-2];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 1];
+ x = p[ 2]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = mempcpy (a5, a7, 4);
+
+ if (i > -1) i = -1;
+ x = p[i];
+
+ if (i > -2) i = -2;
+ x = p[i];
+
+ if (i > -3) i = -3;
+ x = p[i];
+
+ if (i > -4) i = -4;
+ x = p[i];
+
+ if (i > -5) i = -5;
+ x = p[i]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-83.c b/gcc/testsuite/gcc.dg/Warray-bounds-83.c
new file mode 100644
index 0000000..b1d02ea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-83.c
@@ -0,0 +1,172 @@
+/* PR tree-optimization/101397 - spurious warning writing to the result
+ of stpcpy minus 1
+ Verify warnings for indexing into a pointer returned from stpncpy.
+ The call stpncpy(S1, S2, N) returns the address of the copy of
+ the first NUL is it exists or &S1[N] otherwise.
+ { dg-do compile }
+ { dg-options "-O2 -Wall -Wno-stringop-truncation" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+__attribute__ ((alloc_size (1))) const void* alloc (size_t);
+
+void* memchr (const void*, int, size_t);
+
+void sink (int, ...);
+
+extern char ax[], a3[3], a5[5], a7[7], a9[9];
+
+volatile int x;
+
+/* Verify warnings for indexing into the result of memchr. */
+
+void test_memchr (int i, int n, int n3_5, int n3_9)
+{
+ {
+ /* Because memchr never returns a past-the-end pointer the result
+ below is in [ax, ax + 4]. */
+ const char *p = memchr (ax, x, 5);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[-4];
+ x = p[-1];
+ x = p[ 0];
+ x = p[ 9];
+ }
+
+ {
+ // The returned pointer is in [ax, ax + n].
+ const char *p = memchr (ax, x, n);
+ sink (p[-99], p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[99]);
+ }
+
+
+ {
+ // The returned pointer is in [a5, a5 + 2].
+ const char *p = memchr (a5, x, 3);
+ x = p[-3]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ // The returned pointer is a5 + 4.
+ const char *p = memchr (a5, x, 4);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ // The returned pointer is in [a5, a5 + 4].
+ const char *p = memchr (a5, x, n);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ if (n3_5 < 3 || 5 < n3_5)
+ n3_5 = 3;
+
+ // The returned pointer is in [a7, a7 + 4].
+ const char *p = memchr (a7, x, n3_5);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ if (n3_9 < 3 || 9 < n3_9)
+ n3_9 = 3;
+
+ // The returned pointer is in [a5, a5 + 4].
+ const char *p = memchr (a5, x, n3_9);
+ x = p[-5]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *p = memchr (a5, x, 4);
+
+ if (i > -1) i = -1;
+ x = p[i];
+
+ if (i > -2) i = -2;
+ x = p[i];
+
+ if (i > -3) i = -3;
+ x = p[i];
+
+ if (i > -4) i = -4;
+ x = p[i]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+}
+
+
+void test_memchr_in_allocated (int i, int n, int n5_7, int n3_9)
+{
+ if (n5_7 < 5 || 7 < n5_7)
+ n5_7 = 5;
+
+ {
+ const char *s = alloc (n5_7);
+ const char *p = memchr (s, x, n);
+ x = p[-7]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-6], p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *s = alloc (n5_7);
+ const char *p = memchr (s, x, n);
+ x = p[-7]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *s = alloc (n5_7);
+ const char *p = memchr (s, x, n);
+ x = p[-7]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *s = alloc (n5_7);
+ const char *p = memchr (s, x, n);
+ x = p[-7]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-6], p[-5], p[-3], p[-4], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *s = alloc (n5_7);
+ const char *p = memchr (s, x, n3_9);
+ x = p[-7]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ const char *s = alloc (n5_7);
+ const char *p = memchr (s, x, n3_9);
+ x = p[-7]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-6], p[-5], p[-4], p[-4], p[-2], p[-1], p[0]);
+ sink (p[1], p[2], p[3], p[4], p[5], p[6]);
+ x = p[7]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-84.c b/gcc/testsuite/gcc.dg/Warray-bounds-84.c
new file mode 100644
index 0000000..b9350d7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-84.c
@@ -0,0 +1,65 @@
+/* PR tree-optimization/101397 - spurious warning writing to the result
+ of stpcpy minus 1
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+char* strcpy (char*, const char*);
+
+void sink (int, ...);
+
+extern char ax[], a3[3], a5[5], *s;
+
+volatile int x;
+
+void test_strcpy (int i)
+{
+ {
+ char *p = strcpy (ax, s);
+ x = p[-1]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[ 0];
+ x = p[+9];
+ }
+
+ {
+ char *p = strcpy (a3, s);
+ x = p[-1]; // { dg-warning "\\\[-Warray-bounds" }
+ x = p[0];
+ x = p[1];
+ x = p[2];
+ x = p[3]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = strcpy (a5, s);
+ x = p[-1]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[0], p[1], p[2], p[3], p[4]);
+ x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = strcpy (a5 + 1, s);
+ x = p[-2]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-1], p[0], p[1], p[2], p[3]);
+ x = p[4]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = strcpy (a5 + 2, s);
+ x = p[-3]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-2], p[-1], p[0], p[1], p[2]);
+ x = p[3]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = strcpy (a5 + 3, s);
+ x = p[-4]; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[-3], p[-2], p[-1], p[0], p[1]);
+ x = p[2]; // { dg-warning "\\\[-Warray-bounds" }
+ }
+
+ {
+ char *p = strcpy (ax, a3);
+ p[-1] = 1; // { dg-warning "\\\[-Warray-bounds" }
+ sink (p[0], p[1], p[2], p[9], p[99]);
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-85.c b/gcc/testsuite/gcc.dg/Warray-bounds-85.c
new file mode 100644
index 0000000..0ee7120
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-85.c
@@ -0,0 +1,30 @@
+/* PR middle-end/101601 - [12 Regression] -Warray-bounds triggers error:
+ arrays of functions are not meaningful
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+typedef void Fvv (void);
+
+extern Fvv* pf; // { dg-message "'pf'" }
+
+void f (void*);
+
+void test_funptr (void)
+{
+ f (&pf);
+ f (&pf + 1);
+ f (&pf + 2); // { dg-warning "subscript 2 is outside array bounds of 'void \\\(\\\*\\\[1]\\\)\\\(void\\\)'" }
+}
+
+typedef int Fii_ (int, ...);
+
+extern Fii_* pfa[3]; // { dg-message "'pfa'" }
+
+void test_funptr_array (void)
+{
+ f (pfa);
+ f (pfa + 1);
+ f (pfa + 2);
+ f (pfa + 3);
+ f (pfa + 4); // { dg-warning "subscript 4 is outside array bounds of 'int \\\(\\\*\\\[3]\\\)\\\(int, ...\\\)'" }
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-87.c b/gcc/testsuite/gcc.dg/Warray-bounds-87.c
new file mode 100644
index 0000000..a49874d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-87.c
@@ -0,0 +1,48 @@
+/* PR middle-end/101671 - pr83510 fails with -Os because threader confuses
+ -Warray-bounds
+ { dg-do compile }
+ { dg-options "-Os -Wall" } */
+
+extern int f (void);
+extern void sink (unsigned int);
+
+unsigned int a[10];
+
+static unsigned int g (int i, int j)
+{
+ if (i == 9)
+ return j;
+ else if (i == 10)
+ return a[i]; // no warning here
+ return 0;
+}
+
+void test_g (int j)
+{
+ for (int i = 0; i < 10; i++)
+ {
+ if (f ())
+ sink (g (i, j));
+ }
+}
+
+static unsigned int h (int i, int j)
+{
+ switch (i)
+ {
+ case 9:
+ return j;
+ case 10:
+ return a[i]; // { dg-bogus "-Warray-bounds" "pr101671" { xfail *-*-* } }
+ }
+ return 0;
+}
+
+void test_h (int j)
+{
+ for (int i = 0; i < 10; i++)
+ {
+ if (f ())
+ sink (h (i, j));
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-88.c b/gcc/testsuite/gcc.dg/Warray-bounds-88.c
new file mode 100644
index 0000000..8cee8d2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-88.c
@@ -0,0 +1,134 @@
+/* PR middle-end/101977 - bogus -Warray-bounds on a negative index into
+ a parameter in conditional with null
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+struct A { int i; };
+struct B { struct A a1; struct A a2; };
+
+
+void nowarn_p_0_0 (struct A *p, int i)
+{
+ struct A *q = i < 0 ? p : 0 < i ? (struct A*)0 : 0;
+ struct B *r = (struct B*)((char *)q - __builtin_offsetof (struct B, a2));
+ r->a1.i = 0;
+}
+
+void nowarn_0_p_0 (struct A *p, int i)
+{
+ struct A *q = i < 0 ? 0 : 0 < i ? p : 0;
+ struct B *r = (struct B*)((char *)q - __builtin_offsetof (struct B, a2));
+ r->a1.i = 0; // { dg-bogus "-Warray-bounds" }
+}
+
+void nowarn_0_0_p (struct A *p, int i)
+{
+ struct A *q = i < 0 ? 0 : 0 < i ? 0 : p;
+ struct B *r = (struct B*)((char *)q - __builtin_offsetof (struct B, a2));
+ r->a1.i = 0; // { dg-bogus "-Warray-bounds" }
+}
+
+
+void nowarn_p_q_0 (struct A *p, struct A *q, int i)
+{
+ struct A *r = i < 0 ? p : 0 < i ? q : 0;
+ struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2));
+ s->a1.i = 0; // { dg-bogus "-Warray-bounds" }
+}
+
+void nowarn_p_0_q (struct A *p, struct A *q, int i)
+{
+ struct A *r = i < 0 ? p : 0 < i ? 0 : q;
+ struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2));
+ s->a1.i = 0; // { dg-bogus "-Warray-bounds" }
+}
+
+void nowarn_0_p_q (struct A *p, struct A *q, int i)
+{
+ struct A *r = i < 0 ? 0 : 0 < i ? p : q;
+ struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2));
+ s->a1.i = 0;
+}
+
+
+void nowarn_p_q_r (struct A *p, struct A *q, struct A *r, int i)
+{
+ struct A *s = i < 0 ? p : 0 < i ? q : r;
+ struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2));
+ t->a1.i = 0;
+}
+
+
+extern struct B b1, b2, b3;
+
+void nowarn_p_b1_0 (struct A *p, int i)
+{
+ struct A *r = i < 0 ? p : 0 < i ? &b1.a2 : 0;
+ struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2));
+ s->a1.i = 0; // { dg-bogus "-Warray-bounds" }
+}
+
+void nowarn_p_0_b1 (struct A *p, int i)
+{
+ struct A *r = i < 0 ? p : 0 < i ? 0 : &b1.a2;
+ struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2));
+ s->a1.i = 0; // { dg-bogus "-Warray-bounds" }
+}
+
+void nowarn_0_p_b1 (struct A *p, int i)
+{
+ struct A *r = i < 0 ? 0 : 0 < i ? p : &b1.a2;
+ struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2));
+ s->a1.i = 0;
+}
+
+
+void nowarn_p_b1_b2 (struct A *p, int i)
+{
+ struct A *s = i < 0 ? p : 0 < i ? &b1.a2 : &b2.a2;
+ struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2));
+ t->a1.i = 0;
+}
+
+void nowarn_b1_p_b2 (struct A *p, int i)
+{
+ struct A *s = i < 0 ? &b1.a2 : 0 < i ? p : &b2.a2;
+ struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2));
+ t->a1.i = 0;
+}
+
+void nowarn_b1_b2_p (struct A *p, int i)
+{
+ struct A *s = i < 0 ? &b1.a2 : 0 < i ? &b2.a2 : p;
+ struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2));
+ t->a1.i = 0;
+}
+
+void nowarn_b1_b2_b3 (struct A *p, int i)
+{
+ struct A *s = i < 0 ? &b1.a2 : 0 < i ? &b2.a2 : &b3.a2;
+ struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2));
+ t->a1.i = 0;
+}
+
+
+void nowarn_0_b1_b2 (int i)
+{
+ struct A *s = i < 0 ? 0 : 0 < i ? &b1.a2 : &b2.a2;
+ struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2));
+ t->a1.i = 0;
+}
+
+void warn_b1_0_b2 (int i)
+{
+ struct A *s = i < 0 ? &b1.a2 : 0 < i ? 0 : &b2.a2;
+ struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2));
+ t->a1.i = 0;
+}
+
+void warn_b1_b2_0 (int i)
+{
+ struct A *s = i < 0 ? &b1.a2 : 0 < i ? &b2.a2 : 0;
+ struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2));
+ t->a1.i = 0;
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-parameter-9.c b/gcc/testsuite/gcc.dg/Warray-parameter-9.c
new file mode 100644
index 0000000..b5d3d96
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-parameter-9.c
@@ -0,0 +1,54 @@
+/* PR c/99420 - bogus -Warray-parameter on a function redeclaration
+ in function scope
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+extern int a1[1], a2[2], a3[3], a4[4];
+
+void fa1 (int [1]); // { dg-message "previously declared as 'int\\\[1]'" }
+void fa1 (int [1]);
+
+
+void nested_decl (void)
+{
+ void fa2 (int [2]);
+
+ fa2 (a1); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
+ fa2 (a2);
+ fa2 (a3);
+
+ void fa3 (int [3]);
+
+ fa3 (a2); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
+ fa3 (a3);
+}
+
+
+void nested_redecl (void)
+{
+ void fa1 (int [2]); // { dg-warning "argument 1 of type 'int\\\[2]' with mismatched bound" }
+
+ fa1 (a1 + 1); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
+ fa1 (a1);
+
+ void fa2 (int [2]); // { dg-bogus "\\\[-Warray-parameter" }
+
+ fa2 (a1); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
+ fa2 (a2);
+ fa2 (a3);
+
+ void fa3 (int [3]); // { dg-bogus "\\\[-Warray-parameter" }
+
+ fa3 (a2); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
+ fa3 (a3);
+
+ void fa4 (int [4]);
+}
+
+void fa4 (int [5]); // { dg-warning "\\\[-Warray-parameter" }
+
+void call_fa4 (void)
+{
+ fa4 (a4);
+ fa4 (a3); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-parameter.c b/gcc/testsuite/gcc.dg/Warray-parameter.c
index 42be310..6c5195a 100644
--- a/gcc/testsuite/gcc.dg/Warray-parameter.c
+++ b/gcc/testsuite/gcc.dg/Warray-parameter.c
@@ -5,7 +5,7 @@
Also verify that the array/pointer argument form in a mismatched
redeclaration doesn't override the form in the initial declaration.
{ dg-do compile }
- { dg-options "-Wall -Warray-parameter -Wno-vla-paramater" } */
+ { dg-options "-Wall -Warray-parameter -Wno-vla-parameter" } */
/* Redclarations with the same or equivalent array form should not
be dianosed. T[0] is diagnosed by -Wpedantic for being invalid
diff --git a/gcc/testsuite/gcc.dg/Wattributes-6.c b/gcc/testsuite/gcc.dg/Wattributes-6.c
index 4ba59bf..978f3f9 100644
--- a/gcc/testsuite/gcc.dg/Wattributes-6.c
+++ b/gcc/testsuite/gcc.dg/Wattributes-6.c
@@ -97,6 +97,8 @@ fnoinline1 (void); /* { dg-message "previous declaration here" } */
/* Verify a warning for always_inline conflict. */
void ATTR ((always_inline))
fnoinline1 (void) { } /* { dg-warning "ignoring attribute .always_inline. because it conflicts with attribute .noinline." } */
+ /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
+ /* { dg-note "previous definition" "" { target *-*-* } .-2 } */
/* Verify a warning for gnu_inline conflict. */
inline void ATTR ((gnu_inline))
@@ -364,13 +366,15 @@ inline int ATTR ((cold))
finline_cold_noreturn (int);
inline int ATTR ((noreturn))
-finline_cold_noreturn (int);
+finline_cold_noreturn (int); /* { dg-note "previous declaration here" } */
inline int ATTR ((noinline))
finline_cold_noreturn (int); /* { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } */
+ /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
inline int ATTR ((hot))
finline_cold_noreturn (int); /* { dg-warning "ignoring attribute .hot. because it conflicts with attribute .cold." } */
+ /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
inline int ATTR ((warn_unused_result))
finline_cold_noreturn (int); /* { dg-warning "ignoring attribute .warn_unused_result. because it conflicts with attribute .noreturn." } */
@@ -389,23 +393,25 @@ finline_cold_noreturn (int i) { (void)&i; __builtin_abort (); }
and some on distinct declarations. */
inline int ATTR ((always_inline, hot))
-finline_hot_noret_align (int);
+finline_hot_noret_align (int); /* { dg-note "previous declaration here" } */
inline int ATTR ((noreturn, noinline))
finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } */
+ /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
inline int ATTR ((cold, aligned (8)))
finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .cold. because it conflicts with attribute .hot." } */
+ /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
inline int ATTR ((warn_unused_result))
finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .warn_unused_result. because it conflicts with attribute .noreturn." } */
+ /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */
inline int ATTR ((aligned (4)))
- finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .aligned \\(4\\). because it conflicts with attribute .aligned \\(8\\)." "" { target { ! { hppa*64*-*-* s390*-*-* } } } } */
-/* { dg-error "alignment for 'finline_hot_noret_align' must be at least 8" "" { target s390*-*-* } .-1 } */
+ finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .aligned \\(4\\). because it conflicts with attribute .aligned \\(8\\)." "" { target { ! { hppa*64*-*-* } } } } */
inline int ATTR ((aligned (8)))
-finline_hot_noret_align (int);
+finline_hot_noret_align (int); /* { dg-note "previous declaration here" } */
inline int ATTR ((const))
finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .const. because it conflicts with attribute .noreturn." } */
@@ -416,6 +422,26 @@ inline int ATTR ((noreturn))
finline_hot_noret_align (int i) { (void)&i; __builtin_abort (); }
+/* Expect a warning about conflicting alignment but without
+ other declarations inbetween. */
+inline int ATTR ((aligned (32)))
+finline_align (int); /* { dg-note "previous declaration here" } */
+
+inline int ATTR ((aligned (4)))
+finline_align (int); /* { dg-warning "ignoring attribute .aligned \\(4\\). because it conflicts with attribute .aligned \\(32\\)." "" } */
+
+inline int ATTR ((noreturn))
+finline_align (int i) { (void)&i; __builtin_abort (); }
+
+
+/* Expect no note that would refer to the same declaration. */
+inline int ATTR ((aligned (32), aligned (4)))
+finline_double_align (int); /* { dg-warning "ignoring attribute .aligned \\(4\\). because it conflicts with attribute .aligned \\(32\\)." } */
+
+inline int ATTR ((noreturn))
+finline_double_align (int i) { (void)&i; __builtin_abort (); }
+
+
/* Exercise variable attributes. */
extern int ATTR ((common))
diff --git a/gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c
index a7d9212..e459b24 100644
--- a/gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c
+++ b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c
@@ -10,23 +10,23 @@ struct A
void *p;
};
-void f0 (struct A *p, void *q) { p->p = q; }
-void f1 (struct A *p, void *q) { f0 (p, q); }
-void f2 (struct A *p, void *q) { f1 (p, q); }
+static void f0 (struct A *p, void *q) { p->p = q; }
+static void f1 (struct A *p, void *q) { f0 (p, q); }
+static void f2 (struct A *p, void *q) { f1 (p, q); }
-void g0 (struct A *p)
+static void g0 (struct A *p)
{
__builtin_free (p->p); // { dg-warning "\\\[-Wfree-nonheap-object" }
}
-void g1 (struct A *p) { g0 (p); }
-void g2 (struct A *p) { g1 (p); }
+static void g1 (struct A *p) { g0 (p); }
+static void g2 (struct A *p) { g1 (p); }
# 26 "Wfree-nonheap-object-4.c"
#define NOIPA __attribute__ ((noipa))
-extern int array[];
+extern int array[]; // { dg-message "declared here" "note on line 29" }
/* Verify the warning is issued even for calls in a system header inlined
into a function outside the header. */
@@ -39,7 +39,7 @@ NOIPA void warn_g0 (struct A *p)
g0 (p);
}
-// { dg-message "inlined from 'warn_g0'" "" { target *-*-* } 0 }
+// { dg-message "inlined from 'warn_g0'" "note on line 42" { target *-*-* } 0 }
/* Also verify the warning can be suppressed. */
@@ -65,8 +65,8 @@ NOIPA void warn_g1 (struct A *p)
g1 (p);
}
-// { dg-message "inlined from 'g1'" "" { target *-*-* } 0 }
-// { dg-message "inlined from 'warn_g1'" "" { target *-*-* } 0 }
+// { dg-message "inlined from 'g1'" "note on line 68" { target *-*-* } 0 }
+// { dg-message "inlined from 'warn_g1'" "note on line 69" { target *-*-* } 0 }
NOIPA void nowarn_g1 (struct A *p)
@@ -90,8 +90,8 @@ NOIPA void warn_g2 (struct A *p)
g2 (p);
}
-// { dg-message "inlined from 'g2'" "" { target *-*-* } 0 }
-// { dg-message "inlined from 'warn_g2'" "" { target *-*-* } 0 }
+// { dg-message "inlined from 'g2'" "note on line 93" { target *-*-* } 0 }
+// { dg-message "inlined from 'warn_g2'" "note on line 94" { target *-*-* } 0 }
NOIPA void nowarn_g2 (struct A *p)
diff --git a/gcc/testsuite/gcc.dg/Wfree-nonheap-object-5.c b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-5.c
new file mode 100644
index 0000000..026cd45
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-5.c
@@ -0,0 +1,46 @@
+/* Similar to Wfree-nonheap-object-4.c but without system headers:
+ verify that warnings for the same call site from distinct callers
+ include the correct function names in the inlining stack.
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+struct A
+{
+ void *p;
+};
+
+static void f0 (struct A *p)
+{
+ __builtin_free (p->p); // { dg-warning "\\\[-Wfree-nonheap-object" }
+}
+
+// Expect two instances of the text below:
+// { dg-regexp "In function 'f0'," "first f0 prefix" { target *-*-* } 0 }
+// { dg-regexp "In function 'f0'," "second f0 prefix" { target *-*-* } 0 }
+
+static void f1 (struct A *p) { f0 (p); }
+static void f2 (struct A *p) { f1 (p); }
+
+extern int array[];
+// Also expect two instances of the note:
+// { dg-regexp "declared here" "first note on line 24" { target *-*-* } .-2 }
+// { dg-regexp "declared here" "second note on line 24" { target *-*-* } .-3 }
+
+void foo (struct A *p)
+{
+ p->p = array + 1;
+ f0 (p);
+}
+
+// { dg-regexp " +inlined from 'foo' at \[^:\]+Wfree-nonheap-object-5.c:32:\\d+:" "note on line 32" }
+
+
+void bar (struct A *p)
+{
+ p->p = array + 2;
+ f2 (p);
+}
+
+// { dg-regexp " +inlined from 'f1' at \[^:\]+Wfree-nonheap-object-5.c:21:\\d+," "inlined from f1" }
+// { dg-regexp " +inlined from 'f2' at \[^:\]+Wfree-nonheap-object-5.c:22:\\d+," "inlined from f2" }
+// { dg-regexp " +inlined from 'bar' at \[^:\]+Wfree-nonheap-object-5.c:41:\\d+:" "inlined from bar" }
diff --git a/gcc/testsuite/gcc.dg/Wfree-nonheap-object-6.c b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-6.c
new file mode 100644
index 0000000..c109558
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-6.c
@@ -0,0 +1,49 @@
+/* Similar to Wfree-nonheap-object-5.c but with attribute artificial:
+ verify that warnings for the same call site from distinct callers
+ include the correct function names in the inlining stack.
+ { dg-do compile }
+ { dg-options "-O1 -Wall" } */
+
+struct A
+{
+ void *p;
+};
+
+__attribute__ ((always_inline, artificial))
+inline void f0 (struct A *p)
+{
+ __builtin_free (p->p); // { dg-warning "\\\[-Wfree-nonheap-object" }
+}
+
+// Expect two instances of the text below:
+// { dg-regexp "In function 'f0'," "first f0 prefix" { target *-*-* } 0 }
+// { dg-regexp "In function 'f0'," "second f0 prefix" { target *-*-* } 0 }
+
+__attribute__ ((always_inline, artificial))
+inline void f1 (struct A *p) { f0 (p); }
+__attribute__ ((always_inline, artificial))
+inline void f2 (struct A *p) { f1 (p); }
+
+extern int array[];
+// Also expect two instances of the note:
+// { dg-regexp "declared here" "first note for array" { target *-*-* } .-2 }
+// { dg-regexp "declared here" "second note for array" { target *-*-* } .-3 }
+
+void foo (struct A *p)
+{
+ p->p = array + 1;
+ f0 (p);
+}
+
+// { dg-regexp " +inlined from 'foo' at \[^:\]+Wfree-nonheap-object-6.c:35:\\d+:" "inlined from foo" }
+
+
+void bar (struct A *p)
+{
+ p->p = array + 2;
+ f2 (p);
+}
+
+// { dg-regexp " +inlined from 'f1' at \[^:\]+Wfree-nonheap-object-6.c:23:\\d+," "inlined from f1" }
+// { dg-regexp " +inlined from 'f2' at \[^:\]+Wfree-nonheap-object-6.c:25:\\d+," "inlined from f2" }
+// { dg-regexp " +inlined from 'bar' at \[^:\]+Wfree-nonheap-object-6.c:44:\\d+:" "inlined from bar" }
diff --git a/gcc/testsuite/gcc.dg/Wnonnull-4.c b/gcc/testsuite/gcc.dg/Wnonnull-4.c
index 180a40d..2c1c45a 100644
--- a/gcc/testsuite/gcc.dg/Wnonnull-4.c
+++ b/gcc/testsuite/gcc.dg/Wnonnull-4.c
@@ -27,9 +27,9 @@ void test_fca_n (int r_m1)
T ( 0);
// Verify positive bounds.
- T ( 1); // { dg-warning "argument 1 of variable length array 'char\\\[n]' is null but the corresponding bound argument 2 value is 1" }
- T ( 9); // { dg-warning "argument 1 of variable length array 'char\\\[n]' is null but the corresponding bound argument 2 value is 9" }
- T (max); // { dg-warning "argument 1 of variable length array 'char\\\[n]' is null but the corresponding bound argument 2 value is \\d+" }
+ T ( 1); // { dg-warning "argument 2 of variable length array 'char\\\[n]' is null but the corresponding bound argument 1 value is 1" }
+ T ( 9); // { dg-warning "argument 2 of variable length array 'char\\\[n]' is null but the corresponding bound argument 1 value is 9" }
+ T (max); // { dg-warning "argument 2 of variable length array 'char\\\[n]' is null but the corresponding bound argument 1 value is \\d+" }
}
@@ -55,9 +55,9 @@ void test_fsa_x_n (int r_m1)
T ( 0);
// Verify positive bounds.
- T ( 1); // { dg-warning "argument 1 of variable length array 'short int\\\[]\\\[n]' is null but the corresponding bound argument 2 value is 1" }
- T ( 9); // { dg-warning "argument 1 of variable length array 'short int\\\[]\\\[n]' is null but the corresponding bound argument 2 value is 9" }
- T (max); // { dg-warning "argument 1 of variable length array 'short int\\\[]\\\[n]' is null but the corresponding bound argument 2 value is \\d+" }
+ T ( 1); // { dg-warning "argument 2 of variable length array 'short int\\\[]\\\[n]' is null but the corresponding bound argument 1 value is 1" }
+ T ( 9); // { dg-warning "argument 2 of variable length array 'short int\\\[]\\\[n]' is null but the corresponding bound argument 1 value is 9" }
+ T (max); // { dg-warning "argument 2 of variable length array 'short int\\\[]\\\[n]' is null but the corresponding bound argument 1 value is \\d+" }
}
@@ -83,9 +83,9 @@ void test_fia_1_n (int r_m1)
T ( 0);
// Verify positive bounds.
- T ( 1); // { dg-warning "argument 1 of variable length array 'int\\\[1]\\\[n]' is null but the corresponding bound argument 2 value is 1" }
- T ( 9); // { dg-warning "argument 1 of variable length array 'int\\\[1]\\\[n]' is null but the corresponding bound argument 2 value is 9" }
- T (max); // { dg-warning "argument 1 of variable length array 'int\\\[1]\\\[n]' is null but the corresponding bound argument 2 value is \\d+" }
+ T ( 1); // { dg-warning "argument 2 of variable length array 'int\\\[1]\\\[n]' is null but the corresponding bound argument 1 value is 1" }
+ T ( 9); // { dg-warning "argument 2 of variable length array 'int\\\[1]\\\[n]' is null but the corresponding bound argument 1 value is 9" }
+ T (max); // { dg-warning "argument 2 of variable length array 'int\\\[1]\\\[n]' is null but the corresponding bound argument 1 value is \\d+" }
}
@@ -111,9 +111,9 @@ void test_fla_3_n (int r_m1)
T ( 0);
// Verify positive bounds.
- T ( 1); // { dg-warning "argument 1 of variable length array 'long int\\\[3]\\\[n]' is null but the corresponding bound argument 2 value is 1" }
- T ( 9); // { dg-warning "argument 1 of variable length array 'long int\\\[3]\\\[n]' is null but the corresponding bound argument 2 value is 9" }
- T (max); // { dg-warning "argument 1 of variable length array 'long int\\\[3]\\\[n]' is null but the corresponding bound argument 2 value is \\d+" }
+ T ( 1); // { dg-warning "argument 2 of variable length array 'long int\\\[3]\\\[n]' is null but the corresponding bound argument 1 value is 1" }
+ T ( 9); // { dg-warning "argument 2 of variable length array 'long int\\\[3]\\\[n]' is null but the corresponding bound argument 1 value is 9" }
+ T (max); // { dg-warning "argument 2 of variable length array 'long int\\\[3]\\\[n]' is null but the corresponding bound argument 1 value is \\d+" }
}
@@ -139,9 +139,9 @@ void test_fda_n_5 (int r_m1)
T ( 0);
// Verify positive bounds.
- T ( 1); // { dg-warning "argument 1 of variable length array 'double\\\[n]\\\[5]' is null but the corresponding bound argument 2 value is 1" }
- T ( 9); // { dg-warning "argument 1 of variable length array 'double\\\[n]\\\[5]' is null but the corresponding bound argument 2 value is 9" }
- T (max); // { dg-warning "argument 1 of variable length array 'double\\\[n]\\\[5]' is null but the corresponding bound argument 2 value is \\d+" }
+ T ( 1); // { dg-warning "argument 2 of variable length array 'double\\\[n]\\\[5]' is null but the corresponding bound argument 1 value is 1" }
+ T ( 9); // { dg-warning "argument 2 of variable length array 'double\\\[n]\\\[5]' is null but the corresponding bound argument 1 value is 9" }
+ T (max); // { dg-warning "argument 2 of variable length array 'double\\\[n]\\\[5]' is null but the corresponding bound argument 1 value is \\d+" }
}
@@ -167,7 +167,7 @@ void test_fca_n_n (int r_m1)
T ( 0);
// Verify positive bounds.
- T ( 1); // { dg-warning "argument 1 of variable length array 'char\\\[n]\\\[n]' is null but the corresponding bound argument 2 value is 1" }
- T ( 9); // { dg-warning "argument 1 of variable length array 'char\\\[n]\\\[n]' is null but the corresponding bound argument 2 value is 9" }
- T (max); // { dg-warning "argument 1 of variable length array 'char\\\[n]\\\[n]' is null but the corresponding bound argument 2 value is \\d+" }
+ T ( 1); // { dg-warning "argument 2 of variable length array 'char\\\[n]\\\[n]' is null but the corresponding bound argument 1 value is 1" }
+ T ( 9); // { dg-warning "argument 2 of variable length array 'char\\\[n]\\\[n]' is null but the corresponding bound argument 1 value is 9" }
+ T (max); // { dg-warning "argument 2 of variable length array 'char\\\[n]\\\[n]' is null but the corresponding bound argument 1 value is \\d+" }
}
diff --git a/gcc/testsuite/gcc.dg/Wnonnull-6.c b/gcc/testsuite/gcc.dg/Wnonnull-6.c
new file mode 100644
index 0000000..48f09da
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wnonnull-6.c
@@ -0,0 +1,93 @@
+/* Verify that attribute nonnull on global and local function declarations
+ or those to pointers to functions is merged.
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+void fnonnull_local_local (void)
+{
+ extern __attribute__ ((nonnull)) void fnonnull1 (void*);
+
+ fnonnull1 (0); // { dg-warning "\\\[-Wnonnull" }
+}
+
+void gnonnull_local_local (void)
+{
+ extern void fnonnull1 (void*);
+
+ fnonnull1 (0); // { dg-warning "\\\[-Wnonnull" }
+}
+
+
+void fnonnull_local_global (void)
+{
+ extern __attribute__ ((nonnull)) void fnonnull2 (void*);
+
+ fnonnull2 (0); // { dg-warning "\\\[-Wnonnull" }
+}
+
+extern void fnonnull2 (void*);
+
+void gnonnull_local_global (void)
+{
+ fnonnull2 (0); // { dg-warning "\\\[-Wnonnull" }
+}
+
+
+extern __attribute__ ((nonnull)) void fnonnull3 (void*);
+
+void fnonnull_global_local (void)
+{
+ fnonnull3 (0); // { dg-warning "\\\[-Wnonnull" }
+}
+
+void gnonnull_global_local (void)
+{
+ extern void fnonnull3 (void*);
+
+ fnonnull3 (0); // { dg-warning "\\\[-Wnonnull" }
+}
+
+
+void pfnonnull_local_local (void)
+{
+ extern __attribute__ ((nonnull)) void (*pfnonnull1) (void*);
+
+ pfnonnull1 (0); // { dg-warning "\\\[-Wnonnull" }
+}
+
+void gpnonnull_local_local (void)
+{
+ extern void (*pfnonnull1) (void*);
+
+ pfnonnull1 (0); // { dg-warning "\\\[-Wnonnull" "pr?????" { xfail *-*-* } }
+}
+
+
+void pfnonnull_local_global (void)
+{
+ extern __attribute__ ((nonnull)) void (*pfnonnull2) (void*);
+
+ pfnonnull2 (0); // { dg-warning "\\\[-Wnonnull" }
+}
+
+extern void (*pfnonnull2) (void*);
+
+void gpnonnull_local_global (void)
+{
+ pfnonnull2 (0); // { dg-warning "\\\[-Wnonnull" "pr?????" { xfail *-*-* } }
+}
+
+
+extern __attribute__ ((nonnull)) void (*pfnonnull3) (void*);
+
+void pfnonnull_global_local (void)
+{
+ pfnonnull3 (0); // { dg-warning "\\\[-Wnonnull" }
+}
+
+void gpnonnull_global_local (void)
+{
+ extern void (*pfnonnull3) (void*);
+
+ pfnonnull3 (0); // { dg-warning "\\\[-Wnonnull" }
+}
diff --git a/gcc/testsuite/gcc.dg/Wnonnull-7.c b/gcc/testsuite/gcc.dg/Wnonnull-7.c
new file mode 100644
index 0000000..e7b331a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wnonnull-7.c
@@ -0,0 +1,15 @@
+/* PR middle-end/101216 - spurious notes for function calls
+ { dg-do compile }
+ { dg-options "-O2 -w" } */
+
+__attribute__ ((access (write_only, 1, 2))) char*
+getcwd (char *, __SIZE_TYPE__);
+
+char* f (void)
+{
+ char a[8];
+ return getcwd (0, 8);
+}
+
+/* Expect no messages of any kind on output.
+ { dg-bogus "" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/gcc.dg/Wobjsize-1.c b/gcc/testsuite/gcc.dg/Wobjsize-1.c
index e80c8ad..2bd2f93 100644
--- a/gcc/testsuite/gcc.dg/Wobjsize-1.c
+++ b/gcc/testsuite/gcc.dg/Wobjsize-1.c
@@ -4,13 +4,17 @@
#include "Wobjsize-1.h"
char buf[6];
-/* { dg-warning "writing" "" { target *-*-* } .-1 } */
int main(int argc, char **argv)
{
- strcpy (buf,"hello ");
+ strcpy (buf,"hello "); /* { dg-warning "\\\[-Wstringop-overflow" } */
return 0;
}
-/* { dg-message "file included" "included" { target *-*-* } 0 } */
-/* { dg-message "inlined from" "inlined" { target *-*-* } 0 } */
+/* { dg-message "file included" "included" { target *-*-* } 0 }
+ { dg-message "inlined from" "inlined" { target *-*-* } 0 }
+
+ The test might emit two warnings, one for the strcpy call and
+ another for the inlined call to __builtin___strcpy_chk() called
+ from strcpy().
+ { dg-prune-output "writing 7 bytes into a region of size 6" } */
diff --git a/gcc/testsuite/gcc.dg/Wrestrict-8.c b/gcc/testsuite/gcc.dg/Wrestrict-8.c
index 24946b0..62e8bbc 100644
--- a/gcc/testsuite/gcc.dg/Wrestrict-8.c
+++ b/gcc/testsuite/gcc.dg/Wrestrict-8.c
@@ -7,7 +7,9 @@ typedef __SIZE_TYPE__ size_t;
extern void* memcpy (void* restrict, const void* restrict, size_t);
-#define T(d, s, n) memcpy (d, s, n)
+void foo (void *);
+
+#define T(d, s, n) do { memcpy (d, s, n); foo (d); } while (0)
struct S1 { char c; } a8_1[8];
diff --git a/gcc/testsuite/gcc.dg/Wreturn-type3.c b/gcc/testsuite/gcc.dg/Wreturn-type3.c
new file mode 100644
index 0000000..93596b3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wreturn-type3.c
@@ -0,0 +1,54 @@
+/* Verify that attribute noreturn on global and local function declarations
+ is merged.
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+int fnr_local_local (void)
+{
+ __attribute__ ((noreturn)) void fnr1 (void);
+
+ fnr1 ();
+ // no return, no warning (good)
+}
+
+int gnr_local_local (void)
+{
+ void fnr1 (void);
+
+ fnr1 ();
+ // no return, no warning (good)
+}
+
+
+int fnr_local_global (void)
+{
+ __attribute__ ((noreturn)) void fnr2 (void);
+
+ fnr2 ();
+ // no return, no warning (good)
+}
+
+void fnr2 (void);
+
+int gnr_local_global (void)
+{
+ fnr2 ();
+ // no return, no warning (good)
+}
+
+
+__attribute__ ((noreturn)) void fnr3 (void);
+
+int fnr_global_local (void)
+{
+ fnr3 ();
+ // no return, no warning (good)
+}
+
+int gnr_global_local (void)
+{
+ void fnr3 (void);
+
+ fnr3 ();
+ // no return, no warning (good)
+}
diff --git a/gcc/testsuite/gcc.dg/Wstring-compare-3.c b/gcc/testsuite/gcc.dg/Wstring-compare-3.c
index d4d7121..6d0d5be 100644
--- a/gcc/testsuite/gcc.dg/Wstring-compare-3.c
+++ b/gcc/testsuite/gcc.dg/Wstring-compare-3.c
@@ -1,6 +1,6 @@
/* PR middle-end/95673 - missing -Wstring-compare for an impossible strncmp test
{ dg-do compile }
- { dg-options "-O2 -Wall -Wstring-compare -ftrack-macro-expansion=0" } */
+ { dg-options "-O2 -Wall -Wstring-compare -Wno-stringop-overread -ftrack-macro-expansion=0" } */
typedef __SIZE_TYPE__ size_t;
diff --git a/gcc/testsuite/gcc.dg/Wstring-compare.c b/gcc/testsuite/gcc.dg/Wstring-compare.c
index d1534bf..239bbfe 100644
--- a/gcc/testsuite/gcc.dg/Wstring-compare.c
+++ b/gcc/testsuite/gcc.dg/Wstring-compare.c
@@ -21,7 +21,7 @@ extern char b4[4];
void strcmp_array_lit (void)
{
if (strcmp (a4, "1234")) // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero" }
- // { dg-bogus "in this expreession" "unwanted note" { target *-*-* } .-1 }
+ // { dg-bogus "in this expression" "unwanted note" { target *-*-* } .-1 }
sink (0, a4);
int cmp;
@@ -44,7 +44,7 @@ void strcmp_array_pstr (void)
{
if (strcmp (a4, s4)) // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero" }
- // { dg-bogus "in this expreession" "unwanted note" { target *-*-* } .-1 }
+ // { dg-bogus "in this expression" "unwanted note" { target *-*-* } .-1 }
sink (1, a4);
else
sink (0, a4);
@@ -86,7 +86,7 @@ void strcmp_array_copy (void)
{
strcpy (s, "1234");
if (strcmp (a4, s)) // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero" }
- // { dg-bogus "in this expreession" "unwanted note" { target *-*-* } .-1 }
+ // { dg-bogus "in this expression" "unwanted note" { target *-*-* } .-1 }
sink (1, a4);
else
sink (0, a4);
@@ -131,7 +131,7 @@ void strcmp_member_array_lit (const struct S *p)
void strncmp_array_lit (void)
{
if (strncmp (a4, "12345", 5)) // { dg-warning "'strncmp' of a string of length 5, an array of size 4 and bound of 5 evaluates to nonzero" }
- // { dg-bogus "in this expreession" "unwanted note" { target *-*-* } .-1 }
+ // { dg-bogus "in this expression" "unwanted note" { target *-*-* } .-1 }
sink (0, a4);
int cmp;
@@ -161,7 +161,7 @@ void strncmp_strarray_copy (void)
char b[6];
strcpy (b, "12345");
if (strncmp (a, b, 5)) // { dg-warning "'strncmp' of strings of length 4 and 5 and bound of 5 evaluates to nonzero" }
- // { dg-bogus "in this expreession" "unwanted note" { target *-*-* } .-1 }
+ // { dg-bogus "in this expression" "unwanted note" { target *-*-* } .-1 }
sink (0, a, b);
}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-11.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-11.c
index ec3c97e..cf53652 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-11.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-11.c
@@ -56,7 +56,7 @@ void test_memset_array_cst_range_off (void)
T (2, SR ( 1, 2), 4);
T (2, SR ( 1, 2), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
- T (2, SR ( 0, 1), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" { xfail *-*-* } } */
+ T (2, SR ( 0, 1), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */
T (2, UR ( 1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
T (7, UR (-7, 0), 7);
T (7, UR (-7, 0), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
@@ -134,7 +134,7 @@ void test_memcpy_array_cst_range_off (const void *s)
T (2, SR ( 1, 2), 4);
T (2, SR ( 1, 2), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
- T (2, SR ( 0, 1), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" { xfail *-*-* } } */
+ T (2, SR ( 0, 1), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */
T (2, UR ( 1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
T (7, UR (-7, 0), 7);
T (7, UR (-7, 0), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
@@ -211,7 +211,7 @@ void test_strcpy_array_cst_range_off (void)
T (2, SR ( 1, 2), 3);
T (2, SR ( 1, 2), 4); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
- T (2, SR ( 0, 1), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" { xfail *-*-* } } */
+ T (2, SR ( 0, 1), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */
T (2, UR ( 1, 2), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
T (7, UR (-7, 0), 6);
T (7, UR (-7, 0), 8); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
@@ -277,7 +277,7 @@ void test_strncpy_array_cst_range_off (const char *s)
T (2, SR ( 1, 2), 4);
T (2, SR ( 1, 2), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
- T (2, SR ( 0, 1), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" { xfail *-*-* } } */
+ T (2, SR ( 0, 1), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */
T (2, UR ( 1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
T (7, UR (-7, 0), 7);
T (7, UR (-7, 0), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-12.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-12.c
index 7c3dc8c..1ba7720 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-12.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-12.c
@@ -25,9 +25,7 @@ void test_memcpy_array_cst_range_off (const void *s)
T (d + UR (1, 2), 5);
T (d + UR (0, 1), 6);
- /* The warning below should be "writing" but the [0, 1] range
- is somehow lost and get_range_info() returns VR_VARYING. */
- T (d + UR (0, 1), 7); /* { dg-warning ".memcpy. writing 7 bytes into a region of size 6 overflows the destination" "pr89428" { xfail *-*-* } } */
+ T (d + UR (0, 1), 7); /* { dg-warning ".memcpy. writing 7 bytes into a region of size 6 overflows the destination" "pr89428" } */
T (d + UR (1, 2), 6); /* { dg-warning ".memcpy. writing 6 bytes into a region of size 5 overflows the destination" } */
T (d + UR (1, 2), 7); /* { dg-warning "writing 7 bytes into a region of size 5 " } */
@@ -66,7 +64,7 @@ void test_memset_array_unsigned_off (void)
T (d + UR (1, 2), 5);
T (d + UR (0, 1), 6);
- T (d + UR (0, 1), 7); /* { dg-warning ".memset. writing 6 bytes into a region of size 5 overflows the destination" "pr89428" { xfail *-*-* } } */
+ T (d + UR (0, 1), 7); /* { dg-warning ".memset. writing 7 bytes into a region of size 6 overflows the destination" "pr89428" } */
T (d + UR (1, 2), 6); /* { dg-warning ".memset. writing 6 bytes into a region of size 5 overflows the destination" } */
T (d + UR (1, 2), 7); /* { dg-warning "writing 7 bytes into a region of size 5 " } */
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-15.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-15.c
index 1907bac..87f8462 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-15.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-15.c
@@ -30,7 +30,7 @@ void vla_bounded (int n)
a[0] = 0;
a[1] = 1;
a[n] = n; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" { xfail *-*-* } }
- a[69] = n; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" { xfail *-*-* } }
+ a[69] = n; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" }
sink (&a);
}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-34.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-34.c
index a1b1039..d9ca344 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-34.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-34.c
@@ -112,7 +112,7 @@ void s2_warn_cstoff_cstidx (struct S2 *p)
void s2_warn_varoff_cstdix (struct S2 *p, int i)
{
char *q = p->a + i;
- q[2] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" }
+ q[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
}
void s2_warn_cstoff_varidx (struct S2 *p, int i)
@@ -235,8 +235,8 @@ void si0_warn_cstoff_cstidx (struct Si0 *p)
void si0_warn_varoff_cstdix (struct Si0 *p, int i)
{
char *q = p->a + i;
- q[1] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" }
- q[9] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" }
+ q[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
+ q[9] = __LINE__; // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
}
void si0_warn_cstoff_varidx (struct Si0 *p, int i)
@@ -248,5 +248,5 @@ void si0_warn_cstoff_varidx (struct Si0 *p, int i)
void si0_warn_varoff_varidx (struct Si0 *p, int i, int j)
{
char *q = p->a + i;
- q[j] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" }
+ q[j] = __LINE__; // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-41.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-41.c
index 9b2d2cb..e255e67 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-41.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-41.c
@@ -29,7 +29,8 @@ void char_array_cst_off_cst_size (void)
sink (p);
++idx;
- memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 1" "pr?????" { xfail ilp32 } }
+ memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 1" }
+ sink (p);
++idx;
memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 0" }
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-42.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-42.c
index 4bb22f2..8527eea 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-42.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-42.c
@@ -23,21 +23,21 @@ void cpy_ui_1_max (unsigned i, const char *s)
{
if (i < 1) i = 1;
d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
- d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { xfail ilp32 } }
+ d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { xfail { ! lp64 } } }
}
void cpy_sl_1_max (long i, const char *s)
{
if (i < 1) i = 1;
- d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
- d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
+ d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
+ d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
}
void cpy_ul_1_max (unsigned long i, const char *s)
{
if (i < 1) i = 1;
- d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
+ d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
/* Because of integer wraparound the offset's range is [1, 0] so
the overflow isn't diagnosed (yet). */
@@ -56,7 +56,7 @@ void cpy_si_min_m1 (int i, const char *s)
void cpy_sl_min_m1 (long i, const char *s)
{
if (i > -1) i = -1;
- d = strcpy (a + i - 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
- d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
+ d = strcpy (a + i - 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
+ d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
d = strcpy (a + i + 2, s);
}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-43.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-43.c
index 14ab925..9100661 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-43.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-43.c
@@ -161,18 +161,19 @@ void warn_memset_reversed_range (void)
/* Since the offset is excessive, either starting before &a11[0]
ot just past &a[11], the region size in the warning should
- probably be zero, but accept other sizes too. */
- T1 (p, SAR (INT_MIN, -11), n11); // { dg-warning "writing 11 or more bytes into a region of size \\d+" }
+ probably be zero, but accept other sizes too.
+
+ The problem isn't detected anymore because the offset is in
+ the anti-range ~[INT_MIN, -11] which isn't handled. */
+ T1 (p, SAR (INT_MIN, -11), n11); // { dg-warning "writing 11 or more bytes into a region of size \\d+" "" { xfail *-*-* } }
/* The following are represented as ordinary ranges with reversed bounds
and those are handled. */
T1 (p, SAR (INT_MIN, 11), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" }
- /* In ILP32 the offset in the following has no range info associated
- with it. */
- T1 (p, SAR (INT_MIN, 1), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" "pr?????" { xfail ilp32 } }
+ T1 (p, SAR (INT_MIN, 1), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" }
T1 (p, SAR (INT_MIN, 0), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" }
/* Also represented as a true anti-range. */
- T1 (p, SAR ( -12, -11), n11); // { dg-warning "writing 11 or more bytes into a region of size \\d+" }
+ T1 (p, SAR ( -12, -11), n11); // { dg-warning "writing 11 or more bytes into a region of size \\d+" "" { xfail *-*-* } }
T1 (p, SAR ( -12, -1), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" }
T1 (p, SAR ( -11, 0), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" }
T1 (p, SAR ( -11, 11), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" }
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-46.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-46.c
index b126fcb..042c967 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-46.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-46.c
@@ -79,9 +79,8 @@ void warn_memchr_var_memset_range (const void *s, unsigned n)
as in the first two notes. The exact value probably isn't too
important. */
char *p0 = malloc (UR (5, 7));
- // { dg-message ": destination object of size \\\[5, 7]" "note 1" { target *-*-* } .-1 }
- // { dg-message "at offset \\\[1, 7] into destination object of size \\\[5, 7]" "note 2" { target *-*-* } .-2 }
- // { dg-message "at offset \\\[2, 7] into destination object of size \\\[5, 7]" "note 3" { target *-*-* } .-3 }
+ // { dg-message "at offset \\\[\[01\], 6] into destination object of size \\\[5, 7]" "note 2" { target *-*-* } .-1 }
+ // { dg-message "at offset \\\[2, 7] into destination object of size \\\[5, 7]" "note 3" { target *-*-* } .-2 }
sink (p0);
char *p1 = memchr (p0, '1', n);
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c
index 9bfc84a..968f6ee 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c
@@ -24,22 +24,22 @@ void nowarn_c32 (char c)
sink (p);
}
-/* The tests below fail as a result of the hack for PR 96963. However,
- with -Wall, the invalid stores are diagnosed by -Warray-bounds which
- runs before vectorization and so doesn't need the hack. If/when
- -Warray changes to use compute_objsize() this will need adjusting. */
+/* The tests below failed as a result of the hack for PR 96963. However,
+ with -Wall, the invalid stores were diagnosed by -Warray-bounds which
+ runs before vectorization and so doesn't need the hack. Now that
+ -Warray-bounds has changed to use compute_objsize() the tests pass. */
void warn_c32 (char c)
{
- extern char warn_a32[32]; // { dg-message "at offset 32 into destination object 'warn_a32' of size 32" "pr97027" { xfail *-*-* } }
+ extern char warn_a32[32]; // { dg-message "at offset (32|1) into destination object 'warn_a32' of size 32" "pr97027" }
void *p = warn_a32 + 1;
- *(C32*)p = (C32){ c }; // { dg-warning "writing 1 byte into a region of size 0" "pr97027" { xfail *-*-* } }
+ *(C32*)p = (C32){ c }; // { dg-warning "writing (1 byte|32 bytes) into a region of size (0|31)" "pr97027" }
/* Verify a local variable too. */
char a32[32];
p = a32 + 1;
- *(C32*)p = (C32){ c }; // { dg-warning "writing 1 byte into a region of size 0" "pr97027" { xfail *-*-* } }
+ *(C32*)p = (C32){ c }; // { dg-warning "writing (1 byte|32 bytes) into a region of size (0|31)" "pr97027" }
sink (p);
}
@@ -60,15 +60,20 @@ void nowarn_i16_64 (int16_t i)
void warn_i16_64 (int16_t i)
{
- extern char warn_a64[64]; // { dg-message "at offset 128 to object 'warn_a64' with size 64" "pr97027" { xfail *-*-* } }
+/* The IL below that's visible to the warning changes from one target to
+ another. On some like aarch64 it's a single vector store, on others
+ like x86_64 it's a series of BIT_FIELD_REFs. The overflow by
+ the former is detected but the latter is not yet. */
+
+ extern char warn_a64[64]; // { dg-message "at offset (1|128) into destination object 'warn_a64' of size (63|64)" "pr97027 note" { xfail { ! aarch64-*-* } } }
void *p = warn_a64 + 1;
I16_64 *q = (I16_64*)p;
- *q = (I16_64){ i }; // { dg-warning "writing 1 byte into a region of size 0" "pr97027" { xfail *-*-* } }
+ *q = (I16_64){ i }; // { dg-warning "writing (1 byte|64 bytes) into a region of size (0|63)" "pr97027" { xfail { ! aarch64-*-* } } }
char a64[64];
p = a64 + 1;
q = (I16_64*)p;
- *q = (I16_64){ i }; // { dg-warning "writing 1 byte into a region of size 0" "pr97027" { xfail *-*-* } }
+ *q = (I16_64){ i }; // { dg-warning "writing (1 byte|64 bytes) into a region of size (0|63)" "pr97027" { xfail { ! aarch64-*-* } } }
sink (p);
}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c
index 25f5b82..c3c2dbe 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c
@@ -1,6 +1,6 @@
/* Verify that offsets in "anti-ranges" are handled correctly.
{ dg-do compile }
- { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */
+ { dg-options "-O2 -Wall -ftrack-macro-expansion=0 -fno-ipa-icf" } */
typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __SIZE_TYPE__ size_t;
@@ -66,7 +66,7 @@ void warn_ptrdiff_anti_range_add (ptrdiff_t i)
{
i |= 1;
- char ca5[5]; // { dg-message "at offset \\\[1, 5]" "pr?????" { xfail *-*-* } }
+ char ca5[5]; // { dg-message "at offset \\\[1, 5]" "pr?????" }
char *p0 = ca5; // offset
char *p1 = p0 + i; // 1-5
char *p2 = p1 + i; // 2-5
@@ -74,7 +74,7 @@ void warn_ptrdiff_anti_range_add (ptrdiff_t i)
char *p4 = p3 + i; // 4-5
char *p5 = p4 + i; // 5
- memset (p5, 0, 5); // { dg-warning "writing 5 bytes into a region of size 0" "pr?????" { xfail *-*-* } }
+ memset (p5, 0, 5); // { dg-warning "writing 5 bytes into a region of size" "pr?????" }
sink (p0, p1, p2, p3, p4, p5);
}
@@ -83,7 +83,7 @@ void warn_int_anti_range (int i)
{
i |= 1;
- char ca5[5]; // { dg-message "at offset \\\[1, 5]" "pr?????" { xfail *-*-* } }
+ char ca5[5]; // { dg-message "at offset \\\[1, 5]" "pr?????" }
char *p0 = ca5; // offset
char *p1 = p0 + i; // 1-5
char *p2 = p1 + i; // 2-5
@@ -91,7 +91,7 @@ void warn_int_anti_range (int i)
char *p4 = p3 + i; // 4-5
char *p5 = p4 + i; // 5
- memset (p5, 0, 5); // { dg-warning "writing 5 bytes into a region of size 0" "pr?????" { xfail *-*-* } }
+ memset (p5, 0, 5); // { dg-warning "writing 5 bytes into a region of size" "pr?????" }
sink (p0, p1, p2, p3, p4, p5);
}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-61.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-61.c
index 7601679..93c54c6 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-61.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-61.c
@@ -65,7 +65,7 @@ void nowarn_cond_escape (int c, int *x)
void warn_cond_escape (int c, int *x)
{
extern char a3_2[3];
- extern char a5_2[5]; // { dg-message "at offset 5 into destination object 'a5_2'" }
+ extern char a5_2[5]; // { dg-message "at offset 5 into object 'a5_2'" }
char *p;
if (c)
@@ -84,5 +84,5 @@ void warn_cond_escape (int c, int *x)
if (*x == 2)
p[2] = 0;
else if (*x == 5)
- p[5] = 0; // { dg-warning "\\\[-Wstringop-overflow" }
+ p[5] = 0; // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-67.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-67.c
new file mode 100644
index 0000000..7b8f3f0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-67.c
@@ -0,0 +1,92 @@
+/* PR middle-end/100571 - bogus -Wstringop-overflow with VLA of elements
+ larger than byte
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+__attribute__ ((access (read_only, 1, 2))) void fro (int *, int);
+__attribute__ ((access (write_only, 1, 2))) void fwo (int *, int);
+__attribute__ ((access (read_write, 1, 2))) void frw (int *, int);
+
+extern __SIZE_TYPE__ n;
+
+void alloca_ro (void)
+{
+ int *a = __builtin_alloca (n * sizeof *a);
+ a[0] = 0;
+ fro (a, n);
+}
+
+void alloca_wo (void)
+{
+ int *a = __builtin_alloca (n * sizeof *a);
+ fwo (a, n);
+}
+
+void alloca_rw (void)
+{
+ int *a = __builtin_alloca (n * sizeof *a);
+ a[0] = 0;
+ frw (a, n);
+}
+
+
+void calloc_ro (void)
+{
+ int *a = __builtin_calloc (n, sizeof *a);
+ fro (a, n);
+}
+
+void calloc_wo (void)
+{
+ int *a = __builtin_calloc (n, sizeof *a);
+ fwo (a, n);
+}
+
+void calloc_rw (void)
+{
+ int *a = __builtin_calloc (n, sizeof *a);
+ a[0] = 0;
+ frw (a, n);
+}
+
+
+void malloc_ro (void)
+{
+ int *a = __builtin_malloc (n * sizeof *a);
+ a[0] = 0;
+ fro (a, n);
+}
+
+void malloc_wo (void)
+{
+ int *a = __builtin_malloc (n * sizeof *a);
+ fwo (a, n);
+}
+
+void malloc_rw (void)
+{
+ int *a = __builtin_malloc (n * sizeof *a);
+ a[0] = 0;
+ frw (a, n);
+}
+
+
+void vla_ro (void)
+{
+ int a[n];
+ a[0] = 0;
+ fro (a, n);
+}
+
+void vla_wo (void)
+{
+ int a[n];
+ fwo (a, n);
+}
+
+void vla_rw (void)
+{
+ int a[n];
+ a[0] = 0;
+ frw (a, n);
+}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-68.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-68.c
new file mode 100644
index 0000000..6bcba27
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-68.c
@@ -0,0 +1,104 @@
+/* PR tree-optimization/97027 - missing warning on buffer overflow storing
+ a larger scalar into a smaller array
+ Verify overflow by aggregate stores.
+ { dg-do compile }
+ { dg-options "-O2" } */
+
+#define A(N) (A ## N)
+#define Ac1 (AC1){ 0 }
+#define Ac2 (AC2){ 0, 1 }
+#define Ac4 (AC4){ 0, 1, 2, 3 }
+#define Ac8 (AC8){ 0, 1, 2, 3, 4, 5, 6, 7 }
+#define Ac16 (AC16){ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
+
+typedef struct AC1 { char a[1]; } AC1;
+typedef struct AC2 { char a[2]; } AC2;
+typedef struct AC3 { char a[3]; } AC3;
+typedef struct AC4 { char a[4]; } AC4;
+typedef struct AC5 { char a[5]; } AC5;
+typedef struct AC8 { char a[8]; } AC8;
+typedef struct AC16 { char a[16]; } AC16;
+
+extern char a1[1], a2[2], a3[3], a4[4], a5[5], a6[6], a7[7], a8[8], a15[15];
+
+extern AC1 ac1;
+extern AC2 ac2;
+extern AC4 ac4;
+extern AC8 ac8;
+extern AC16 ac16;
+
+extern AC1 fac1 (void);
+extern AC2 fac2 (void);
+extern AC4 fac4 (void);
+extern AC8 fac8 (void);
+extern AC16 fac16 (void);
+
+void nowarn (void)
+{
+ *(AC1*)a1 = Ac1;
+ *(AC2*)a2 = Ac2;
+ *(AC4*)a4 = Ac4;
+ *(AC4*)a5 = Ac4;
+ *(AC4*)a6 = Ac4;
+ *(AC4*)a7 = Ac4;
+ *(AC8*)a8 = Ac8;
+ *(AC8*)a15 = Ac8;
+}
+
+void warn_comp_lit_zero (void)
+{
+ *(AC2*)a1 = (AC2){ }; // { dg-warning "writing 2 bytes into a region of size 1" }
+ *(AC4*)a2 = (AC4){ }; // { dg-warning "writing 4 bytes into a region of size 2" }
+ *(AC4*)a3 = (AC4){ }; // { dg-warning "writing 4 bytes into a region of size 3" }
+ *(AC8*)a4 = (AC8){ }; // { dg-warning "writing 8 bytes into a region of size 4" }
+ *(AC8*)a7 = (AC8){ }; // { dg-warning "writing 8 bytes into a region of size 7" }
+ *(AC16*)a15 = (AC16){ };// { dg-warning "writing 16 bytes into a region of size 15" }
+}
+
+void warn_comp_lit (void)
+{
+ *(AC2*)a1 = Ac2; // { dg-warning "writing 2 bytes into a region of size 1" "pr101475" { xfail *-*-* } }
+ *(AC4*)a2 = Ac4; // { dg-warning "writing 4 bytes into a region of size 2" "pr101475" { xfail *-*-* } }
+ *(AC4*)a3 = Ac4; // { dg-warning "writing 4 bytes into a region of size 3" "pr101475" { xfail *-*-* } }
+ *(AC8*)a4 = Ac8; // { dg-warning "writing 8 bytes into a region of size 4" "pr101475" { xfail *-*-* } }
+ *(AC8*)a7 = Ac8; // { dg-warning "writing 8 bytes into a region of size 7" "pr101475" { xfail *-*-* } }
+ *(AC16*)a15 = Ac16; // { dg-warning "writing 16 bytes into a region of size 15" "pr101475" { xfail *-*-* } }
+}
+
+void warn_aggr_decl (void)
+{
+ *(AC2*)a1 = ac2; // { dg-warning "writing 2 bytes into a region of size 1" }
+ *(AC4*)a2 = ac4; // { dg-warning "writing 4 bytes into a region of size 2" }
+ *(AC4*)a3 = ac4; // { dg-warning "writing 4 bytes into a region of size 3" }
+ *(AC8*)a4 = ac8; // { dg-warning "writing 8 bytes into a region of size 4" }
+ *(AC8*)a7 = ac8; // { dg-warning "writing 8 bytes into a region of size 7" }
+ *(AC16*)a15 = ac16; // { dg-warning "writing 16 bytes into a region of size 15" }
+}
+
+void warn_aggr_parm (AC2 pc2, AC4 pc4, AC8 pc8, AC16 pc16)
+{
+ *(AC2*)a1 = pc2; // { dg-warning "writing 2 bytes into a region of size 1" }
+ *(AC4*)a2 = pc4; // { dg-warning "writing 4 bytes into a region of size 2" }
+ *(AC4*)a3 = pc4; // { dg-warning "writing 4 bytes into a region of size 3" }
+ *(AC8*)a4 = pc8; // { dg-warning "writing 8 bytes into a region of size 4" }
+ *(AC8*)a7 = pc8; // { dg-warning "writing 8 bytes into a region of size 7" }
+ *(AC16*)a15 = pc16; // { dg-warning "writing 16 bytes into a region of size 15" }
+}
+
+void warn_aggr_func (void)
+{
+ *(AC2*)a1 = fac2 (); // { dg-warning "writing 2 bytes into a region of size 1" }
+ *(AC4*)a2 = fac4 (); // { dg-warning "writing 4 bytes into a region of size 2" }
+ *(AC4*)a3 = fac4 (); // { dg-warning "writing 4 bytes into a region of size 3" }
+ *(AC8*)a4 = fac8 (); // { dg-warning "writing 8 bytes into a region of size 4" }
+ *(AC8*)a7 = fac8 (); // { dg-warning "writing 8 bytes into a region of size 7" }
+ *(AC16*)a15 = fac16 ();// { dg-warning "writing 16 bytes into a region of size 15" }
+
+ extern AC2 fac2_x ();
+
+ *(AC2*)a1 = fac2_x (); // { dg-warning "writing 2 bytes into a region of size 1" }
+
+ extern AC2 fac2_p (char*);
+
+ *(AC2*)a1 = fac2_p (0); // { dg-warning "writing 2 bytes into a region of size 1" }
+}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-69.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-69.c
new file mode 100644
index 0000000..754b481
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-69.c
@@ -0,0 +1,84 @@
+/* PR tree-optimization/97027 - missing warning on buffer overflow storing
+ a larger scalar into a smaller array
+ Verify overflow by vector stores.
+ { dg-do compile }
+ { dg-options "-O2" } */
+
+#define V(N) __attribute__ ((vector_size (N)))
+#define C1 (VC1){ 0 }
+#define C2 (VC2){ 0, 1 }
+#define C4 (VC4){ 0, 1, 2, 3 }
+#define C8 (VC8){ 0, 1, 2, 3, 4, 5, 6, 7 }
+#define C16 (VC16){ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
+
+typedef V (1) char VC1;
+typedef V (2) char VC2;
+typedef V (4) char VC4;
+typedef V (8) char VC8;
+typedef V (16) char VC16;
+
+extern char a1[1], a2[2], a3[3], a4[4], a5[5], a6[6], a7[7], a8[8], a15[15];
+
+extern VC1 c1;
+extern VC2 c2;
+extern VC4 c4;
+extern VC8 c8;
+extern VC16 c16;
+
+extern VC1 fc1 (void);
+extern VC2 fc2 (void);
+extern VC4 fc4 (void);
+extern VC8 fc8 (void);
+extern VC16 fc16 (void);
+
+void nowarn (void)
+{
+ *(VC1*)a1 = C1;
+ *(VC2*)a2 = C2;
+ *(VC4*)a4 = C4;
+ *(VC4*)a5 = C4;
+ *(VC4*)a6 = C4;
+ *(VC4*)a7 = C4;
+ *(VC8*)a8 = C8;
+ *(VC8*)a15 = C8;
+}
+
+void warn_vec_lit (void)
+{
+ *(VC2*)a1 = C2; // { dg-warning "writing 2 bytes into a region of size 1" }
+ *(VC4*)a2 = C4; // { dg-warning "writing 4 bytes into a region of size 2" }
+ *(VC4*)a3 = C4; // { dg-warning "writing 4 bytes into a region of size 3" }
+ *(VC8*)a4 = C8; // { dg-warning "writing 8 bytes into a region of size 4" }
+ *(VC8*)a7 = C8; // { dg-warning "writing 8 bytes into a region of size 7" }
+ *(VC16*)a15 = C16; // { dg-warning "writing 16 bytes into a region of size 15" }
+}
+
+void warn_vec_decl (void)
+{
+ *(VC2*)a1 = c2; // { dg-warning "writing 2 bytes into a region of size 1" }
+ *(VC4*)a2 = c4; // { dg-warning "writing 4 bytes into a region of size 2" }
+ *(VC4*)a3 = c4; // { dg-warning "writing 4 bytes into a region of size 3" }
+ *(VC8*)a4 = c8; // { dg-warning "writing 8 bytes into a region of size 4" }
+ *(VC8*)a7 = c8; // { dg-warning "writing 8 bytes into a region of size 7" }
+ *(VC16*)a15 = c16; // { dg-warning "writing 16 bytes into a region of size 15" }
+}
+
+void warn_vec_parm (VC2 pc2, VC4 pc4, VC8 pc8, VC16 pc16)
+{
+ *(VC2*)a1 = pc2; // { dg-warning "writing 2 bytes into a region of size 1" }
+ *(VC4*)a2 = pc4; // { dg-warning "writing 4 bytes into a region of size 2" }
+ *(VC4*)a3 = pc4; // { dg-warning "writing 4 bytes into a region of size 3" }
+ *(VC8*)a4 = pc8; // { dg-warning "writing 8 bytes into a region of size 4" }
+ *(VC8*)a7 = pc8; // { dg-warning "writing 8 bytes into a region of size 7" }
+ *(VC16*)a15 = pc16; // { dg-warning "writing 16 bytes into a region of size 15" }
+}
+
+void warn_vec_func (void)
+{
+ *(VC2*)a1 = fc2 (); // { dg-warning "writing 2 bytes into a region of size 1" }
+ *(VC4*)a2 = fc4 (); // { dg-warning "writing 4 bytes into a region of size 2" }
+ *(VC4*)a3 = fc4 (); // { dg-warning "writing 4 bytes into a region of size 3" }
+ *(VC8*)a4 = fc8 (); // { dg-warning "writing 8 bytes into a region of size 4" }
+ *(VC8*)a7 = fc8 (); // { dg-warning "writing 8 bytes into a region of size 7" }
+ *(VC16*)a15 = fc16 ();// { dg-warning "writing 16 bytes into a region of size 15" }
+}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-70.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-70.c
new file mode 100644
index 0000000..82c4d9f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-70.c
@@ -0,0 +1,24 @@
+/* PR tree-optimization/97027 - missing warning on buffer overflow storing
+ a larger scalar into a smaller array
+ Verify overflow by vector stores.
+ { dg-do compile }
+ { dg-options "-O3" } */
+
+void* nowarn_loop (void)
+{
+ char *p = __builtin_malloc (16);
+ for (int i = 0; i != 16; ++i)
+ p[i] = i;
+ return p;
+}
+
+void* warn_loop (void)
+{
+ char *p = __builtin_malloc (15);
+ for (int i = 0; i != 16; ++i)
+ /* The size of the write below depends on the target. When vectorized
+ the vector size may be 4 or 16, otherwise it may be a series of byte
+ assignments. */
+ p[i] = i; // { dg-warning "writing (1|2|4|16) bytes? into a region of size (0|1|3|15)" }
+ return p;
+}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-71.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-71.c
new file mode 100644
index 0000000..f56a005
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-71.c
@@ -0,0 +1,113 @@
+/* PR tree-optimization/97027 - missing warning on buffer overflow storing
+ a larger scalar into a smaller array
+ Verify warnings for overflow by stores of results of built-in functions.
+ { dg-do compile }
+ { dg-options "-O2" } */
+
+typedef __INT16_TYPE__ int16_t;
+typedef __SIZE_TYPE__ size_t;
+
+extern int abs (int);
+
+extern void* alloca (size_t);
+
+extern double nan (const char *);
+
+#ifdef __DEC32_MAX__
+ _Decimal32 nand32 (const char *);
+#else
+/* _Decimal32 is supported only conditionally and not available on all
+ targets. */
+# define _Decimal32 double
+# define nand32(s) nan (s)
+#endif
+
+extern size_t strlen (const char *);
+extern char* strcpy (char *, const char *);
+
+
+extern unsigned char ax[], a1[1], a2[2], a8[8];
+
+
+void nowarn_abs (int i)
+{
+ *(int *)ax = abs (i);
+ *(char *)a1 = abs (i);
+}
+
+void warn_abs (int i)
+{
+ *(int *)a1 = abs (i); // { dg-warning "\\\[-Wstringop-overflow" }
+}
+
+
+void nowarn_alloca (size_t n)
+{
+ *(void **)ax = alloca (n);
+}
+
+void warn_alloca (size_t n)
+{
+ *(void **)a1 = alloca (n); // { dg-warning "\\\[-Wstringop-overflow" }
+}
+
+
+void nowarn_complex (double x, double i)
+{
+ *(_Complex double *)ax = __builtin_complex (x, i);
+}
+
+void warn_complex (double x, double i)
+{
+ _Complex double *p = (_Complex double *)a1;
+ *p = __builtin_complex (x, i); // { dg-warning "\\\[-Wstringop-overflow" "pr101455" { xfail *-*-* } }
+}
+
+
+__attribute__ ((noipa)) void nowarn_nan (const char *s)
+{
+ *(double *)ax = nan (s);
+}
+
+__attribute__ ((noipa)) void warn_nan (const char *s)
+{
+ *(double *)a1 = nan (s); // { dg-warning "\\\[-Wstringop-overflow" }
+}
+
+
+__attribute__ ((noipa)) void nowarn_nand32 (const char *s)
+{
+ *(_Decimal32 *)ax = nand32 (s);
+}
+
+__attribute__ ((noipa)) void warn_nand32 (const char *s)
+{
+ *(_Decimal32 *)a1 = nand32 (s); // { dg-warning "\\\[-Wstringop-overflow" }
+}
+
+
+void nowarn_strlen (const char *s1, const char *s2, const char *s3)
+{
+ *(char *)ax = strlen (s1);
+ *(char *)a1 = strlen (s2);
+ *(size_t *)a8 = strlen (s3);
+}
+
+void warn_strlen (const char *s1, const char *s2)
+{
+ *(int16_t *)a1 = strlen (s1); // { dg-warning "\\\[-Wstringop-overflow" }
+ *(size_t *)a2 = strlen (s2); // { dg-warning "\\\[-Wstringop-overflow" "!ptr_eq_short" { target { ! ptr_eq_short } } }
+}
+
+
+void nowarn_strcpy (char *s1, char *s2, const char *s3)
+{
+ *(char **)ax = strcpy (s1, s2);
+ *(char **)a8 = strcpy (s2, s3);
+}
+
+void warn_strcpy (char *s1, char *s2, const char *s3)
+{
+ *(char **)a1 = strcpy (s1, s2); // { dg-warning "\\\[-Wstringop-overflow" }
+ *(char **)a2 = strcpy (s2, s3); // { dg-warning "\\\[-Wstringop-overflow" "!ptr_eq_short" { target { ! ptr_eq_short } } }
+}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-72.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-72.c
new file mode 100644
index 0000000..c10773e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-72.c
@@ -0,0 +1,13 @@
+/* PR middle-end/101854 - Invalid warning -Wstringop-overflow wrong argument
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+struct A { int a[5]; };
+
+struct A g (int*, int[6][8]);
+
+struct A f (void)
+{
+ int a[2];
+ return g (a, 0); // { dg-bogus "-Wstringop-overflow" }
+}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-73.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-73.c
new file mode 100644
index 0000000..0bb4afe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-73.c
@@ -0,0 +1,35 @@
+/*
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+int memcmp (const void*, const void*, size_t);
+int strncmp (const char*, const char*, size_t);
+char* stpncpy (char*, const char*, size_t);
+char* strncpy (char*, const char*, size_t);
+
+extern char a4[4], b5[5];
+
+struct A { char a4[4]; };
+
+extern volatile int i;
+extern void* volatile ptr;
+
+void test_stpncpy (struct A *p)
+{
+ ptr = stpncpy (a4, b5, 4);
+ ptr = stpncpy (a4, b5, 5); // { dg-warning "writing 5 bytes" }
+
+ ptr = stpncpy (p->a4, b5, 4);
+ ptr = stpncpy (p->a4, b5, 5); // { dg-warning "writing 5 bytes" }
+}
+
+void test_strncpy (struct A *p)
+{
+ ptr = strncpy (a4, b5, 4);
+ ptr = strncpy (a4, b5, 5); // { dg-warning "writing 5 bytes" }
+
+ ptr = strncpy (p->a4, b5, 4);
+ ptr = strncpy (p->a4, b5, 5); // { dg-warning "writing 5 bytes" }
+}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overread-6.c b/gcc/testsuite/gcc.dg/Wstringop-overread-6.c
new file mode 100644
index 0000000..a8177a3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstringop-overread-6.c
@@ -0,0 +1,574 @@
+/* Verify -Wstringop-overread is issued appropriately for calls to string
+ functions at -O0 and without -Wall.
+ { dg-do compile }
+ { dg-options "-O0 -ftrack-macro-expansion=0" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+#define S2 "12"
+#define S9 "123456789"
+
+// <libint.h> functions.
+
+char* gettext (const char *);
+
+// <stdio.h> functions.
+
+typedef struct FILE FILE;
+
+int fputs (const char*, FILE*);
+int fputs_unlocked (const char*, FILE*);
+
+int puts (const char*);
+int puts_unlocked (const char*);
+
+// <string.h> functions.
+
+void* memchr (const void*, int, size_t);
+int memcmp (const void*, const void*, size_t);
+void* memcpy (void*, const void*, size_t);
+void* mempcpy (void*, const void*, size_t);
+void* memmove (void*, const void*, size_t);
+
+char* strchr (const char*, int);
+char* strrchr (const char*, int);
+
+int strcmp (const char*, const char*);
+int strncmp (const char*, const char*, size_t);
+
+char* strcat (char*, const char*);
+char* stpcpy (char*, const char*);
+char* strcpy (char*, const char*);
+char* stpncpy (char*, const char*, size_t);
+char* strncpy (char*, const char*, size_t);
+char* strdup (const char*);
+char* strndup (const char*, size_t);
+
+char* strpbrk (const char*, const char*);
+size_t strcspn (const char*, const char*);
+size_t strspn (const char*, const char*);
+char* strstr (const char*, const char*);
+
+size_t strlen (const char*);
+size_t strnlen (const char*, size_t);
+
+
+extern void* malloc (size_t);
+
+void sink (void*);
+
+
+extern char *d;
+extern char a0[0];
+
+const char arr[7] = "abc\0def";
+
+/* Unterminated array at the end of ARR above. */
+#define unterm (arr + __builtin_strlen (arr) + 1)
+
+/* Size of the unterminated array - 1. */
+#define unterm_size (sizeof arr - __builtin_strlen (arr) - 1)
+
+const void* nowarn_memchr (int x)
+{
+ const char *p1 = unterm;
+ return memchr (p1, x, unterm_size);
+}
+
+const void* warn_memchr (int x)
+{
+ const char *p1 = unterm;
+ return memchr (p1, x, unterm_size + 1); // { dg-warning "-Wstringop-overread" }
+}
+
+
+void* nowarn_memcpy (void)
+{
+ const char *s = unterm;
+ return memcpy (d, s, unterm_size);
+}
+
+void* warn_memcpy (void)
+{
+ const char *s = unterm;
+ /* Use + 2 for an odd size to prevent the memmove --> MEM_REF transform
+ from defeating the warning (for now). */
+ return memcpy (d, s, unterm_size + 2 | 1); // { dg-warning "-Wstringop-overread" }
+}
+
+
+void* nowarn_mempcpy (void)
+{
+ const char *s = unterm;
+ return mempcpy (d, s, unterm_size);
+}
+
+void* warn_mempcpy (void)
+{
+ const char *s = unterm;
+ /* Use + 2 for an odd size to prevent the memmove --> MEM_REF transform
+ from defeating the warning (for now). */
+ return mempcpy (d, s, unterm_size + 2 | 1); // { dg-warning "-Wstringop-overread" }
+}
+
+
+void* nowarn_memmove (void)
+{
+ const char *s = unterm;
+ return memmove (d, s, unterm_size);
+}
+
+void* warn_memmove (void)
+{
+ const char *s = unterm;
+ /* Use + 2 for an odd size to prevent the memmove --> MEM_REF transform
+ from defeating the warning (for now). */
+ return memmove (d, s, unterm_size + 2); // { dg-warning "-Wstringop-overread" }
+}
+
+
+int nowarn_memcmp_1 (const char *p2)
+{
+ const char *p1 = unterm;
+ return memcmp (p1, p2, unterm_size);
+}
+
+int warn_memcmp_1 (const char *p2)
+{
+ const char *p1 = unterm;
+ return memcmp (p1, p2, unterm_size + 1); // { dg-warning "-Wstringop-overread" }
+}
+
+int nowarn_memcmp_2 (const char *p1)
+{
+ const char *p2 = unterm;
+ return memcmp (p1, p2, unterm_size);
+}
+
+int warn_memcmp_2 (const char *p1)
+{
+ const char *p2 = unterm;
+ return memcmp (p1, p2, unterm_size + 1); // { dg-warning "-Wstringop-overread" }
+}
+
+
+void warn_strcat (void)
+{
+ strcat (d, unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+void warn_strcat_a0 (void)
+{
+ strcat (d, a0); // { dg-warning "-Wstringop-overread" }
+}
+
+void warn_strcat_end (void)
+{
+ const char *s = arr + sizeof arr;
+ strcat (d, s); // { dg-warning "-Wstringop-overread" }
+}
+
+char* warn_stpcpy (void)
+{
+ return stpcpy (d, unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+char* warn_stpcpy_a0 (void)
+{
+ return stpcpy (d, a0); // { dg-warning "-Wstringop-overread" }
+}
+
+char* warn_stpcpy_end (void)
+{
+ const char *s = arr + sizeof arr;
+ return stpcpy (d, s); // { dg-warning "-Wstringop-overread" }
+}
+
+char* warn_stpcpy_malloc0 (void)
+{
+ char *s = malloc (0);
+ sink (s);
+ return stpcpy (d, s); // { dg-warning "-Wstringop-overread" }
+}
+
+
+void warn_strcpy (void)
+{
+ strcpy (d, unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+void warn_strcpy_a0 (void)
+{
+ strcpy (d, a0); // { dg-warning "-Wstringop-overread" }
+}
+
+void warn_strcpy_end (void)
+{
+ const char *s = arr + sizeof arr;
+ strcpy (d, s); // { dg-warning "-Wstringop-overread" }
+}
+
+void warn_strcpy_malloc0 (void)
+{
+ char *s = malloc (0);
+ sink (s);
+ strcpy (d, s); // { dg-warning "-Wstringop-overread" }
+}
+
+
+char* nowarn_stpncpy (void)
+{
+ const char *s = unterm;
+ return stpncpy (d, s, unterm_size);
+}
+
+char* warn_stpncpy (void)
+{
+ const char *s = unterm;
+ return stpncpy (d, s, unterm_size + 1); // { dg-warning "-Wstringop-overread" }
+}
+
+char* warn_stpncpy_a0 (void)
+{
+ return stpncpy (d, a0, 3); // { dg-warning "-Wstringop-overread" }
+}
+
+char* warn_stpncpy_end (void)
+{
+ const char *s = arr + sizeof arr;
+ return stpncpy (d, s, sizeof arr); // { dg-warning "-Wstringop-overread" }
+}
+
+
+void nowarn_strncpy (void)
+{
+ const char *s = unterm;
+ strncpy (d, s, unterm_size);
+}
+
+void warn_strncpy (void)
+{
+ const char *s = unterm;
+ strncpy (d, s, unterm_size + 1); // { dg-warning "-Wstringop-overread" }
+}
+
+void warn_strncpy_a0 (void)
+{
+ const char *s = a0;
+ strncpy (d, s, sizeof arr); // { dg-warning "-Wstringop-overread" }
+}
+
+void warn_strncpy_end (void)
+{
+ const char *s = arr + sizeof arr;
+ strncpy (d, s, sizeof arr); // { dg-warning "-Wstringop-overread" }
+}
+
+
+int warn_strlen (void)
+{
+ return strlen (unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+int warn_strlen_a0 (void)
+{
+ return strlen (a0); // { dg-warning "-Wstringop-overread" }
+}
+
+int warn_strlen_end (void)
+{
+ const char *s = arr + sizeof arr;
+ return strlen (s); // { dg-warning "-Wstringop-overread" }
+}
+
+int warn_strlen_malloc0 (void)
+{
+ char *s = malloc (0);
+ sink (s);
+ return strlen (s); // { dg-warning "-Wstringop-overread" }
+}
+
+
+int nowarn_strnlen (void)
+{
+ return strnlen (unterm, unterm_size);
+}
+
+int warn_strnlen (void)
+{
+ return strnlen (unterm, unterm_size + 1); // { dg-warning "-Wstringop-overread" }
+}
+
+int warn_strnlen_end (void)
+{
+ const char *s = arr + sizeof arr;
+ return strnlen (s, 2); // { dg-warning "-Wstringop-overread" }
+}
+
+
+int warn_strcmp_1 (const char *s)
+{
+ return strcmp (unterm, s); // { dg-warning "-Wstringop-overread" }
+}
+
+int warn_strcmp_2 (const char *s)
+{
+ return strcmp (s, unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+int warn_strcmp_2_end (const char *s)
+{
+ const char *t = arr + sizeof arr;
+ return strcmp (s, t); // { dg-warning "-Wstringop-overread" }
+}
+
+
+int nowarn_strncmp_1 (const char *s2)
+{
+ const char *s1 = unterm;
+ return strncmp (s1, s2, unterm_size);
+}
+
+int warn_strncmp_1 (const char *s2)
+{
+ const char *s1 = unterm;
+ return strncmp (s1, s2, unterm_size + 1); // { dg-warning "-Wstringop-overread" }
+}
+
+int nowarn_strncmp_2 (const char *s1)
+{
+ const char *s2 = unterm;
+ return strncmp (s1, s2, unterm_size);
+}
+
+int warn_strncmp_2 (const char *s1)
+{
+ const char *s2 = unterm;
+ return strncmp (s1, s2, unterm_size + 1); // { dg-warning "-Wstringop-overread" }
+}
+
+int warn_strncmp_2_end (const char *s1)
+{
+ const char *s2 = arr + sizeof arr;;
+ return strncmp (s1, s2, sizeof arr); // { dg-warning "-Wstringop-overread" }
+}
+
+
+int nowarn_strncmp_1_s2 (void)
+{
+ /* Since the read is also bounded by the length of the S2 literal
+ and so safe, expect no warning. */
+ const char *s = unterm;
+ return strncmp (s, S2, unterm_size + 1); // { dg-bogus "-Wstringop-overread" "pr101778" { xfail *-*-* } }
+}
+
+int warn_strncmp_2_s2 (void)
+{
+ /* Same as above. */
+ const char *t = unterm;
+ return strncmp (S2, t, unterm_size + 1); // { dg-bogus "-Wstringop-overread" "pr101778" { xfail *-*-* } }
+}
+
+
+int warn_strncmp_1_s9 (void)
+{
+ /* Since both the bound and the length of the S9 literal are greater
+ than the size of UNNTERM the call reads past the end of the array.
+ Expect a warning. */
+ const char *s1 = unterm;
+ return strncmp (s1, S9, unterm_size + 1); // { dg-warning "-Wstringop-overread" }
+}
+
+int warn_strncmp_2_s9 (void)
+{
+ /* Same as above. */
+ const char *s2 = unterm;
+ return strncmp (S9, s2, unterm_size + 1); // { dg-warning "-Wstringop-overread" }
+}
+
+
+const char* warn_strchr (int x)
+{
+ return strchr (unterm, x); // { dg-warning "-Wstringop-overread" }
+}
+
+const char* warn_strchr_end (int x)
+{
+ const char *s = arr + sizeof arr;
+ return strchr (s, x); // { dg-warning "-Wstringop-overread" }
+}
+
+
+const char* warn_strrchr (int x)
+{
+ return strrchr (unterm, x); // { dg-warning "-Wstringop-overread" }
+}
+
+const char* warn_strrchr_end (int x)
+{
+ const char *s = arr + sizeof arr;
+ return strrchr (s, x); // { dg-warning "-Wstringop-overread" }
+}
+
+
+char* warn_strdup (void)
+{
+ return strdup (unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+char* warn_strdup_end (void)
+{
+ const char *s = arr + sizeof arr;
+ return strdup (s); // { dg-warning "-Wstringop-overread" }
+}
+
+
+char* nowarn_strndup (void)
+{
+ return strndup (unterm, unterm_size);
+}
+
+char* warn_strndup (void)
+{
+ return strndup (unterm, unterm_size + 1); // { dg-warning "-Wstringop-overread" }
+}
+
+char* warn_strndup_end (void)
+{
+ const char *s = arr + sizeof arr;
+ return strndup (s, sizeof arr); // { dg-warning "-Wstringop-overread" }
+}
+
+
+const char* warn_strpbrk_1 (const char *s2)
+{
+ return strpbrk (unterm, s2); // { dg-warning "-Wstringop-overread" }
+}
+
+const char* warn_strpbrk_2 (const char *s1)
+{
+ return strpbrk (s1, unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+
+size_t warn_strspn_1 (const char *s2)
+{
+ return strspn (unterm, s2); // { dg-warning "-Wstringop-overread" }
+}
+
+size_t warn_strspn_1_end (const char *s2)
+{
+ const char *s1 = arr + sizeof arr;
+ return strspn (s1, s2); // { dg-warning "-Wstringop-overread" }
+}
+
+size_t warn_strspn_2 (const char *s1)
+{
+ return strspn (s1, unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+size_t warn_strspn_2_end (const char *s1)
+{
+ const char *s2 = arr + sizeof arr;
+ return strspn (s1, s2); // { dg-warning "-Wstringop-overread" }
+}
+
+
+size_t warn_strcspn_1 (const char *s2)
+{
+ return strcspn (unterm, s2); // { dg-warning "-Wstringop-overread" }
+}
+
+size_t warn_strcspn_1_end (const char *s2)
+{
+ const char *s1 = arr + sizeof arr;
+ return strcspn (s1, s2); // { dg-warning "-Wstringop-overread" }
+}
+
+size_t warn_strcspn_2 (const char *s1)
+{
+ return strcspn (s1, unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+size_t warn_strcspn_2_end (const char *s1)
+{
+ const char *s2 = arr + sizeof arr;
+ return strcspn (s1, s2); // { dg-warning "-Wstringop-overread" }
+}
+
+
+const char* warn_strstr_1 (const char *s2)
+{
+ return strstr (unterm, s2); // { dg-warning "-Wstringop-overread" }
+}
+
+const char* warn_strstr_1_end (const char *s2)
+{
+ const char *s1 = arr + sizeof arr;
+ return strstr (s1, s2); // { dg-warning "-Wstringop-overread" }
+}
+
+
+const char* warn_strstr_2 (const char *s1)
+{
+ return strstr (s1, unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+const char* warn_strstr_2_end (const char *s1)
+{
+ const char *s2 = arr + sizeof arr;
+ return strstr (s1, s2); // { dg-warning "-Wstringop-overread" }
+}
+
+
+void warn_puts (void)
+{
+ puts (unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+void warn_puts_end (void)
+{
+ const char *s = arr + sizeof arr;
+ puts (s); // { dg-warning "-Wstringop-overread" }
+}
+
+
+void warn_fputs (FILE *f)
+{
+ fputs (unterm, f); // { dg-warning "-Wstringop-overread" }
+}
+
+void warn_fputs_end (FILE *f)
+{
+ const char *s = arr + sizeof arr;
+ fputs (s, f); // { dg-warning "-Wstringop-overread" }
+}
+
+
+void warn_puts_unlocked (void)
+{
+ puts_unlocked (unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+void warn_puts_unlocked_end (void)
+{
+ const char *s = arr + sizeof arr;
+ puts_unlocked (s); // { dg-warning "-Wstringop-overread" }
+}
+
+void warn_fputs_unlocked (FILE *f)
+{
+ fputs_unlocked (unterm, f); // { dg-warning "-Wstringop-overread" }
+}
+
+
+const char* warn_gettext (void)
+{
+ return gettext (unterm); // { dg-warning "-Wstringop-overread" }
+}
+
+const char* warn_gettext_end (void)
+{
+ const char *s = arr + sizeof arr;
+ return gettext (s); // { dg-warning "-Wstringop-overread" }
+}
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overread.c b/gcc/testsuite/gcc.dg/Wstringop-overread.c
index 0343e43..7db7402 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overread.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overread.c
@@ -317,9 +317,9 @@ void test_strnlen_array (int i, int i0, unsigned n)
T (strnlen (a1, n));
T (strnlen (a1 + 1, 0));
- T (strnlen (a1 + 1, 1)); // { dg-warning "'strnlen' reading 1 byte from a region of size 0" }
+ T (strnlen (a1 + 1, 1)); // { dg-warning "'strnlen' specified bound 1 exceeds source size 0" }
T (strnlen (a1 + 1, i0));
- T (strnlen (a1 + 1, i0 + 1)); // { dg-warning "'strnlen' reading between 1 and \[0-9\]+ bytes from a region of size 0" }
+ T (strnlen (a1 + 1, i0 + 1)); // { dg-warning "'strnlen' specified bound \\\[1, \\d+] exceeds source size 0" }
T (strnlen (a1 + 1, n));
T (strnlen (a1 + i, 0));
T (strnlen (a1 + i, 1));
@@ -335,7 +335,7 @@ void test_strnlen_array (int i, int i0, unsigned n)
T (strnlen (a1 + i0, 2)); // { dg-warning "'strnlen' specified bound 2 exceeds source size 1" }
T (strnlen (a1 + i0, n));
T (strnlen (a1 + i0 + 1, 0));
- T (strnlen (a1 + i0 + 1, 1)); // { dg-warning "'strnlen' reading 1 byte from a region of size 0" }
+ T (strnlen (a1 + i0 + 1, 1)); // { dg-warning "'strnlen' specified bound 1 exceeds source size 0" }
T (strnlen (a1 + i0 + 1, n));
T (strnlen (a2, 0));
@@ -344,10 +344,10 @@ void test_strnlen_array (int i, int i0, unsigned n)
T (strnlen (a2, n));
T (strnlen (a2 + 1, 0));
T (strnlen (a2 + 1, 1));
- T (strnlen (a2 + 1, 2)); // { dg-warning "'strnlen' specified bound 2 exceeds source size 1" "pr87492" { xfail *-*-* } }
+ T (strnlen (a2 + 1, 2)); // { dg-warning "'strnlen' specified bound 2 exceeds source size 1" "pr87492" }
T (strnlen (a2 + 1, n));
T (strnlen (a2 + 2, 0));
- T (strnlen (a2 + 2, 1)); // { dg-warning "'strnlen' reading 1 byte from a region of size 0" }
+ T (strnlen (a2 + 2, 1)); // { dg-warning "'strnlen' specified bound 1 exceeds source size 0" }
T (strnlen (a2 + 2, n));
T (strnlen (a2 + i, 0));
T (strnlen (a2 + i, 1));
@@ -365,13 +365,13 @@ void test_strnlen_array (int i, int i0, unsigned n)
T (strnlen (a2 + i0 + 1, 0));
T (strnlen (a2 + i0 + 1, 1));
- T (strnlen (a2 + i0 + 1, 2));
+ T (strnlen (a2 + i0 + 1, 2)); // { dg-warning "'strnlen' specified bound 2 exceeds source size 1" }
T (strnlen (a2 + i0 + 1, n));
T (strnlen (a2 + i0 + 2, 0));
- T (strnlen (a2 + i0 + 2, 1)); // { dg-warning "'strnlen' reading 1 byte from a region of size 0" }
+ T (strnlen (a2 + i0 + 2, 1)); // { dg-warning "'strnlen' specified bound 1 exceeds source size 0" }
T (strnlen (a2 + i0 + 2, i0));
- T (strnlen (a2 + i0 + 2, i0 + 1)); // { dg-warning "'strnlen' reading between 1 and \[0-9\]+ bytes from a region of size 0" }
+ T (strnlen (a2 + i0 + 2, i0 + 1)); // { dg-warning "'strnlen' specified bound \\\[1, \\d+] exceeds source size 0" }
T (strnlen (a2 + i0 + 2, n));
}
@@ -512,9 +512,9 @@ void test_strndup_array (int i, int i0, unsigned n)
T (strndup (a1, 2)); // { dg-warning "'strndup' specified bound 2 exceeds source size 1" }
T (strndup (a1, n));
T (strndup (a1 + 1, 0));
- T (strndup (a1 + 1, 1)); // { dg-warning "'strndup' reading 1 byte from a region of size 0" }
+ T (strndup (a1 + 1, 1)); // { dg-warning "'strndup' specified bound 1 exceeds source size 0" }
T (strndup (a1 + 1, i0));
- T (strndup (a1 + 1, i0 + 1)); // { dg-warning "'strndup' reading between 1 and \[0-9\]+ bytes from a region of size 0" }
+ T (strndup (a1 + 1, i0 + 1)); // { dg-warning "'strndup' specified bound \\\[1, \\d+] exceeds source size 0" }
T (strndup (a1 + 1, n));
T (strndup (a1 + i, 0));
T (strndup (a1 + i, 1));
@@ -529,7 +529,7 @@ void test_strndup_array (int i, int i0, unsigned n)
T (strndup (a1 + i0, 1));
T (strndup (a1 + i0, n));
T (strndup (a1 + i0 + 1, 0));
- T (strndup (a1 + i0 + 1, 1)); // { dg-warning "'strndup' reading 1 byte from a region of size 0" }
+ T (strndup (a1 + i0 + 1, 1)); // { dg-warning "'strndup' specified bound 1 exceeds source size 0" }
T (strndup (a1 + i0 + 1, n));
T (strndup (a2, 0));
@@ -538,10 +538,10 @@ void test_strndup_array (int i, int i0, unsigned n)
T (strndup (a2, n));
T (strndup (a2 + 1, 0));
T (strndup (a2 + 1, 1));
- T (strndup (a2 + 1, 2));
+ T (strndup (a2 + 1, 2)); // { dg-warning "'strndup' specified bound 2 exceeds source size 1" }
T (strndup (a2 + 1, n));
T (strndup (a2 + 2, 0));
- T (strndup (a2 + 2, 1)); // { dg-warning "'strndup' reading 1 byte from a region of size 0" }
+ T (strndup (a2 + 2, 1)); // { dg-warning "'strndup' specified bound 1 exceeds source size 0" }
T (strndup (a2 + 2, n));
T (strndup (a2 + i, 0));
T (strndup (a2 + i, 1));
@@ -559,13 +559,13 @@ void test_strndup_array (int i, int i0, unsigned n)
T (strndup (a2 + i0 + 1, 0));
T (strndup (a2 + i0 + 1, 1));
- T (strndup (a2 + i0 + 1, 2));
+ T (strndup (a2 + i0 + 1, 2)); // { dg-warning "'strndup' specified bound 2 exceeds source size 1" }
T (strndup (a2 + i0 + 1, n));
T (strndup (a2 + i0 + 2, 0));
- T (strndup (a2 + i0 + 2, 1)); // { dg-warning "'strndup' reading 1 byte from a region of size 0" }
+ T (strndup (a2 + i0 + 2, 1)); // { dg-warning "'strndup' specified bound 1 exceeds source size 0" }
T (strndup (a2 + i0 + 2, i0));
- T (strndup (a2 + i0 + 2, i0 + 1)); // { dg-warning "'strndup' reading between 1 and \[0-9\]+ bytes from a region of size 0" }
+ T (strndup (a2 + i0 + 2, i0 + 1)); // { dg-warning "'strndup' specified bound \\\[1, \\d+] exceeds source size 0" }
T (strndup (a2 + i0 + 2, n));
}
diff --git a/gcc/testsuite/gcc.dg/Wunused-result.c b/gcc/testsuite/gcc.dg/Wunused-result.c
new file mode 100644
index 0000000..c0bb9ae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wunused-result.c
@@ -0,0 +1,50 @@
+/* PR c/99972 - missing -Wunused-result on a call to a locally redeclared
+ warn_unused_result function
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+void gwur_local_local (void)
+{
+ __attribute__ ((warn_unused_result)) int fwur1 (void);
+
+ fwur1 (); // { dg-warning "\\\[-Wunused-result" }
+}
+
+void hwur_local_local (void)
+{
+ /* Verify the attribute from the declaration above is copied/merged
+ into the declaration below. */
+ int fwur1 (void);
+
+ fwur1 (); // { dg-warning "\\\[-Wunused-result" }
+}
+
+
+void gwur_local_global (void)
+{
+ __attribute__ ((warn_unused_result)) int fwur2 (void);
+
+ fwur2 (); // { dg-warning "\\\[-Wunused-result" }
+}
+
+int fwur2 (void);
+
+void hwur_local_global (void)
+{
+ fwur2 (); // { dg-warning "\\\[-Wunused-result" }
+}
+
+
+__attribute__ ((warn_unused_result)) int fwur3 (void);
+
+void gwur_global_local (void)
+{
+ fwur3 (); // { dg-warning "\\\[-Wunused-result" }
+}
+
+void hwur_global_local (void)
+{
+ int fwur3 (void);
+
+ fwur3 (); // { dg-warning "\\\[-Wunused-result" }
+}
diff --git a/gcc/testsuite/gcc.dg/Wunused-var-5.c b/gcc/testsuite/gcc.dg/Wunused-var-5.c
new file mode 100644
index 0000000..cc5bbf5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wunused-var-5.c
@@ -0,0 +1,23 @@
+/* PR c/99588 */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -Wunused-but-set-variable" } */
+
+void bar (int, ...);
+void f1 (void) { static _Atomic int x = 0; bar (0, x); }
+void f2 (void) { static _Atomic int x = 0; bar (0, x += 1); }
+void f3 (void) { static _Atomic int x = 0; bar (x); }
+void f4 (void) { static _Atomic int x = 0; bar (x += 1); }
+void f5 (void) { static _Atomic int x = 0; bar (x = 1); }
+void f6 (void) { static _Atomic int x = 0; x = 1; } /* { dg-warning "variable 'x' set but not used" } */
+void f7 (void) { static _Atomic int x = 0; x += 3; }
+void f8 (void) { _Atomic int x = 0; bar (0, x); }
+void f9 (void) { _Atomic int x = 0; bar (0, x += 1); }
+void f10 (void) { _Atomic int x = 0; bar (x); }
+void f11 (void) { _Atomic int x = 0; bar (x += 1); }
+void f12 (void) { _Atomic int x = 0; bar (x = 1); }
+void f13 (void) { _Atomic int x = 0; x = 1; } /* { dg-warning "variable 'x' set but not used" } */
+void f14 (void) { _Atomic int x = 0; x += 3; }
+void f15 (void) { _Atomic int x = 0; int y = 3; x += y; }
+void f16 (void) { _Atomic int x = 0; int y = 3; bar (x += y); }
+void f17 (void) { _Atomic int x = 0; int y = 3; x = y; } /* { dg-warning "variable 'x' set but not used" } */
+void f18 (void) { _Atomic int x = 0; int y = 3; bar (x = y); }
diff --git a/gcc/testsuite/gcc.dg/Wunused-var-6.c b/gcc/testsuite/gcc.dg/Wunused-var-6.c
new file mode 100644
index 0000000..f48a455
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wunused-var-6.c
@@ -0,0 +1,14 @@
+/* PR c/99588 */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -Wunused-but-set-variable" } */
+
+void bar (int, ...);
+struct S { int a, b, c; };
+typedef _Atomic struct S T;
+
+void
+foo (void)
+{
+ static T x = (struct S) { 0, 0, 0 }; /* { dg-bogus "set but not used" } */
+ bar (0, x = (struct S) { 1, 1, 1 });
+}
diff --git a/gcc/testsuite/gcc.dg/Wvla-larger-than-5.c b/gcc/testsuite/gcc.dg/Wvla-larger-than-5.c
new file mode 100644
index 0000000..c131f83
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wvla-larger-than-5.c
@@ -0,0 +1,38 @@
+/* PR middle-end/100510 - bogus -Wvla-large-than with -Walloca
+ { dg-do compile }
+ { dg-options "-O0 -Walloca -Wvla-larger-than=1000" } */
+
+void f (void*);
+
+#pragma GCC optimize ("0")
+
+void nowarn_O0 (__SIZE_TYPE__ n)
+{
+ if (n > 32)
+ return;
+
+ char a[n]; // { dg-bogus "\\\[-Wvla-larger-than=" }
+ f (a);
+}
+
+#pragma GCC optimize ("1")
+
+void nowarn_O1 (__SIZE_TYPE__ n)
+{
+ if (n > 33)
+ return;
+
+ char a[n]; // { dg-bogus "\\\[-Wvla-larger-than=" }
+ f (a);
+}
+
+#pragma GCC optimize ("2")
+
+void nowarn_O2 (__SIZE_TYPE__ n)
+{
+ if (n > 34)
+ return;
+
+ char a[n]; // { dg-bogus "\\\[-Wvla-larger-than=" }
+ f (a);
+}
diff --git a/gcc/testsuite/gcc.dg/Wvla-parameter-10.c b/gcc/testsuite/gcc.dg/Wvla-parameter-10.c
new file mode 100644
index 0000000..68db3ed
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wvla-parameter-10.c
@@ -0,0 +1,68 @@
+/* PR c/100719 - missing -Wvla-parameter on a mismatch in second parameter
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+typedef struct A1 { int i; } A1;
+typedef struct A2 { int i; } A2;
+typedef struct A3 { int i; } A3;
+
+void f2 (int n, A1[n], A2[n]);
+void f2 (int n, A1[n], A2[n]);
+
+void f2_x1 (int n, A1[n], A2[n]); // { dg-note "previously declared as 'A1\\\[n]' with bound argument 1" }
+void f2_x1 (int n, A1[n + 1], A2[n]); // { dg-warning "argument 2 of type 'A1\\\[n \\+ 1]' declared with mismatched bound 'n \\+ 1'" }
+
+void f2_x2 (int n, A1[n], A2[n]); // { dg-note "previously declared as 'A2\\\[n]' with bound argument 1" }
+void f2_x2 (int n, A1[n], A2[n + 2]); // { dg-warning "argument 3 of type 'A2\\\[n \\+ 2]' declared with mismatched bound 'n \\+ 2'" }
+
+
+void f3 (int n, A1[n], A2[n], A3[n]);
+void f3 (int n, A1[n], A2[n], A3[n]);
+
+void f3_x1 (int n, A1[n], A2[n], A3[n]);
+// { dg-note "previously declared as 'A1\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 }
+void f3_x1 (int n, A1[n + 1], A2[n], A3[n]);
+// { dg-warning "argument 2 of type 'A1\\\[n \\+ 1]' declared with mismatched bound 'n \\+ 1'" "" { target *-*-* } .-1 }
+
+void f3_x2 (int n, A1[n], A2[n], A3[n]);
+// { dg-note "previously declared as 'A2\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 }
+void f3_x2 (int n, A1[n], A2[n + 2], A3[n]);
+// { dg-warning "argument 3 of type 'A2\\\[n \\+ 2]' declared with mismatched bound 'n \\+ 2'" "" { target *-*-* } .-1 }
+
+void f3_x3 (int n, A1[n], A2[n], A3[n]);
+// { dg-note "previously declared as 'A3\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 }
+void f3_x3 (int n, A1[n], A2[n], A3[n + 3]);
+// { dg-warning "argument 4 of type 'A3\\\[n \\+ 3]' declared with mismatched bound 'n \\+ 3'" "" { target *-*-* } .-1 }
+
+
+void g3_x1 (int n, A1[n], A2[*], A3[n]);
+// { dg-note "previously declared as 'A1\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 }
+void g3_x1 (int n, A1[n + 1], A2[*], A3[n]);
+// { dg-warning "argument 2 of type 'A1\\\[n \\+ 1]' declared with mismatched bound 'n \\+ 1'" "" { target *-*-* } .-1 }
+
+void g3_x2 (int n, A1[*], A2[n], A3[n]);
+// { dg-note "previously declared as 'A2\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 }
+void g3_x2 (int n, A1[*], A2[n + 2], A3[n]);
+// { dg-warning "argument 3 of type 'A2\\\[n \\+ 2]' declared with mismatched bound 'n \\+ 2'" "" { target *-*-* } .-1 }
+
+void g3_x3 (int n, A1[*], A2[*], A3[n]);
+// { dg-note "previously declared as 'A3\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 }
+void g3_x3 (int n, A1[*], A2[*], A3[n + 3]);
+// { dg-warning "argument 4 of type 'A3\\\[n \\+ 3]' declared with mismatched bound 'n \\+ 3'" "" { target *-*-* } .-1 }
+
+
+void h3_x1 (int n, A1[n], A2[ ], A3[n]);
+// { dg-note "previously declared as 'A1\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 }
+void h3_x1 (int n, A1[n + 1], A2[ ], A3[n]);
+// { dg-warning "argument 2 of type 'A1\\\[n \\+ 1]' declared with mismatched bound 'n \\+ 1'" "" { target *-*-* } .-1 }
+
+void h3_x2 (int n, A1[ ], A2[n], A3[n]);
+// { dg-note "previously declared as 'A2\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 }
+void h3_x2 (int n, A1[ ], A2[n + 2], A3[n]);
+// { dg-warning "argument 3 of type 'A2\\\[n \\+ 2]' declared with mismatched bound 'n \\+ 2'" "" { target *-*-* } .-1 }
+
+void h3_x3 (int n, A1[ ], A2[ ], A3[n]);
+// { dg-note "previously declared as 'A3\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 }
+void h3_x3 (int n, A1[ ], A2[ ], A3[n + 3]);
+// { dg-warning "argument 4 of type 'A3\\\[n \\+ 3]' declared with mismatched bound 'n \\+ 3'" "" { target *-*-* } .-1 }
+
diff --git a/gcc/testsuite/gcc.dg/Wvla-parameter-11.c b/gcc/testsuite/gcc.dg/Wvla-parameter-11.c
new file mode 100644
index 0000000..39886a2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wvla-parameter-11.c
@@ -0,0 +1,70 @@
+/* PR c/100719 - missing -Wvla-parameter on a mismatch in second parameter
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+typedef struct A1 { int i; } A1;
+typedef struct A2 { int i; } A2;
+typedef struct A3 { int i; } A3;
+
+extern int n, n1, n2, n3;
+
+void f2 (int, A1[n], A2[n]);
+void f2 (int, A1[n], A2[n]);
+
+void f2_x1 (int, A1[n], A2[n]); // { dg-note "previously declared as 'A1\\\[n]'" }
+void f2_x1 (int, A1[n1], A2[n]); // { dg-warning "argument 2 of type 'A1\\\[n1]' declared with mismatched bound 'n1'" }
+
+void f2_x2 (int, A1[n], A2[n]); // { dg-note "previously declared as 'A2\\\[n]'" }
+void f2_x2 (int, A1[n], A2[n2]); // { dg-warning "argument 3 of type 'A2\\\[n2]' declared with mismatched bound 'n2'" }
+
+
+void f3 (int, A1[n], A2[n], A3[n]);
+void f3 (int, A1[n], A2[n], A3[n]);
+
+void f3_x1 (int, A1[n], A2[n], A3[n]);
+// { dg-note "previously declared as 'A1\\\[n]'" "note" { target *-*-* } .-1 }
+void f3_x1 (int, A1[n1], A2[n], A3[n]);
+// { dg-warning "argument 2 of type 'A1\\\[n1]' declared with mismatched bound 'n1'" "" { target *-*-* } .-1 }
+
+void f3_x2 (int, A1[n], A2[n], A3[n]);
+// { dg-note "previously declared as 'A2\\\[n]'" "note" { target *-*-* } .-1 }
+void f3_x2 (int, A1[n], A2[n2], A3[n]);
+// { dg-warning "argument 3 of type 'A2\\\[n2]' declared with mismatched bound 'n2'" "" { target *-*-* } .-1 }
+
+void f3_x3 (int, A1[n], A2[n], A3[n]);
+// { dg-note "previously declared as 'A3\\\[n]'" "note" { target *-*-* } .-1 }
+void f3_x3 (int, A1[n], A2[n], A3[n3]);
+// { dg-warning "argument 4 of type 'A3\\\[n3]' declared with mismatched bound 'n3'" "" { target *-*-* } .-1 }
+
+
+void g3_x1 (int, A1[n], A2[*], A3[n]);
+// { dg-note "previously declared as 'A1\\\[n]'" "note" { target *-*-* } .-1 }
+void g3_x1 (int, A1[n1], A2[*], A3[n]);
+// { dg-warning "argument 2 of type 'A1\\\[n1]' declared with mismatched bound 'n1'" "" { target *-*-* } .-1 }
+
+void g3_x2 (int, A1[*], A2[n], A3[n]);
+// { dg-note "previously declared as 'A2\\\[n]'" "note" { target *-*-* } .-1 }
+void g3_x2 (int, A1[*], A2[n2], A3[n]);
+// { dg-warning "argument 3 of type 'A2\\\[n2]' declared with mismatched bound 'n2'" "" { target *-*-* } .-1 }
+
+void g3_x3 (int, A1[*], A2[*], A3[n]);
+// { dg-note "previously declared as 'A3\\\[n]'" "note" { target *-*-* } .-1 }
+void g3_x3 (int, A1[*], A2[*], A3[n3]);
+// { dg-warning "argument 4 of type 'A3\\\[n3]' declared with mismatched bound 'n3'" "" { target *-*-* } .-1 }
+
+
+void h3_x1 (int, A1[n], A2[ ], A3[n]);
+// { dg-note "previously declared as 'A1\\\[n]'" "note" { target *-*-* } .-1 }
+void h3_x1 (int, A1[n1], A2[ ], A3[n]);
+// { dg-warning "argument 2 of type 'A1\\\[n1]' declared with mismatched bound 'n1'" "" { target *-*-* } .-1 }
+
+void h3_x2 (int, A1[ ], A2[n], A3[n]);
+// { dg-note "previously declared as 'A2\\\[n]'" "note" { target *-*-* } .-1 }
+void h3_x2 (int, A1[ ], A2[n2], A3[n]);
+// { dg-warning "argument 3 of type 'A2\\\[n2]' declared with mismatched bound 'n2'" "" { target *-*-* } .-1 }
+
+void h3_x3 (int, A1[ ], A2[ ], A3[n]);
+// { dg-note "previously declared as 'A3\\\[n]'" "note" { target *-*-* } .-1 }
+void h3_x3 (int, A1[ ], A2[ ], A3[n3]);
+// { dg-warning "argument 4 of type 'A3\\\[n3]' declared with mismatched bound 'n3'" "" { target *-*-* } .-1 }
+
diff --git a/gcc/testsuite/gcc.dg/Wvla-parameter-12.c b/gcc/testsuite/gcc.dg/Wvla-parameter-12.c
new file mode 100644
index 0000000..1be5e48
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wvla-parameter-12.c
@@ -0,0 +1,36 @@
+/* PR c/101289 - bogus -Wvla-parameter warning when using const bound
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+void f1ci_can (const int n, char a[n]);
+void f1ci_can (const int n, char a[n]); // { dg-bogus "-Wvla-parameter" }
+
+void f2ci_can (const int m, char a[m]);
+void f2ci_can (int n, char a[n]); // { dg-bogus "-Wvla-parameter" }
+
+void f3i_can (int n, char a[n]);
+void f3i_can (const int n, char a[n]); // { dg-bogus "-Wvla-parameter" }
+
+void f4i_can (int n, char a[n]);
+void f4i_can (const int n, char a[(int)n]); // { dg-bogus "-Wvla-parameter" }
+
+void f5i_can (int n, char a[(char)n]);
+void f5i_can (const int n, char a[(char)n]); // { dg-bogus "-Wvla-parameter" }
+
+void f6i_can (int m, char a[(char)m]);
+void f6i_can (const int n, char a[(char)n]); // { dg-bogus "-Wvla-parameter" "" { xfail *-*-* } }
+
+
+/* PR c/97548 - bogus -Wvla-parameter on a bound expression involving
+ a parameter */
+
+int n;
+
+void f7ianp1 (int, int[n + 1]);
+void f7ianp1 (int, int[n + 1]);
+void f7ianp1 (int, int[n + 2]); // { dg-warning "-Wvla-parameter" }
+
+void f8iakp1 (int k, int [k + 1]);
+void f8iakp1 (int k, int [k + 1]); // { dg-bogus "-Wvla-parameter" }
+void f8iakp1 (int k, int [1 + k]); // { dg-bogus "-Wvla-parameter" }
+void f8iakp1 (int k, int [k + 2]); // { dg-warning "-Wvla-parameter" }
diff --git a/gcc/testsuite/gcc.dg/Wvla-parameter-13.c b/gcc/testsuite/gcc.dg/Wvla-parameter-13.c
new file mode 100644
index 0000000..f64d29c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wvla-parameter-13.c
@@ -0,0 +1,18 @@
+/* PR c/101585 - Bad interaction of -fsanitize=undefined and -Wvla-parameters
+ { dg-do compile }
+ { dg-options "-Wall -fsanitize=undefined" } */
+
+void f1 (int n, int (*)[n]);
+void f1 (int n, int (*)[n]); // { dg-bogus "\\\[-Wvla-parameter" }
+
+void g1 (int m, int (*)[m]);
+void g1 (int n, int (*)[n]); // { dg-bogus "\\\[-Wvla-parameter" "pr101605" { xfail *-*-* } }
+
+void h1 (int n, int (*)[n]);
+void h1 (int n, int (*)[n + 1]); // { dg-warning "\\\[-Wvla-parameter" }
+
+void f2 (int m, int n, int (*)[m][n]);
+void f2 (int n, int m, int (*)[n][m]); // { dg-bogus "\\\[-Wvla-parameter" "pr101605" { xfail *-*-* } }
+
+void g2 (int m, int n, int (*)[m][n]);
+void g2 (int n, int m, int (*)[m][n]); // { dg-warning "\\\[-Wvla-parameter" "pr101605" { xfail *-*-* } }
diff --git a/gcc/testsuite/gcc.dg/Wvla-parameter-2.c b/gcc/testsuite/gcc.dg/Wvla-parameter-2.c
index 01728e7..daa71d8 100644
--- a/gcc/testsuite/gcc.dg/Wvla-parameter-2.c
+++ b/gcc/testsuite/gcc.dg/Wvla-parameter-2.c
@@ -37,14 +37,14 @@ void f (int[n1][2][n3][4][n5][6][n7][8][n9]);
/* Due to a limitation and because [*] is represented the same as [0]
only the most significant array bound is rendered as [*]; the others
are rendered as [0]. */
-void f (int[n1][2][n3][4][n5][6][n7][8][*]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[\\\*]' declared with 1 unspecified variable bound" "pr?????" { xfail *-*-* } }
-// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[0]' declared with 1 unspecified variable bound" "pr?????" { target *-*-* } .-1 }
-void f (int[n1][2][n3][4][n5][6][*][8][n9]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[\\\*]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr?????" { xfail *-*-* } }
-// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[0]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr?????" { target *-*-* } .-1 }
-void f (int[n1][2][n3][4][*][6][n7][8][n9]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[\\\*]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr?????" { xfail *-*-*} }
-// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[0]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr?????" { target *-*-* } .-1 }
-void f (int[n1][2][*][4][n5][6][n7][8][n9]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[\\\*]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr?????" { xfail *-*-* } }
-// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[0]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr?????" { target *-*-* } .-1 }
+void f (int[n1][2][n3][4][n5][6][n7][8][*]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[\\\*]' declared with 1 unspecified variable bound" "pr100420 (expected)" { xfail *-*-* } }
+// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[0]' declared with 1 unspecified variable bound" "pr100420" { target *-*-* } .-1 }
+void f (int[n1][2][n3][4][n5][6][*][8][n9]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[\\\*]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420 (expected)" { xfail *-*-* } }
+// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[0]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420" { target *-*-* } .-1 }
+void f (int[n1][2][n3][4][*][6][n7][8][n9]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[\\\*]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420 (expected)" { xfail *-*-*} }
+// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[0]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420" { target *-*-* } .-1 }
+void f (int[n1][2][*][4][n5][6][n7][8][n9]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[\\\*]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420 (expected)" { xfail *-*-* } }
+// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[0]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420" { target *-*-* } .-1 }
void f (int[*][2][n3][4][n5][6][n7][8][n9]); // { dg-warning "argument 1 of type 'int\\\[\\\*]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" }
void f (int[n1][n2][n3][n4][n5][n6][n7][n8][n9]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[n2]\\\[n3]\\\[n4]\\\[n5]\\\[n6]\\\[n7]\\\[n8]\\\[n9]' declared with 9 variable bounds" }
diff --git a/gcc/testsuite/gcc.dg/Wvla-parameter-3.c b/gcc/testsuite/gcc.dg/Wvla-parameter-3.c
index 51f0172..f1cf139 100644
--- a/gcc/testsuite/gcc.dg/Wvla-parameter-3.c
+++ b/gcc/testsuite/gcc.dg/Wvla-parameter-3.c
@@ -25,19 +25,19 @@ void ppax (int (**)[*]); // { dg-message "previously declared as
void ppax (int (**)[n]); // { dg-warning "\\\[-Wvla-parameter" }
/* A VLA with an unspecified bound is represented the same as [0] so
so the pretty printer can't differentiate between the two forms. */
-void ppax (int (**)[1]); // { dg-bogus "\\\[-Warray-parameter" "pr?????" { xfail *-*-* } }
- // { dg-warning "\\\[-Wvla-parameter" "pr?????" { xfail *-*-* } .-1 }
+void ppax (int (**)[1]); // { dg-bogus "\\\[-Warray-parameter" "pr100420 (expected)" { xfail *-*-* } }
+ // { dg-warning "\\\[-Wvla-parameter" "pr100420 (expected)" { xfail *-*-* } .-1 }
void ppax (int (**)[n + 1]); // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int *\\\(\\\*\\\*\\\)\\\[n \\\+ 1\\\]'" }
void pa1_n (int (*)[1][n]);
void pa1_n (int (*)[1][n]);
-void pa1_n (int (*)[*][n]); // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int \\\(\\\*\\\)\\\[\\\*]\\\[n]'" "pr?????" { xfail *-*-*} }
- // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int \\\(\\\*\\\)\\\[0]\\\[n]'" "pr?????" { target *-*-* } .-1 }
+void pa1_n (int (*)[*][n]); // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int \\\(\\\*\\\)\\\[\\\*]\\\[n]'" "pr100420 (expected)" { xfail *-*-*} }
+ // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int \\\(\\\*\\\)\\\[0]\\\[n]'" "pr100420" { target *-*-* } .-1 }
void pa1_n_2 (int (*)[1][n][2]);
-void pa1_n_2 (int (*)[1][n][*]); // { dg-warning "mismatch in bound 3 of argument 1 declared as 'int \\\(\\\*\\\)\\\[1]\\\[n]\\\[\\\*]'" "pr?????" { xfail *-*-* } }
- // { dg-warning "mismatch in bound 3 of argument 1 declared as 'int \\\(\\\*\\\)\\\[1]\\\[n]\\\[0]'" "pr?????" { target *-*-* } .-1 }
+void pa1_n_2 (int (*)[1][n][*]); // { dg-warning "mismatch in bound 3 of argument 1 declared as 'int \\\(\\\*\\\)\\\[1]\\\[n]\\\[\\\*]'" "pr100420 (expected)" { xfail *-*-* } }
+ // { dg-warning "mismatch in bound 3 of argument 1 declared as 'int \\\(\\\*\\\)\\\[1]\\\[n]\\\[0]'" "pr100420" { target *-*-* } .-1 }
void pa1_n_2_a1_n_2 (int (*)[1][n][2], int (*)[1][n][2]);
diff --git a/gcc/testsuite/gcc.dg/Wvla-parameter-9.c b/gcc/testsuite/gcc.dg/Wvla-parameter-9.c
new file mode 100644
index 0000000..6c8987a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wvla-parameter-9.c
@@ -0,0 +1,30 @@
+/* PR c/100550 - ICE: in fold_convert_loc with function call VLA argument
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+struct S { int i; };
+
+extern void v;
+extern void *pv;
+extern struct S s;
+void vf (void);
+
+/* Verify that a function redeclaration with an invalid VLA doesn't ICE. */
+
+void f0 (int[]);
+void f0 (int[undeclared]); // { dg-error "undeclared" }
+
+void f1 (int[]);
+void f1 (int[-1]); // { dg-error "size" }
+
+void f2 (int[]);
+void f2 (int[v]); // { dg-error "size" }
+
+void f3 (int[]);
+void f3 (int b[s]); // { dg-error "size" }
+
+void f4 (int[]);
+void f4 (int c[pv]); // { dg-error "size" }
+
+void f5 (int[]);
+void f5 (int d[vf ()]); // { dg-error "size" }
diff --git a/gcc/testsuite/gcc.dg/alias-7.c b/gcc/testsuite/gcc.dg/alias-7.c
index 591c302..e0c24bd 100644
--- a/gcc/testsuite/gcc.dg/alias-7.c
+++ b/gcc/testsuite/gcc.dg/alias-7.c
@@ -1,6 +1,7 @@
/* { dg-do run } */
/* { dg-require-alias "" } */
/* { dg-options "-O2" } */
+/* { dg-skip-if "weak alias" { powerpc-ibm-aix* } } */
extern void abort (void);
diff --git a/gcc/testsuite/gcc.dg/analyzer/analyzer-decls.h b/gcc/testsuite/gcc.dg/analyzer/analyzer-decls.h
index d96b3f2..e8745c0 100644
--- a/gcc/testsuite/gcc.dg/analyzer/analyzer-decls.h
+++ b/gcc/testsuite/gcc.dg/analyzer/analyzer-decls.h
@@ -15,6 +15,9 @@ extern void __analyzer_describe (int verbosity, ...);
/* Dump copious information about the analyzer’s state when reached. */
extern void __analyzer_dump (void);
+/* Emit a warning describing the size of the base region of (*ptr). */
+extern void __analyzer_dump_capacity (const void *ptr);
+
/* Dump information after analysis on all of the exploded nodes at this
program point.
@@ -32,6 +35,11 @@ extern void __analyzer_dump_path (void);
/* Dump the region_model's state to stderr. */
extern void __analyzer_dump_region_model (void);
+/* Emit a warning describing the state of the 2nd argument
+ (which can be of any type) with respect to NAME.
+ This is for use when debugging, and may be of use in DejaGnu tests. */
+extern void __analyzer_dump_state (const char *name, ...);
+
/* Emit a warning with text "TRUE", FALSE" or "UNKNOWN" based on the
truthfulness of the argument. */
extern void __analyzer_eval (int);
diff --git a/gcc/testsuite/gcc.dg/analyzer/asm-x86-1.c b/gcc/testsuite/gcc.dg/analyzer/asm-x86-1.c
new file mode 100644
index 0000000..f6026b7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/asm-x86-1.c
@@ -0,0 +1,69 @@
+/* { dg-do assemble { target x86_64-*-* } } */
+
+#include "analyzer-decls.h"
+
+int test_out (void)
+{
+ int dst_a, dst_b;
+ asm ("mov 42, %0"
+ : "=r" (dst_a));
+ asm ("mov 42, %0"
+ : "=r" (dst_b));
+ __analyzer_eval (dst_a == dst_b); /* { dg-warning "TRUE" } */
+ return dst_a;
+}
+
+int test_out_in (int src_a)
+{
+ int dst_a, dst_b;
+ asm ("mov %1, %0"
+ : "=r" (dst_a)
+ : "r" (src_a));
+ asm ("mov %1, %0"
+ : "=r" (dst_b)
+ : "r" (src_a));
+ __analyzer_eval (dst_a == dst_b); /* { dg-warning "TRUE" } */
+ return dst_a;
+}
+
+int test_out_in_in (int src_a, int src_b)
+{
+ int dst_a, dst_b;
+ asm ("mov %1, %0;\n"
+ "add %2, %0"
+ : "=r" (dst_a)
+ : "r" (src_a),
+ "r" (src_b));
+ asm ("mov %1, %0;\n"
+ "add %2, %0"
+ : "=r" (dst_b)
+ : "r" (src_a),
+ "r" (src_b));
+ __analyzer_eval (dst_a == dst_b); /* { dg-warning "TRUE" } */
+ return dst_a;
+}
+
+void test_inout_1 (int v)
+{
+ int saved = v;
+ int result_a, result_b;
+ asm ("dec %0"
+ : "+r" (v));
+ result_a = v;
+
+ asm ("dec %0"
+ : "+r" (v));
+ result_b = v;
+
+ __analyzer_eval (v == saved); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (v == result_a); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (v == result_b); /* { dg-warning "TRUE" } */
+}
+
+void test_inout_2 (void)
+{
+ int v;
+ int result_a, result_b;
+ asm ("dec %0" /* { dg-warning "use of uninitialized value 'v'" } */
+ : "+r" (v));
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/asm-x86-lp64-1.c b/gcc/testsuite/gcc.dg/analyzer/asm-x86-lp64-1.c
new file mode 100644
index 0000000..c235e22
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/asm-x86-lp64-1.c
@@ -0,0 +1,131 @@
+/* { dg-do assemble { target x86_64-*-* } } */
+/* { dg-require-effective-target lp64 } */
+
+#include "analyzer-decls.h"
+
+#include <stdint.h>
+
+int test_1 (int src)
+{
+ int dst;
+ asm ("mov %1, %0\n\t"
+ "add $1, %0"
+ : "=r" (dst)
+ : "r" (src));
+ return dst;
+}
+
+uint32_t test_2 (uint32_t Mask)
+{
+ uint32_t Index;
+ asm ("bsfl %[aMask], %[aIndex]"
+ : [aIndex] "=r" (Index)
+ : [aMask] "r" (Mask)
+ : "cc");
+ return Index;
+}
+
+int test_3a (int p1, int p2)
+{
+ asm goto ("btl %1, %0\n\t"
+ "jc %l2"
+ : // No outputs
+ : "r" (p1), "r" (p2)
+ : "cc"
+ : carry);
+
+ return 0;
+
+ carry:
+ return 1;
+}
+
+int test_3b (int p1, int p2)
+{
+ asm goto ("btl %1, %0\n\t"
+ "jc %l[carry]"
+ : // No outputs
+ : "r" (p1), "r" (p2)
+ : "cc"
+ : carry);
+
+ return 0;
+
+ carry:
+ return 1;
+}
+
+uint64_t test_4 (void)
+{
+ uint64_t start_time, end_time;
+
+ // Get start time
+ asm volatile ("rdtsc\n\t" // Returns the time in EDX:EAX.
+ "shl $32, %%rdx\n\t" // Shift the upper bits left.
+ "or %%rdx, %0" // 'Or' in the lower bits.
+ : "=a" (start_time)
+ :
+ : "rdx");
+
+ // could do other work here
+
+ // Get end time
+ asm volatile ("rdtsc\n\t" // Returns the time in EDX:EAX.
+ "shl $32, %%rdx\n\t" // Shift the upper bits left.
+ "or %%rdx, %0" // 'Or' in the lower bits.
+ : "=a" (end_time)
+ :
+ : "rdx");
+
+ __analyzer_eval (start_time == end_time); /* { dg-warning "UNKNOWN" } */
+
+ // Get elapsed time
+ return end_time - start_time;
+}
+
+static uint64_t get_time (void)
+{
+ uint64_t result;
+ asm volatile ("rdtsc\n\t" // Returns the time in EDX:EAX.
+ "shl $32, %%rdx\n\t" // Shift the upper bits left.
+ "or %%rdx, %0" // 'Or' in the lower bits.
+ : "=a" (result)
+ :
+ : "rdx");
+ return result;
+}
+
+uint64_t test_4a (void)
+{
+ uint64_t start_time, end_time;
+
+ start_time = get_time ();
+ // could do other work here
+ end_time = get_time ();
+
+ __analyzer_eval (start_time == end_time); /* { dg-warning "UNKNOWN" } */
+
+ // Get elapsed time
+ return end_time - start_time;
+}
+
+asm ("\t.pushsection .text\n"
+ "\t.globl add_asm\n"
+ "\t.type add_asm, @function\n"
+ "add_asm:\n"
+ "\tmovq %rdi, %rax\n"
+ "\tadd %rsi, %rax\n"
+ "\tret\n"
+ "\t.popsection\n");
+
+int test_5 (int count)
+{
+ asm goto ("dec %0; jb %l[stop]"
+ : "+r" (count)
+ :
+ :
+ : stop);
+ return count;
+stop:
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/asm-x86-lp64-2.c b/gcc/testsuite/gcc.dg/analyzer/asm-x86-lp64-2.c
new file mode 100644
index 0000000..fa50739
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/asm-x86-lp64-2.c
@@ -0,0 +1,34 @@
+/* { dg-do assemble { target x86_64-*-* } } */
+/* { dg-require-effective-target lp64 } */
+
+/* Adapted from Linux x86: page_ref_dec_and_test.c (GPL-2.0). */
+
+typedef _Bool bool;
+
+typedef struct {
+ int counter;
+} atomic_t;
+
+bool
+arch_atomic_dec_and_test(atomic_t *v) {
+ return ({
+ bool c;
+ asm volatile(".pushsection .smp_locks,\"a\"\n"
+ ".balign 4\n"
+ ".long 671f - .\n"
+ ".popsection\n"
+ "671:"
+ "\n\tlock; "
+ "decl"
+ " "
+ "%[var]"
+ "\n\t/* output condition code "
+ "e"
+ "*/\n"
+ : [ var ] "+m"(v->counter), "=@cc"
+ "e"(c)
+ :
+ : "memory");
+ c;
+ });
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c
index 3de32b1..a9a2a3d 100644
--- a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c
@@ -11,6 +11,12 @@ extern struct foo *foo_acquire (void)
extern void use_foo (const struct foo *)
__attribute__((nonnull));
+extern struct foo *compatible_alloc (void)
+ __attribute__ ((malloc (__builtin_free)));
+
+extern struct foo *compatible_alloc2 (void)
+ __attribute__ ((malloc (free)));
+
void test_1 (void)
{
struct foo *p = foo_acquire ();
@@ -73,3 +79,16 @@ int test_8 (struct foo *p)
foo_release (p);
return p->m_int; /* { dg-warning "use after 'foo_release' of 'p'" } */
}
+
+/* Recognize that __builtin_free and free are the same thing. */
+void test_9 (void)
+{
+ struct foo *p = compatible_alloc ();
+ free (p);
+}
+
+void test_10 (void)
+{
+ struct foo *p = compatible_alloc2 ();
+ __builtin_free (p);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c
index 905d50e..e086843 100644
--- a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c
+++ b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c
@@ -192,9 +192,7 @@ static int ath10k_usb_hif_tx_sg(struct ath10k *ar, u8 pipe_id,
goto err_free_urb_to_pipe;
}
- /* TODO: the loop confuses the double-free checker (another
- instance of PR analyzer/93695). */
- usb_free_urb(urb); /* { dg-bogus "double-'usb_free_urb' of 'urb'" "" { xfail *-*-* } } */
+ usb_free_urb(urb); /* { dg-bogus "double-'usb_free_urb' of 'urb'" } */
}
return 0;
diff --git a/gcc/testsuite/gcc.dg/analyzer/bitfields-1.c b/gcc/testsuite/gcc.dg/analyzer/bitfields-1.c
new file mode 100644
index 0000000..8bbe76b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/bitfields-1.c
@@ -0,0 +1,144 @@
+#include "analyzer-decls.h"
+
+typedef unsigned char u8;
+typedef unsigned __INT16_TYPE__ u16;
+typedef unsigned __INT32_TYPE__ u32;
+
+struct st1
+{
+ u16 nonzero_offset;
+ unsigned int f0 : 1;
+ unsigned int f1 : 1;
+ unsigned int f2 : 1;
+ unsigned int f3 : 1;
+ unsigned int f4 : 1;
+ unsigned int f5 : 1;
+ unsigned int f6 : 1;
+ unsigned int f7 : 1;
+};
+
+void test_1 (void)
+{
+ struct st1 s;
+ s.f0 = 0;
+ __analyzer_eval (s.f0 == 0); /* { dg-warning "TRUE" } */
+ s.f0 = 1;
+ __analyzer_eval (s.f0 == 1); /* { dg-warning "TRUE" } */
+
+ s.f1 = 0;
+ __analyzer_eval (s.f1 == 0); /* { dg-warning "TRUE" } */
+ s.f1 = 1;
+ __analyzer_eval (s.f1 == 1); /* { dg-warning "TRUE" } */
+
+ /* etc */
+
+ s.f6 = 0;
+ __analyzer_eval (s.f6 == 0); /* { dg-warning "TRUE" } */
+ s.f6 = 1;
+ __analyzer_eval (s.f6 == 1); /* { dg-warning "TRUE" } */
+
+ s.f7 = 0;
+ __analyzer_eval (s.f7 == 0); /* { dg-warning "TRUE" } */
+ s.f7 = 1;
+ __analyzer_eval (s.f7 == 1); /* { dg-warning "TRUE" } */
+};
+
+void test_2 (_Bool v0, _Bool v1, _Bool v2, _Bool v3,
+ _Bool v4, _Bool v5, _Bool v6, _Bool v7)
+{
+ struct st1 s;
+ s.f0 = v0;
+ s.f1 = v1;
+ s.f2 = v2;
+ s.f3 = v3;
+ s.f4 = v4;
+ s.f5 = v5;
+ s.f6 = v6;
+ s.f7 = v7;
+
+ __analyzer_eval (s.f0 == v0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (s.f1 == v1); /* { dg-warning "TRUE" } */
+ __analyzer_eval (s.f2 == v2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (s.f3 == v3); /* { dg-warning "TRUE" } */
+ __analyzer_eval (s.f4 == v4); /* { dg-warning "TRUE" } */
+ __analyzer_eval (s.f5 == v5); /* { dg-warning "TRUE" } */
+ __analyzer_eval (s.f6 == v6); /* { dg-warning "TRUE" } */
+ __analyzer_eval (s.f7 == v7); /* { dg-warning "TRUE" } */
+};
+
+struct st3
+{
+ unsigned int f01 : 2;
+ unsigned int f23 : 2;
+ unsigned int f34 : 2;
+ unsigned int f56 : 2;
+};
+
+void test_3 (void)
+{
+ struct st3 s;
+ s.f01 = 0;
+ __analyzer_eval (s.f01 == 0); /* { dg-warning "TRUE" } */
+ s.f01 = 1;
+ __analyzer_eval (s.f01 == 1); /* { dg-warning "TRUE" } */
+ s.f01 = 2;
+ __analyzer_eval (s.f01 == 2); /* { dg-warning "TRUE" } */
+ s.f01 = 3;
+ __analyzer_eval (s.f01 == 3); /* { dg-warning "TRUE" } */
+
+ /* etc */
+
+ s.f56 = 0;
+ __analyzer_eval (s.f56 == 0); /* { dg-warning "TRUE" } */
+ s.f56 = 1;
+ __analyzer_eval (s.f56 == 1); /* { dg-warning "TRUE" } */
+ s.f56 = 2;
+ __analyzer_eval (s.f56 == 2); /* { dg-warning "TRUE" } */
+ s.f56 = 3;
+ __analyzer_eval (s.f56 == 3); /* { dg-warning "TRUE" } */
+};
+
+/* A signed bitfield. */
+
+struct st4
+{
+ signed int f012 : 3;
+ signed int f345 : 3;
+};
+
+void test_4 (void)
+{
+ struct st4 s;
+ s.f345 = -4;
+ __analyzer_eval (s.f345 == -4); /* { dg-warning "TRUE" } */
+ s.f345 = -3;
+ __analyzer_eval (s.f345 == -3); /* { dg-warning "TRUE" } */
+ s.f345 = -2;
+ __analyzer_eval (s.f345 == -2); /* { dg-warning "TRUE" } */
+ s.f345 = -1;
+ __analyzer_eval (s.f345 == -1); /* { dg-warning "TRUE" } */
+ s.f345 = 0;
+ __analyzer_eval (s.f345 == 0); /* { dg-warning "TRUE" } */
+ s.f345 = 1;
+ __analyzer_eval (s.f345 == 1); /* { dg-warning "TRUE" } */
+ s.f345 = 2;
+ __analyzer_eval (s.f345 == 2); /* { dg-warning "TRUE" } */
+ s.f345 = 3;
+ __analyzer_eval (s.f345 == 3); /* { dg-warning "TRUE" } */
+};
+
+/* A zero bitfield to break up padding. */
+
+struct st5
+{
+ unsigned f0 : 5;
+ unsigned :0;
+ unsigned f1 : 16;
+};
+
+void test_5 (void)
+{
+ struct st5 s;
+ s.f1 = 0xcafe;
+ __analyzer_eval (s.f1 == 0xcafe); /* { dg-warning "TRUE" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/capacity-1.c b/gcc/testsuite/gcc.dg/analyzer/capacity-1.c
new file mode 100644
index 0000000..9ea41f7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/capacity-1.c
@@ -0,0 +1,106 @@
+#include <stdlib.h>
+#include "analyzer-decls.h"
+
+typedef unsigned __INT32_TYPE__ u32;
+
+void
+test_1 (void)
+{
+ char buf[16];
+ __analyzer_dump_capacity (buf); /* { dg-warning "capacity: '\\(sizetype\\)16'" } */
+}
+
+void
+test_2 (void)
+{
+ char ch;
+ __analyzer_dump_capacity (&ch); /* { dg-warning "capacity: '\\(sizetype\\)1'" } */
+}
+
+struct s3 { char buf[100]; };
+
+void
+test_3 (void)
+{
+ struct s3 s;
+ __analyzer_dump_capacity (&s); /* { dg-warning "capacity: '\\(sizetype\\)100'" } */
+}
+
+/* Capacity refers to the base region, not any offset within it. */
+
+void
+test_4 (void)
+{
+ char buf[1024];
+ __analyzer_dump_capacity (buf + 100); /* { dg-warning "capacity: '\\(sizetype\\)1024'" } */
+}
+
+void
+test_5 (void *p)
+{
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'UNKNOWN\\(sizetype\\)'" } */
+}
+
+void
+test_malloc (void)
+{
+ void *p = malloc (1024);
+
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: '\\(size_t\\)1024'" } */
+ free (p);
+}
+
+void
+test_alloca (size_t sz)
+{
+ void *p = alloca (sz);
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'INIT_VAL\\(sz_\[^\n\r\]*\\)'" } */
+}
+
+void
+test_vla (size_t sz)
+{
+ char buf[sz];
+ __analyzer_dump_capacity (buf); /* { dg-warning "capacity: 'INIT_VAL\\(sz_\[^\n\r\]*\\)'" } */
+}
+
+static void * __attribute__((noinline))
+called_by_test_interproc_malloc (size_t a)
+{
+ return malloc (a);
+}
+
+void *
+test_interproc_malloc (size_t sz)
+{
+ void *p = called_by_test_interproc_malloc (sz);
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'INIT_VAL\\(sz_\[^\n\r\]*\\)'" } */
+ return p;
+}
+
+struct s
+{
+ u32 f1;
+ char arr[];
+};
+
+static struct s * __attribute__((noinline))
+alloc_s (size_t num)
+{
+ struct s *p = malloc (sizeof(struct s) + num);
+ return p;
+}
+
+struct s *
+test_trailing_array (void)
+{
+ struct s *p = alloc_s (5);
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: '\\(\[^\n\r\]*\\)9'" } */
+ return p;
+}
+
+void
+test_unknown_arr (int p[])
+{
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'UNKNOWN\\(sizetype\\)'" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/capacity-2.c b/gcc/testsuite/gcc.dg/analyzer/capacity-2.c
new file mode 100644
index 0000000..2db1b3f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/capacity-2.c
@@ -0,0 +1,55 @@
+#include <stdlib.h>
+#include "analyzer-decls.h"
+
+extern void might_realloc (void *);
+extern void cant_realloc (const void *);
+
+void *
+test_realloc_1 (void *p, size_t new_sz)
+{
+ void *q = realloc (p, new_sz);
+ __analyzer_dump_capacity (q); /* { dg-warning "capacity: 'UNKNOWN\\(sizetype\\)'" "failure" } */
+ /* { dg-warning "capacity: 'INIT_VAL\\(new_sz\[^\n\r\]*\\)'" "success" { target *-*-* } .-1 } */
+ return q;
+}
+
+void *
+test_realloc_2 (size_t sz_a, size_t sz_b)
+{
+ void *p = malloc (sz_a);
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'INIT_VAL\\(sz_a_\[^\n\r\]*\\)'" } */
+ void *q = realloc (p, sz_b);
+ __analyzer_dump_capacity (q); /* { dg-warning "capacity: 'UNKNOWN\\(sizetype\\)'" "failure" } */
+ /* { dg-warning "capacity: 'INIT_VAL\\(sz_b\[^\n\r\]*\\)'" "success" { target *-*-* } .-1 } */
+ return q; /* { dg-warning "leak of 'p'" } */
+}
+
+void *
+test_might_realloc (void)
+{
+ void *p = malloc (1024);
+
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: '\\(size_t\\)1024'" } */
+
+ might_realloc (p);
+
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'UNKNOWN\\(sizetype\\)'" } */
+
+ return p;
+}
+
+void *
+test_cant_realloc (void)
+{
+ void *p = malloc (1024);
+
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: '\\(size_t\\)1024'" } */
+
+ cant_realloc (p);
+
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: '\\(size_t\\)1024'" } */
+
+ return p;
+}
+
+
diff --git a/gcc/testsuite/gcc.dg/analyzer/capacity-3.c b/gcc/testsuite/gcc.dg/analyzer/capacity-3.c
new file mode 100644
index 0000000..41e282c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/capacity-3.c
@@ -0,0 +1,82 @@
+#include <stdlib.h>
+#include "analyzer-decls.h"
+
+static void __attribute__((noinline))
+__analyzer_callee_1 (size_t inner_sz)
+{
+ void *p = alloca (inner_sz);
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'INIT_VAL\\(outer_sz_\[^\n\r\]*\\)'" } */
+}
+
+void
+test_1 (int flag, size_t outer_sz)
+{
+ if (flag)
+ __analyzer_callee_1 (outer_sz);
+
+ /* Verify that we merge state; in particular, the dynamic size of "p"
+ in the called frame should have been purged. */
+ __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
+}
+
+void
+test_2 (int flag, size_t sz)
+{
+ if (flag)
+ {
+ void *p = malloc (sz);
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'INIT_VAL\\(sz_\[^\n\r\]*\\)'" } */
+ free (p);
+ /* The dynamic size of "p" should have been purged. */
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'UNKNOWN\\(sizetype\\)'" } */
+ }
+
+ /* Verify that we merge state. */
+ __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
+}
+/* Verify that we purge state on the NULL branch when a malloc result is
+ tested against NULL. */
+
+void
+test_3 (size_t sz)
+{
+ void *p = malloc (sz);
+
+ if (p)
+ {
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'INIT_VAL\\(sz_\[^\n\r\]*\\)'" } */
+ }
+ else
+ {
+ /* The dynamic size of "p" should have been purged
+ due to "p" being equal to NULL. */
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'UNKNOWN\\(sizetype\\)'" } */
+ }
+
+ free (p);
+
+ /* The dynamic size of "p" should have been purged. */
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'UNKNOWN\\(sizetype\\)'" } */
+
+ /* Verify that we merge state. */
+ __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
+}
+
+/* Verify that we purge dynamic extent of a pointer when it leaks. */
+
+static void __attribute__((noinline))
+__analyzer_callee_4 (size_t inner_sz)
+{
+ void *p = malloc (inner_sz);
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: 'INIT_VAL\\(outer_sz_\[^\n\r\]*\\)'" } */
+} /* { dg-warning "leak of 'p'" } */
+
+void
+test_4 (int flag, size_t outer_sz)
+{
+ if (flag)
+ __analyzer_callee_4 (outer_sz);
+
+ /* Verify that we merge state. */
+ __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/clobbers-1.c b/gcc/testsuite/gcc.dg/analyzer/clobbers-1.c
new file mode 100644
index 0000000..6400f84
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/clobbers-1.c
@@ -0,0 +1,97 @@
+#include "analyzer-decls.h"
+
+struct foo
+{
+ int i;
+ int j;
+};
+
+struct coord
+{
+ int x;
+ int y;
+ int z;
+};
+
+struct foo g;
+
+void test_1 (void)
+{
+ g.i = 42;
+ if (g.j)
+ __analyzer_eval (g.j); /* { dg-warning "TRUE" } */
+ else
+ __analyzer_eval (g.j); /* { dg-warning "FALSE" } */
+ __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
+}
+
+void test_2 (struct foo f)
+{
+ f.i = 42;
+ if (f.j)
+ __analyzer_eval (f.j); /* { dg-warning "TRUE" } */
+ else
+ __analyzer_eval (f.j); /* { dg-warning "FALSE" } */
+ __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
+}
+
+void test_3 (struct foo *p)
+{
+ struct foo f = *p;
+ f.i = 42;
+ if (f.j)
+ __analyzer_eval (f.j); /* { dg-warning "TRUE" } */
+ else
+ __analyzer_eval (f.j); /* { dg-warning "FALSE" } */
+ __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
+}
+
+void test_4 (struct coord *p)
+{
+ struct coord f = *p;
+ f.x = 42;
+ __analyzer_eval (f.y == p->y); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.z == p->z); /* { dg-warning "TRUE" } */
+}
+
+struct s5
+{
+ char arr[8];
+};
+
+void test_5 (struct s5 *p)
+{
+ struct s5 f = *p;
+ f.arr[3] = 42;
+ __analyzer_eval (f.arr[0] == p->arr[0]); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[1] == p->arr[1]); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[2] == p->arr[2]); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[3] == 42); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[4] == p->arr[4]); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[5] == p->arr[5]); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[6] == p->arr[6]); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[7] == p->arr[7]); /* { dg-warning "TRUE" } */
+}
+
+struct s6
+{
+ int before; /* Give "arr" a nonzero offset. */
+ struct foo arr[4];
+ int after;
+};
+
+void test_6 (struct s6 *p, struct foo *q)
+{
+ struct s6 f = *p;
+ f.arr[1] = *q;
+ __analyzer_eval (f.before == p->before); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[0].i == p->arr[0].i); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[0].j == p->arr[0].j); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[1].i == q->i); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[1].j == q->j); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[2].i == p->arr[2].i); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[2].j == p->arr[2].j); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[3].i == p->arr[3].i); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.arr[3].j == p->arr[3].j); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f.after == p->after); /* { dg-warning "TRUE" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/clobbers-2.c b/gcc/testsuite/gcc.dg/analyzer/clobbers-2.c
new file mode 100644
index 0000000..9a88349
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/clobbers-2.c
@@ -0,0 +1,72 @@
+#include "analyzer-decls.h"
+
+typedef __SIZE_TYPE__ size_t;
+extern void bzero (void *s, size_t n);
+extern void *memset(void *s, int c, size_t n);
+
+void test_1 (void)
+{
+ char arr[16];
+ bzero (arr, sizeof (arr));
+ __analyzer_eval (arr[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[7] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[8] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[9] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[15] == 0); /* { dg-warning "TRUE" } */
+
+ /* Clobber in the middle (with prefix and suffix). */
+ arr[8] = 42;
+ __analyzer_eval (arr[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[7] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[8] == 0); /* { dg-warning "FALSE" } */
+ __analyzer_eval (arr[8] == 42); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[9] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[15] == 0); /* { dg-warning "TRUE" } */
+}
+
+void test_2 (void)
+{
+ char arr[16];
+ bzero (arr, sizeof (arr));
+ __analyzer_eval (arr[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[1] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[15] == 0); /* { dg-warning "TRUE" } */
+
+ /* Clobber at the front (suffix, but no prefix). */
+ arr[0] = 42;
+ __analyzer_eval (arr[0] == 0); /* { dg-warning "FALSE" } */
+ __analyzer_eval (arr[0] == 42); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[1] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[15] == 0); /* { dg-warning "TRUE" } */
+}
+
+void test_3 (void)
+{
+ char arr[16];
+ bzero (arr, sizeof (arr));
+ __analyzer_eval (arr[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[14] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[15] == 0); /* { dg-warning "TRUE" } */
+
+ /* Clobber at the end (prefix, but no suffix). */
+ arr[15] = 42;
+ __analyzer_eval (arr[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[14] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[15] == 0); /* { dg-warning "FALSE" } */
+ __analyzer_eval (arr[15] == 42); /* { dg-warning "TRUE" } */
+}
+
+void test_4 (void)
+{
+ char arr[16];
+ bzero (arr, sizeof (arr));
+ __analyzer_eval (arr[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[15] == 0); /* { dg-warning "TRUE" } */
+
+ /* Exact overlap, no prefix or suffix. */
+ memset (arr, 1, 16);
+ __analyzer_eval (arr[0] == 0); /* { dg-warning "FALSE" } */
+ __analyzer_eval (arr[15] == 0); /* { dg-warning "FALSE" } */
+ __analyzer_eval (arr[0] == 1); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[15] == 1); /* { dg-warning "TRUE" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
index afd1556..908d999 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
@@ -137,7 +137,7 @@ void test_11 (void)
/* alloca. */
-void test_12 (void)
+int test_12 (void)
{
void *p = __builtin_alloca (256);
void *q = __builtin_alloca (256);
@@ -145,14 +145,14 @@ void test_12 (void)
/* alloca results should be unique. */
__analyzer_eval (p == q); /* { dg-warning "FALSE" } */
- // FIXME: complain about uses of poisoned values
+ return *(int *)p; /* { dg-warning "use of uninitialized value '\\*\\(int \\*\\)p" } */
}
/* Use of uninit value. */
int test_12a (void)
{
int i;
- return i; // FIXME: do we see the return stmt?
+ return i; /* { dg-warning "use of uninitialized value 'i'" } */
}
void test_12b (void *p, void *q)
@@ -165,9 +165,11 @@ int test_12c (void)
int i;
int j;
- j = i; // FIXME: should complain about this
+ j = i; /* { dg-warning "use of uninitialized value 'i'" } */
- return j;
+ /* We should not emit followup warnings after the first warning about
+ an uninitialized value. */
+ return j; /* { dg-bogus "use of uninitialized value" } */
}
struct coord
@@ -348,7 +350,9 @@ void test_19 (void)
{
int i, j;
/* Compare two uninitialized locals. */
- __analyzer_eval (i == j); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (i == j); /* { dg-warning "UNKNOWN" "unknown " } */
+ /* { dg-warning "use of uninitialized value 'i'" "uninit i" { target *-*-* } .-1 } */
+ /* { dg-warning "use of uninitialized value 'j'" "uninit j" { target *-*-* } .-2 } */
}
void test_20 (int i, int j)
@@ -503,9 +507,7 @@ void test_26 (struct coord *p, struct coord *q)
the dest value. */
*p = *q;
__analyzer_eval (p->x); /* { dg-warning "UNKNOWN" } */
- __analyzer_eval (p->y == 17); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
- /* { dg-warning "UNKNOWN" "status quo" { target *-*-* } .-1 } */
- // TODO(xfail): should have been overwritten with q->y
+ __analyzer_eval (p->y == 17); /* { dg-warning "TRUE" } */
__analyzer_eval (q->x); /* { dg-warning "UNKNOWN" } */
__analyzer_eval (q->y == 17); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
@@ -522,19 +524,11 @@ void test_27 (struct coord *p)
void test_28 (struct coord *p)
{
memset (p, 0, sizeof (struct coord) * 10);
- __analyzer_eval (p[0].x == 0); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
- /* { dg-warning "UNKNOWN" "status quo" { target *-*-* } .-1 } */
- // TODO(xfail):
- __analyzer_eval (p[0].y == 0); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
- /* { dg-warning "UNKNOWN" "status quo" { target *-*-* } .-1 } */
- // TODO(xfail):
+ __analyzer_eval (p[0].x == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (p[0].y == 0); /* { dg-warning "TRUE" } */
- __analyzer_eval (p[9].x == 0); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
- /* { dg-warning "UNKNOWN" "status quo" { target *-*-* } .-1 } */
- // TODO(xfail):
- __analyzer_eval (p[9].y == 0); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
- /* { dg-warning "UNKNOWN" "status quo" { target *-*-* } .-1 } */
- // TODO(xfail):
+ __analyzer_eval (p[9].x == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (p[9].y == 0); /* { dg-warning "TRUE" } */
__analyzer_eval (p[10].x == 0); /* { dg-warning "UNKNOWN" } */
__analyzer_eval (p[10].y == 0); /* { dg-warning "UNKNOWN" } */
@@ -659,8 +653,10 @@ void test_29b (void)
__analyzer_eval (p[9].x == 109024); /* { dg-warning "TRUE" } */
__analyzer_eval (p[9].y == 109025); /* { dg-warning "TRUE" } */
- __analyzer_eval (p[10].x == 0); /* { dg-warning "UNKNOWN" } */
- __analyzer_eval (p[10].y == 0); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (p[10].x == 0); /* { dg-warning "UNKNOWN" "unknown" } */
+ /* { dg-warning "use of uninitialized value 'p\\\[10\\\].x'" "uninit" { target *-*-* } .-1 } */
+ __analyzer_eval (p[10].y == 0); /* { dg-warning "UNKNOWN" "unknown" } */
+ /* { dg-warning "use of uninitialized value 'p\\\[10\\\].y'" "uninit" { target *-*-* } .-1 } */
q = &p[7];
@@ -708,8 +704,10 @@ void test_29c (int len)
__analyzer_eval (p[9].x == 109024); /* { dg-warning "TRUE" } */
__analyzer_eval (p[9].y == 109025); /* { dg-warning "TRUE" } */
- __analyzer_eval (p[10].x == 0); /* { dg-warning "UNKNOWN" } */
- __analyzer_eval (p[10].y == 0); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (p[10].x == 0); /* { dg-warning "UNKNOWN" "unknown" } */
+ /* { dg-warning "use of uninitialized value '\\*p\\\[10\\\].x'" "uninit" { target *-*-* } .-1 } */
+ __analyzer_eval (p[10].y == 0); /* { dg-warning "UNKNOWN" "unknown" } */
+ /* { dg-warning "use of uninitialized value '\\*p\\\[10\\\].y'" "uninit" { target *-*-* } .-1 } */
q = &p[7];
@@ -821,7 +819,7 @@ void test_36 (int i)
int test_37 (void)
{
int *ptr;
- return *ptr; /* { dg-warning "use of uninitialized value 'ptr'" "uninit-warning-removed" { xfail *-*-* } } */
+ return *ptr; /* { dg-warning "use of uninitialized value 'ptr'" } */
}
/* Write through uninitialized pointer. */
@@ -829,7 +827,7 @@ int test_37 (void)
void test_37a (int i)
{
int *ptr;
- *ptr = i; /* { dg-warning "use of uninitialized value 'ptr'" "uninit-warning-removed" { xfail *-*-* } } */
+ *ptr = i; /* { dg-warning "use of uninitialized value 'ptr'" } */
}
// TODO: the various other ptr deref poisonings
@@ -934,24 +932,20 @@ void test_43 (void)
struct sbits
{
- int b0 : 1;
- int b123 : 3;
- int b456 : 3;
- int b7 : 1;
+ signed int b0 : 1;
+ signed int b123 : 3;
+ signed int b456 : 3;
+ signed int b7 : 1;
};
void test_44 (void)
{
struct sbits bits;
- bits.b0 = 1;
- __analyzer_eval (bits.b0 == 1); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
- /* { dg-warning "FALSE" "status quo" { target *-*-* } .-1 } */
- // TODO(xfail): ^^^^
+ bits.b0 = -1;
+ __analyzer_eval (bits.b0 == -1); /* { dg-warning "TRUE" } */
- bits.b456 = 5;
- __analyzer_eval (bits.b456 == 5); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
- /* { dg-warning "FALSE" "status quo" { target *-*-* } .-1 } */
- // TODO(xfail): ^^^^
+ bits.b456 = -4;
+ __analyzer_eval (bits.b456 == -4); /* { dg-warning "TRUE" } */
};
struct ubits
@@ -962,20 +956,14 @@ struct ubits
unsigned int b7 : 1;
};
-/* FIXME: this requires BIT_FIELD_REF to work. */
-
void test_45 (void)
{
struct ubits bits;
bits.b0 = 1;
- __analyzer_eval (bits.b0 == 1); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
- /* { dg-warning "UNKNOWN" "status quo" { target *-*-* } .-1 } */
- // TODO(xfail): ^^^^
+ __analyzer_eval (bits.b0 == 1); /* { dg-warning "TRUE" } */
bits.b456 = 5;
- __analyzer_eval (bits.b456 == 5); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
- /* { dg-warning "UNKNOWN" "status quo" { target *-*-* } .-1 } */
- // TODO(xfail): ^^^^
+ __analyzer_eval (bits.b456 == 5); /* { dg-warning "TRUE" } */
};
extern const char *char_ptr;
@@ -1045,8 +1033,8 @@ void test_52 (struct big b)
{
struct big d;
memcpy (&d, &b, sizeof (struct big));
- __analyzer_eval (b.ia[0] == d.ia[0]); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
- /* { dg-warning "UNKNOWN" "status quo" { target *-*-* } .-1 } */
+ __analyzer_eval (b.ia[0] == d.ia[0]); /* { dg-warning "TRUE" } */
+ __analyzer_eval (b.ia[1023] == d.ia[1023]); /* { dg-warning "TRUE" } */
}
void test_53 (const char *msg)
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-10.c b/gcc/testsuite/gcc.dg/analyzer/data-model-10.c
index c261edc..04c9891 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-10.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-10.c
@@ -12,6 +12,7 @@ test (void)
if (!new_table)
return NULL;
new_table->m_f = (char **)malloc(sizeof(char **));
- *new_table->m_f = NULL; /* { dg-warning "dereference of possibly-NULL '<unknown>'" } */ // FIXME: something better than "unknown" here
+ *new_table->m_f = NULL; /* { dg-warning "dereference of possibly-NULL '\\*new_table.m_f'" } */
+ /* { dg-message "'\\*new_table.m_f' could be NULL" "final event wording" { target *-*-* } .-1 } */
return new_table;
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-20.c b/gcc/testsuite/gcc.dg/analyzer/data-model-20.c
index 8fdbb6b..ff65883 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-20.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-20.c
@@ -17,7 +17,7 @@ test (int n) {
for (; i >= 0; i++) {
free(arr[i]); /* { dg-bogus "double-'free'" } */
}
- free(arr);
+ free(arr); /* { dg-warning "leak" } */
return NULL;
}
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-22.c b/gcc/testsuite/gcc.dg/analyzer/data-model-22.c
new file mode 100644
index 0000000..8429b2f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-22.c
@@ -0,0 +1,101 @@
+#include <string.h>
+#include "analyzer-decls.h"
+
+extern void check_init_char (char v);
+extern void check_init_int (int v);
+
+void test_1 (void)
+{
+ union
+ {
+ char c[16];
+ int i[4];
+ } v;
+ memset (&v, 0, sizeof (v));
+ v.c[5] = 42;
+ check_init_int (v.c[0]);
+ check_init_int (v.c[4]);
+ check_init_int (v.c[6]);
+ check_init_int (v.i[1]);
+}
+
+void test_2 (void)
+{
+ /* Intersection of byte ranges within "v". */
+ union
+ {
+ struct {
+ int a;
+ char b;
+ char c;
+ } __attribute__((packed)) icc;
+ struct {
+ char a;
+ int b;
+ char c;
+ } __attribute__((packed)) cic;
+ struct {
+ char a;
+ char b;
+ int c;
+ } __attribute__((packed)) cci;
+ } v;
+
+ v.icc.a = 1066;
+ v.icc.b = 42;
+ v.icc.c = 17;
+
+ __analyzer_eval (v.icc.a == 1066); /* { dg-warning "TRUE" } */
+ __analyzer_eval (v.icc.b == 42); /* { dg-warning "TRUE" } */
+ __analyzer_eval (v.icc.c == 17); /* { dg-warning "TRUE" } */
+ check_init_int (v.icc.a);
+ check_init_char (v.icc.b);
+ check_init_char (v.icc.c);
+
+ check_init_char (v.cic.a);
+ check_init_int (v.cic.b);
+ check_init_char (v.cic.c);
+
+ check_init_char (v.cci.a);
+ check_init_char (v.cci.b);
+ check_init_int (v.cci.c);
+
+ v.cic.a = 42;
+ v.cic.b = 1066;
+ v.cic.c = 17;
+
+ __analyzer_eval (v.cic.a == 42); /* { dg-warning "TRUE" } */
+ __analyzer_eval (v.cic.b == 1066); /* { dg-warning "TRUE" } */
+ __analyzer_eval (v.cic.c == 17); /* { dg-warning "TRUE" } */
+ check_init_int (v.icc.a);
+ check_init_char (v.icc.b);
+ check_init_char (v.icc.c);
+
+ check_init_char (v.cic.a);
+ check_init_int (v.cic.b);
+ check_init_char (v.cic.c);
+
+ check_init_char (v.cci.a);
+ check_init_char (v.cci.b);
+ check_init_int (v.cci.c);
+
+ v.cci.a = 42;
+ v.cci.b = 17;
+ v.cci.c = 1066;
+
+ __analyzer_eval (v.cci.a == 42); /* { dg-warning "TRUE" } */
+ __analyzer_eval (v.cci.b == 17); /* { dg-warning "TRUE" } */
+ __analyzer_eval (v.cci.c == 1066); /* { dg-warning "TRUE" } */
+ check_init_int (v.icc.a);
+ check_init_char (v.icc.b);
+ check_init_char (v.icc.c);
+
+ check_init_char (v.cic.a);
+ check_init_int (v.cic.b);
+ check_init_char (v.cic.c);
+
+ check_init_char (v.cci.a);
+ check_init_char (v.cci.b);
+ check_init_int (v.cci.c);
+
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-23.c b/gcc/testsuite/gcc.dg/analyzer/data-model-23.c
new file mode 100644
index 0000000..c76dd4e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-23.c
@@ -0,0 +1,26 @@
+#include "analyzer-decls.h"
+
+#define NULL ((void *)0)
+
+void * __attribute__((noinline))
+hide (void *ptr)
+{
+ return ptr;
+}
+
+void test_1 (void)
+{
+ int a;
+ __analyzer_eval (hide (&a) == NULL); /* { dg-warning "FALSE" } */
+ __analyzer_eval (hide (&a) + 1 != NULL); /* { dg-warning "TRUE" } */
+ __analyzer_eval (hide (&a) + 1 == NULL); /* { dg-warning "FALSE" } */
+ __analyzer_eval (hide (&a) - 1 != NULL); /* { dg-warning "TRUE" } */
+ __analyzer_eval (hide (&a) - 1 == NULL); /* { dg-warning "FALSE" } */
+}
+
+void test_2 (void)
+{
+ __analyzer_eval (hide (NULL) == NULL); /* { dg-warning "TRUE" } */
+ __analyzer_eval (hide (NULL) - 1 == NULL); /* { dg-warning "FALSE" } */
+ __analyzer_eval (hide (NULL) + 1 == NULL); /* { dg-warning "FALSE" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/dump-state.c b/gcc/testsuite/gcc.dg/analyzer/dump-state.c
new file mode 100644
index 0000000..618a5a9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/dump-state.c
@@ -0,0 +1,14 @@
+/* Verify that __analyzer_dump_state works as expected. */
+
+#include <stdlib.h>
+#include "analyzer-decls.h"
+
+void test_1 (void)
+{
+ void *p = malloc (1024);
+ __analyzer_dump_state ("malloc", p); /* { dg-warning "state: 'unchecked'" } */
+ free (p);
+ __analyzer_dump_state ("malloc", p); /* { dg-warning "state: 'freed'" } */
+ __analyzer_dump_state (NULL, p); /* { dg-error "cannot determine state machine" } */
+ __analyzer_dump_state ("not a state machine", p); /* { dg-error "unrecognized state machine 'not a state machine'" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/explode-1.c b/gcc/testsuite/gcc.dg/analyzer/explode-1.c
index 6b62e8e..f48408e 100644
--- a/gcc/testsuite/gcc.dg/analyzer/explode-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/explode-1.c
@@ -12,7 +12,7 @@ void test (void)
{
void *p0, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8;
void **pp;
- while (get ())
+ while (get ()) /* { dg-warning "leak" } */
{
switch (get ())
{
diff --git a/gcc/testsuite/gcc.dg/analyzer/explode-2.c b/gcc/testsuite/gcc.dg/analyzer/explode-2.c
index 70d8fec..c16982f 100644
--- a/gcc/testsuite/gcc.dg/analyzer/explode-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/explode-2.c
@@ -2,9 +2,11 @@
independently, so the total combined number of states
at any program point within the loop is NUM_VARS * NUM_STATES.
- Set the limits high enough that we can fully explore this. */
+ However, due to the way the analyzer represents heap-allocated regions
+ this never terminates, eventually hitting the complexity limit
+ (PR analyzer/93695). */
-/* { dg-additional-options "--param analyzer-max-enodes-per-program-point=200 --param analyzer-bb-explosion-factor=50" } */
+/* { dg-additional-options "-Wno-analyzer-too-complex -Wno-analyzer-malloc-leak" } */
#include <stdlib.h>
@@ -12,35 +14,35 @@ extern int get (void);
void test (void)
{
- void *p0, *p1, *p2, *p3;
+ void *p0 = NULL, *p1 = NULL, *p2 = NULL, *p3 = NULL;
while (get ())
{
switch (get ())
{
default:
case 0:
- p0 = malloc (16); /* { dg-warning "leak" } */
+ p0 = malloc (16); /* { dg-warning "leak" "" { xfail *-*-* } } */
break;
case 1:
- free (p0); /* { dg-warning "double-'free' of 'p0'" "" { xfail *-*-* } } */
+ free (p0); /* { dg-warning "double-'free' of 'p0'" } */
break;
case 2:
- p1 = malloc (16); /* { dg-warning "leak" } */
+ p1 = malloc (16); /* { dg-warning "leak" "" { xfail *-*-* } } */
break;
case 3:
free (p1); /* { dg-warning "double-'free' of 'p1'" "" { xfail *-*-* } } */
break;
case 4:
- p2 = malloc (16); /* { dg-warning "leak" } */
+ p2 = malloc (16); /* { dg-warning "leak" "" { xfail *-*-* } } */
break;
case 5:
free (p2); /* { dg-warning "double-'free' of 'p2'" "" { xfail *-*-* } } */
break;
case 6:
- p3 = malloc (16); /* { dg-warning "leak" } */
+ p3 = malloc (16); /* { dg-warning "leak" "" { xfail *-*-* } } */
break;
case 7:
free (p3); /* { dg-warning "double-'free' of 'p3'" "" { xfail *-*-* } } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/explode-2a.c b/gcc/testsuite/gcc.dg/analyzer/explode-2a.c
new file mode 100644
index 0000000..32c71ca
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/explode-2a.c
@@ -0,0 +1,51 @@
+/* PR analyzer/101068. */
+
+/* { dg-additional-options "--param analyzer-max-enodes-per-program-point=200 --param analyzer-bb-explosion-factor=50" } */
+
+#include <stdlib.h>
+
+extern int get (void);
+
+void test (void)
+{
+ void *p0 = NULL, *p1 = NULL, *p2 = NULL, *p3 = NULL;
+ /* Due to not purging constraints on SSA names within loops
+ (PR analyzer/101068), the analyzer effectively treats the original
+ explode-2.c as this code. */
+ int a = get ();
+ int b = get ();
+ while (a)
+ {
+ switch (b)
+ {
+ default:
+ case 0:
+ p0 = malloc (16); /* { dg-warning "leak" } */
+ break;
+ case 1:
+ free (p0); /* { dg-warning "double-'free' of 'p0'" "" { xfail *-*-* } } */
+ break;
+
+ case 2:
+ p1 = malloc (16); /* { dg-warning "leak" } */
+ break;
+ case 3:
+ free (p1); /* { dg-warning "double-'free' of 'p1'" "" { xfail *-*-* } } */
+ break;
+
+ case 4:
+ p2 = malloc (16); /* { dg-warning "leak" } */
+ break;
+ case 5:
+ free (p2); /* { dg-warning "double-'free' of 'p2'" "" { xfail *-*-* } } */
+ break;
+
+ case 6:
+ p3 = malloc (16); /* { dg-warning "leak" } */
+ break;
+ case 7:
+ free (p3); /* { dg-warning "double-'free' of 'p3'" "" { xfail *-*-* } } */
+ break;
+ }
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/feasibility-3.c b/gcc/testsuite/gcc.dg/analyzer/feasibility-3.c
new file mode 100644
index 0000000..0c0bd14
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/feasibility-3.c
@@ -0,0 +1,133 @@
+/* Reduced and adapted from Linux: fs/proc/inode.c: proc_reg_open
+ (GPL v2.0). */
+
+/* Types. */
+
+typedef unsigned char u8;
+typedef _Bool bool;
+typedef unsigned int gfp_t;
+
+struct file;
+struct kmem_cache;
+struct proc_dir_entry;
+
+struct inode { /* [...snip...] */ };
+
+enum {
+ PROC_ENTRY_PERMANENT = 1U << 0,
+};
+
+struct proc_ops {
+ /* [...snip...] */
+ int (*proc_open)(struct inode *, struct file *);
+ /* [...snip...] */
+ int (*proc_release)(struct inode *, struct file *);
+ /* [...snip...] */
+};
+
+struct proc_dir_entry {
+ /* [...snip...] */
+ struct completion *pde_unload_completion;
+ /* [...snip...] */
+ union {
+ const struct proc_ops *proc_ops;
+ const struct file_operations *proc_dir_ops;
+ };
+ /* [...snip...] */
+ u8 flags;
+ /* [...snip...] */
+};
+
+struct pde_opener {
+ /* [...snip...] */
+ struct file *file;
+ /* [...snip...] */
+};
+
+struct proc_inode {
+ /* [...snip...] */
+ struct proc_dir_entry *pde;
+ /* [...snip...] */
+ struct inode vfs_inode;
+};
+
+/* Data. */
+
+static struct kmem_cache *pde_opener_cache __attribute__((__section__(".data..ro_after_init")));
+
+/* Functions. */
+
+void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags) __attribute__((__malloc__));
+void kmem_cache_free(struct kmem_cache *, void *);
+
+static inline bool pde_is_permanent(const struct proc_dir_entry *pde)
+{
+ return pde->flags & PROC_ENTRY_PERMANENT;
+}
+
+static inline struct proc_inode *PROC_I(const struct inode *inode)
+{
+ void *__mptr = (void *)(inode);
+ return ((struct proc_inode *)(__mptr - __builtin_offsetof(struct proc_inode, vfs_inode)));
+}
+
+static inline struct proc_dir_entry *PDE(const struct inode *inode)
+{
+ return PROC_I(inode)->pde;
+}
+
+/* We don't want to emit bogus use of uninitialized value 'pdeo'
+ warnings from -Wanalyzer-use-of-uninitialized-value in this function;
+ these would require following infeasible paths in which "release" is
+ first NULL (to avoid the initialization of "pdeo") and then is non-NULL
+ (to access "pdeo").
+
+ "release" is sufficiently complicated in this function to hit the
+ complexity limit for symbolic values during enode exploration. */
+
+static int proc_reg_open(struct inode *inode, struct file *file)
+{
+ struct proc_dir_entry *pde = PDE(inode);
+ int rv = 0;
+ typeof(((struct proc_ops*)0)->proc_open) open;
+ typeof(((struct proc_ops*)0)->proc_release) release;
+ struct pde_opener *pdeo;
+
+ if (pde_is_permanent(pde)) {
+ open = pde->proc_ops->proc_open;
+ if (open)
+ rv = open(inode, file);
+ return rv;
+ }
+
+ /* [...snip...] */
+
+ release = pde->proc_ops->proc_release;
+ if (release) {
+ pdeo = kmem_cache_alloc(pde_opener_cache,
+ ((( gfp_t)(0x400u|0x800u))
+ | (( gfp_t)0x40u)
+ | (( gfp_t)0x80u)));
+ if (!pdeo) {
+ rv = -12;
+ goto out_unuse;
+ }
+ }
+
+ open = pde->proc_ops->proc_open;
+ if (open)
+ rv = open(inode, file);
+
+ if (release) {
+ if (rv == 0) {
+
+ pdeo->file = file; /* { dg-bogus "uninit" } */
+ /* [...snip...] */
+ } else
+ kmem_cache_free(pde_opener_cache, pdeo); /* { dg-bogus "uninit" } */
+ }
+
+out_unuse:
+ /* [...snip...] */
+ return rv;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/fgets-1.c b/gcc/testsuite/gcc.dg/analyzer/fgets-1.c
new file mode 100644
index 0000000..e93d24c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/fgets-1.c
@@ -0,0 +1,31 @@
+/* { dg-do "compile" } */
+
+#define NULL ((void *) 0)
+typedef struct _IO_FILE FILE;
+
+extern char *fgets(char *__restrict __s, int __n,
+ FILE *__restrict __stream);
+extern char *fgets_unlocked(char *__restrict __s, int __n,
+ FILE *__restrict __stream);
+
+char
+test_1 (FILE *fp)
+{
+ char buf[400];
+
+ if (fgets (buf, sizeof buf, fp) == NULL)
+ return 0;
+
+ return buf[0];
+}
+
+char
+test_2 (FILE *fp)
+{
+ char buf[400];
+
+ if (fgets_unlocked (buf, sizeof buf, fp) == NULL)
+ return 0;
+
+ return buf[0];
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/fread-1.c b/gcc/testsuite/gcc.dg/analyzer/fread-1.c
new file mode 100644
index 0000000..593cb7f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/fread-1.c
@@ -0,0 +1,13 @@
+/* { dg-additional-options "-fanalyzer-checker=taint" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+extern size_t fread (void *, size_t, size_t, void *);
+
+int
+test_1 (void *fp)
+{
+ int i;
+ fread (&i, sizeof (i), 1, fp);
+ return i;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/function-ptr-2.c b/gcc/testsuite/gcc.dg/analyzer/function-ptr-2.c
index 411b1b3..fd25e3b 100644
--- a/gcc/testsuite/gcc.dg/analyzer/function-ptr-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/function-ptr-2.c
@@ -6,9 +6,10 @@ typedef void (*fn_ptr_t) (void *);
void
calls_free (void *victim)
{
- free (victim);
+ free (victim); /* { dg-warning "double-'free' of 'victim'" } */
}
+
void
no_op (void *ptr)
{
@@ -25,7 +26,6 @@ void test_1 (void *ptr)
fn_ptr (ptr);
fn_ptr (ptr);
}
-// TODO: issue a double-'free' warning at 2nd call to fn_ptr.
/* As above, but with an extra indirection to try to thwart
the optimizer. */
@@ -41,4 +41,3 @@ void test_2 (void *ptr, fn_ptr_t *fn_ptr)
(*fn_ptr) (ptr);
(*fn_ptr) (ptr);
}
-// TODO: issue a double-'free' warning at 2nd call to fn_ptr.
diff --git a/gcc/testsuite/gcc.dg/analyzer/function-ptr-4.c b/gcc/testsuite/gcc.dg/analyzer/function-ptr-4.c
new file mode 100644
index 0000000..016351a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/function-ptr-4.c
@@ -0,0 +1,24 @@
+/* Test to see if the analyzer detect and analyze calls via
+ function pointers or not. */
+
+#include <stdlib.h>
+
+void fun(int *int_ptr)
+{
+ free(int_ptr); /* { dg-warning "double-'free' of 'int_ptr'" } */
+}
+
+void single_call()
+{
+ int *int_ptr = (int*)malloc(sizeof(int));
+ void (*fun_ptr)(int *) = &fun;
+ (*fun_ptr)(int_ptr);
+}
+
+void double_call()
+{
+ int *int_ptr = (int*)malloc(sizeof(int));
+ void (*fun_ptr)(int *) = &fun;
+ (*fun_ptr)(int_ptr); /* { dg-message "calling 'fun' from 'double_call'" } */
+ (*fun_ptr)(int_ptr);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/loop-0-up-to-n-by-1-with-iter-obj.c b/gcc/testsuite/gcc.dg/analyzer/loop-0-up-to-n-by-1-with-iter-obj.c
index 2b03527..0172c9b 100644
--- a/gcc/testsuite/gcc.dg/analyzer/loop-0-up-to-n-by-1-with-iter-obj.c
+++ b/gcc/testsuite/gcc.dg/analyzer/loop-0-up-to-n-by-1-with-iter-obj.c
@@ -69,6 +69,5 @@ void test(int n)
free (it);
- __analyzer_dump_exploded_nodes (0); /* { dg-warning "2 processed enodes" } */
- // TODO: why 2 enodes here, rather than 1
+ __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
index 448b8558..df2fc9c 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
@@ -204,8 +204,7 @@ void test_16 (void)
bar ();
fail:
- free (q); /* { dg-warning "free of uninitialized 'q'" "" { xfail *-*-* } } */
- /* TODO(xfail): implement uninitialized detection. */
+ free (q); /* { dg-warning "use of uninitialized value 'q'" } */
free (p);
}
@@ -459,8 +458,8 @@ int *
test_40 (int i)
{
int *p = (int*)malloc(sizeof(int*));
- i = *p; /* { dg-warning "dereference of possibly-NULL 'p' \\\[CWE-690\\\]" } */
- /* TODO: (it's also uninitialized) */
+ i = *p; /* { dg-warning "dereference of possibly-NULL 'p' \\\[CWE-690\\\]" "possibly-null" } */
+ /* { dg-warning "use of uninitialized value '\\*p'" "uninit" { target *-*-*} .-1 } */
return p;
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c b/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c
index 901ca5c..8820ddd 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c
@@ -69,7 +69,7 @@ int *test_5 (void)
static void __attribute__((noinline))
called_by_test_6a (void *ptr)
{
- free (ptr); /* { dg-warning "double-'free'" "" { xfail *-*-* } } */
+ free (ptr); /* { dg-warning "double-'free'" } */
}
static deallocator_t __attribute__((noinline))
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-13.c b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-13.c
index 2e3d80e..a08386a 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-13.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-13.c
@@ -23,8 +23,7 @@ void test (struct foo f)
do_stuff ();
- calls_free (f.m_p); /* { dg-message "passing freed pointer '<unknown>' in call to 'calls_free' from 'test'" } */
- // TODO: something better than '<unknown>'
+ calls_free (f.m_p); /* { dg-message "passing freed pointer 'f\\.m_p' in call to 'calls_free' from 'test'" } */
do_stuff ();
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-13a.c b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-13a.c
new file mode 100644
index 0000000..d74ef59
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-13a.c
@@ -0,0 +1,38 @@
+/* { dg-additional-options "-fanalyzer-verbosity=1" } */
+
+#include <stdlib.h>
+
+void
+calls_free (void *victim)
+{
+ free (victim); /* { dg-warning "double-'free' of 'victim'" } */
+}
+
+extern void do_stuff (void);
+
+struct foo
+{
+ void *m_p;
+};
+
+static void * __attribute__((noinline))
+test_a (struct foo f)
+{
+ do_stuff ();
+
+ calls_free (f.m_p);
+
+ do_stuff ();
+
+ return f.m_p;
+}
+
+void test_b (void *p)
+{
+ void *q;
+ struct foo f;
+ f.m_p = p;
+ q = test_a (f);
+ calls_free (q); /* { dg-message "passing freed pointer 'q' in call to 'calls_free' from 'test_b'" } */
+ do_stuff ();
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/memset-1.c b/gcc/testsuite/gcc.dg/analyzer/memset-1.c
index 5748aa1..94c5a1b 100644
--- a/gcc/testsuite/gcc.dg/analyzer/memset-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/memset-1.c
@@ -36,22 +36,16 @@ void test_3 (int val)
{
char buf[256];
memset (buf, 'A', 256);
- /* We currently merely mark such regions as "unknown", so querying
- values within them yields UNKNOWN when ideally it would be TRUE. */
- __analyzer_eval (buf[42] == 'A'); /* { dg-warning "TRUE" "known nonzero" { xfail *-*-* } } */
- /* { dg-bogus "UNKNOWN" "status quo" { xfail *-*-* } .-1 } */
+ __analyzer_eval (buf[42] == 'A'); /* { dg-warning "TRUE" } */
}
/* A "memset" with unknown value. */
-void test_4 (int val)
+void test_4 (char val)
{
char buf[256];
memset (buf, val, 256);
- /* We currently merely mark such regions as "unknown", so querying
- values within them yields UNKNOWN when ideally it would be TRUE. */
- __analyzer_eval (buf[42] == (char)val); /* { dg-warning "TRUE" "known nonzero" { xfail *-*-* } } */
- /* { dg-bogus "UNKNOWN" "status quo" { xfail *-*-* } .-1 } */
+ __analyzer_eval (buf[42] == (char)val); /* { dg-warning "TRUE" } */
}
/* A "memset" with unknown num bytes. */
@@ -98,6 +92,14 @@ void test_6 (int val)
__analyzer_eval (buf[42] == 'A'); /* { dg-warning "TRUE" } */
}
+void test_6b (int val)
+{
+ char buf[256];
+ memset (buf, 'A', sizeof (buf));
+ memset (buf, 'B', get_zero ());
+ __analyzer_eval (buf[42] == 'A'); /* { dg-warning "TRUE" } */
+}
+
/* A "memset" of known size that's not the full buffer. */
void test_7 (void)
@@ -105,10 +107,96 @@ void test_7 (void)
char buf[256];
buf[128] = 'A';
memset (buf, 0, 128);
- /* We currently merely mark the whole region as "unknown", so querying
- values within them yields UNKNOWN. */
- __analyzer_eval (buf[127] == '\0'); /* { dg-warning "TRUE" "known nonzero" { xfail *-*-* } } */
- /* { dg-bogus "UNKNOWN" "status quo" { xfail *-*-* } .-1 } */
- __analyzer_eval (buf[128] == 'A'); /* { dg-warning "TRUE" "known nonzero" { xfail *-*-* } } */
- /* { dg-bogus "UNKNOWN" "status quo" { xfail *-*-* } .-1 } */
+ __analyzer_eval (buf[0] == '\0'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[127] == '\0'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[128] == 'A'); /* { dg-warning "TRUE" } */
+}
+
+void test_8 (void)
+{
+ char buf[20];
+ memset (buf + 0, 0, 1);
+ memset (buf + 1, 1, 1);
+ memset (buf + 2, 2, 1);
+ memset (buf + 3, 3, 1);
+ memset (buf + 4, 4, 2);
+ memset (buf + 6, 6, 2);
+ memset (buf + 8, 8, 4);
+ memset (buf + 12, 12, 8);
+ __analyzer_eval (buf[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[1] == 1); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[2] == 2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[3] == 3); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[4] == 4); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[5] == 4); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[6] == 6); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[7] == 6); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[8] == 8); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[9] == 8); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[10] == 8); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[11] == 8); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[12] == 12); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[13] == 12); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[14] == 12); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[15] == 12); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[16] == 12); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[17] == 12); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[18] == 12); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[19] == 12); /* { dg-warning "TRUE" } */
+}
+
+/* Various overlapping memset calls with different sizes and values. */
+
+void test_9 (void)
+{
+ char buf[8];
+ memset (buf, 0, 8);
+ __analyzer_eval (buf[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[1] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[2] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[3] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[4] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[5] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[6] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[7] == 0); /* { dg-warning "TRUE" } */
+
+ memset (buf + 1, 1, 4);
+ __analyzer_eval (buf[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[1] == 1); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[2] == 1); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[3] == 1); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[4] == 1); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[5] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[6] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[7] == 0); /* { dg-warning "TRUE" } */
+
+ memset (buf + 2, 2, 4);
+ __analyzer_eval (buf[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[1] == 1); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[2] == 2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[3] == 2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[4] == 2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[5] == 2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[6] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[7] == 0); /* { dg-warning "TRUE" } */
+
+ memset (buf + 4, 3, 3);
+ __analyzer_eval (buf[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[1] == 1); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[2] == 2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[3] == 2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[4] == 3); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[5] == 3); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[6] == 3); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[7] == 0); /* { dg-warning "TRUE" } */
+
+ memset (buf + 0, 4, 3);
+ __analyzer_eval (buf[0] == 4); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[1] == 4); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[2] == 4); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[3] == 2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[4] == 3); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[5] == 3); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[6] == 3); /* { dg-warning "TRUE" } */
+ __analyzer_eval (buf[7] == 0); /* { dg-warning "TRUE" } */
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/memset-CVE-2017-18549-1.c b/gcc/testsuite/gcc.dg/analyzer/memset-CVE-2017-18549-1.c
new file mode 100644
index 0000000..de9b5e3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/memset-CVE-2017-18549-1.c
@@ -0,0 +1,107 @@
+/* This is a very simplified version of CVE-2017-18549,
+ a use of uninitialized padding values affecting the Linux kernel
+ (and thus GPLv2).
+
+ It was fixed by e.g. 342ffc26693b528648bdc9377e51e4f2450b4860 on linux-4.13.y
+ in linux-stable. */
+
+#include "analyzer-decls.h"
+#include <string.h>
+
+typedef unsigned int __u32;
+typedef unsigned int u32;
+typedef unsigned char u8;
+
+/* Adapted from include/uapi/linux/types.h */
+
+#define __bitwise
+typedef __u32 __bitwise __le32;
+
+/* Adapted from drivers/scsi/aacraid/aacraid.h */
+
+#define AAC_SENSE_BUFFERSIZE 30
+
+struct aac_srb_reply
+{
+ __le32 status;
+ __le32 srb_status;
+ __le32 scsi_status;
+ __le32 data_xfer_length;
+ __le32 sense_data_size;
+ u8 sense_data[AAC_SENSE_BUFFERSIZE];
+
+ /* Manually added to help verify the fix. */
+ u8 padding[2];
+};
+
+#define ST_OK 0
+#define SRB_STATUS_SUCCESS 0x01
+
+extern void check_uninit (u8 v);
+
+/* Adapted from drivers/scsi/aacraid/commctrl.c */
+
+static int aac_send_raw_srb(/* [...snip...] */)
+{
+ u32 byte_count = 0;
+
+ /* [...snip...] */
+
+ struct aac_srb_reply reply;
+
+ reply.status = ST_OK;
+
+ /* [...snip...] */
+
+ reply.srb_status = SRB_STATUS_SUCCESS;
+ reply.scsi_status = 0;
+ reply.data_xfer_length = byte_count;
+ reply.sense_data_size = 0;
+ memset(reply.sense_data, 0, AAC_SENSE_BUFFERSIZE);
+
+ /* [...snip...] */
+
+ __analyzer_eval (reply.status == ST_OK); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.srb_status == SRB_STATUS_SUCCESS); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.scsi_status == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.data_xfer_length == byte_count); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.sense_data_size == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.sense_data[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.sense_data[AAC_SENSE_BUFFERSIZE - 1] == 0); /* { dg-warning "TRUE" } */
+ check_uninit (reply.padding[0]); /* { dg-warning "uninitialized value" } */
+ check_uninit (reply.padding[1]); /* { dg-warning "uninitialized value" } */
+}
+
+static int aac_send_raw_srb_fixed(/* [...snip...] */)
+{
+ u32 byte_count = 0;
+
+ /* [...snip...] */
+
+ struct aac_srb_reply reply;
+
+ /* This is the fix. */
+ memset(&reply, 0, sizeof(reply));
+
+ reply.status = ST_OK;
+
+ /* [...snip...] */
+
+ reply.srb_status = SRB_STATUS_SUCCESS;
+ reply.scsi_status = 0;
+ reply.data_xfer_length = byte_count;
+ reply.sense_data_size = 0;
+ memset(reply.sense_data, 0, AAC_SENSE_BUFFERSIZE);
+
+ /* [...snip...] */
+
+ __analyzer_eval (reply.status == ST_OK); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.srb_status == SRB_STATUS_SUCCESS); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.scsi_status == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.data_xfer_length == byte_count); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.sense_data_size == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.sense_data[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.sense_data[AAC_SENSE_BUFFERSIZE - 1] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.padding[0] == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (reply.padding[1] == 0); /* { dg-warning "TRUE" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/paths-8.c b/gcc/testsuite/gcc.dg/analyzer/paths-8.c
new file mode 100644
index 0000000..b350d4d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/paths-8.c
@@ -0,0 +1,17 @@
+#include "analyzer-decls.h"
+
+static void __attribute__((noinline))
+__analyzer_callee_1 (void)
+{
+ /* empty. */
+}
+
+void
+test_1 (int flag)
+{
+ if (flag)
+ __analyzer_callee_1 ();
+
+ /* Verify that we merge state, whether or not the call happens. */
+ __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pattern-test-2.c b/gcc/testsuite/gcc.dg/analyzer/pattern-test-2.c
index f5424f5..7c8d1b3 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pattern-test-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pattern-test-2.c
@@ -25,11 +25,8 @@ void test_2 (void *p, void *q)
return;
foo(p);
- /* { dg-warning "pattern match on 'tmp1 == 0'" "tmp1 == 0" { target *-*-* } cond_2 } */
- /* { dg-warning "pattern match on 'tmp2 == 0'" "tmp2 == 0" { target *-*-* } cond_2 } */
- /* { dg-warning "pattern match on '<unknown> == 0'" "<unknown> == 0" { target *-*-* } cond_2 } */
- /* { dg-warning "pattern match on '<unknown> != 0'" "<unknown> != 0" { target *-*-* } cond_2 } */
/* { dg-warning "pattern match on 'p != 0'" "p != 0" { target *-*-* } cond_2 } */
+ /* { dg-warning "pattern match on 'tmp1 | tmp2 != 0'" "tmp1 | tmp2 != 0" { target *-*-* } cond_2 } */
/* { dg-warning "pattern match on 'q != 0'" "q != 0" { target *-*-* } cond_2 } */
}
@@ -44,10 +41,7 @@ void test_3 (void *p, void *q)
return;
foo(p);
- /* { dg-warning "pattern match on 'tmp1 != 0'" "tmp1 != 0" { target *-*-* } cond_3 } */
- /* { dg-warning "pattern match on 'tmp2 != 0'" "tmp2 != 0" { target *-*-* } cond_3 } */
- /* { dg-warning "pattern match on '<unknown> == 0'" "<unknown> == 0" { target *-*-* } cond_3 } */
- /* { dg-warning "pattern match on '<unknown> != 0'" "<unknown> != 0" { target *-*-* } cond_3 } */
/* { dg-warning "pattern match on 'p == 0'" "p == 0" { target *-*-* } cond_3 } */
+ /* { dg-warning "pattern match on 'tmp1 & tmp2 == 0'" "tmp1 & tmp2 == 0" { target *-*-* } cond_3 } */
/* { dg-warning "pattern match on 'q == 0'" "q == 0" { target *-*-* } cond_3 } */
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/phi-1.c b/gcc/testsuite/gcc.dg/analyzer/phi-1.c
new file mode 100644
index 0000000..0926003
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/phi-1.c
@@ -0,0 +1,24 @@
+/* { dg-do "compile" } */
+
+typedef __SIZE_TYPE__ size_t;
+#define NULL ((void *) 0)
+
+extern const char *foo (void);
+extern size_t bar (void);
+
+void
+_nl_expand_alias (const char *locale_alias_path)
+{
+ size_t added;
+ do
+ {
+ added = 0;
+ while (added == 0 && locale_alias_path[0] != '\0')
+ {
+ const char *start = foo ();
+ if (start < locale_alias_path)
+ added = bar ();
+ }
+ }
+ while (added != 0);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/phi-2.c b/gcc/testsuite/gcc.dg/analyzer/phi-2.c
new file mode 100644
index 0000000..2ab8344
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/phi-2.c
@@ -0,0 +1,27 @@
+/* { dg-additional-options "-O1" } */
+
+struct list_head {
+ struct list_head *next, *prev;
+};
+
+struct mbochs_dmabuf {
+ /* [...snip...] */
+ struct dma_buf *buf;
+ /* [...snip...] */
+ struct list_head next;
+ /* [...snip...] */
+};
+
+void mbochs_close(struct list_head *dmabufs,
+ struct mbochs_dmabuf *dmabuf,
+ struct mbochs_dmabuf *tmp)
+{
+ /* [...snip...] */
+ while (&dmabuf->next != dmabufs)
+ {
+ dmabuf = tmp;
+ tmp = ((struct mbochs_dmabuf *)((void *)(tmp->next.next) - __builtin_offsetof(struct mbochs_dmabuf, next)));
+ }
+
+ /* [...snip...] */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr100011.c b/gcc/testsuite/gcc.dg/analyzer/pr100011.c
new file mode 100644
index 0000000..228cfdf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr100011.c
@@ -0,0 +1,16 @@
+/* { dg-require-effective-target signal } */
+
+#include <stdlib.h>
+#include <signal.h>
+
+void terminate(int sig)
+{
+ char buf[64] = { 0 };
+ exit(1); /* { dg-warning "call to 'exit' from within signal handler" } */
+}
+
+int main(int argc, char **argv)
+{
+ signal(0, terminate); /* { dg-message "registering 'terminate' as signal handler" } */
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr100546.c b/gcc/testsuite/gcc.dg/analyzer/pr100546.c
new file mode 100644
index 0000000..3349d40
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr100546.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+static void noReturn(const char *str) __attribute__((noreturn));
+static void noReturn(const char *str) {
+ printf("%s\n", str);
+ exit(1);
+}
+
+void (*noReturnPtr)(const char *str) = &noReturn;
+
+int main(int argc, char **argv) {
+ char *str = 0;
+ if (!str)
+ noReturnPtr(__FILE__);
+ return printf("%c\n", *str);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr100615.c b/gcc/testsuite/gcc.dg/analyzer/pr100615.c
new file mode 100644
index 0000000..7a06f98
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr100615.c
@@ -0,0 +1,53 @@
+/* Adapted from
+ https://github.com/stackpath/rxtxcpu/blob/816d86c5d49c4db2ea5649f6b87e96da5af660f1/cpu.c
+ which is MIT-licensed. */
+
+typedef __SIZE_TYPE__ size_t;
+#define NULL ((void *)0)
+
+extern size_t strlen (const char *__s)
+ __attribute__ ((__nothrow__ , __leaf__))
+ __attribute__ ((__pure__))
+ __attribute__ ((__nonnull__ (1)));
+extern char *strdup (const char *__s)
+ __attribute__ ((__nothrow__ , __leaf__))
+ __attribute__ ((__malloc__))
+ __attribute__ ((__nonnull__ (1)));
+extern char *strsep (char **__restrict __stringp,
+ const char *__restrict __delim)
+ __attribute__ ((__nothrow__ , __leaf__))
+ __attribute__ ((__nonnull__ (1, 2)));
+extern long int strtol (const char *__restrict __nptr,
+ char **__restrict __endptr, int __base)
+ __attribute__ ((__nothrow__ , __leaf__))
+ __attribute__ ((__nonnull__ (1)));
+extern void free (void *__ptr)
+ __attribute__ ((__nothrow__ , __leaf__));
+
+#define CPU_LIST_BASE 10
+
+int parse_cpu_list(char *cpu_list) {
+ if (strlen(cpu_list) == 0) {
+ return 0;
+ }
+
+ char *endptr;
+ char *tofree, *string, *range;
+
+ tofree = string = strdup(cpu_list); /* { dg-message "allocated here" } */
+
+ while ((range = strsep(&string, ",")) != NULL) {
+ int first = strtol(range, &endptr, CPU_LIST_BASE);
+ if (!*endptr) {
+ continue;
+ }
+ char *save = endptr;
+ endptr++;
+ int last = strtol(endptr, &endptr, CPU_LIST_BASE);
+ if (save[0] != '-' || *endptr || last < first) {
+ return -1; /* { dg-warning "leak of 'tofree'" } */
+ }
+ }
+ free(tofree);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr101143.c b/gcc/testsuite/gcc.dg/analyzer/pr101143.c
new file mode 100644
index 0000000..bcc0974
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr101143.c
@@ -0,0 +1,18 @@
+/* { dg-additional-options "-Wno-builtin-declaration-mismatch" } */
+
+extern void *malloc (unsigned int);
+extern void *alloca (unsigned int);
+extern void unknown_fn (void *);
+
+void *
+test_malloc (void)
+{
+ return malloc (sizeof (int));
+}
+
+void *
+test_alloca (void)
+{
+ void *p = alloca (sizeof (int));
+ unknown_fn (p);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr101503.c b/gcc/testsuite/gcc.dg/analyzer/pr101503.c
new file mode 100644
index 0000000..16faf6e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr101503.c
@@ -0,0 +1,11 @@
+/* { dg-additional-options "--param analyzer-max-svalue-depth=0" } */
+
+int val;
+
+int
+fn (void)
+{
+ val = fn ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr101547.c b/gcc/testsuite/gcc.dg/analyzer/pr101547.c
new file mode 100644
index 0000000..8791cff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr101547.c
@@ -0,0 +1,11 @@
+char *
+fopen (const char *restrict, const char *restrict);
+
+void
+k2 (void)
+{
+ char *setfiles[1];
+ int i;
+
+ setfiles[i] = fopen ("", ""); /* { dg-warning "use of uninitialized value 'i'" } */
+} /* { dg-warning "leak of FILE" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr101570.c b/gcc/testsuite/gcc.dg/analyzer/pr101570.c
new file mode 100644
index 0000000..809bad6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr101570.c
@@ -0,0 +1,5 @@
+void
+test2 (_Complex double f)
+{
+ __asm__ ("" : "=r" (__real f));
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr101721.c b/gcc/testsuite/gcc.dg/analyzer/pr101721.c
new file mode 100644
index 0000000..07ef2d6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr101721.c
@@ -0,0 +1,8 @@
+/* PR analyzer/101721 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+
+void
+foo ()
+{
+ __builtin_ia32_pause ();
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr101837.c b/gcc/testsuite/gcc.dg/analyzer/pr101837.c
new file mode 100644
index 0000000..f99374d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr101837.c
@@ -0,0 +1,10 @@
+/* { dg-additional-options "-O3 -fsanitize=undefined" } */
+
+void memory_exhausted();
+void memcheck(void *ptr) {
+ if (ptr) /* { dg-warning "leak" } */
+ memory_exhausted();
+}
+
+int emalloc(int size) { memcheck(__builtin_malloc(size)); } /* { dg-message "allocated here" } */
+int main() { int max_envvar_len = emalloc(max_envvar_len + 1); } /* { dg-message "use of uninitialized value 'max_envvar_len'" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr101875.c b/gcc/testsuite/gcc.dg/analyzer/pr101875.c
new file mode 100644
index 0000000..5988b8e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr101875.c
@@ -0,0 +1,16 @@
+char *
+fopen (const char *restrict, const char *restrict);
+
+void
+err (void);
+
+void
+k2 (void)
+{
+ char *setfiles[1];
+ int i;
+
+ setfiles[i] = fopen("", ""); /* { dg-warning "use of uninitialized value 'i'" } */
+ if (!setfiles[i]) /* { dg-warning "use of uninitialized value 'i'" } */
+ err ();
+} /* { dg-warning "leak of FILE" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr101962.c b/gcc/testsuite/gcc.dg/analyzer/pr101962.c
new file mode 100644
index 0000000..7b83d03
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr101962.c
@@ -0,0 +1,51 @@
+#include "analyzer-decls.h"
+
+#define NULL ((void *)0)
+
+/* Verify that the analyzer makes the simplifying assumption that we don't
+ hit NULL when incrementing pointers to non-NULL memory regions. */
+
+static int * __attribute__((noinline))
+maybe_inc_int_ptr (int *ptr)
+{
+ if (!ptr)
+ return NULL;
+ return ++ptr;
+}
+
+int
+test_1 (void)
+{
+ int stack;
+ int *a = &stack;
+ a = maybe_inc_int_ptr (a);
+ a = maybe_inc_int_ptr (a);
+ __analyzer_eval (a == NULL); /* { dg-warning "FALSE" } */
+ __analyzer_eval (a != NULL); /* { dg-warning "TRUE" } */
+ return *a; /* { dg-warning "use of uninitialized value '\\*a'" } */
+ /* TODO: a complaint about out-of-bounds would be a better warning. */
+}
+
+static const char * __attribute__((noinline))
+maybe_inc_char_ptr (const char *ptr)
+{
+ if (!ptr)
+ return NULL;
+ return ++ptr;
+}
+
+char
+test_s (void)
+{
+ const char *msg = "hello world";
+ const char *a = msg;
+ __analyzer_eval (*a == 'h'); /* { dg-warning "TRUE" } */
+ a = maybe_inc_char_ptr (a);
+ __analyzer_eval (*a == 'e'); /* { dg-warning "TRUE" } */
+ a = maybe_inc_char_ptr (a);
+ __analyzer_eval (*a == 'l'); /* { dg-warning "TRUE" } */
+ a = maybe_inc_char_ptr (a);
+ __analyzer_eval (*a == 'l'); /* { dg-warning "TRUE" } */
+ a = maybe_inc_char_ptr (a);
+ __analyzer_eval (*a == 'o'); /* { dg-warning "TRUE" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr93355-localealias-feasibility.c b/gcc/testsuite/gcc.dg/analyzer/pr93355-localealias-feasibility.c
index 1a34d05..c7b49d2 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr93355-localealias-feasibility.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr93355-localealias-feasibility.c
@@ -30,6 +30,7 @@ typedef __SIZE_TYPE__ size_t;
typedef struct _IO_FILE FILE;
extern FILE *fopen (const char *__restrict __filename,
const char *__restrict __modes);
+extern size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
extern int fclose (FILE *__stream);
extern int isspace (int) __attribute__((__nothrow__, __leaf__));
@@ -50,6 +51,12 @@ read_alias_file (const char *fname, int fname_len)
if (fp == NULL)
return 0;
+ if (fread (buf, sizeof buf, 1, fp) != 1)
+ {
+ fclose (fp);
+ return 0;
+ }
+
cp = buf;
/* Ignore leading white space. */
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr93695-1.c b/gcc/testsuite/gcc.dg/analyzer/pr93695-1.c
new file mode 100644
index 0000000..e0500c4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr93695-1.c
@@ -0,0 +1,53 @@
+/* { dg-additional-options "-Wno-analyzer-too-complex" } */
+/* TODO: remove the need for this option (PR analyzer/93695). */
+
+#define NELEMS 10
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0]))
+
+void
+test_1 (void)
+{
+ int *p[NELEMS];
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE (p); ++i)
+ p[i] = __builtin_malloc (sizeof (i));
+
+ for (i = 0; i < ARRAY_SIZE (p); ++i)
+ __builtin_free (p [i]);
+}
+
+void
+test_2 (int n)
+{
+ int **p;
+ int i;
+
+ p = (int **)__builtin_malloc (sizeof (int *) * n);
+ if (!p)
+ return;
+
+ for (i = 0; i < n; ++i)
+ p[i] = __builtin_malloc (sizeof (i));
+
+ for (i = 0; i < n; ++i)
+ __builtin_free (p [i]);
+
+ __builtin_free (p);
+}
+
+void
+test_3 (int **p, int n)
+{
+ int i;
+ for (i = 0; i < n; ++i)
+ p[i] = __builtin_malloc (sizeof (i));
+}
+
+void
+test_4 (void **p, int n)
+{
+ int i;
+ for (i = 0; i < n; ++i)
+ __builtin_free (p[i]);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr94047.c b/gcc/testsuite/gcc.dg/analyzer/pr94047.c
index 5107ec0..d13da3e 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr94047.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr94047.c
@@ -13,7 +13,7 @@ void
foo (void)
{
struct list l;
- tlist t = l;
+ tlist t = l; /* { dg-warning "use of uninitialized value 'l'" } */
for (;;)
bar (&t);
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr94851-2.c b/gcc/testsuite/gcc.dg/analyzer/pr94851-2.c
index 6094721..0acf488 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr94851-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr94851-2.c
@@ -45,7 +45,7 @@ int pamark(void) {
if (curbp->b_amark == (AMARK *)NULL)
curbp->b_amark = p;
else
- last->m_next = p;
+ last->m_next = p; /* { dg-warning "dereference of NULL 'last'" "deref" { xfail *-*-* } } */
}
p->m_name = (char)c; /* { dg-bogus "leak of 'p'" "bogus leak" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr96841.c b/gcc/testsuite/gcc.dg/analyzer/pr96841.c
index 8546661..c766582 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr96841.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr96841.c
@@ -10,10 +10,8 @@ void
th (int *);
void
-bv (__SIZE_TYPE__ ny)
+bv (__SIZE_TYPE__ ny, int ***mf)
{
- int ***mf;
-
while (l8 ())
{
*mf = 0;
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98599-a.c b/gcc/testsuite/gcc.dg/analyzer/pr98599-a.c
new file mode 100644
index 0000000..2bbf37b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr98599-a.c
@@ -0,0 +1,8 @@
+/* { dg-do link } */
+/* { dg-require-effective-target lto } */
+/* { dg-additional-options "-Os -flto" } */
+/* { dg-additional-sources pr98599-b.c } */
+
+int b(int x);
+int a() { b(5); }
+int main() { a(); }
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98599-b.c b/gcc/testsuite/gcc.dg/analyzer/pr98599-b.c
new file mode 100644
index 0000000..cfdeb3b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr98599-b.c
@@ -0,0 +1 @@
+int b(int x) { return x; }
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98628.c b/gcc/testsuite/gcc.dg/analyzer/pr98628.c
index e2fa778..fa0ca96 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr98628.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr98628.c
@@ -7,8 +7,7 @@ struct chanset_t {
struct chanset_t *next;
char dname[];
};
-void help_subst() {
- char *writeidx;
+void help_subst(char *writeidx) {
for (;; help_subst_chan = *help_subst_chan_0_0) {
foo(help_subst_chan.next->dname);
if (help_subst_chan_0_0) {
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99042.c b/gcc/testsuite/gcc.dg/analyzer/pr99042.c
new file mode 100644
index 0000000..f28a9de
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99042.c
@@ -0,0 +1,53 @@
+#include <stdio.h>
+
+struct foo {
+ FILE *file;
+};
+
+extern void unknown_fn ();
+extern void unknown_fn2 (const struct foo *f);
+
+int test_1 (struct foo *p)
+{
+ if ((p->file = fopen("test.txt", "w")) == NULL)
+ return 1;
+ unknown_fn ();
+ return 0; /* { dg-bogus "leak" } */
+}
+
+int test_2 (struct foo *p)
+{
+ if ((p->file = fopen("test.txt", "w")) == NULL)
+ return 1;
+ return 0; /* { dg-bogus "leak" } */
+}
+
+int test_3 (void)
+{
+ struct foo f;
+ struct foo *p = &f;
+ if ((p->file = fopen("test.txt", "w")) == NULL)
+ return 1;
+ unknown_fn ();
+ return 0;
+} /* { dg-warning "leak" } */
+
+int test_4 (void)
+{
+ struct foo f;
+ struct foo *p = &f;
+ if ((p->file = fopen("test.txt", "w")) == NULL)
+ return 1;
+ return 0;
+} /* { dg-warning "leak" } */
+
+int test_5 (void)
+{
+ struct foo f;
+ struct foo *p = &f;
+ if ((p->file = fopen("test.txt", "w")) == NULL)
+ return 1;
+ /* Although p is const, the underlying FILE * is not and could be closed. */
+ unknown_fn2 (p);
+ return 0; /* { dg-bogus "leak" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99044-1.c b/gcc/testsuite/gcc.dg/analyzer/pr99044-1.c
new file mode 100644
index 0000000..6b5d901
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99044-1.c
@@ -0,0 +1,60 @@
+#include <stdlib.h>
+
+struct hashmap_entry {
+ struct hashmap_entry *next;
+ unsigned int hash;
+};
+
+struct strbuf {
+ size_t alloc;
+ size_t len;
+ char *buf;
+};
+
+struct oid2strbuf {
+ struct hashmap_entry ent; /* must be the first member! */
+ unsigned char key[21];
+ struct strbuf *value;
+};
+
+
+struct hashmap_iter {
+ struct hashmap *map;
+ struct hashmap_entry *next;
+ unsigned int tablepos;
+};
+
+struct hashmap {
+ struct hashmap_entry **table;
+ // hashmap_cmp_fn cmpfn;
+ unsigned int size, tablesize, grow_at, shrink_at;
+ unsigned disallow_rehash : 1;
+};
+void strbuf_init(struct strbuf *, size_t);
+void *hashmap_iter_next(struct hashmap_iter *iter);
+void hashmap_free(struct hashmap *map, int free_entries);
+void hashmap_iter_init(struct hashmap *map, struct hashmap_iter *iter);
+
+void strbuf_release(struct strbuf *sb)
+{
+ if (sb->alloc) { /* { dg-bogus "use after 'free'" } */
+ free(sb->buf);
+ strbuf_init(sb, 0);
+ }
+}
+
+void oid2strbuf_free(struct hashmap *map) {
+ struct hashmap_iter iter;
+ struct hashmap_entry *e;
+
+ hashmap_iter_init(map, &iter);
+ while ((e = hashmap_iter_next(&iter))) {
+ struct oid2strbuf *e_strbuf = (struct oid2strbuf *)e;
+ strbuf_release(e_strbuf->value); /* { dg-bogus "use after 'free'" } */
+ free(e_strbuf->value);
+ free(e);
+ }
+
+ hashmap_free(map, 0);
+}
+
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99044-2.c b/gcc/testsuite/gcc.dg/analyzer/pr99044-2.c
new file mode 100644
index 0000000..fd71d35
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99044-2.c
@@ -0,0 +1,42 @@
+struct node
+{
+ struct node *next;
+};
+
+void test_1 (struct node *n)
+{
+ while (n)
+ {
+ struct node *next = n->next;
+ __builtin_free (n);
+ n = next;
+ }
+}
+
+extern void *get_ptr (void);
+
+void test_2 (void)
+{
+ void *p;
+ while (p = get_ptr ())
+ __builtin_free (p); /* { dg-bogus "double-'free' of 'p'" } */
+}
+
+extern void **get_ptr_ptr (void);
+
+void test_3 (void)
+{
+ void **p;
+ while (p = get_ptr_ptr ())
+ __builtin_free (*p); /* { dg-bogus "double-'free'" } */
+}
+
+void test_4 (void)
+{
+ void *p = (void *)0;
+ while (1)
+ {
+ __builtin_free (p); /* { dg-bogus "double-'free' of 'p'" } */
+ p = get_ptr ();
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99193-1.c b/gcc/testsuite/gcc.dg/analyzer/pr99193-1.c
index c6179e9..459357c 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr99193-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99193-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-Wno-analyzer-too-complex" } */
+
/* Verify absence of false positive from -Wanalyzer-mismatching-deallocation
on realloc(3).
Based on https://github.com/libguestfs/libguestfs/blob/f19fd566f6387ce7e4d82409528c9dde374d25e0/daemon/command.c#L115
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99193-3.c b/gcc/testsuite/gcc.dg/analyzer/pr99193-3.c
index 3e7ffd6..d64b045 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr99193-3.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99193-3.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-Wno-analyzer-too-complex" } */
+
/* Verify absence of false positive from -Wanalyzer-mismatching-deallocation
on realloc(3).
Based on https://github.com/libguestfs/libguestfs/blob/f19fd566f6387ce7e4d82409528c9dde374d25e0/daemon/debug.c#L115
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99716-1.c b/gcc/testsuite/gcc.dg/analyzer/pr99716-1.c
new file mode 100644
index 0000000..6720c3c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99716-1.c
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+test_1 (void)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i) {
+ FILE *fp = fopen ("/tmp/test", "w");
+ fprintf (fp, "hello:%s ", "world");
+ fclose (fp); /* { dg-bogus "double 'fclose'" } */
+ }
+}
+
+void
+test_2 (void)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i) {
+ FILE *fp = fopen ("/tmp/test", "w");
+ fprintf (fp, "hello");
+ }
+} /* { dg-warning "leak of FILE 'fp'" } */
+
+FILE *fp3;
+
+void
+test_3 (FILE **fpp)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i) {
+ *fpp = fopen ("/tmp/test", "w");
+ fprintf (*fpp, "hello");
+ fclose (*fpp); /* { dg-bogus "double 'fclose'" } */
+ *fpp = NULL;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99716-2.c b/gcc/testsuite/gcc.dg/analyzer/pr99716-2.c
new file mode 100644
index 0000000..7c9881c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99716-2.c
@@ -0,0 +1,34 @@
+/* Reduced from
+ https://github.com/libguestfs/libguestfs/blob/e0a11061035d47b118c95706240bcc17fd576edc/tests/mount-local/test-parallel-mount-local.c#L299-L335
+ which is GPLv2 or later. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int foo (void);
+
+void
+test_mountpoint (const char *mp)
+{
+ const int nr_passes = 5 + (random () & 31);
+ int pass;
+ int ret = 1;
+ FILE *fp;
+
+ for (pass = 0; pass < nr_passes; ++pass) {
+ if (foo ()) {
+ goto error;
+ }
+ fp = fopen ("file", "w");
+ if (fp == NULL) {
+ goto error;
+ }
+ fprintf (fp, "hello world\n");
+ fclose (fp); /* { dg-bogus "double 'fclose'" } */
+ }
+
+ ret = 0;
+
+ error:
+ exit (ret);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99716-3.c b/gcc/testsuite/gcc.dg/analyzer/pr99716-3.c
new file mode 100644
index 0000000..77d450e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99716-3.c
@@ -0,0 +1,16 @@
+#include <stdlib.h>
+
+extern void foo (void *);
+
+void
+test_1 (int nr_passes)
+{
+ int pass;
+ void *p;
+
+ for (pass = 0; pass < nr_passes; ++pass) {
+ p = malloc (1024);
+ foo (p);
+ free (p);
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99771-1.c b/gcc/testsuite/gcc.dg/analyzer/pr99771-1.c
new file mode 100644
index 0000000..08449f9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99771-1.c
@@ -0,0 +1,63 @@
+/* Verify that we don't print "<unknown>" in various diagnostics
+ (PR analyzer/99771). */
+
+#include <stdlib.h>
+
+void test_1 (void)
+{
+ *(char*)malloc (1024) = 42; /* { dg-warning "dereference of possibly-NULL 'malloc\\(1024\\)'" } */
+} /* { dg-warning "leak of 'malloc\\(1024\\)'" "warning" } */
+ /* { dg-message "'malloc\\(1024\\)' leaks here" "final event" { target *-*-* } .-1 } */
+
+void test_2 (size_t n)
+{
+ *(char*)malloc (4 * n) = 42; /* { dg-warning "dereference of possibly-NULL 'malloc\\(n \\* 4\\)'" "warning" } */
+ /* { dg-message "'malloc\\(n \\* 4\\)' could be NULL" "final event" { target *-*-* } .-1 } */
+} /* { dg-warning "leak of 'malloc\\(n \\* 4\\)'" "warning" } */
+ /* { dg-message "'malloc\\(n \\* 4\\)' leaks here" "final event" { target *-*-* } .-1 } */
+
+/* A compound example. */
+
+void test_3 (size_t a, size_t b, size_t c)
+{
+ *(char*)malloc (a + (b * c)) = 42; /* { dg-warning "dereference of possibly-NULL 'malloc\\(a \\+ b \\* c\\)'" "warning" } */
+ /* { dg-message "'malloc\\(a \\+ b \\* c\\)' could be NULL" "final event" { target *-*-* } .-1 } */
+} /* { dg-warning "leak of 'malloc\\(a \\+ b \\* c\\)'" "warning" } */
+ /* { dg-message "'malloc\\(a \\+ b \\* c\\)' leaks here" "final event" { target *-*-* } .-1 } */
+
+void test_4 (size_t a, size_t b, size_t c)
+{
+ *(char *)malloc (a ? b : c) = 42; /* { dg-warning "dereference of possibly-NULL 'malloc\\(<unknown>\\)'" "warning" } */
+ /* { dg-message "'malloc\\(<unknown>\\)' could be NULL" "final event" { target *-*-* } .-1 } */
+} /* { dg-warning "leak of 'malloc\\(<unknown>\\)'" "warning" } */
+ /* { dg-message "'malloc\\(<unknown>\\)' leaks here" "final event" { target *-*-* } .-1 } */
+
+/* Unary operators. */
+
+void test_5 (size_t a)
+{
+ *(char*)malloc (-a) = 42; /* { dg-warning "dereference of possibly-NULL 'malloc\\(-a\\)'" } */
+} /* { dg-warning "leak of 'malloc\\(-a\\)'" "warning" } */
+ /* { dg-message "'malloc\\(-a\\)' leaks here" "final event" { target *-*-* } .-1 } */
+
+void test_6 (size_t a)
+{
+ *(char*)malloc (~a) = 42; /* { dg-warning "dereference of possibly-NULL 'malloc\\(~a\\)'" } */
+} /* { dg-warning "leak of 'malloc\\(~a\\)'" "warning" } */
+ /* { dg-message "'malloc\\(~a\\)' leaks here" "final event" { target *-*-* } .-1 } */
+
+/* Field access. */
+
+struct s7 { size_t sz; };
+
+void test_7a(struct s7 s)
+{
+ *(char*)malloc (s.sz) = 42; /* { dg-warning "dereference of possibly-NULL 'malloc\\(s\\.sz\\)'" } */
+} /* { dg-warning "leak of 'malloc\\(s\\.sz\\)'" "warning" } */
+ /* { dg-message "'malloc\\(s\\.sz\\)' leaks here" "final event" { target *-*-* } .-1 } */
+
+void test_7b (struct s7 *s)
+{
+ *(char*)malloc (s->sz) = 42; /* { dg-warning "dereference of possibly-NULL 'malloc\\(\\*s\\.sz\\)'" } */
+} /* { dg-warning "leak of 'malloc\\(\\*s\\.sz\\)'" "warning" } */
+ /* { dg-message "'malloc\\(\\*s\\.sz\\)' leaks here" "final event" { target *-*-* } .-1 } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99774-1.c b/gcc/testsuite/gcc.dg/analyzer/pr99774-1.c
new file mode 100644
index 0000000..620cf65
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99774-1.c
@@ -0,0 +1,61 @@
+/* Reproducer for report from -Wanalyzer-malloc-leak
+ Reduced from
+ https://git.qemu.org/?p=qemu.git;a=blob;f=subprojects/libvhost-user/libvhost-user.c;h=fab7ca17ee1fb27bcfc338527d1aeb9f923aade5;hb=HEAD#l1184
+ which is licensed under GNU GPLv2 or later. */
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned long uint64_t;
+typedef unsigned long uint64_t;
+typedef long unsigned int size_t;
+
+extern void *calloc(size_t __nmemb, size_t __size)
+ __attribute__((__nothrow__, __leaf__))
+ __attribute__((__malloc__))
+ __attribute__((__alloc_size__(1, 2)))
+ __attribute__((__warn_unused_result__));
+
+typedef struct VuDescStateSplit {
+ uint8_t inflight;
+ uint64_t counter;
+} VuDescStateSplit;
+
+typedef struct VuVirtqInflight {
+ uint16_t desc_num;
+ VuDescStateSplit desc[];
+} VuVirtqInflight;
+
+typedef struct VuVirtqInflightDesc {
+ uint16_t index;
+ uint64_t counter;
+} VuVirtqInflightDesc;
+
+typedef struct VuVirtq {
+ VuVirtqInflight *inflight;
+ VuVirtqInflightDesc *resubmit_list;
+ uint16_t resubmit_num;
+ uint64_t counter;
+ int inuse;
+} VuVirtq;
+
+int vu_check_queue_inflights(VuVirtq *vq) {
+ int i = 0;
+
+ if (vq->inuse) {
+ vq->resubmit_list = calloc(vq->inuse, sizeof(VuVirtqInflightDesc));
+ if (!vq->resubmit_list) {
+ return -1;
+ }
+
+ for (i = 0; i < vq->inflight->desc_num; i++) {
+ if (vq->inflight->desc[i].inflight) {
+ vq->resubmit_list[vq->resubmit_num].index = i; /* { dg-bogus "leak" } */
+ vq->resubmit_list[vq->resubmit_num].counter =
+ vq->inflight->desc[i].counter;
+ vq->resubmit_num++;
+ }
+ }
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99774-2.c b/gcc/testsuite/gcc.dg/analyzer/pr99774-2.c
new file mode 100644
index 0000000..d9704de
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99774-2.c
@@ -0,0 +1,144 @@
+#include <stdlib.h>
+
+struct st
+{
+ void *m_f;
+};
+
+struct node
+{
+ struct node *m_next;
+};
+
+extern void unknown_fn (void *);
+extern void const_unknown_fn (const void *);
+
+void
+test_1 (struct st *p, struct st *q)
+{
+ p->m_f = malloc (1024);
+ q->m_f = NULL; /* { dg-bogus "leak" } */
+ free (p->m_f);
+}
+
+void
+test_2 (void)
+{
+ struct st s;
+ s.m_f = malloc (1024);
+ unknown_fn (&s);
+ free (s.m_f);
+}
+
+void
+test_3 (void)
+{
+ struct st s;
+ s.m_f = malloc (1024);
+ const_unknown_fn (&s);
+ free (s.m_f);
+}
+
+void
+test_4 (void)
+{
+ struct st s;
+ s.m_f = malloc (1024);
+ unknown_fn (&s);
+} /* { dg-bogus "leak" } */
+
+void
+test_5 (void)
+{
+ struct st s;
+ s.m_f = malloc (1024);
+ /* s is const, but the pointer could still be freed; hence not a leak. */
+ const_unknown_fn (&s);
+} /* { dg-bogus "leak" } */
+
+void
+test_6 (void)
+{
+ struct st s;
+ s.m_f = malloc (1024);
+} /* { dg-warning "leak" } */
+
+struct st
+test_7 (void)
+{
+ struct st s;
+ s.m_f = malloc (1024);
+ return s;
+} /* { dg-bogus "leak" } */
+
+struct node *
+test_8 (void)
+{
+ struct node *n1 = malloc (sizeof (struct node));
+ if (!n1)
+ return NULL;
+ n1->m_next = malloc (sizeof (struct node));
+ return n1;
+}
+
+void
+test_9 (void)
+{
+ struct node *n1 = malloc (sizeof (struct node));
+ if (!n1)
+ return;
+ n1->m_next = malloc (sizeof (struct node));
+ /* Could free n1 and n1->m_next. */
+ unknown_fn (n1);
+}
+
+void
+test_10 (void)
+{
+ struct node *n1 = malloc (sizeof (struct node));
+ if (!n1)
+ return;
+ n1->m_next = malloc (sizeof (struct node));
+ /* Could free n1->m_next, but not n1. */
+ const_unknown_fn (n1); /* { dg-warning "leak of 'n1'" } */
+}
+
+void
+test_11 (void)
+{
+ struct node *n1 = malloc (sizeof (struct node));
+ if (!n1)
+ return;
+ n1->m_next = malloc (sizeof (struct node));
+ /* Could free n1->m_next, but not n1. */
+ unknown_fn (n1->m_next); /* { dg-warning "leak of 'n1'" } */
+}
+
+void
+test_12a (void)
+{
+ int *ip = malloc (sizeof (int));
+ *ip = 42; /* { dg-warning "dereference of possibly-NULL 'ip'" } */
+ free (ip);
+}
+
+void
+test_12b (void)
+{
+ int *ip = malloc (sizeof (int));
+ unknown_fn (ip);
+ /* Might not be a null-deref, as unknown_fn could abort on NULL. */
+ *ip = 42;
+ free (ip);
+}
+
+void
+test_12c (void)
+{
+ int *ip = malloc (sizeof (int));
+ /* Might not be a null-deref, as const_unknown_fn could abort on NULL.
+ Right now we don't have a great way of handling this. */
+ const_unknown_fn (ip);
+ *ip = 42; /* { dg-bogus "dereference of possibly-NULL 'ip'" "" { xfail *-*-* } } */
+ free (ip);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99886.c b/gcc/testsuite/gcc.dg/analyzer/pr99886.c
new file mode 100644
index 0000000..da768ba
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99886.c
@@ -0,0 +1,21 @@
+/* Regression test for hang with -fanalyzer-verbosity=0. */
+/* { dg-additional-options "-fanalyzer-verbosity=0" } */
+
+#include <stdlib.h>
+
+struct coord {
+ float x;
+ float y;
+};
+
+void test_34 (void)
+{
+ float *q;
+ struct coord *p = malloc (sizeof (struct coord));
+ if (!p)
+ return;
+ p->x = 0.0f;
+ q = &p->x;
+ free (p);
+ *q = 1.0f; /* { dg-warning "use after 'free' of 'q'" } */
+};
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99906.c b/gcc/testsuite/gcc.dg/analyzer/pr99906.c
new file mode 100644
index 0000000..bb399a3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99906.c
@@ -0,0 +1,3 @@
+void bar(void *) __attribute__((__nonnull__));
+void *baz(void);
+void foo(void) { bar(baz()); }
diff --git a/gcc/testsuite/gcc.dg/analyzer/realloc-1.c b/gcc/testsuite/gcc.dg/analyzer/realloc-1.c
index a6c6bfc..ef117ad 100644
--- a/gcc/testsuite/gcc.dg/analyzer/realloc-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/realloc-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-Wno-free-nonheap-object" } */
+
typedef __SIZE_TYPE__ size_t;
#define NULL ((void *)0)
@@ -20,11 +22,10 @@ void *test_1 (void *ptr)
void *test_2 (void *ptr)
{
- void *p = malloc (1024);
- p = realloc (p, 4096);
- /* TODO: should warn about the leak when the above call fails (PR analyzer/99260). */
+ void *p = malloc (1024); /* { dg-message "allocated here" } */
+ p = realloc (p, 4096); /* { dg-message "when 'realloc' fails" } */
free (p);
-}
+} /* { dg-warning "leak of 'p'" } */ // ideally this would be on the realloc stmt
void *test_3 (void *ptr)
{
@@ -44,8 +45,8 @@ void *test_4 (void)
int *test_5 (int *p)
{
*p = 42;
- int *q = realloc (p, sizeof(int) * 4);
- *q = 43; /* { dg-warning "possibly-NULL 'q'" "PR analyzer/99260" { xfail *-*-* } } */
+ int *q = realloc (p, sizeof(int) * 4); /* { dg-message "when 'realloc' fails" } */
+ *q = 43; /* { dg-warning "dereference of NULL 'q'" } */
return q;
}
@@ -53,3 +54,42 @@ void test_6 (size_t sz)
{
void *p = realloc (NULL, sz);
} /* { dg-warning "leak of 'p'" } */
+
+/* The analyzer should complain about realloc of non-heap. */
+
+void *test_7 (size_t sz)
+{
+ char buf[100];
+ void *p = realloc (&buf, sz); /* { dg-warning "'realloc' of '&buf' which points to memory not on the heap" } */
+ return p;
+}
+
+/* Mismatched allocator. */
+
+struct foo
+{
+ int m_int;
+};
+
+extern void foo_release (struct foo *);
+extern struct foo *foo_acquire (void)
+ __attribute__ ((malloc (foo_release)));
+
+void test_8 (void)
+{
+ struct foo *p = foo_acquire ();
+ void *q = realloc (p, 1024); /* { dg-warning "'p' should have been deallocated with 'foo_release' but was deallocated with 'realloc'" } */
+}
+
+/* We should complain about realloc on a freed pointer. */
+
+void test_9 (void *p)
+{
+ free (p);
+ void *q = realloc (p, 1024); /* { dg-warning "double-'free' of 'p'" } */
+}
+
+void test_10 (char *s, int n)
+{
+ __builtin_realloc(s, n); /* { dg-warning "ignoring return value of '__builtin_realloc' declared with attribute 'warn_unused_result'" } */
+} /* { dg-warning "leak" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/realloc-2.c b/gcc/testsuite/gcc.dg/analyzer/realloc-2.c
new file mode 100644
index 0000000..a397753
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/realloc-2.c
@@ -0,0 +1,80 @@
+#include "analyzer-decls.h"
+
+typedef __SIZE_TYPE__ size_t;
+
+#define NULL ((void *)0)
+
+extern void *malloc (size_t __size)
+ __attribute__ ((__nothrow__ , __leaf__))
+ __attribute__ ((__malloc__))
+ __attribute__ ((__alloc_size__ (1)));
+extern void *realloc (void *__ptr, size_t __size)
+ __attribute__ ((__nothrow__ , __leaf__))
+ __attribute__ ((__warn_unused_result__))
+ __attribute__ ((__alloc_size__ (2)));
+extern void free (void *__ptr)
+ __attribute__ ((__nothrow__ , __leaf__));
+
+char *test_8 (size_t sz)
+{
+ char *p, *q;
+
+ p = malloc (3);
+ if (!p)
+ return NULL;
+
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: '\\(size_t\\)3'" } */
+
+ p[0] = 'a';
+ p[1] = 'b';
+ p[2] = 'c';
+
+ __analyzer_eval (p[0] == 'a'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (p[1] == 'b'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (p[2] == 'c'); /* { dg-warning "TRUE" } */
+
+ q = realloc (p, 6);
+
+ /* We should have 3 nodes, corresponding to "failure",
+ "success without moving", and "success with moving". */
+ __analyzer_dump_exploded_nodes (0); /* { dg-warning "3 processed enodes" } */
+
+ if (q)
+ {
+ __analyzer_dump_capacity (q); /* { dg-warning "capacity: '\\(size_t\\)6'" } */
+ q[3] = 'd';
+ q[4] = 'e';
+ q[5] = 'f';
+ if (q == p)
+ {
+ /* "realloc" success, growing the buffer in-place. */
+ __analyzer_eval (p[0] == 'a'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (p[1] == 'b'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (p[2] == 'c'); /* { dg-warning "TRUE" } */
+ // TODO
+ }
+ else
+ {
+ /* "realloc" success, moving the buffer (and thus freeing "p"). */
+ __analyzer_eval (q[0] == 'a'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (q[1] == 'b'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (q[2] == 'c'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (p[0] == 'a'); /* { dg-warning "UNKNOWN" "unknown" } */
+ /* { dg-warning "use after 'free' of 'p'" "use after free" { target *-*-* } .-1 } */
+ }
+ __analyzer_eval (q[3] == 'd'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (q[4] == 'e'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (q[5] == 'f'); /* { dg-warning "TRUE" } */
+ }
+ else
+ {
+ /* "realloc" failure. p should be unchanged. */
+ __analyzer_dump_capacity (p); /* { dg-warning "capacity: '\\(size_t\\)3'" } */
+ __analyzer_eval (p[0] == 'a'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (p[1] == 'b'); /* { dg-warning "TRUE" } */
+ __analyzer_eval (p[2] == 'c'); /* { dg-warning "TRUE" } */
+ return p;
+ }
+
+ return q;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/sock-1.c b/gcc/testsuite/gcc.dg/analyzer/sock-1.c
new file mode 100644
index 0000000..0f3e822
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/sock-1.c
@@ -0,0 +1,112 @@
+typedef unsigned int __u32;
+__extension__ typedef __signed__ long long __s64;
+__extension__ typedef unsigned long long __u64;
+typedef __u32 u32;
+typedef __s64 s64;
+typedef __u64 u64;
+typedef long long __kernel_time64_t;
+typedef _Bool bool;
+typedef __s64 time64_t;
+struct __kernel_timespec {
+ __kernel_time64_t tv_sec;
+ long long tv_nsec;
+};
+struct timespec64 {
+ time64_t tv_sec;
+ long tv_nsec;
+};
+
+extern struct timespec64 ns_to_timespec64(const s64 nsec);
+int put_timespec64(const struct timespec64 *ts,
+ struct __kernel_timespec *uts);
+
+/* [...snip...] */
+
+extern int put_old_timespec32(const struct timespec64 *, void *);
+
+/* [...snip...] */
+
+/* [...snip...] */
+
+typedef s64 ktime_t;
+
+/* [...snip...] */
+
+extern void ktime_get_real_ts64(struct timespec64 *tv);
+
+/* [...snip...] */
+
+enum tk_offsets {
+ TK_OFFS_REAL,
+ TK_OFFS_BOOT,
+ TK_OFFS_TAI,
+ TK_OFFS_MAX,
+};
+
+extern ktime_t ktime_get(void);
+extern ktime_t ktime_get_with_offset(enum tk_offsets offs);
+extern ktime_t ktime_get_coarse_with_offset(enum tk_offsets offs);
+extern ktime_t ktime_mono_to_any(ktime_t tmono, enum tk_offsets offs);
+extern ktime_t ktime_get_raw(void);
+extern u32 ktime_get_resolution_ns(void);
+
+
+static ktime_t ktime_get_real(void)
+{
+ return ktime_get_with_offset(TK_OFFS_REAL);
+}
+
+/* [...snip...] */
+
+struct socket {
+ /* [...snip...] */
+ struct sock *sk;
+ /* [...snip...] */
+};
+
+/* [...snip...] */
+
+struct sock {
+ /* [...snip...] */
+ ktime_t sk_stamp;
+ /* [...snip...] */
+};
+
+/* [...snip...] */
+
+static ktime_t sock_read_timestamp(struct sock *sk)
+{
+ return *(const volatile typeof(sk->sk_stamp) *)&(sk->sk_stamp);
+}
+
+static void sock_write_timestamp(struct sock *sk, ktime_t kt)
+{
+ *(volatile typeof(sk->sk_stamp) *)&(sk->sk_stamp) = kt;
+}
+
+/* [...snip...] */
+
+int sock_gettstamp(struct socket *sock, void *userstamp,
+ bool timeval, bool time32)
+{
+ struct sock *sk = sock->sk;
+ struct timespec64 ts;
+
+ /* [...snip...] */
+ ts = ns_to_timespec64((sock_read_timestamp(sk)));
+ if (ts.tv_sec == -1)
+ return -2;
+ if (ts.tv_sec == 0) {
+ ktime_t kt = ktime_get_real();
+ sock_write_timestamp(sk, kt);
+ ts = ns_to_timespec64((kt));
+ }
+
+ if (timeval)
+ ts.tv_nsec /= 1000;
+
+
+ if (time32)
+ return put_old_timespec32(&ts, userstamp);
+ return put_timespec64(&ts, userstamp);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/sock-2.c b/gcc/testsuite/gcc.dg/analyzer/sock-2.c
new file mode 100644
index 0000000..237e0cb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/sock-2.c
@@ -0,0 +1,20 @@
+__extension__ typedef __signed__ long long __s64;
+typedef __s64 time64_t;
+struct timespec64 {
+ time64_t tv_sec;
+ long tv_nsec;
+};
+
+extern struct timespec64 ns_to_timespec64(void);
+
+int sock_gettstamp()
+{
+ struct timespec64 ts;
+
+ /* [...snip...] */
+ ts = ns_to_timespec64();
+ if (ts.tv_sec == -1)
+ return -2;
+ /* [...snip...] */
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/strdup-1.c b/gcc/testsuite/gcc.dg/analyzer/strdup-1.c
index 6b950ca..9ac3921 100644
--- a/gcc/testsuite/gcc.dg/analyzer/strdup-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/strdup-1.c
@@ -14,8 +14,27 @@ void test_2 (const char *s)
char *p = strdup (s);
free (p);
}
+
void test_3 (const char *s)
{
char *p = strdup (s); /* { dg-message "this call could return NULL" } */
requires_nonnull (p); /* { dg-warning "use of possibly-NULL 'p'" } */
}
+
+/* Repeat tests for __builtin_strdup. */
+void test_4 (const char *s)
+{
+ char *p = __builtin_strdup (s); /* { dg-message "allocated here" } */
+} /* { dg-warning "leak of 'p'" } */
+
+void test_5 (const char *s)
+{
+ char *p = __builtin_strdup (s);
+ free (p);
+}
+
+void test_6 (const char *s)
+{
+ char *p = __builtin_strdup (s); /* { dg-message "this call could return NULL" } */
+ requires_nonnull (p); /* { dg-warning "use of possibly-NULL 'p'" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/strndup-1.c b/gcc/testsuite/gcc.dg/analyzer/strndup-1.c
index 23d9b60..5822353 100644
--- a/gcc/testsuite/gcc.dg/analyzer/strndup-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/strndup-1.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "no strndup in libc" { *-*-darwin[789]* *-*-darwin10* } } */
#include <string.h>
#include <stdlib.h>
diff --git a/gcc/testsuite/gcc.dg/analyzer/switch.c b/gcc/testsuite/gcc.dg/analyzer/switch.c
index 870b00f..0b9e7e3 100644
--- a/gcc/testsuite/gcc.dg/analyzer/switch.c
+++ b/gcc/testsuite/gcc.dg/analyzer/switch.c
@@ -8,23 +8,156 @@ void test (int i)
{
case 0:
__analyzer_eval (i == 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i != -1); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i != 0); /* { dg-warning "FALSE" } */
+ __analyzer_eval (i != 1); /* { dg-warning "TRUE" } */
break;
case 3 ... 5:
+ __analyzer_eval (i != 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i > 1); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i > 2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i >= 2); /* { dg-warning "TRUE" } */
__analyzer_eval (i >= 3); /* { dg-warning "TRUE" } */
__analyzer_eval (i <= 5); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i < 6); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i <= 6); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i < 7); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i != 6); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i != 3); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (i != 4); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (i != 5); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (i >= 4); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (i >= 5); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (i <= 3); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (i <= 4); /* { dg-warning "UNKNOWN" } */
break;
default:
+ __analyzer_eval (i == -1); /* { dg-warning "UNKNOWN" } */
__analyzer_eval (i == 0); /* { dg-warning "FALSE" } */
__analyzer_eval (i == 2); /* { dg-warning "UNKNOWN" } */
__analyzer_eval (i == 3); /* { dg-warning "FALSE" } */
- __analyzer_eval (i == 4); /* { dg-warning "FALSE" "desired" { xfail *-*-* } } */
- /* { dg-warning "UNKNOWN" "status quo" { target *-*-* } .-1 } */
- /* TODO(xfail^^^): we're only checking against endpoints of case
- ranges, not the insides. */
+ __analyzer_eval (i == 4); /* { dg-warning "FALSE" } */
__analyzer_eval (i == 5); /* { dg-warning "FALSE" } */
__analyzer_eval (i == 6); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (i != 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i != 1); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (i != 3); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i != 4); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i != 5); /* { dg-warning "TRUE" } */
+ __analyzer_eval (i != 6); /* { dg-warning "UNKNOWN" } */
break;
}
}
+
+/* Verify that the analyzer follows the correct paths on a
+ switch statement guarded by an if, using noinline to defeat
+ optimizations. */
+
+static void __attribute__((noinline))
+__analyzer_called_by_test_2 (int y)
+{
+ switch (y)
+ {
+ case 0:
+ __analyzer_dump_path (); /* { dg-bogus "path" } */
+ break;
+ case 1:
+ __analyzer_dump_path (); /* { dg-message "path" } */
+ break;
+ case 2:
+ __analyzer_dump_path (); /* { dg-bogus "path" } */
+ break;
+ default:
+ __analyzer_dump_path (); /* { dg-bogus "path" } */
+ break;
+ }
+}
+
+void test_2 (int x)
+{
+ if (x == 1)
+ __analyzer_called_by_test_2 (x);
+}
+
+void test_3 (int x, int y)
+{
+ if (y == 3)
+ switch (x)
+ {
+ case 0 ... 9:
+ case 20 ... 29:
+ if (x == y)
+ __analyzer_dump_path (); /* { dg-message "path" } */
+ else
+ __analyzer_dump_path (); /* { dg-message "path" } */
+ }
+}
+
+struct s4
+{
+ unsigned char level:3;
+ unsigned char key_id_mode:2;
+ unsigned char reserved:3;
+};
+
+void test_4 (struct s4 *p)
+{
+ switch (p->key_id_mode)
+ {
+ case 0:
+ __analyzer_dump_path (); /* { dg-message "path" } */
+ break;
+ case 1:
+ __analyzer_dump_path (); /* { dg-message "path" } */
+ break;
+ case 2:
+ __analyzer_dump_path (); /* { dg-message "path" } */
+ break;
+ case 3:
+ __analyzer_dump_path (); /* { dg-message "path" } */
+ break;
+ }
+ __analyzer_dump_path (); /* { dg-message "path" } */
+}
+
+int test_5 (unsigned v)
+{
+ switch (v)
+ {
+ case 0:
+ return 7;
+ break;
+ case 1:
+ return 23;
+ break;
+ default:
+ return v * 2;
+ }
+}
+
+int test_6 (unsigned v)
+{
+ switch (v)
+ {
+ case 0:
+ return 3;
+ case -1:
+ return 22;
+ }
+ return -3;
+}
+
+int g7 = -1;
+int test_7 ()
+{
+ switch (g7++) {
+ case 0:
+ return 32;
+
+ case 100:
+ return 42;
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/symbolic-1.c b/gcc/testsuite/gcc.dg/analyzer/symbolic-1.c
index 9d228e6..0eba646 100644
--- a/gcc/testsuite/gcc.dg/analyzer/symbolic-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/symbolic-1.c
@@ -1,6 +1,6 @@
#include "analyzer-decls.h"
-/* The example from store2.h */
+/* The example from store.h */
void test_1 (char a, char b, char c, char d, char e, char f,
int i, int j)
@@ -11,14 +11,16 @@ void test_1 (char a, char b, char c, char d, char e, char f,
__analyzer_eval (arr[2] == a); /* { dg-warning "TRUE" } */
__analyzer_eval (arr[3] == b); /* { dg-warning "TRUE" } */
- __analyzer_eval (arr[4]); /* { dg-warning "UNKNOWN" } */ // TODO: report uninit
+ __analyzer_eval (arr[4]); /* { dg-warning "UNKNOWN" "unknown" } */
+ /* { dg-warning "use of uninitialized value 'arr\\\[4\\\]'" "uninit" { target *-*-* } .-1 } */
/* Replace one concrete binding's value with a different value. */
arr[3] = c; /* (3) */
__analyzer_eval (arr[2] == a); /* { dg-warning "TRUE" } */
__analyzer_eval (arr[3] == c); /* { dg-warning "TRUE" } */
__analyzer_eval (arr[3] == b); /* { dg-warning "UNKNOWN" } */
- __analyzer_eval (arr[4]); /* { dg-warning "UNKNOWN" } */ // TODO: report uninit
+ __analyzer_eval (arr[4]); /* { dg-warning "UNKNOWN" "unknown" } */
+ /* { dg-warning "use of uninitialized value 'arr\\\[4\\\]'" "uninit" { target *-*-* } .-1 } */
/* Symbolic binding. */
arr[i] = d; /* (4) */
diff --git a/gcc/testsuite/gcc.dg/analyzer/symbolic-7.c b/gcc/testsuite/gcc.dg/analyzer/symbolic-7.c
new file mode 100644
index 0000000..665e0b6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/symbolic-7.c
@@ -0,0 +1,46 @@
+#include "analyzer-decls.h"
+
+extern void maybe_write (int *);
+
+void test_1 (int i)
+{
+ /* An array with purely concrete bindings. */
+ int arr[2];
+ arr[0] = 1066;
+ arr[1] = 1776;
+
+ /* Concrete reads. */
+ __analyzer_eval (arr[0] == 1066); /* { dg-warning "TRUE" } */
+ __analyzer_eval (arr[1] == 1776); /* { dg-warning "TRUE" } */
+
+ /* Symbolic read. */
+ __analyzer_describe (0, arr[i]); /* { dg-warning "svalue: 'UNKNOWN\\(int\\)'" } */
+ __analyzer_eval (arr[i] == 1776); /* { dg-warning "UNKNOWN" } */
+}
+
+void test_2 (int i)
+{
+ /* An array that could have been touched. */
+ int arr[2];
+ maybe_write (arr);
+
+ /* Concrete reads. */
+ __analyzer_eval (arr[0] == 42); /* { dg-warning "UNKNOWN" } */
+
+ /* Symbolic read. */
+ __analyzer_eval (arr[i] == 42); /* { dg-warning "UNKNOWN" } */
+}
+
+void test_3 (int i)
+{
+ /* An array that can't have been touched. */
+ int arr[2];
+
+ /* Concrete reads. */
+ __analyzer_eval (arr[0] == 42); /* { dg-warning "UNKNOWN" "unknown" } */
+ /* { dg-warning "use of uninitialized value 'arr\\\[0\\\]'" "uninit" { target *-*-* } .-1 } */
+
+ /* Symbolic read. */
+ __analyzer_eval (arr[i] == 42); /* { dg-warning "UNKNOWN" "unknown" } */
+ /* { dg-warning "use of uninitialized value 'arr\\\[i\\\]'" "uninit" { target *-*-* } .-1 } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/symbolic-8.c b/gcc/testsuite/gcc.dg/analyzer/symbolic-8.c
new file mode 100644
index 0000000..f9c3596
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/symbolic-8.c
@@ -0,0 +1,11 @@
+/* Merger where "arr" has two different symbolic bindings. */
+
+void test (int i, int j, int flag)
+{
+ int arr[16];
+
+ if (flag)
+ arr[i] = 42;
+ else
+ arr[j] = 17;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-array_index_mask_nospec.c b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-array_index_mask_nospec.c
new file mode 100644
index 0000000..6201fdb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-array_index_mask_nospec.c
@@ -0,0 +1,74 @@
+/* { dg-do assemble { target x86_64-*-* } } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+
+#include "../analyzer-decls.h"
+
+/* Copied from linux: arch/x86/include/asm/barrier.h (GPL-2.0) */
+
+static inline unsigned long array_index_mask_nospec(unsigned long index,
+ unsigned long size)
+{
+ unsigned long mask;
+
+ asm volatile ("cmp %1,%2; sbb %0,%0;"
+ :"=r" (mask)
+ :"g"(size),"r" (index)
+ :"cc");
+ return mask;
+}
+
+/* The analyzer ought to treat array_index_mask_nospec as being
+ effectively pure. */
+
+void test_1 (unsigned long index, unsigned long size)
+{
+ unsigned long a = array_index_mask_nospec (index, size);
+ unsigned long b = array_index_mask_nospec (index, size);
+ __analyzer_eval (a == b); /* { dg-warning "TRUE" } */
+}
+
+void test_2 (unsigned long index_a, unsigned long size_a,
+ unsigned long index_b, unsigned long size_b)
+{
+ unsigned long aa_1 = array_index_mask_nospec (index_a, size_a);
+ unsigned long ab_1 = array_index_mask_nospec (index_a, size_b);
+ unsigned long ba_1 = array_index_mask_nospec (index_b, size_a);
+ unsigned long bb_1 = array_index_mask_nospec (index_b, size_b);
+
+ unsigned long aa_2 = array_index_mask_nospec (index_a, size_a);
+ unsigned long ab_2 = array_index_mask_nospec (index_a, size_b);
+ unsigned long ba_2 = array_index_mask_nospec (index_b, size_a);
+ unsigned long bb_2 = array_index_mask_nospec (index_b, size_b);
+
+ __analyzer_eval (aa_1 == aa_2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (ab_1 == ab_2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (ba_1 == ba_2); /* { dg-warning "TRUE" } */
+ __analyzer_eval (bb_1 == bb_2); /* { dg-warning "TRUE" } */
+
+ __analyzer_eval (aa_1 == ab_1); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (aa_1 == ba_1); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (aa_1 == bb_1); /* { dg-warning "UNKNOWN" } */
+
+ __analyzer_eval (ab_1 == ba_1); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (ab_1 == bb_1); /* { dg-warning "UNKNOWN" } */
+
+ __analyzer_eval (ba_1 == bb_1); /* { dg-warning "UNKNOWN" } */
+}
+
+/* Equivalent asm strings should be treated the same, rather
+ than requiring the results to come from the same stmt. */
+
+void test_3 (unsigned long index, unsigned long size)
+{
+ unsigned long a = array_index_mask_nospec (index, size);
+ unsigned long b;
+
+ /* Copy of the asm from array_index_mask_nospec. */
+ asm volatile ("cmp %1,%2; sbb %0,%0;"
+ :"=r" (b)
+ :"g"(size),"r" (index)
+ :"cc");
+
+ __analyzer_eval (a == b); /* { dg-warning "TRUE" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid-paravirt-1.c b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid-paravirt-1.c
new file mode 100644
index 0000000..cf5cf97
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid-paravirt-1.c
@@ -0,0 +1,81 @@
+/* { dg-do assemble { target x86_64-*-* } } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+
+/* Adapted/reduced from linux kernel (GPL-2.0). */
+
+register unsigned long current_stack_pointer asm("rsp");
+
+struct pv_cpu_ops {
+ /* snip */
+ void (*cpuid)(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
+ unsigned int *edx);
+ /* snip */
+};
+struct paravirt_patch_template {
+ struct pv_cpu_ops cpu;
+ /* snip */
+};
+extern struct paravirt_patch_template pv_ops;
+
+/* snip */
+static void cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
+ unsigned int *edx) {
+ unsigned long __edi = __edi, __esi = __esi, __edx = __edx, __ecx = __ecx,
+ __eax = __eax;
+ asm volatile(
+ "771:\n\t"
+ "999:\n\t"
+ ".pushsection .discard.retpoline_safe\n\t"
+ " "
+ ".quad"
+ " "
+ " 999b\n\t"
+ ".popsection\n\t"
+ "call *%c[paravirt_opptr];"
+ "\n"
+ "772:\n"
+ ".pushsection .parainstructions,\"a\"\n"
+ " "
+ ".balign 8"
+ " "
+ "\n"
+ " "
+ ".quad"
+ " "
+ " 771b\n"
+ " .byte "
+ "%c[paravirt_typenum]"
+ "\n"
+ " .byte 772b-771b\n"
+ " .short "
+ "%c[paravirt_clobber]"
+ "\n"
+ ".popsection\n"
+ : "=D"(__edi), "=S"(__esi), "=d"(__edx), "=c"(__ecx),
+ "+r"(current_stack_pointer)
+ : [ paravirt_typenum ] "i"(
+ (__builtin_offsetof(struct paravirt_patch_template, cpu.cpuid) /
+ sizeof(void *))),
+ [ paravirt_opptr ] "i"(&(pv_ops.cpu.cpuid)),
+ [ paravirt_clobber ] "i"(((1 << 9) - 1)), "D"((unsigned long)(eax)),
+ "S"((unsigned long)(ebx)), "d"((unsigned long)(ecx)),
+ "c"((unsigned long)(edx))
+ : "memory", "cc", "rax", "r8", "r9", "r10", "r11");
+}
+
+extern void check_init_int(int v);
+
+void test(unsigned int op) {
+ unsigned int eax, ebx, ecx, edx;
+
+ eax = op;
+ ecx = 0;
+ cpuid(&eax, &ebx, &ecx, &edx);
+
+ check_init_int(eax);
+ check_init_int(ebx); /* { dg-bogus "use of uninitialized value 'ebx'" } */
+ check_init_int(ecx);
+ check_init_int(edx); /* { dg-bogus "use of uninitialized value 'edx'" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid-paravirt-2.c b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid-paravirt-2.c
new file mode 100644
index 0000000..c4b365f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid-paravirt-2.c
@@ -0,0 +1,135 @@
+/* { dg-do assemble { target x86_64-*-* } } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+
+/* Adapted/reduced from linux kernel (GPL-2.0). */
+
+typedef __SIZE_TYPE__ size_t;
+
+#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)
+
+#define __stringify_1(x...) #x
+#define __stringify(x...) __stringify_1(x)
+#define __ASM_FORM(x, ...) " " __stringify(x,##__VA_ARGS__) " "
+#define __ASM_FORM_RAW(x, ...) __stringify(x,##__VA_ARGS__)
+#define __ASM_SEL(a,b) __ASM_FORM(b)
+#define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(b)
+#define __ASM_REG(reg) __ASM_SEL_RAW(e##reg, r##reg)
+#define _ASM_PTR __ASM_SEL(.long, .quad)
+#define _ASM_ALIGN __ASM_SEL(.balign 4, .balign 8)
+#define _ASM_SP __ASM_REG(sp)
+
+
+register unsigned long current_stack_pointer asm(_ASM_SP);
+#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)
+
+#define ANNOTATE_RETPOLINE_SAFE \
+ "999:\n\t" \
+ ".pushsection .discard.retpoline_safe\n\t" \
+ _ASM_PTR " 999b\n\t" \
+ ".popsection\n\t"
+
+/* Adapted from Linux arch/x86/include/asm/paravirt.h */
+
+struct pv_cpu_ops {
+ /* snip */
+ void (*cpuid)(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
+ unsigned int *edx);
+ /* snip */
+};
+
+struct paravirt_patch_template {
+ struct pv_cpu_ops cpu;
+ /* snip */
+};
+extern struct paravirt_patch_template pv_ops;
+
+#define PARAVIRT_PATCH(x) \
+ (offsetof(struct paravirt_patch_template, x) / sizeof(void *))
+
+#define paravirt_type(op) \
+ [paravirt_typenum] "i" (PARAVIRT_PATCH(op)), \
+ [paravirt_opptr] "i" (&(pv_ops.op))
+#define paravirt_clobber(clobber) \
+ [paravirt_clobber] "i" (clobber)
+
+#define CLBR_ANY ((1 << 9) - 1)
+
+#define _paravirt_alt(insn_string, type, clobber) \
+ "771:\n\t" insn_string "\n" "772:\n" \
+ ".pushsection .parainstructions,\"a\"\n" \
+ _ASM_ALIGN "\n" \
+ _ASM_PTR " 771b\n" \
+ " .byte " type "\n" \
+ " .byte 772b-771b\n" \
+ " .short " clobber "\n" \
+ ".popsection\n"
+
+#define paravirt_alt(insn_string) \
+ _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]")
+
+#define PARAVIRT_CALL \
+ ANNOTATE_RETPOLINE_SAFE \
+ "call *%c[paravirt_opptr];"
+
+#define PVOP_CALL_ARGS \
+ unsigned long __edi = __edi, __esi = __esi, \
+ __edx = __edx, __ecx = __ecx, __eax = __eax;
+
+#define PVOP_CALL_ARG1(x) "D" ((unsigned long)(x))
+#define PVOP_CALL_ARG2(x) "S" ((unsigned long)(x))
+#define PVOP_CALL_ARG3(x) "d" ((unsigned long)(x))
+#define PVOP_CALL_ARG4(x) "c" ((unsigned long)(x))
+
+#define PVOP_VCALL_CLOBBERS "=D" (__edi), \
+ "=S" (__esi), "=d" (__edx), \
+ "=c" (__ecx)
+/* void functions are still allowed [re]ax for scratch */
+#define PVOP_VCALLEE_CLOBBERS "=a" (__eax)
+
+#define VEXTRA_CLOBBERS , "rax", "r8", "r9", "r10", "r11"
+
+#define PVOP_TEST_NULL(op) ((void)pv_ops.op)
+
+#define ____PVOP_CALL(ret, op, clbr, call_clbr, extra_clbr, ...) \
+ ({ \
+ PVOP_CALL_ARGS; \
+ PVOP_TEST_NULL(op); \
+ asm volatile(paravirt_alt(PARAVIRT_CALL) \
+ : call_clbr, ASM_CALL_CONSTRAINT \
+ : paravirt_type(op), \
+ paravirt_clobber(clbr), \
+ ##__VA_ARGS__ \
+ : "memory", "cc" extra_clbr); \
+ ret; \
+ })
+
+#define __PVOP_VCALL(op, ...) \
+ (void)____PVOP_CALL(, op, CLBR_ANY, PVOP_VCALL_CLOBBERS, \
+ VEXTRA_CLOBBERS, ##__VA_ARGS__)
+
+#define PVOP_VCALL4(op, arg1, arg2, arg3, arg4) \
+ __PVOP_VCALL(op, PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2), \
+ PVOP_CALL_ARG3(arg3), PVOP_CALL_ARG4(arg4))
+
+static void cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
+ unsigned int *edx)
+{
+ PVOP_VCALL4(cpu.cpuid, eax, ebx, ecx, edx);
+}
+
+extern void check_init_int(int v);
+
+void test(unsigned int op) {
+ unsigned int eax, ebx, ecx, edx;
+
+ eax = op;
+ ecx = 0;
+ cpuid(&eax, &ebx, &ecx, &edx);
+
+ check_init_int(eax);
+ check_init_int(ebx); /* { dg-bogus "use of uninitialized value 'ebx'" } */
+ check_init_int(ecx);
+ check_init_int(edx); /* { dg-bogus "use of uninitialized value 'edx'" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid.c b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid.c
new file mode 100644
index 0000000..243931a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-cpuid.c
@@ -0,0 +1,46 @@
+/* { dg-do assemble { target x86_64-*-* } } */
+/* { dg-require-effective-target lp64 } */
+
+#include "../analyzer-decls.h"
+
+typedef unsigned __INT32_TYPE__ u32;
+typedef unsigned __INT64_TYPE__ u64;
+
+extern void check_init_u32 (u32 v);
+extern void check_init_u64 (u32 v);
+
+/* Adapted from linux kernel: arch/x86/include/asm/processor.h (GPL-2.0). */
+
+static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
+{
+ /* ecx is often an input as well as an output. */
+ asm volatile("cpuid"
+ : "=a" (*eax),
+ "=b" (*ebx),
+ "=c" (*ecx),
+ "=d" (*edx)
+ : "0" (*eax), "2" (*ecx)
+ : "memory");
+}
+
+static inline void cpuid(unsigned int op,
+ unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
+{
+ *eax = op;
+ *ecx = 0;
+ native_cpuid(eax, ebx, ecx, edx);
+}
+
+void test_1 (void)
+{
+ u32 eax, ebx, ecx, edx;
+ cpuid(0x8000001e, &eax, &ebx, &ecx, &edx); /* from "amd_get_topology". */
+
+ /* Verify that they are now initialized. */
+ check_init_u32 (eax);
+ check_init_u32 (ebx);
+ check_init_u32 (ecx);
+ check_init_u32 (edx);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-rdmsr-paravirt.c b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-rdmsr-paravirt.c
new file mode 100644
index 0000000..d994787
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-rdmsr-paravirt.c
@@ -0,0 +1,210 @@
+/* Adapted from Linux: arch/x86/include/asm/paravirt.h */
+
+/* { dg-do assemble { target x86_64-*-* } } */
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+/* Adapted/reduced from linux kernel (GPL-2.0). */
+
+#include "../analyzer-decls.h"
+
+typedef unsigned char u8;
+typedef unsigned __INT32_TYPE__ u32;
+typedef unsigned __INT64_TYPE__ u64;
+typedef __SIZE_TYPE__ size_t;
+
+#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)
+
+#define __stringify_1(x...) #x
+#define __stringify(x...) __stringify_1(x)
+
+# define __ASM_FORM(x, ...) " " __stringify(x,##__VA_ARGS__) " "
+# define __ASM_FORM_RAW(x, ...) __stringify(x,##__VA_ARGS__)
+
+#ifndef __x86_64__
+/* 32 bit */
+# define __ASM_SEL(a,b) __ASM_FORM(a)
+# define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(a)
+#else
+/* 64 bit */
+# define __ASM_SEL(a,b) __ASM_FORM(b)
+# define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(b)
+#endif
+
+#define __ASM_REG(reg) __ASM_SEL_RAW(e##reg, r##reg)
+
+#define _ASM_PTR __ASM_SEL(.long, .quad)
+#define _ASM_ALIGN __ASM_SEL(.balign 4, .balign 8)
+
+#define _ASM_SP __ASM_REG(sp)
+
+
+register unsigned long current_stack_pointer asm(_ASM_SP);
+#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)
+
+#define ANNOTATE_RETPOLINE_SAFE \
+ "999:\n\t" \
+ ".pushsection .discard.retpoline_safe\n\t" \
+ _ASM_PTR " 999b\n\t" \
+ ".popsection\n\t"
+
+/* Adapted from Linux arch/x86/include/asm/paravirt.h */
+
+
+/* snip */
+
+/* ./arch/x86/include/asm/paravirt.h I think; was:
+ PVOP_VCALL4(cpu.cpuid, eax, ebx, ecx, edx);
+
+*/
+
+#ifndef __x86_64__
+#define CLBR_ANY ((1 << 4) - 1)
+#else
+#define CLBR_ANY ((1 << 9) - 1)
+#endif /* X86_64 */
+
+struct pv_cpu_ops {
+ /* snip */
+ u64 (*read_msr_safe)(unsigned int msr, int *err);
+ /* snip */
+};
+
+struct paravirt_patch_template {
+ struct pv_cpu_ops cpu;
+ /* snip */
+};
+extern struct paravirt_patch_template pv_ops;
+
+#define PARAVIRT_PATCH(x) \
+ (offsetof(struct paravirt_patch_template, x) / sizeof(void *))
+
+#define paravirt_type(op) \
+ [paravirt_typenum] "i" (PARAVIRT_PATCH(op)), \
+ [paravirt_opptr] "i" (&(pv_ops.op))
+#define paravirt_clobber(clobber) \
+ [paravirt_clobber] "i" (clobber)
+
+/*
+ * Generate some code, and mark it as patchable by the
+ * apply_paravirt() alternate instruction patcher.
+ */
+#define _paravirt_alt(insn_string, type, clobber) \
+ "771:\n\t" insn_string "\n" "772:\n" \
+ ".pushsection .parainstructions,\"a\"\n" \
+ _ASM_ALIGN "\n" \
+ _ASM_PTR " 771b\n" \
+ " .byte " type "\n" \
+ " .byte 772b-771b\n" \
+ " .short " clobber "\n" \
+ ".popsection\n"
+
+/* Generate patchable code, with the default asm parameters. */
+#define paravirt_alt(insn_string) \
+ _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]")
+
+#define PARAVIRT_CALL \
+ ANNOTATE_RETPOLINE_SAFE \
+ "call *%c[paravirt_opptr];"
+
+#ifndef __x86_64__
+
+/* 32-bit. */
+
+#define PVOP_CALL_ARGS \
+ unsigned long __eax = __eax, __edx = __edx, __ecx = __ecx;
+
+#define PVOP_CALL_ARG1(x) "a" ((unsigned long)(x))
+#define PVOP_CALL_ARG2(x) "d" ((unsigned long)(x))
+
+#define PVOP_VCALL_CLOBBERS "=a" (__eax), "=d" (__edx), \
+ "=c" (__ecx)
+#define PVOP_CALL_CLOBBERS PVOP_VCALL_CLOBBERS
+
+#define PVOP_VCALLEE_CLOBBERS "=a" (__eax), "=d" (__edx)
+#define PVOP_CALLEE_CLOBBERS PVOP_VCALLEE_CLOBBERS
+
+#define EXTRA_CLOBBERS
+
+#else
+
+/* 64-bit. */
+
+/* [re]ax isn't an arg, but the return val */
+#define PVOP_CALL_ARGS \
+ unsigned long __edi = __edi, __esi = __esi, \
+ __edx = __edx, __ecx = __ecx, __eax = __eax;
+
+#define PVOP_CALL_ARG1(x) "D" ((unsigned long)(x))
+#define PVOP_CALL_ARG2(x) "S" ((unsigned long)(x))
+
+#define PVOP_VCALL_CLOBBERS "=D" (__edi), \
+ "=S" (__esi), "=d" (__edx), \
+ "=c" (__ecx)
+#define PVOP_CALL_CLOBBERS PVOP_VCALL_CLOBBERS, "=a" (__eax)
+#define PVOP_VCALLEE_CLOBBERS "=a" (__eax)
+#define PVOP_CALLEE_CLOBBERS PVOP_VCALLEE_CLOBBERS
+
+#define EXTRA_CLOBBERS , "r8", "r9", "r10", "r11"
+#endif /* CONFIG_X86_32 */
+
+#define PVOP_TEST_NULL(op) ((void)pv_ops.op)
+
+#define PVOP_RETVAL(rettype) \
+ ({ unsigned long __mask = ~0UL; \
+ switch (sizeof(rettype)) { \
+ case 1: __mask = 0xffUL; break; \
+ case 2: __mask = 0xffffUL; break; \
+ case 4: __mask = 0xffffffffUL; break; \
+ default: break; \
+ } \
+ __mask & __eax; \
+ })
+
+#define ____PVOP_CALL(ret, op, clbr, call_clbr, extra_clbr, ...) \
+ ({ \
+ PVOP_CALL_ARGS; \
+ PVOP_TEST_NULL(op); \
+ asm volatile(paravirt_alt(PARAVIRT_CALL) \
+ : call_clbr, ASM_CALL_CONSTRAINT \
+ : paravirt_type(op), \
+ paravirt_clobber(clbr), \
+ ##__VA_ARGS__ \
+ : "memory", "cc" extra_clbr); \
+ ret; \
+ })
+
+#define __PVOP_CALL(rettype, op, ...) \
+ ____PVOP_CALL(PVOP_RETVAL(rettype), op, CLBR_ANY, \
+ PVOP_CALL_CLOBBERS, EXTRA_CLOBBERS, ##__VA_ARGS__)
+
+#define PVOP_CALL2(rettype, op, arg1, arg2) \
+ __PVOP_CALL(rettype, op, PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2))
+
+static inline u64 paravirt_read_msr_safe(unsigned msr, int *err)
+{
+ return PVOP_CALL2(u64, cpu.read_msr_safe, msr, err);
+}
+
+#define rdmsr_safe(msr, a, b) \
+({ \
+ int _err; \
+ u64 _l = paravirt_read_msr_safe(msr, &_err); \
+ (*a) = (u32)_l; \
+ (*b) = _l >> 32; \
+ _err; \
+})
+
+
+void check_init_int(int);
+void check_init_u32(u32);
+
+void test(void)
+{
+ int err;
+ u32 eax, edx;
+ err = rdmsr_safe(0, &eax, &edx);
+ check_init_int(err);
+ check_init_u32(eax);
+ check_init_u32(edx);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-rdmsr.c b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-rdmsr.c
new file mode 100644
index 0000000..0a1c48f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-rdmsr.c
@@ -0,0 +1,33 @@
+/* { dg-do assemble { target x86_64-*-* } } */
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+
+#include "../analyzer-decls.h"
+
+/* Adapted from Linux: arch/x86/include/asm/msr.h (GPL-2.0) */
+
+#ifdef __x86_64__
+#define DECLARE_ARGS(val, low, high) unsigned long low, high
+#define EAX_EDX_VAL(val, low, high) ((low) | (high) << 32)
+#define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high)
+#else
+#define DECLARE_ARGS(val, low, high) unsigned long long val
+#define EAX_EDX_VAL(val, low, high) (val)
+#define EAX_EDX_RET(val, low, high) "=A" (val)
+#endif
+
+static unsigned long long __rdmsr(unsigned int msr)
+{
+ DECLARE_ARGS(val, low, high);
+
+ asm volatile("1: rdmsr\n"
+ "2:\n"
+ : EAX_EDX_RET(val, low, high) : "c" (msr));
+
+ return EAX_EDX_VAL(val, low, high);
+}
+
+void test (void)
+{
+ __analyzer_eval (__rdmsr (0)); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (__rdmsr (1)); /* { dg-warning "UNKNOWN" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-wfx_get_ps_timeout-full.c b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-wfx_get_ps_timeout-full.c
new file mode 100644
index 0000000..e90dccf5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-wfx_get_ps_timeout-full.c
@@ -0,0 +1,319 @@
+/* { dg-do assemble { target x86_64-*-* } } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-additional-options "-fsanitize=bounds -fno-analyzer-call-summaries" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+/* Reduced from linux kernel: drivers/staging/wfx/sta.c (GPL-2.0)
+ on x86_64 with "allyesconfig"
+
+ This test is deliberately not fully reduced, as an integration test
+ that the analyzer doesn't emit bogus "dereference of NULL" warnings
+ on the repeated wdev_to_wvif calls. */
+
+#define NULL ((void *)0)
+
+/* Types. */
+
+typedef unsigned char __u8;
+typedef unsigned short __u16;
+__extension__ typedef unsigned long long __u64;
+
+typedef __u8 u8;
+typedef __u16 u16;
+typedef __u64 u64;
+
+enum { false = 0, true = 1 };
+typedef _Bool bool;
+
+struct device;
+
+typedef struct {
+ int counter;
+} atomic_t;
+
+struct static_key {
+ atomic_t enabled;
+ union {
+ unsigned long type;
+ struct jump_entry *entries;
+ struct static_key_mod *next;
+ };
+};
+
+struct static_key_true {
+ struct static_key key;
+};
+
+struct static_key_false {
+ struct static_key key;
+};
+
+struct _ddebug {
+ const char *modname;
+ const char *function;
+ const char *filename;
+ const char *format;
+ unsigned int lineno : 18;
+ unsigned int flags : 8;
+
+ union {
+ struct static_key_true dd_key_true;
+ struct static_key_false dd_key_false;
+ } key;
+
+} __attribute__((aligned(8)));
+
+enum nl80211_iftype {
+ /* [...snip...] */
+ NL80211_IFTYPE_AP,
+ /* [...snip...] */
+ NUM_NL80211_IFTYPES,
+ NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1
+};
+
+struct ieee80211_channel {
+ /* [...snip...] */
+ u16 hw_value;
+ /* [...snip...] */
+};
+
+struct cfg80211_chan_def {
+ struct ieee80211_channel *chan;
+ /* [...snip...] */
+};
+
+struct ieee80211_bss_conf {
+ /* [...snip...] */
+ bool assoc, ibss_joined;
+ /* [...snip...] */
+ struct cfg80211_chan_def chandef;
+ /* [...snip...] */
+ bool ps;
+ /* [...snip...] */
+};
+
+struct ieee80211_conf {
+ /* [...snip...] */
+ int power_level, dynamic_ps_timeout;
+ /* [...snip...] */
+};
+
+struct ieee80211_vif {
+ enum nl80211_iftype type;
+ struct ieee80211_bss_conf bss_conf;
+ /* [...snip...] */
+ u8 drv_priv[] __attribute__((__aligned__(sizeof(void *))));
+};
+
+struct ieee80211_hw {
+ struct ieee80211_conf conf;
+ /* [...snip...] */
+};
+
+struct wfx_dev {
+ /* [...snip...] */
+ struct device *dev;
+ struct ieee80211_hw *hw;
+ struct ieee80211_vif *vif[2];
+ /* [...snip...] */
+ int force_ps_timeout;
+};
+
+struct wfx_vif {
+ struct wfx_dev *wdev;
+ struct ieee80211_vif *vif;
+ /* [...snip...] */
+};
+
+/* Function decls. */
+
+extern __attribute__((__format__(printf, 1, 2))) void
+__warn_printk(const char *fmt, ...);
+
+extern bool ____wrong_branch_error(void);
+
+extern __attribute__((__format__(printf, 3, 4))) void
+__dynamic_dev_dbg(struct _ddebug *descriptor, const struct device *dev,
+ const char *fmt, ...);
+
+bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor);
+
+/* Function defns. */
+
+static inline unsigned long array_index_mask_nospec(unsigned long index,
+ unsigned long size) {
+ unsigned long mask;
+
+ asm volatile("cmp %1,%2; sbb %0,%0;"
+ : "=r"(mask)
+ : "g"(size), "r"(index)
+ : "cc");
+ return mask;
+}
+
+static inline __attribute__((__always_inline__)) bool
+arch_static_branch(struct static_key *key, bool branch) {
+ asm goto("1:"
+ "jmp %l[l_yes] # objtool NOPs this \n\t"
+ ".pushsection __jump_table, \"aw\" \n\t"
+ " "
+ ".balign 8"
+ " "
+ "\n\t"
+ ".long 1b - . \n\t"
+ ".long %l[l_yes] - . \n\t"
+ " "
+ ".quad"
+ " "
+ "%c0 + %c1 - .\n\t"
+ ".popsection \n\t"
+ :
+ : "i"(key), "i"(2 | branch)
+ :
+ : l_yes);
+ asm("");
+
+ return false;
+l_yes:
+ return true;
+}
+
+static inline __attribute__((__always_inline__)) bool
+arch_static_branch_jump(struct static_key *const key, const bool branch) {
+ asm goto("1:"
+ "jmp %l[l_yes]\n\t"
+ ".pushsection __jump_table, \"aw\" \n\t"
+ " "
+ ".balign 8"
+ " "
+ "\n\t"
+ ".long 1b - . \n\t"
+ ".long %l[l_yes] - . \n\t"
+ " "
+ ".quad"
+ " "
+ "%c0 + %c1 - .\n\t"
+ ".popsection \n\t"
+ :
+ : "i"(key), "i"(branch)
+ :
+ : l_yes);
+ asm("");
+
+ return false;
+l_yes:
+ return true;
+}
+
+static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) {
+ if (vif_id >=
+ (sizeof(wdev->vif) / sizeof((wdev->vif)[0]) + ((int)(sizeof(struct {
+ int : (-!!(__builtin_types_compatible_p(typeof((wdev->vif)),
+ typeof(&(wdev->vif)[0]))));
+ }))))) {
+ static struct _ddebug __attribute__((__aligned__(8)))
+ __attribute__((__section__("__dyndbg"))) __UNIQUE_ID_ddebug1678 = {
+ .modname = "wfx",
+ .function = __func__,
+ .filename = "drivers/staging/wfx/wfx.h",
+ .format = ("requesting non-existent vif: %d\n"),
+ .lineno = 97,
+ .flags = 0,
+ .key.dd_key_false = ((struct static_key_false){
+ .key = {.enabled = {0}, {.entries = (void *)0UL}},
+ })};
+ if (({
+ bool branch;
+ if (__builtin_types_compatible_p(
+ typeof(*&__UNIQUE_ID_ddebug1678.key.dd_key_false),
+ struct static_key_true))
+ branch = arch_static_branch_jump(
+ &(&__UNIQUE_ID_ddebug1678.key.dd_key_false)->key, false);
+ else if (__builtin_types_compatible_p(
+ typeof(*&__UNIQUE_ID_ddebug1678.key.dd_key_false),
+ struct static_key_false))
+ branch = arch_static_branch(
+ &(&__UNIQUE_ID_ddebug1678.key.dd_key_false)->key, false);
+ else
+ branch = ____wrong_branch_error();
+ __builtin_expect(!!(branch), 0);
+ }))
+ __dynamic_dev_dbg(&__UNIQUE_ID_ddebug1678, wdev->dev,
+ "requesting non-existent vif: %d\n", vif_id);
+ return NULL;
+ }
+ typeof(vif_id) _i = (vif_id);
+ typeof((sizeof(wdev->vif) / sizeof((wdev->vif)[0]) + ((int)(sizeof(struct {
+ int : (-!!(__builtin_types_compatible_p(typeof((wdev->vif)),
+ typeof(&(wdev->vif)[0]))));
+ }))))) _s =
+ ((sizeof(wdev->vif) / sizeof((wdev->vif)[0]) + ((int)(sizeof(struct {
+ int : (-!!(__builtin_types_compatible_p(typeof((wdev->vif)),
+ typeof(&(wdev->vif)[0]))));
+ })))));
+ unsigned long _mask = array_index_mask_nospec(_i, _s);
+ vif_id = (typeof(_i))(_i & _mask);
+ if (!wdev->vif[vif_id]) {
+ static struct _ddebug __attribute__((__aligned__(8)))
+ __attribute__((__section__("__dyndbg"))) __UNIQUE_ID_ddebug1681 = {
+ .modname = "wfx",
+ .function = __func__,
+ .filename = "drivers/staging/wfx/wfx.h",
+ .format = ("requesting non-allocated vif: %d\n"),
+ .lineno = 102,
+ .flags = 0,
+ .key.dd_key_false = ((struct static_key_false){
+ .key = {.enabled = {0}, {.entries = (void *)0UL}},
+ })};
+ if (({
+ bool branch;
+ if (__builtin_types_compatible_p(
+ typeof(*&__UNIQUE_ID_ddebug1681.key.dd_key_false),
+ struct static_key_true))
+ branch = arch_static_branch_jump(
+ &(&__UNIQUE_ID_ddebug1681.key.dd_key_false)->key, false);
+ else if (__builtin_types_compatible_p(
+ typeof(*&__UNIQUE_ID_ddebug1681.key.dd_key_false),
+ struct static_key_false))
+ branch = arch_static_branch(
+ &(&__UNIQUE_ID_ddebug1681.key.dd_key_false)->key, false);
+ else
+ branch = ____wrong_branch_error();
+ __builtin_expect(!!(branch), 0);
+ }))
+ __dynamic_dev_dbg(&__UNIQUE_ID_ddebug1681, wdev->dev,
+ "requesting non-allocated vif: %d\n", vif_id);
+ return NULL;
+ }
+ return (struct wfx_vif *)wdev->vif[vif_id]->drv_priv;
+}
+
+int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps) {
+ struct ieee80211_channel *chan0 = NULL, *chan1 = NULL;
+ struct ieee80211_conf *conf = &wvif->wdev->hw->conf;
+
+ if (wdev_to_wvif(wvif->wdev, 0))
+ chan0 = wdev_to_wvif(wvif->wdev, 0)->vif->bss_conf.chandef.chan; /* { dg-bogus "dereference of NULL" } */
+ if (wdev_to_wvif(wvif->wdev, 1))
+ chan1 = wdev_to_wvif(wvif->wdev, 1)->vif->bss_conf.chandef.chan; /* { dg-bogus "dereference of NULL" } */
+ if (chan0 && chan1 && chan0->hw_value != chan1->hw_value &&
+ wvif->vif->type != NL80211_IFTYPE_AP) {
+
+ if (enable_ps)
+ *enable_ps = true;
+ if (wvif->wdev->force_ps_timeout > -1)
+ return wvif->wdev->force_ps_timeout;
+ else if (wfx_api_older_than(wvif->wdev, 3, 2))
+ return 0;
+ else
+ return 30;
+ }
+ if (enable_ps)
+ *enable_ps = wvif->vif->bss_conf.ps;
+ if (wvif->wdev->force_ps_timeout > -1)
+ return wvif->wdev->force_ps_timeout;
+ else if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps)
+ return conf->dynamic_ps_timeout;
+ else
+ return -1;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-wfx_get_ps_timeout-reduced.c b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-wfx_get_ps_timeout-reduced.c
new file mode 100644
index 0000000..a18c58c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/asm-x86-linux-wfx_get_ps_timeout-reduced.c
@@ -0,0 +1,77 @@
+/* { dg-do assemble { target x86_64-*-* } } */
+/* { dg-require-effective-target lp64 } */
+
+/* Reproducer for false positive from -Wanalyzer-null-dereference seen
+ in Linux kernel (drivers/staging/wfx/sta.c; GPL-2.0) due to
+ the analyzer not grokking that array_index_mask_nospec is
+ effectively pure, and thus not realizing that array_index_no_spec
+ is also pure, leading to wdev_to_wvif not being treated as pure,
+ and thus able to return non-NULL and then NULL. */
+
+typedef unsigned char u8;
+#define NULL ((void *)0)
+
+/* Types. */
+
+struct ieee80211_vif {
+ int placeholder;
+ /* snip */
+ u8 drv_priv[];
+};
+
+struct wfx_dev {
+ /* snip */
+ struct ieee80211_vif *vif[2];
+ /* snip */
+};
+
+struct wfx_vif {
+ struct wfx_dev *wdev;
+ struct ieee80211_vif *vif;
+ /* snip */
+};
+
+/* Copied from arch/x86/include/asm/barrier.h */
+
+static inline unsigned long array_index_mask_nospec(unsigned long index,
+ unsigned long size)
+{
+ unsigned long mask;
+
+ asm volatile ("cmp %1,%2; sbb %0,%0;"
+ :"=r" (mask)
+ :"g"(size),"r" (index)
+ :"cc");
+ return mask;
+}
+
+/* Simplified from include/linux/kernel.h */
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+/* Simplified from include/linux/nospec.h */
+
+#define array_index_nospec(index, size) \
+({ \
+ typeof(index) _i = (index); \
+ typeof(size) _s = (size); \
+ unsigned long _mask = array_index_mask_nospec(_i, _s); \
+ /* snip */ \
+ (typeof(_i)) (_i & _mask); \
+})
+
+/* Simplified from drivers/staging/wfx/wfx.h */
+
+static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) {
+ vif_id = array_index_nospec(vif_id, ARRAY_SIZE(wdev->vif));
+ if (!wdev->vif[vif_id]) {
+ return NULL;
+ }
+ return (struct wfx_vif *)wdev->vif[vif_id]->drv_priv;
+}
+
+struct ieee80211_vif *test (struct wfx_vif *wvif) {
+ if (wdev_to_wvif(wvif->wdev, 1))
+ return wdev_to_wvif(wvif->wdev, 1)->vif; /* { dg-bogus "dereference of NULL" } */
+ else
+ return NULL;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr102225.c b/gcc/testsuite/gcc.dg/analyzer/torture/pr102225.c
new file mode 100644
index 0000000..a7c3249
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/pr102225.c
@@ -0,0 +1,6 @@
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+
+void bad_realloc(char *s, int n)
+{
+ char *p = __builtin_realloc(s, n);
+} /* { dg-warning "leak" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c b/gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c
index 9d92939..314c8f3 100644
--- a/gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c
@@ -1,3 +1,4 @@
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
/* { dg-additional-options "-Wno-incompatible-pointer-types -Wno-analyzer-too-complex" } */
/* TODO: ideally we shouldn't have -Wno-analyzer-too-complex above; it
appears to be needed due to the recursion. */
@@ -57,7 +58,7 @@ ts (struct dz *cx)
{
struct dz nt;
- if (nt.r5)
+ if (nt.r5) /* { dg-warning "use of uninitialized value 'nt.r5'" } */
{
m6 (cx);
h5 (cx);
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/switch-2.c b/gcc/testsuite/gcc.dg/analyzer/torture/switch-2.c
new file mode 100644
index 0000000..3da2e30
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/switch-2.c
@@ -0,0 +1,42 @@
+struct s
+{
+ int f0;
+ int f1;
+};
+
+int test (int cmd)
+{
+ int err = 0;
+ struct s foo;
+ struct s bar;
+
+ switch (cmd)
+ {
+ case 0:
+ foo.f0 = 0;
+ break;
+ case 1:
+ foo.f0 = 1;
+ break;
+ case 30 ... 50:
+ case 70 ... 80:
+ __builtin_memset (&bar, 0, sizeof (bar));
+ break;
+ }
+
+ switch (cmd)
+ {
+ default:
+ return -1;
+ case 0 ... 1:
+ return foo.f0;
+ break;
+ case 42:
+ return bar.f1;
+ break;
+ case 65:
+ return bar.f1;
+ break;
+ }
+ return err;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/switch-3.c b/gcc/testsuite/gcc.dg/analyzer/torture/switch-3.c
new file mode 100644
index 0000000..57b8acd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/switch-3.c
@@ -0,0 +1,158 @@
+typedef unsigned int __u32;
+__extension__ typedef unsigned long long __u64;
+
+extern unsigned long
+copy_from_user(void *to, const void *from, unsigned long n);
+
+extern unsigned long
+copy_to_user(void *to, const void *from, unsigned long n);
+
+struct mtrr_sentry {
+ __u64 base;
+ __u32 size;
+ __u32 type;
+};
+
+struct mtrr_gentry {
+ __u64 base;
+ __u32 size;
+ __u32 regnum;
+ __u32 type;
+ __u32 _pad;
+};
+
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 14
+#define _IOC_DIRBITS 2
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+#define _IOC_WRITE 1U
+#define _IOC_READ 2U
+
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT))
+
+#define _IOC_TYPECHECK(t) (sizeof(t))
+
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
+
+#define MTRR_IOCTL_BASE 'M'
+
+#define EFAULT 14
+#define EINVAL 22
+#define ENOTTY 25
+
+#define MTRRIOC_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry)
+#define MTRRIOC_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry)
+#define MTRRIOC_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry)
+#define MTRRIOC_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry)
+#define MTRRIOC_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry)
+#define MTRRIOC_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry)
+#define MTRRIOC_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry)
+#define MTRRIOC_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry)
+#define MTRRIOC_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry)
+#define MTRRIOC_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry)
+
+extern void check_init_u64 (__u64 v);
+extern void check_init_u32 (__u32 v);
+
+/* Adapted/reduced from arch/x86/kernel/cpu/mtrr/if.c: mtrr_ioctl,
+ which is GPL-2.0 */
+
+long mtrr_ioctl(unsigned int cmd, unsigned long __arg) {
+ int err = 0;
+ struct mtrr_sentry sentry;
+ struct mtrr_gentry gentry;
+ void *arg = (void *)__arg;
+
+ __builtin_memset(&gentry, 0, sizeof(gentry));
+
+ switch (cmd) {
+ case MTRRIOC_ADD_ENTRY:
+ case MTRRIOC_SET_ENTRY:
+ case MTRRIOC_DEL_ENTRY:
+ case MTRRIOC_KILL_ENTRY:
+ case MTRRIOC_ADD_PAGE_ENTRY:
+ case MTRRIOC_SET_PAGE_ENTRY:
+ case MTRRIOC_DEL_PAGE_ENTRY:
+ case MTRRIOC_KILL_PAGE_ENTRY:
+ if (copy_from_user(&sentry, arg, sizeof(sentry)))
+ return -EFAULT;
+ break;
+ case MTRRIOC_GET_ENTRY:
+ case MTRRIOC_GET_PAGE_ENTRY:
+ if (copy_from_user(&gentry, arg, sizeof(gentry)))
+ return -EFAULT;
+ break;
+ }
+
+ switch (cmd) {
+ default:
+ return -ENOTTY;
+ case MTRRIOC_ADD_ENTRY:
+ check_init_u64 (sentry.base);
+ check_init_u32 (sentry.size);
+ check_init_u32 (sentry.type);
+ break;
+ case MTRRIOC_SET_ENTRY:
+ check_init_u64 (sentry.base);
+ check_init_u32 (sentry.size);
+ check_init_u32 (sentry.type);
+ break;
+ case MTRRIOC_DEL_ENTRY:
+ check_init_u64 (sentry.base);
+ check_init_u32 (sentry.size);
+ check_init_u32 (sentry.type);
+ break;
+ case MTRRIOC_KILL_ENTRY:
+ check_init_u64 (sentry.base);
+ check_init_u32 (sentry.size);
+ check_init_u32 (sentry.type);
+ break;
+ case MTRRIOC_GET_ENTRY:
+ check_init_u64 (gentry.base);
+ check_init_u32 (gentry.size);
+ check_init_u32 (gentry.regnum);
+ check_init_u32 (gentry.type);
+ check_init_u32 (gentry._pad);
+ break;
+ case MTRRIOC_ADD_PAGE_ENTRY:
+ check_init_u64 (sentry.base);
+ check_init_u32 (sentry.size);
+ check_init_u32 (sentry.type);
+ break;
+ case MTRRIOC_SET_PAGE_ENTRY:
+ check_init_u64 (sentry.base);
+ check_init_u32 (sentry.size);
+ check_init_u32 (sentry.type);
+ break;
+ case MTRRIOC_DEL_PAGE_ENTRY:
+ check_init_u64 (sentry.base);
+ check_init_u32 (sentry.size);
+ check_init_u32 (sentry.type);
+ break;
+ case MTRRIOC_KILL_PAGE_ENTRY:
+ check_init_u64 (sentry.base);
+ check_init_u32 (sentry.size);
+ check_init_u32 (sentry.type);
+ break;
+ case MTRRIOC_GET_PAGE_ENTRY:
+ check_init_u64 (gentry.base);
+ check_init_u32 (gentry.size);
+ check_init_u32 (gentry.regnum);
+ check_init_u32 (gentry.type);
+ check_init_u32 (gentry._pad);
+ break;
+ }
+
+ return err;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/switch-4.c b/gcc/testsuite/gcc.dg/analyzer/torture/switch-4.c
new file mode 100644
index 0000000..f5cdb5c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/switch-4.c
@@ -0,0 +1,27 @@
+struct snd_ac97 {
+ // snip
+ unsigned int id;
+ // snip
+};
+
+int snd_ac97_valid_reg(struct snd_ac97 *ac97, unsigned short reg) {
+
+ switch (ac97->id) {
+ case 0x53544d02:
+ if (reg == 0x22 || reg == 0x7a)
+ return 1;
+ __attribute__((__fallthrough__));
+ case 0x414b4d00:
+ return 0;
+ }
+ return 1;
+}
+
+int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg) {
+ if (ac97->id == 0x414c4781)
+ {
+ if (!snd_ac97_valid_reg(ac97, reg))
+ return -22;
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/switch-5.c b/gcc/testsuite/gcc.dg/analyzer/torture/switch-5.c
new file mode 100644
index 0000000..10b2f29
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/switch-5.c
@@ -0,0 +1,68 @@
+/* { dg-additional-options "-fno-analyzer-call-summaries" } */
+
+typedef unsigned char u8;
+typedef signed int s32;
+typedef unsigned int u32;
+
+enum v4l2_mpeg_video_hevc_profile {
+ V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN = 0,
+ V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE = 1,
+ V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10 = 2
+};
+enum v4l2_buf_type {
+ V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
+ V4L2_BUF_TYPE_VIDEO_OUTPUT = 2
+};
+struct v4l2_fmtdesc {
+ u32 index;
+ u32 type;
+};
+struct v4l2_ctrl;
+s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
+struct create_channel_param {
+ u8 profile;
+};
+
+u8
+hevc_profile_to_mcu_profile(enum v4l2_mpeg_video_hevc_profile profile) {
+ switch (profile) {
+ default:
+ case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN:
+ return 1;
+ case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10:
+ return 2;
+ case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE:
+ return 3;
+ }
+}
+
+int fill_create_channel_param(struct v4l2_ctrl *ctrl,
+ struct create_channel_param *param) {
+ enum v4l2_mpeg_video_hevc_profile profile;
+ profile = v4l2_ctrl_g_ctrl(ctrl);
+ param->profile = hevc_profile_to_mcu_profile(profile);
+ return 0;
+}
+
+int allegro_enum_fmt_vid(struct v4l2_fmtdesc *f) {
+ switch (f->type) {
+ case V4L2_BUF_TYPE_VIDEO_OUTPUT:
+ if (f->index >= 1)
+ return -22;
+ break;
+ case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+ if (f->index >= 2)
+ return -22;
+ break;
+ default:
+ return -22;
+ }
+ return 0;
+}
+
+int allegro_ioctl_streamon(struct v4l2_ctrl *ctrl,
+ struct create_channel_param *param) {
+ fill_create_channel_param(ctrl, param);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/ubsan-1.c b/gcc/testsuite/gcc.dg/analyzer/torture/ubsan-1.c
new file mode 100644
index 0000000..b9f34f1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/ubsan-1.c
@@ -0,0 +1,60 @@
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+/* { dg-additional-options "-fsanitize=bounds" } */
+
+#include <stdlib.h>
+#include "../analyzer-decls.h"
+
+int test_1 (int *arr, int i, int n)
+{
+ if (i >= n)
+ return 0;
+ return arr[i];
+}
+
+int test_2 (int *arr, int i, int n)
+{
+ if (i >= n)
+ return 0;
+ if (arr[i])
+ __analyzer_eval (arr[i]); /* { dg-warning "TRUE" } */
+ else
+ __analyzer_eval (arr[i]); /* { dg-warning "FALSE" } */
+}
+
+int test_3 (int arr[], int i, int n)
+{
+ if (i >= n)
+ return 0;
+ if (arr[i])
+ __analyzer_eval (arr[i]); /* { dg-warning "TRUE" } */
+ else
+ __analyzer_eval (arr[i]); /* { dg-warning "FALSE" } */
+}
+
+void test_4 (int i, int n)
+{
+ int arr[n];
+ arr[i] = 42;
+ __analyzer_eval (arr[i] == 42); /* { dg-warning "TRUE" } */
+}
+
+void test_5 (int i, int n)
+{
+ int *arr = malloc (sizeof(int) * n);
+ if (arr)
+ {
+ arr[i] = 42;
+ __analyzer_eval (arr[i] == 42); /* { dg-warning "TRUE" } */
+ }
+ free (arr);
+}
+
+int global;
+
+void test_6 (int i, int n)
+{
+ int arr[n];
+ int saved = global;
+ arr[i] = 42;
+ __analyzer_eval (saved == global); /* { dg-warning "TRUE" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-1.c b/gcc/testsuite/gcc.dg/analyzer/uninit-1.c
new file mode 100644
index 0000000..8fcdcd6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/uninit-1.c
@@ -0,0 +1,44 @@
+#include "analyzer-decls.h"
+
+int test_1 (void)
+{
+ int i;
+ return i; /* { dg-warning "use of uninitialized value 'i'" } */
+}
+
+int test_2 (void)
+{
+ int i;
+ return i * 2; /* { dg-warning "use of uninitialized value 'i'" } */
+}
+
+int test_3 (void)
+{
+ static int i;
+ return i;
+}
+
+int test_4 (void)
+{
+ int *p;
+ return *p; /* { dg-warning "use of uninitialized value 'p'" } */
+}
+
+int test_5 (int flag, int *q)
+{
+ int *p;
+ if (flag) /* { dg-message "following 'false' branch" } */
+ p = q;
+
+ /* There should be two enodes here,
+ i.e. not merging the init vs non-init states. */
+ __analyzer_dump_exploded_nodes (0); /* { dg-warning "2 processed enodes" } */
+
+ return *p; /* { dg-warning "use of uninitialized value 'p'" } */
+}
+
+int test_6 (int i)
+{
+ int arr[10];
+ return arr[i]; /* { dg-warning "use of uninitialized value 'arr\\\[i\\\]'" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-2.c b/gcc/testsuite/gcc.dg/analyzer/uninit-2.c
new file mode 100644
index 0000000..0b0b8b6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/uninit-2.c
@@ -0,0 +1,14 @@
+typedef __SIZE_TYPE__ size_t;
+
+extern size_t strlen (const char *__s)
+ __attribute__ ((__nothrow__ , __leaf__))
+ __attribute__ ((__pure__))
+ __attribute__ ((__nonnull__ (1)));
+
+extern char *read_file (const char *file);
+
+size_t test_1 (const char *file)
+{
+ char *str = read_file (file);
+ return strlen (str);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-3.c b/gcc/testsuite/gcc.dg/analyzer/uninit-3.c
new file mode 100644
index 0000000..fa33e0a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/uninit-3.c
@@ -0,0 +1,36 @@
+/* Reduced from linux 5.3.11: drivers/net/wireless/ath/ath10k/usb.c */
+
+/* The original file has this licence header. */
+
+// SPDX-License-Identifier: ISC
+/*
+ * Copyright (c) 2007-2011 Atheros Communications Inc.
+ * Copyright (c) 2011-2012,2017 Qualcomm Atheros, Inc.
+ * Copyright (c) 2016-2017 Erik Stromdahl <erik.stromdahl@gmail.com>
+ */
+
+/* Adapted from include/linux/compiler_attributes.h. */
+#define __printf(a, b) __attribute__((__format__(printf, a, b)))
+
+/* From drivers/net/wireless/ath/ath10k/core.h. */
+
+struct ath10k;
+
+/* From drivers/net/wireless/ath/ath10k/debug.h. */
+
+enum ath10k_debug_mask {
+ /* [...other values removed...] */
+ ATH10K_DBG_USB_BULK = 0x00080000,
+};
+
+extern unsigned int ath10k_debug_mask;
+
+__printf(3, 4) void __ath10k_dbg(struct ath10k *ar,
+ enum ath10k_debug_mask mask,
+ const char *fmt, ...);
+
+static void ath10k_usb_hif_tx_sg(struct ath10k *ar)
+{
+ if (ath10k_debug_mask & ATH10K_DBG_USB_BULK)
+ __ath10k_dbg(ar, ATH10K_DBG_USB_BULK, "usb bulk transmit failed: %d\n", 42);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-4.c b/gcc/testsuite/gcc.dg/analyzer/uninit-4.c
new file mode 100644
index 0000000..791b111
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/uninit-4.c
@@ -0,0 +1,39 @@
+/* Example of interprocedural detection of an uninitialized field
+ in a heap-allocated struct. */
+
+#include <stdlib.h>
+#include "analyzer-decls.h"
+
+struct foo
+{
+ int i;
+ int j;
+ int k;
+};
+
+struct foo *__attribute__((noinline))
+alloc_foo (int a, int b)
+{
+ struct foo *p = malloc (sizeof (struct foo));
+ if (!p)
+ return NULL;
+ p->i = a;
+ p->k = b;
+ return p;
+}
+
+void test (int x, int y, int z)
+{
+ struct foo *p = alloc_foo (x, z);
+ if (!p)
+ return;
+
+ __analyzer_eval (p->i == x); /* { dg-warning "TRUE" } */
+
+ __analyzer_eval (p->j == y); /* { dg-warning "UNKNOWN" "unknown" } */
+ /* { dg-warning "use of uninitialized value '\\*p\\.j'" "uninit" { target *-*-* } .-1 } */
+
+ __analyzer_eval (p->k == z); /* { dg-warning "TRUE" } */
+
+ free (p);
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-6.c b/gcc/testsuite/gcc.dg/analyzer/uninit-6.c
new file mode 100644
index 0000000..75a99ad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/uninit-6.c
@@ -0,0 +1,29 @@
+/* Reduced from uninit false positive seen on Linux kernel with
+ net/ethtool/ioctl.c */
+
+typedef signed char s8;
+typedef unsigned int u32;
+typedef __SIZE_TYPE__ size_t;
+
+void *memset(void *s, int c, size_t n);
+
+struct ethtool_link_settings {
+ u32 cmd;
+ s8 link_mode_masks_nwords;
+};
+
+struct ethtool_link_ksettings {
+ struct ethtool_link_settings base;
+ u32 lanes;
+};
+
+struct ethtool_link_settings
+ethtool_get_link_ksettings(void) {
+ struct ethtool_link_ksettings link_ksettings;
+
+ memset(&link_ksettings, 0, sizeof(link_ksettings));
+ link_ksettings.base.cmd = 0x0000004c;
+ link_ksettings.base.link_mode_masks_nwords = -3;
+
+ return link_ksettings.base;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-6b.c b/gcc/testsuite/gcc.dg/analyzer/uninit-6b.c
new file mode 100644
index 0000000..32ba30f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/uninit-6b.c
@@ -0,0 +1,29 @@
+/* Reduced from uninit false positive seen on Linux kernel with
+ net/ethtool/ioctl.c */
+
+typedef signed char s8;
+typedef unsigned int u32;
+typedef __SIZE_TYPE__ size_t;
+
+void *memset(void *s, int c, size_t n);
+
+struct ethtool_link_settings {
+ u32 cmd;
+ s8 link_mode_masks_nwords;
+};
+
+struct ethtool_link_ksettings {
+ u32 lanes;
+ struct ethtool_link_settings base;
+};
+
+struct ethtool_link_settings
+ethtool_get_link_ksettings(void) {
+ struct ethtool_link_ksettings link_ksettings;
+
+ memset(&link_ksettings, 0, sizeof(link_ksettings));
+ link_ksettings.base.cmd = 0x0000004c;
+ link_ksettings.base.link_mode_masks_nwords = -3;
+
+ return link_ksettings.base;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-pr94713.c b/gcc/testsuite/gcc.dg/analyzer/uninit-pr94713.c
new file mode 100644
index 0000000..cc337dc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/uninit-pr94713.c
@@ -0,0 +1,11 @@
+void f1 (int *);
+void f2 (int);
+
+int foo (void)
+{
+ int *p;
+
+ f1 (p); /* { dg-warning "use of uninitialized value 'p'" } */
+ f2 (p[0]); /* { dg-warning "use of uninitialized value 'p'" } */
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-pr94714.c b/gcc/testsuite/gcc.dg/analyzer/uninit-pr94714.c
new file mode 100644
index 0000000..df07f98
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/uninit-pr94714.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+int main (void)
+{
+ int *p;
+ int i;
+
+ p = &i; /* { dg-bogus "uninitialized" } */
+ printf ("%d\n", p[0]); /* { dg-warning "use of uninitialized value '\\*p'" } */
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/use-after-free-2.c b/gcc/testsuite/gcc.dg/analyzer/use-after-free-2.c
new file mode 100644
index 0000000..fc138ee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/use-after-free-2.c
@@ -0,0 +1,8 @@
+int test (void)
+{
+ int *ptr = (int *)__builtin_malloc (sizeof (int));
+ *ptr = 42; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */
+ __builtin_free (ptr);
+
+ return *ptr; /* { dg-warning "use after 'free' of 'ptr'" "use-after-free" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/use-after-free-3.c b/gcc/testsuite/gcc.dg/analyzer/use-after-free-3.c
new file mode 100644
index 0000000..b19fd3d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/use-after-free-3.c
@@ -0,0 +1,12 @@
+#include <stdlib.h>
+
+void test_1 (int x, int y, int *out)
+{
+ int *ptr = (int *)malloc (sizeof (int));
+ if (!ptr)
+ return;
+ *ptr = 19;
+
+ free (ptr);
+ *out = *ptr; /* { dg-warning "use after 'free' of 'ptr'" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/zlib-3.c b/gcc/testsuite/gcc.dg/analyzer/zlib-3.c
index 5faada1..57f5dcd 100644
--- a/gcc/testsuite/gcc.dg/analyzer/zlib-3.c
+++ b/gcc/testsuite/gcc.dg/analyzer/zlib-3.c
@@ -179,7 +179,7 @@ static int huft_build(uInt *b, uInt n, uInt s, const uInt *d, const uInt *e,
f = 1 << (k - w);
for (j = i >> w; j < z; j += f)
- q[j] = r;
+ q[j] = r; /* { dg-warning "use of uninitialized value 'r.base'" } */
mask = (1 << w) - 1;
while ((i & mask) != x[h]) {
diff --git a/gcc/testsuite/gcc.dg/analyzer/zlib-6.c b/gcc/testsuite/gcc.dg/analyzer/zlib-6.c
index 0d814c0..c8e06c6 100644
--- a/gcc/testsuite/gcc.dg/analyzer/zlib-6.c
+++ b/gcc/testsuite/gcc.dg/analyzer/zlib-6.c
@@ -16,15 +16,8 @@ typedef struct inflate_blocks_state {
extern int inflate_flush(inflate_blocks_statef *, z_stream *, int);
-int inflate_blocks(inflate_blocks_statef *s, z_stream *z, int r) {
- uInt t;
- uLong b;
- uInt k;
- Byte *p;
- uInt n;
- Byte *q;
- uInt m;
-
+int inflate_blocks(inflate_blocks_statef *s, z_stream *z, int r,
+ uLong b, uInt k, Byte *p, uInt n, Byte *q, uInt m) {
while (k < (3)) {
{
if (n)
@@ -41,7 +34,7 @@ int inflate_blocks(inflate_blocks_statef *s, z_stream *z, int r) {
return inflate_flush(s, z, r);
}
};
- b |= ((uLong)(n--, *p++)) << k; /* { dg-warning "use of uninitialized value" "uninit-warning-removed" { xfail *-*-* } } */
+ b |= ((uLong)(n--, *p++)) << k;
k += 8;
}
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/zlib-6a.c b/gcc/testsuite/gcc.dg/analyzer/zlib-6a.c
new file mode 100644
index 0000000..9676e0b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/zlib-6a.c
@@ -0,0 +1,47 @@
+typedef unsigned char Byte;
+typedef unsigned int uInt;
+typedef unsigned long uLong;
+
+typedef struct z_stream_s {
+ Byte *next_in;
+ uInt avail_in;
+ uLong total_in;
+} z_stream;
+
+typedef struct inflate_blocks_state {
+ uInt bitk;
+ uLong bitb;
+ Byte *write;
+} inflate_blocks_statef;
+
+extern int inflate_flush(inflate_blocks_statef *, z_stream *, int);
+
+int inflate_blocks(inflate_blocks_statef *s, z_stream *z, int r) {
+ uInt t;
+ uLong b;
+ uInt k;
+ Byte *p;
+ uInt n;
+ Byte *q;
+ uInt m;
+
+ while (k < (3)) { /* { dg-warning "use of uninitialized value 'k'" } */
+ {
+ if (n) /* { dg-warning "use of uninitialized value 'n'" } */
+ r = 0;
+ else {
+ {
+ s->bitb = b; /* { dg-warning "use of uninitialized value 'b'" } */
+ s->bitk = k; /* { dg-warning "use of uninitialized value 'k'" } */
+ z->avail_in = n; /* { dg-warning "use of uninitialized value 'n'" } */
+ z->total_in += p - z->next_in; /* { dg-warning "use of uninitialized value 'p'" } */
+ z->next_in = p; /* { dg-warning "use of uninitialized value 'p'" } */
+ s->write = q; /* { dg-warning "use of uninitialized value 'q'" } */
+ }
+ return inflate_flush(s, z, r);
+ }
+ };
+ b |= ((uLong)(n--, *p++)) << k; /* { dg-warning "use of uninitialized value" } */
+ k += 8; /* { dg-warning "use of uninitialized value 'k'" } */
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/array-quals-1.c b/gcc/testsuite/gcc.dg/array-quals-1.c
index 2c04164..b9b55f7 100644
--- a/gcc/testsuite/gcc.dg/array-quals-1.c
+++ b/gcc/testsuite/gcc.dg/array-quals-1.c
@@ -7,26 +7,26 @@
/* { dg-additional-options "-fno-pie" { target pie } } */
/* The MMIX port always switches to the .data section at the end of a file. */
/* { dg-final { scan-assembler-not "\\.data(?!\\.rel\\.ro)" { xfail powerpc*-*-aix* mmix-*-* x86_64-*-mingw* } } } */
-/* { dg-final { scan-assembler-symbol-section {^_?a$} {^\.(const|rodata|srodata)|\[RO\]} } } */
+/* { dg-final { scan-assembler-symbol-section {^_?a$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */
static const int a[2] = { 1, 2 };
/* { dg-final { scan-assembler-symbol-section {^_?a1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */
const int a1[2] = { 1, 2 };
typedef const int ci;
-/* { dg-final { scan-assembler-symbol-section {^_?b$} {^\.(const|rodata|srodata)|\[RO\]} } } */
+/* { dg-final { scan-assembler-symbol-section {^_?b$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */
static ci b[2] = { 3, 4 };
/* { dg-final { scan-assembler-symbol-section {^_?b1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */
ci b1[2] = { 3, 4 };
typedef int ia[2];
-/* { dg-final { scan-assembler-symbol-section {^_?c$} {^\.(const|rodata|srodata)|\[RO\]} } } */
+/* { dg-final { scan-assembler-symbol-section {^_?c$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */
static const ia c = { 5, 6 };
/* { dg-final { scan-assembler-symbol-section {^_?c1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */
const ia c1 = { 5, 6 };
typedef const int cia[2];
-/* { dg-final { scan-assembler-symbol-section {^_?d$} {^\.(const|rodata|srodata)|\[RO\]} } } */
+/* { dg-final { scan-assembler-symbol-section {^_?d$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */
static cia d = { 7, 8 };
/* { dg-final { scan-assembler-symbol-section {^_?d1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */
cia d1 = { 7, 8 };
-/* { dg-final { scan-assembler-symbol-section {^_?e$} {^\.(const|rodata|srodata)|\[RO\]} } } */
+/* { dg-final { scan-assembler-symbol-section {^_?e$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */
static cia e[2] = { { 1, 2 }, { 3, 4 } };
/* { dg-final { scan-assembler-symbol-section {^_?e1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */
cia e1[2] = { { 1, 2 }, { 3, 4 } };
diff --git a/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-2.c b/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-2.c
index 9ee56b6..3e75096 100644
--- a/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-2.c
+++ b/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-2.c
@@ -2,6 +2,7 @@
assignment. */
/* { dg-do run } */
/* { dg-options "-std=c11 -pedantic-errors" } */
+/* { dg-prune-output "warning: using serial compilation" } */
extern void abort (void);
extern void exit (int);
diff --git a/gcc/testsuite/gcc.dg/attr-alloc_size-5.c b/gcc/testsuite/gcc.dg/attr-alloc_size-5.c
index 7aa7cbf..4eea625 100644
--- a/gcc/testsuite/gcc.dg/attr-alloc_size-5.c
+++ b/gcc/testsuite/gcc.dg/attr-alloc_size-5.c
@@ -4,7 +4,7 @@
zero bytes. For standard allocation functions the return value is
implementation-defined and so relying on it may be a source of bugs. */
/* { dg-do compile } */
-/* { dg-options "-O2 -Wall -Walloc-zero" } */
+/* { dg-options "-O1 -Wall -Walloc-zero" } */
#define SCHAR_MAX __SCHAR_MAX__
#define SCHAR_MIN (-SCHAR_MAX - 1)
diff --git a/gcc/testsuite/gcc.dg/attr-alloc_size-7.c b/gcc/testsuite/gcc.dg/attr-alloc_size-7.c
index 68602ec..3adde5c 100644
--- a/gcc/testsuite/gcc.dg/attr-alloc_size-7.c
+++ b/gcc/testsuite/gcc.dg/attr-alloc_size-7.c
@@ -4,7 +4,7 @@
of the maximum specified by -Walloc-size-larger-than=maximum. */
/* { dg-do compile } */
/* { dg-require-effective-target alloca } */
-/* { dg-options "-O2 -Wall -Walloc-size-larger-than=12345" } */
+/* { dg-options "-O1 -Wall -Walloc-size-larger-than=12345" } */
#define SIZE_MAX __SIZE_MAX__
#define MAXOBJSZ 12345
@@ -13,15 +13,40 @@ typedef __SIZE_TYPE__ size_t;
void sink (void*);
-static size_t maxobjsize (void)
+#pragma GCC push_options
+/* Verify that constant evaluation takes place even at -O0. */
+#pragma GCC optimize ("0")
+
+void test_cst (void *p)
{
- return MAXOBJSZ;
+ enum { max = MAXOBJSZ };
+
+ sink (__builtin_aligned_alloc (1, max));
+ sink (__builtin_aligned_alloc (1, max + 1)); /* { dg-warning "argument 2 value .12346\[lu\]*. exceeds maximum object size 12345" } */
+
+ sink (__builtin_alloca (max));
+ sink (__builtin_alloca (max + 2)); /* { dg-warning "argument 1 value .12347\[lu\]*. exceeds maximum object size 12345" } */
+
+ sink (__builtin_calloc (1, max));
+ sink (__builtin_calloc (max, 1));
+
+ sink (__builtin_calloc (max / 2, 3)); /* { dg-warning "product .6172\[lu\]* \\* 3\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */
+ sink (__builtin_calloc (4, max / 3)); /* { dg-warning "product .4\[lu\]* \\* 4115\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */
+
+ sink (__builtin_malloc (max));
+ sink (__builtin_malloc (max + 3)); /* { dg-warning "argument 1 value .12348\[lu\]*. exceeds maximum object size 12345" } */
+
+ sink (__builtin_realloc (p, max));
+ sink (__builtin_realloc (p, max + 4)); /* { dg-warning "argument 2 value .12349\[lu\]*. exceeds maximum object size 12345" } */
}
-void test_var (void *p)
+/* Variable evaluation needs -O1. */
+#pragma GCC pop_options
+
+__attribute__ ((noipa)) void test_var (void *p)
{
- size_t max = maxobjsize ();
+ size_t max = MAXOBJSZ;
sink (__builtin_aligned_alloc (1, max));
sink (__builtin_aligned_alloc (1, max + 1)); /* { dg-warning "argument 2 value .12346\[lu\]*. exceeds maximum object size 12345" } */
@@ -43,7 +68,15 @@ void test_var (void *p)
}
-void test_range (void *p, size_t range)
+/* Value range evaluation (apparently) needs -O2 here. */
+#pragma GCC optimize ("2")
+
+static size_t maxobjsize (void)
+{
+ return MAXOBJSZ;
+}
+
+__attribute__ ((noipa)) void test_range (void *p, size_t range)
{
/* Make sure the variable is at least as large as the maximum object
size but also make sure that it's guaranteed not to be too big to
diff --git a/gcc/testsuite/gcc.dg/attr-alloc_size-8.c b/gcc/testsuite/gcc.dg/attr-alloc_size-8.c
index 91d7eb5..7b47b04 100644
--- a/gcc/testsuite/gcc.dg/attr-alloc_size-8.c
+++ b/gcc/testsuite/gcc.dg/attr-alloc_size-8.c
@@ -4,7 +4,7 @@
two more specific options override the more general latter option. */
/* { dg-do compile } */
/* { dg-require-effective-target alloca } */
-/* { dg-options "-O2 -Walloc-size-larger-than=123 -Walloca-larger-than=234 -Wvla-larger-than=345" } */
+/* { dg-options "-O -Walloc-size-larger-than=123 -Walloca-larger-than=234 -Wvla-larger-than=345" } */
typedef __SIZE_TYPE__ size_t;
diff --git a/gcc/testsuite/gcc.dg/attr-nonstring-2.c b/gcc/testsuite/gcc.dg/attr-nonstring-2.c
index ba4757d..44a102c 100644
--- a/gcc/testsuite/gcc.dg/attr-nonstring-2.c
+++ b/gcc/testsuite/gcc.dg/attr-nonstring-2.c
@@ -26,8 +26,8 @@ void test_strnlen_array_cst (void)
T (strnlen (ns3, 1));
T (strnlen (ns3, 2));
T (strnlen (ns3, 3));
- T (strnlen (ns3, 4)); /* { dg-warning "specified bound 4 exceeds source size 3" } */
- T (strnlen (ns3, DIFF_MAX)); /* { dg-warning "specified bound \[0-9\]+ exceeds source size" } */
+ T (strnlen (ns3, 4)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound 4|specified bound 4 exceeds source size 3" } */
+ T (strnlen (ns3, DIFF_MAX)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound|specified bound \[0-9\]+ exceeds source size" } */
T (strnlen (ns3, SIZE_MAX)); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */
NONSTRING char ns5[5];
@@ -37,8 +37,8 @@ void test_strnlen_array_cst (void)
T (strnlen (ns5, 1));
T (strnlen (ns5, 2));
T (strnlen (ns5, 3));
- T (strnlen (ns5, 6)); /* { dg-warning "specified bound 6 exceeds source size 5" } */
- T (strnlen (ns5, DIFF_MAX)); /* { dg-warning "specified bound \[0-9\]+ exceeds source size 5" } */
+ T (strnlen (ns5, 6)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound 6|specified bound 6 exceeds source size 5" } */
+ T (strnlen (ns5, DIFF_MAX)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound|specified bound \[0-9\]+ exceeds source size 5" } */
T (strnlen (ns5, SIZE_MAX)); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */
}
@@ -52,8 +52,8 @@ void test_strnlen_array_range (void)
T (strnlen (ns3, UR (0, 9)));
T (strnlen (ns3, UR (3, 4)));
T (strnlen (ns3, UR (3, DIFF_MAX)));
- T (strnlen (ns3, UR (4, 5))); /* { dg-warning "specified bound \\\[4, 5] exceeds source size 3" } */
- T (strnlen (ns3, UR (DIFF_MAX, SIZE_MAX))); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds source size 3 " } */
+ T (strnlen (ns3, UR (4, 5))); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\\[4, 5]|specified bound \\\[4, 5] exceeds source size 3" } */
+ T (strnlen (ns3, UR (DIFF_MAX, SIZE_MAX))); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\\[\[0-9\]+, \[0-9\]+] |specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds source size 3 " } */
}
@@ -73,8 +73,8 @@ void test_strnlen_string_cst (void)
T (3, "12", 3, 1);
T (3, "12", 3, 9);
T (3, "123", 3, 1);
- T (3, "123", 3, 4); /* { dg-warning "specified bound 4 exceeds source size 3" } */
- T (3, "123", 3, 9); /* { dg-warning "specified bound 9 exceeds source size 3" } */
+ T (3, "123", 3, 4); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound 4|specified bound 4 exceeds source size 3" } */
+ T (3, "123", 3, 9); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound 9|specified bound 9 exceeds source size 3" } */
T (5, "1", 2, 1);
T (5, "1", 2, 2);
@@ -84,7 +84,7 @@ void test_strnlen_string_cst (void)
T (5, "12", 3, 9);
T (5, "123", 3, 1);
T (5, "123", 3, 5);
- T (5, "123", 3, 6); /* { dg-warning "specified bound 6 exceeds source size 5" } */
+ T (5, "123", 3, 6); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound 6|specified bound 6 exceeds source size 5" } */
/* Strnlen shouldn't trigger a warning for arrays of unknown size
(except for accesses to uninitialized elements when those are
@@ -110,6 +110,6 @@ void test_strnlen_string_range (void)
{
T (3, "1", 2, UR (0, 1));
T (3, "1", 2, UR (3, 9));
- T (3, "123", 3, UR (4, 5)); /* { dg-warning "specified bound \\\[4, 5] exceeds source size 3" } */
- T (3, "123", 3, UR (5, 9)); /* { dg-warning "specified bound \\\[5, 9] exceeds source size 3" } */
+ T (3, "123", 3, UR (4, 5)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\\[4, 5]|specified bound \\\[4, 5] exceeds source size 3" } */
+ T (3, "123", 3, UR (5, 9)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\\[5, 9]|specified bound \\\[5, 9] exceeds source size 3" } */
}
diff --git a/gcc/testsuite/gcc.dg/attr-nonstring-4.c b/gcc/testsuite/gcc.dg/attr-nonstring-4.c
index f2416c1..6f03a56 100644
--- a/gcc/testsuite/gcc.dg/attr-nonstring-4.c
+++ b/gcc/testsuite/gcc.dg/attr-nonstring-4.c
@@ -40,7 +40,7 @@ void strnlen_cst (void)
T (NS, /* [] */, n);
T (NS, /* [] */, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */
- T (NS, 9, n); /* { dg-warning "specified bound \[0-9\]+ exceeds source size 9" } */
+ T (NS, 9, n); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\d+|specified bound \\d+ exceeds source size 9" } */
T (NS, 10, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */
}
@@ -59,6 +59,6 @@ void strnlen_range (void)
T (NS, /* [] */, n);
T (NS, /* [] */, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */
- T (NS, 9, n); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds source size 9" } */
+ T (NS, 9, n); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\\[\\d+, \\d+]|specified bound \\\[\\d+, \\d+] exceeds source size 9" } */
T (NS, 10, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */
}
diff --git a/gcc/testsuite/gcc.dg/attr-noreturn.c b/gcc/testsuite/gcc.dg/attr-noreturn.c
new file mode 100644
index 0000000..8d58f6e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/attr-noreturn.c
@@ -0,0 +1,64 @@
+/* Verify that attribute noreturn on global and local function declarations
+ is merged.
+ { dg-do compile }
+ { dg-options "-Wall -fdump-tree-optimized" } */
+
+void foo (void);
+
+int fnr_local_local (void)
+{
+ __attribute__ ((noreturn)) void fnr1 (void);
+
+ fnr1 ();
+
+ foo ();
+}
+
+int gnr_local_local (void)
+{
+ void fnr1 (void);
+
+ fnr1 ();
+
+ foo ();
+}
+
+
+int fnr_local_global (void)
+{
+ __attribute__ ((noreturn)) void fnr2 (void);
+
+ fnr2 ();
+
+ foo ();
+}
+
+void fnr2 (void);
+
+int gnr_local_global (void)
+{
+ fnr2 ();
+
+ foo ();
+}
+
+
+__attribute__ ((noreturn)) void fnr3 (void);
+
+int fnr_global_local (void)
+{
+ fnr3 ();
+
+ foo ();
+}
+
+int gnr_global_local (void)
+{
+ void fnr3 (void);
+
+ fnr3 ();
+
+ foo ();
+}
+
+/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/attr-returns-nonnull.c b/gcc/testsuite/gcc.dg/attr-returns-nonnull.c
new file mode 100644
index 0000000..22ee30a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/attr-returns-nonnull.c
@@ -0,0 +1,58 @@
+/* Verify that attribute returns_nonnull on global and local function
+ declarations is merged.
+ { dg-do compile }
+ { dg-options "-Wall -fdump-tree-optimized" } */
+
+void foo (void);
+
+
+void frnn_local_local (void)
+{
+ __attribute__ ((returns_nonnull)) void* frnn1 (void);
+
+ if (!frnn1 ())
+ foo ();
+}
+
+void gnr_local_local (void)
+{
+ void* frnn1 (void);
+
+ if (!frnn1 ())
+ foo ();
+}
+
+void frnn_local_global (void)
+{
+ __attribute__ ((returns_nonnull)) void* frnn2 (void);
+
+ if (!frnn2 ())
+ foo ();
+}
+
+void* frnn2 (void);
+
+void gnr_local_global (void)
+{
+ if (!frnn2 ())
+ foo ();
+}
+
+__attribute__ ((returns_nonnull)) void* frnn3 (void);
+
+void frnn_global_local (void)
+{
+ if (!frnn3 ())
+ foo ();
+}
+
+void gnr_global_local (void)
+{
+ void* frnn3 (void);
+
+ if (!frnn3 ())
+ foo ();
+}
+
+
+/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/attr-unavailable-1.c b/gcc/testsuite/gcc.dg/attr-unavailable-1.c
new file mode 100644
index 0000000..768214f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/attr-unavailable-1.c
@@ -0,0 +1,88 @@
+/* Test __attribute__ ((unavailable)) */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+typedef int INT1 __attribute__((unavailable));
+typedef INT1 INT2 __attribute__ ((__unavailable__));
+
+typedef INT1 INT1a; /* { dg-error "'INT1' is unavailable" "" } */
+typedef INT1 INT1b __attribute__ ((unavailable));
+
+INT1 should_be_unavailable; /* { dg-error "'INT1' is unavailable" "" } */
+INT1a should_not_be_unavailable;
+
+INT1 f1(void) __attribute__ ((unavailable));
+INT1 f2(void) { return 0; } /* { dg-error "'INT1' is unavailable" "" } */
+
+INT2 f3(void) __attribute__ ((__unavailable__));
+INT2 f4(void) { return 0; } /* { dg-error "'INT2' is unavailable" "" } */
+int f5(INT2 x); /* { dg-error "'INT2' is unavailable" "" } */
+int f6(INT2 x) __attribute__ ((__unavailable__)); /* { dg-error "'INT2' is unavailable" "" } */
+
+typedef enum {red, green, blue} Color __attribute__((unavailable));
+
+int g1;
+int g2 __attribute__ ((unavailable));
+int g3 __attribute__ ((__unavailable__));
+Color k; /* { dg-error "'Color' is unavailable" "" } */
+
+typedef struct {
+ int field1;
+ int field2 __attribute__ ((unavailable));
+ int field3;
+ int field4 __attribute__ ((__unavailable__));
+ union {
+ int field5;
+ int field6 __attribute__ ((unavailable));
+ } u1;
+ int field7:1;
+ int field8:1 __attribute__ ((unavailable));
+ union {
+ int field9;
+ int field10;
+ } u2 __attribute__ ((unavailable));
+} S1;
+
+int func1()
+{
+ INT1 w; /* { dg-error "'INT1' is unavailable" "" } */
+ int x __attribute__ ((unavailable));
+ int y __attribute__ ((__unavailable__));
+ int z;
+ int (*pf)() = f1; /* { dg-error "'f1' is unavailable" "" } */
+
+ z = w + x + y + g1 + g2 + g3; /* { dg-error "'x' is unavailable" "" } */
+ /* { dg-error "'y' is unavailable" "y" { target *-*-* } .-1 } */
+ /* { dg-error "'g2' is unavailable" "g2" { target *-*-* } .-2 } */
+ /* { dg-error "'g3' is unavailable" "g3" { target *-*-* } .-3 } */
+ return f1(); /* { dg-error "'f1' is unavailable" "f1" } */
+}
+
+int func2(S1 *p)
+{
+ S1 lp;
+
+ if (p->field1)
+ return p->field2; /* { dg-error "'field2' is unavailable" "" } */
+ else if (lp.field4) /* { dg-error "'field4' is unavailable" "" } */
+ return p->field3;
+
+ p->u1.field5 = g1 + p->field7;
+ p->u2.field9; /* { dg-error "'u2' is unavailable" "" } */
+ return p->u1.field6 + p->field8; /* { dg-error "'field6' is unavailable" "" } */
+ /* { dg-error "'field8' is unavailable" "field8" { target *-*-* } .-1 } */
+}
+
+struct SS1 {
+ int x;
+ INT1 y; /* { dg-error "'INT1' is unavailable" "" } */
+} __attribute__ ((unavailable));
+
+struct SS1 *p1; /* { dg-error "'SS1' is unavailable" "" } */
+
+struct __attribute__ ((__unavailable__)) SS2 {
+ int x;
+ INT1 y; /* { dg-error "'INT1' is unavailable" "" } */
+};
+
+struct SS2 *p2; /* { dg-error "'SS2' is unavailable" "" } */
diff --git a/gcc/testsuite/gcc.dg/attr-unavailable-2.c b/gcc/testsuite/gcc.dg/attr-unavailable-2.c
new file mode 100644
index 0000000..303f973
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/attr-unavailable-2.c
@@ -0,0 +1,6 @@
+/* Test __attribute__((unavailable)). Test types without names. */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+struct { int a; } __attribute__((unavailable)) x; /* { dg-error "type is unavailable" } */
+typeof(x) y; /* { dg-error "type is unavailable" } */
diff --git a/gcc/testsuite/gcc.dg/attr-unavailable-3.c b/gcc/testsuite/gcc.dg/attr-unavailable-3.c
new file mode 100644
index 0000000..7274c19
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/attr-unavailable-3.c
@@ -0,0 +1,10 @@
+/* Test __attribute__((unavailable)). */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void func(void);
+void func(void) __attribute__((unavailable));
+
+void f(void) {
+ func(); /* { dg-error "'func' is unavailable" } */
+}
diff --git a/gcc/testsuite/gcc.dg/attr-unavailable-4.c b/gcc/testsuite/gcc.dg/attr-unavailable-4.c
new file mode 100644
index 0000000..9e39c50
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/attr-unavailable-4.c
@@ -0,0 +1,88 @@
+/* Test __attribute__ ((unavailable("message"))) */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+typedef int INT1 __attribute__((unavailable("You can't use INT1")));
+typedef INT1 INT2 __attribute__ ((__unavailable__("You can't use INT2")));
+
+typedef INT1 INT1a; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
+typedef INT1 INT1b __attribute__ ((unavailable("You can't use INT1b")));
+
+INT1 should_be_unavailable; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
+INT1a should_not_be_unavailable;
+
+INT1 f1(void) __attribute__ ((unavailable("You can't use f1")));
+INT1 f2(void) { return 0; } /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
+
+INT2 f3(void) __attribute__ ((__unavailable__("You can't use f3")));
+INT2 f4(void) { return 0; } /* { dg-error "'INT2' is unavailable: You can't use INT2" "" } */
+int f5(INT2 x); /* { dg-error "'INT2' is unavailable: You can't use INT2" "" } */
+int f6(INT2 x) __attribute__ ((__unavailable__("You can't use f6"))); /* { dg-error "'INT2' is unavailable: You can't use INT2" "" } */
+
+typedef enum {red, green, blue} Color __attribute__((unavailable("You can't use Color")));
+
+int g1;
+int g2 __attribute__ ((unavailable("You can't use g2")));
+int g3 __attribute__ ((__unavailable__("You can't use g3")));
+Color k; /* { dg-error "'Color' is unavailable: You can't use Color" "" } */
+
+typedef struct {
+ int field1;
+ int field2 __attribute__ ((unavailable("You can't use field2")));
+ int field3;
+ int field4 __attribute__ ((__unavailable__("You can't use field4")));
+ union {
+ int field5;
+ int field6 __attribute__ ((unavailable("You can't use field6")));
+ } u1;
+ int field7:1;
+ int field8:1 __attribute__ ((unavailable("You can't use field8")));
+ union {
+ int field9;
+ int field10;
+ } u2 __attribute__ ((unavailable("You can't use u2")));
+} S1;
+
+int func1()
+{
+ INT1 w; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
+ int x __attribute__ ((unavailable("Avoid x")));
+ int y __attribute__ ((__unavailable__("Bad y")));
+ int z;
+ int (*pf)() = f1; /* { dg-error "'f1' is unavailable: You can't use f1" "" } */
+
+ z = w + x + y + g1 + g2 + g3; /* { dg-error "'x' is unavailable: Avoid x" "" } */
+ /* { dg-error "'y' is unavailable: Bad y" "y" { target *-*-* } .-1 } */
+ /* { dg-error "'g2' is unavailable: You can't use g2" "g2" { target *-*-* } .-2 } */
+ /* { dg-error "'g3' is unavailable: You can't use g3" "g3" { target *-*-* } .-3 } */
+ return f1(); /* { dg-error "'f1' is unavailable: You can't use f1" "" } */
+}
+
+int func2(S1 *p)
+{
+ S1 lp;
+
+ if (p->field1)
+ return p->field2; /* { dg-error "'field2' is unavailable: You can't use field2" "" } */
+ else if (lp.field4) /* { dg-error "'field4' is unavailable: You can't use field4" "" } */
+ return p->field3;
+
+ p->u1.field5 = g1 + p->field7;
+ p->u2.field9; /* { dg-error "'u2' is unavailable: You can't use u2" "" } */
+ return p->u1.field6 + p->field8; /* { dg-error "'field6' is unavailable: You can't use field6" "" } */
+ /* { dg-error "'field8' is unavailable: You can't use field8" "field8" { target *-*-* } .-1 } */
+}
+
+struct SS1 {
+ int x;
+ INT1 y; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
+} __attribute__ ((unavailable("You can't use SS1")));
+
+struct SS1 *p1; /* { dg-error "'SS1' is unavailable: You can't use SS1" "" } */
+
+struct __attribute__ ((__unavailable__("You can't use SS2"))) SS2 {
+ int x;
+ INT1 y; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
+};
+
+struct SS2 *p2; /* { dg-error "'SS2' is unavailable: You can't use SS2" "" } */
diff --git a/gcc/testsuite/gcc.dg/attr-unavailable-5.c b/gcc/testsuite/gcc.dg/attr-unavailable-5.c
new file mode 100644
index 0000000..051f960
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/attr-unavailable-5.c
@@ -0,0 +1,6 @@
+/* Test __attribute__((unavailable)). Test types without names. */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+struct { int a; } __attribute__((unavailable ("Do not use"))) x; /* { dg-error "type is unavailable" } */
+typeof(x) y; /* { dg-error "type is unavailable: Do not use" } */
diff --git a/gcc/testsuite/gcc.dg/attr-unavailable-6.c b/gcc/testsuite/gcc.dg/attr-unavailable-6.c
new file mode 100644
index 0000000..f5f4560
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/attr-unavailable-6.c
@@ -0,0 +1,11 @@
+/* Test __attribute__((unavailable)). Test merging with multiple
+ declarations. */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void func(void);
+void func(void) __attribute__((unavailable ("Do not use")));
+
+void f(void) {
+ func(); /* { dg-error "'func' is unavailable: Do not use" } */
+}
diff --git a/gcc/testsuite/gcc.dg/attr-vector_size.c b/gcc/testsuite/gcc.dg/attr-vector_size.c
index 00be26a..3f2ce88 100644
--- a/gcc/testsuite/gcc.dg/attr-vector_size.c
+++ b/gcc/testsuite/gcc.dg/attr-vector_size.c
@@ -22,14 +22,6 @@ DEFVEC (extern, 30);
#if __SIZEOF_SIZE_T__ > 4
-DEFVEC (extern, 31);
-DEFVEC (extern, 32);
-DEFVEC (extern, 33);
-DEFVEC (extern, 34);
-DEFVEC (extern, 60);
-DEFVEC (extern, 61);
-DEFVEC (extern, 62);
-
VEC (POW2 (63)) char v63; /* { dg-error "'vector_size' attribute argument value '9223372036854775808' exceeds 9223372036854775807" "LP64" { target lp64 } } */
#else
@@ -49,14 +41,6 @@ void test_local_scope (void)
#if __SIZEOF_SIZE_T__ > 4
- DEFVEC (auto, 31);
- DEFVEC (auto, 32);
- DEFVEC (auto, 33);
- DEFVEC (auto, 34);
- DEFVEC (auto, 60);
- DEFVEC (auto, 61);
- DEFVEC (auto, 62);
-
VEC (POW2 (63)) char v63; /* { dg-error "'vector_size' attribute argument value '9223372036854775808' exceeds 9223372036854775807" "LP64" { target lp64 } } */
#else
diff --git a/gcc/testsuite/gcc.dg/auto-init-sra-1.c b/gcc/testsuite/gcc.dg/auto-init-sra-1.c
new file mode 100644
index 0000000..88fd666
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-sra-1.c
@@ -0,0 +1,24 @@
+/* Verify that SRA total scalarization will not be confused by padding
+ and also not confused by auto initialization. */
+/* { dg-do compile } */
+/* { dg-options "-O1 --param sra-max-scalarization-size-Ospeed=16 -fdump-tree-release_ssa -ftrivial-auto-var-init=zero" } */
+
+struct S
+{
+ int i;
+ unsigned short f1;
+ char f2;
+ unsigned short f3, f4;
+};
+
+
+int foo (struct S *p)
+{
+ struct S l;
+
+ l = *p;
+ l.i++;
+ *p = l;
+}
+
+/* { dg-final { scan-tree-dump-times "l;" 0 "release_ssa" } } */
diff --git a/gcc/testsuite/gcc.dg/auto-init-sra-2.c b/gcc/testsuite/gcc.dg/auto-init-sra-2.c
new file mode 100644
index 0000000..d260f5a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-sra-2.c
@@ -0,0 +1,24 @@
+/* Verify that SRA total scalarization will not be confused by padding
+ and also not confused by auto initialization. */
+/* { dg-do compile } */
+/* { dg-options "-O1 --param sra-max-scalarization-size-Ospeed=16 -fdump-tree-release_ssa -ftrivial-auto-var-init=pattern" } */
+
+struct S
+{
+ int i;
+ unsigned short f1;
+ char f2;
+ unsigned short f3, f4;
+};
+
+
+int foo (struct S *p)
+{
+ struct S l;
+
+ l = *p;
+ l.i++;
+ *p = l;
+}
+
+/* { dg-final { scan-tree-dump-times "l;" 0 "release_ssa" } } */
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-1.c b/gcc/testsuite/gcc.dg/auto-init-uninit-1.c
new file mode 100644
index 0000000..502db59
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-1.c
@@ -0,0 +1,5 @@
+/* Spurious uninitialized variable warnings, case 1.
+ Taken from cppfiles.c (merge_include_chains) */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+#include "uninit-1.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-12.c b/gcc/testsuite/gcc.dg/auto-init-uninit-12.c
new file mode 100644
index 0000000..65da110
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-12.c
@@ -0,0 +1,4 @@
+/* PR 23497 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+#include "uninit-12.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-13.c b/gcc/testsuite/gcc.dg/auto-init-uninit-13.c
new file mode 100644
index 0000000..87dd8b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-13.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+
+typedef _Complex float C;
+C foo()
+{
+ C f;
+ __imag__ f = 0;
+ return f; /* { dg-warning "is used" "unconditional" } */
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-14.c b/gcc/testsuite/gcc.dg/auto-init-uninit-14.c
new file mode 100644
index 0000000..9ffe00a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-14.c
@@ -0,0 +1,4 @@
+/* PR 24931 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+#include "uninit-14.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-15.c b/gcc/testsuite/gcc.dg/auto-init-uninit-15.c
new file mode 100644
index 0000000..121f0cf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-15.c
@@ -0,0 +1,26 @@
+/* PR tree-optimization/17506
+ We issue an uninitialized variable warning at a wrong location at
+ line 11, which is very confusing. Make sure we print out a note to
+ make it less confusing. (not xfailed alternative)
+ But it is of course ok if we warn in bar about uninitialized use
+ of j. (not xfailed alternative) */
+/* { dg-do compile } */
+/* { dg-options "-O1 -Wuninitialized -ftrivial-auto-var-init=zero" } */
+
+inline int
+foo (int i)
+{
+ if (i) /* { dg-warning "used uninitialized" } */
+ return 1;
+ return 0;
+}
+
+void baz (void);
+
+void
+bar (void)
+{
+ int j; /* { dg-message "note: 'j' was declared here" "" } */
+ for (; foo (j); ++j) /* { dg-warning "'j' is used uninitialized" "" { xfail *-*-* } } */
+ baz ();
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-16.c b/gcc/testsuite/gcc.dg/auto-init-uninit-16.c
new file mode 100644
index 0000000..38e1950
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-16.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */
+/* -ftrivial-auto-var-init will make the uninitialized warning for address
+ taken auto var going away, FIXME later. */
+
+int foo, bar;
+
+static
+void decode_reloc(int reloc, int *is_alt)
+{
+ if (reloc >= 20)
+ *is_alt = 1;
+ else if (reloc >= 10)
+ *is_alt = 0;
+}
+
+void testfunc()
+{
+ int alt_reloc;
+
+ decode_reloc(foo, &alt_reloc);
+
+ if (alt_reloc) /* { dg-warning "may be used uninitialized" "" { xfail *-*-* } } */
+ bar = 42;
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-17.c b/gcc/testsuite/gcc.dg/auto-init-uninit-17.c
new file mode 100644
index 0000000..9eec944
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-17.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+
+typedef _Complex float C;
+C foo(int cond)
+{
+ C f;
+ __imag__ f = 0;
+ if (cond)
+ {
+ __real__ f = 1;
+ return f;
+ }
+ return f; /* { dg-warning "may be used" "unconditional" } */
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-18.c b/gcc/testsuite/gcc.dg/auto-init-uninit-18.c
new file mode 100644
index 0000000..1c9afa9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-18.c
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+#include "uninit-18.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-19.c b/gcc/testsuite/gcc.dg/auto-init-uninit-19.c
new file mode 100644
index 0000000..38d27e4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-19.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+/* { dg-additional-options "-finline-small-functions" { target avr-*-* } } */
+
+int a, l, m;
+float *b;
+float c, d, e, g, h;
+unsigned char i, k;
+void
+fn1 (int p1, float *f1, float *f2, float *f3, unsigned char *c1, float *f4,
+ unsigned char *c2, float *p10)
+{
+ if (p1 & 8)
+ b[3] = p10[a];
+ /* { dg-warning "may be used uninitialized" "" { target { { nonpic || pie_enabled } || { hppa*64*-*-* *-*-darwin* } } } .-1 } */
+}
+
+void
+fn2 ()
+{
+ float *n;
+ if (l & 6)
+ n = &c + m;
+ fn1 (l, &d, &e, &g, &i, &h, &k, n);
+ /* { dg-warning "may be used uninitialized" "" { target { ! { { nonpic || pie_enabled } || { hppa*64*-*-* *-*-darwin* } } } } .-1 } */
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-2.c b/gcc/testsuite/gcc.dg/auto-init-uninit-2.c
new file mode 100644
index 0000000..4c32dc8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-2.c
@@ -0,0 +1,5 @@
+/* Spurious uninitialized variable warnings, case 2.
+ Taken from cpphash.c (macroexpand) */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+#include "uninit-2.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-20.c b/gcc/testsuite/gcc.dg/auto-init-uninit-20.c
new file mode 100644
index 0000000..d81957e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-20.c
@@ -0,0 +1,4 @@
+/* Spurious uninitialized variable warnings, from gdb */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */
+#include "uninit-20.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-21.c b/gcc/testsuite/gcc.dg/auto-init-uninit-21.c
new file mode 100644
index 0000000..cc61746
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-21.c
@@ -0,0 +1,4 @@
+/* PR69537, spurious warning because of a missed optimization. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-short-enums -Wuninitialized -ftrivial-auto-var-init=zero" } */
+#include "uninit-21.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-22.c b/gcc/testsuite/gcc.dg/auto-init-uninit-22.c
new file mode 100644
index 0000000..1e522ce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-22.c
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -Wuninitialized --param vect-max-version-for-alias-checks=20 -ftrivial-auto-var-init=zero" } */
+#include "uninit-22.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-23.c b/gcc/testsuite/gcc.dg/auto-init-uninit-23.c
new file mode 100644
index 0000000..f1f7839
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-23.c
@@ -0,0 +1,27 @@
+/* PR tree-optimization/78455 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */
+
+int ij;
+
+void
+ql (void)
+{
+ int m5 = 0;
+
+ for (;;)
+ {
+ if (0)
+ for (;;)
+ {
+ int *go;
+ int *t4 = go; /* { dg-warning "is used uninitialized" } */
+
+ l1:
+ *t4 = (*t4 != 0) ? 0 : 2; /* { dg-warning "is used uninitialized" } */
+ }
+
+ if (ij != 0)
+ goto l1;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-24.c b/gcc/testsuite/gcc.dg/auto-init-uninit-24.c
new file mode 100644
index 0000000..0f839ba
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-24.c
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wmaybe-uninitialized -ftrivial-auto-var-init=zero" } */
+#include "uninit-24.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-25.c b/gcc/testsuite/gcc.dg/auto-init-uninit-25.c
new file mode 100644
index 0000000..f36d95f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-25.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wmaybe-uninitialized -ftrivial-auto-var-init=zero" } */
+
+extern unsigned bar (void);
+extern void quux (void);
+
+unsigned foo (unsigned v)
+{
+ unsigned u;
+ if (v != 1)
+ u = bar ();
+
+ // Prevent the "dom" pass from changing the CFG layout based on the inference
+ // 'if (v != 1) is false then (v != 2) is true'. (Now it would have to
+ // duplicate the loop in order to do so, which is deemed expensive.)
+ for (int i = 0; i < 10; i++)
+ quux ();
+
+ if (v != 2)
+ return u; /* { dg-warning "may be used uninitialized" } */
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-26.c b/gcc/testsuite/gcc.dg/auto-init-uninit-26.c
new file mode 100644
index 0000000..ae97ecf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-26.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wmaybe-uninitialized -ftrivial-auto-var-init=zero" } */
+
+extern unsigned bar (void);
+extern void quux (void);
+
+unsigned foo (unsigned v)
+{
+ unsigned u;
+ if (v != 100)
+ u = bar ();
+
+ // Prevent the "dom" pass from changing the CFG layout based on the inference
+ // 'if (v != 100) is false then (v < 105) is true'. (Now it would have to
+ // duplicate the loop in order to do so, which is deemed expensive.)
+ for (int i = 0; i < 10; i++)
+ quux ();
+
+ if (v < 105) /* v == 100 falls into this range. */
+ return u; /* { dg-warning "may be used uninitialized" } */
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-3.c b/gcc/testsuite/gcc.dg/auto-init-uninit-3.c
new file mode 100644
index 0000000..5c10920
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-3.c
@@ -0,0 +1,5 @@
+/* Spurious uninit variable warnings, case 3.
+ Inspired by cppexp.c (parse_charconst) */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+#include "uninit-3.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-34.c b/gcc/testsuite/gcc.dg/auto-init-uninit-34.c
new file mode 100644
index 0000000..1a68765
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-34.c
@@ -0,0 +1,60 @@
+/* PR middle-end/10138 - warn for uninitialized arrays passed as const*
+ arguments
+ Verify that passing pointers to uninitialized objects to arguments
+ to functions declared with attribute access is diagnosed where expected.
+ { dg-do compile }
+ { dg-options "-O -Wall -ftrivial-auto-var-init=zero" } */
+/* -ftrivial-auto-var-init will make the uninitialized warning for address
+ taken auto var going away, FIXME later. */
+
+#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__)))
+
+RW (1) RW (3) void
+f4pi (int*, int*, int*, int*); // { dg-message "in a call to 'f4pi' declared with attribute 'access \\\(read_write, \[13\]\\\)'" }
+
+
+void nowarn_scalar (void)
+{
+ int i1 = 0, i2, i3 = 1, i4;
+ f4pi (&i1, &i2, &i3, &i4);
+}
+
+void warn_scalar_1 (void)
+{
+ int i1; // { dg-message "declared here" "" { xfail *-*-* } }
+ int i2, i3 = 1, i4;
+
+ f4pi (&i1, &i2, &i3, &i4); // { dg-warning "'i1' may be used uninitialized" "" { xfail *-*-* } }
+}
+
+void warn_scalar_2 (void)
+{
+ int j1 = 0, j2, j4;
+ int j3;
+
+ f4pi (&j1, &j2, &j3, &j4); // { dg-warning "'j3' may be used uninitialized" "" { xfail *-*-* } }
+}
+
+
+void nowarn_array_init (void)
+{
+ int a1[4] = { 0 }, a2[5], a3[6] = { 0 }, a4[7];
+
+ f4pi (a1, a2, a3, a4);
+}
+
+void warn_array_1 (void)
+{
+ int a1[4]; // { dg-message "'a1' declared here" }
+ int a2[5], a3[6] = { 0 }, a4[7];
+
+ f4pi (a1, a2, a3, a4); // { dg-warning "'a1' may be used uninitialized" }
+}
+
+void warn_array_2 (void)
+{
+ int a1[4] = { 0 }, a2[5], a4[7];
+ int a3[6]; // { dg-message "'a3' declared here" }
+
+ f4pi (a1, a2, a3, a4); // { dg-warning "'a3' may be used uninitialized" }
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-36.c b/gcc/testsuite/gcc.dg/auto-init-uninit-36.c
new file mode 100644
index 0000000..64377d3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-36.c
@@ -0,0 +1,238 @@
+/* PR middle-end/10138 - warn for uninitialized arrays passed as const*
+ arguments
+ Verify that passing pointers to uninitialized objects to const
+ arguments to built-ins is diagnosed where expected.
+ { dg-do compile }
+ { dg-options "-O -Wall -ftrivial-auto-var-init=zero" }
+ { dg-require-effective-target alloca } */
+
+typedef __SIZE_TYPE__ size_t;
+
+void* alloca (size_t);
+void* malloc (size_t);
+void* realloc (void*, size_t);
+
+void* memcpy (void*, const void*, size_t);
+char* strcpy (char*, const char*);
+size_t strlen (const char*);
+
+void sink (void*);
+
+void nowarn_array_memcpy (void *d, unsigned n)
+{
+ int a[2];
+ /* Diagnose this? */
+ memcpy (d, a, n /* Non-constant to avoid folding into MEM_REF. */);
+}
+
+void nowarn_array_plus_cst_memcpy (void *d, unsigned n)
+{
+ int a[3];
+ /* Diagnose this? */
+ memcpy (d, a + 1, n);
+}
+
+void nowarn_array_plus_var_memcpy (void *d, unsigned n, int i)
+{
+ int a[4];
+ /* Diagnose this? */
+ memcpy (d, a + i, n);
+}
+
+void nowarn_array_assign_memcpy (char *d, unsigned n)
+{
+ int a[3];
+ a[1] = 3;
+ memcpy (d, a, n);
+}
+
+void nowarn_array_init_memcpy (char *d, unsigned n)
+{
+ int a[4] = { 0 };
+ memcpy (d, a, n);
+}
+
+void nowarn_array_compound_memcpy (void *d, unsigned n)
+{
+ memcpy (d, (int[2]){ 0 }, n);
+}
+
+void nowarn_struct_assign_memcpy (void *d, unsigned n)
+{
+ struct S { int a, b, c, d; } s;
+ s.b = 1;
+ s.d = 2;
+ memcpy (d, &s, n);
+}
+
+
+void nowarn_array_init_strcpy (char *d[], unsigned n)
+{
+ char a[8] = "012";
+
+ strcpy (d[0], a);
+ strcpy (d[1], a + 1);
+ strcpy (d[1], a + 2);
+ strcpy (d[1], a + 3);
+ strcpy (d[1], a + 4);
+ strcpy (d[1], a + 5);
+ strcpy (d[1], a + 6);
+ strcpy (d[1], a + 7);
+}
+
+
+void nowarn_array_assign_strcpy (char *d[], unsigned n)
+{
+ char a[8];
+ a[0] = '0';
+ a[1] = '1';
+ a[2] = '2';
+ a[3] = '\0';
+
+ strcpy (d[0], a);
+ strcpy (d[1], a + 1);
+ strcpy (d[1], a + 2);
+ strcpy (d[1], a + 3);
+}
+
+void warn_array_plus_cst_strcpy (char *d, unsigned n)
+{
+ char a[8];
+ a[0] = '1';
+ a[1] = '2';
+ a[2] = '3';
+ a[3] = '\0';
+
+ strcpy (d, a + 4); // { dg-warning "\\\[-Wuninitialized" }
+ strcpy (d, a + 5); // { dg-warning "\\\[-Wuninitialized" }
+ strcpy (d, a + 6); // { dg-warning "\\\[-Wuninitialized" }
+ strcpy (d, a + 7); // { dg-warning "\\\[-Wuninitialized" }
+}
+
+void nowarn_array_plus_var_strcpy (char *d, int i)
+{
+ char a[8];
+ a[0] = '1';
+ a[1] = '2';
+ a[2] = '3';
+ a[3] = '\0';
+
+ strcpy (d, a + i);
+}
+
+
+size_t nowarn_array_assign_strlen (const char *s)
+{
+ char a[8];
+ a[0] = s[0];
+ a[1] = s[1];
+ a[2] = s[2];
+ a[3] = s[3];
+
+ size_t n = 0;
+
+ n += strlen (a);
+ n += strlen (a + 1);
+ n += strlen (a + 2);
+ n += strlen (a + 3);
+ return n;
+}
+
+size_t warn_array_plus_cst_strlen (const char *s)
+{
+ char a[8];
+ a[0] = s[0];
+ a[1] = s[1];
+ a[2] = s[2];
+ a[3] = s[3];
+
+ return strlen (a + 4); // { dg-warning "\\\[-Wuninitialized" }
+}
+
+size_t nowarn_array_plus_var_strlen (const char *s, int i)
+{
+ char a[8];
+ a[0] = s[0];
+ a[1] = s[1];
+ a[2] = s[2];
+ a[3] = s[3];
+
+ return strlen (a + i);
+}
+
+
+size_t nowarn_alloca_assign_strlen (int i)
+{
+ char *p = (char*)alloca (8);
+ p[i] = '\0';
+ return strlen (p);
+}
+
+size_t nowarn_alloca_escape_strlen (int i)
+{
+ char *p = (char*)alloca (8);
+ sink (p);
+ return strlen (p);
+}
+
+size_t warn_alloca_strlen (void)
+{
+ char *p = (char*)alloca (8);
+ return strlen (p); // { dg-warning "\\\[-Wuninitialized" }
+}
+
+
+size_t nowarn_malloc_assign_strlen (int i)
+{
+ char *p = (char*)malloc (8);
+ p[i] = '\0';
+ return strlen (p);
+}
+
+size_t nowarn_malloc_escape_strlen (int i)
+{
+ char *p = (char*)malloc (8);
+ sink (p);
+ return strlen (p);
+}
+
+size_t warn_malloc_strlen (void)
+{
+ char *p = (char*)malloc (8);
+ return strlen (p); // { dg-warning "\\\[-Wuninitialized" }
+}
+
+
+size_t nowarn_realloc_strlen (void *p)
+{
+ char *q = (char*)realloc (p, 8);
+ return strlen (q);
+}
+
+
+size_t nowarn_vla_assign_strlen (int n, int i)
+{
+ char vla[n];
+ vla[i] = '\0';
+ return strlen (vla);
+}
+
+size_t nowarn_vla_strcpy_strlen (int n, const char *s, int i)
+{
+ char vla[n];
+ strcpy (vla, s);
+ return strlen (vla + i);
+}
+
+size_t nowarn_vla_escape_strlen (int n, int i)
+{
+ char vla[n];
+ sink (vla);
+ return strlen (vla);
+}
+
+size_t warn_vla_strlen (unsigned n)
+{
+ char vla[n];
+ return strlen (vla); // { dg-warning "\\\[-Wuninitialized" }
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-37.c b/gcc/testsuite/gcc.dg/auto-init-uninit-37.c
new file mode 100644
index 0000000..2791b37
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-37.c
@@ -0,0 +1,156 @@
+/* PR middle-end/10138 - warn for uninitialized arrays passed as const arguments
+ Verify that -Wuninitialized and -Wmaybe-uninitialized trigger (or don't)
+ when passing uninitialized variables by reference to functions declared
+ with or without attribute access and with (or without) const qualified
+ arguments of array, VLA, or pointer types.
+ { dg-do compile }
+ { dg-options "-O2 -Wall -ftrack-macro-expansion=0 -ftrivial-auto-var-init=zero" } */
+/* -ftrivial-auto-var-init will make the uninitialized warning for address
+ taken auto var going away, FIXME later. */
+
+#define NONE /* none */
+#define RO(...) __attribute__ ((access (read_only, __VA_ARGS__)))
+#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__)))
+#define WO(...) __attribute__ ((access (write_only, __VA_ARGS__)))
+#define X(...) __attribute__ ((access (none, __VA_ARGS__)))
+
+#define CONCAT(x, y) x ## y
+#define CAT(x, y) CONCAT (x, y)
+#define UNIQ(pfx) CAT (pfx, __LINE__)
+
+extern void sink (void*);
+
+
+#define T1(attr, name, type) \
+ void UNIQ (CAT (test_, name))(void) { \
+ extern attr void UNIQ (name)(type); \
+ int x; \
+ UNIQ (name)(&x); \
+ sink (&x); \
+ }
+
+#define T2(attr, name, types) \
+ void UNIQ (CAT (test_, name))(void) { \
+ extern attr void UNIQ (name)(types); \
+ int x; \
+ UNIQ (name)(1, &x); \
+ sink (&x); \
+ }
+
+
+typedef int IA_[];
+typedef const int CIA_[];
+
+T1 (NONE, fia_, IA_);
+T1 (NONE, fcia_, CIA_); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (RO (1), froia_, IA_); // { dg-warning "\\\[-Wuninitialized" "" { xfail *-*-* } }
+T1 (RW (1), frwia_, IA_); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (WO (1), fwoia_, IA_);
+T1 (X (1), fxia_, IA_);
+
+
+typedef int IA1[1];
+typedef const int CIA1[1];
+
+T1 (NONE, fia1, IA1);
+T1 (NONE, fcia1, CIA1); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (RO (1), froia1, IA1); // { dg-warning "\\\[-Wuninitialized" "" { xfail *-*-* } }
+T1 (RW (1), frwia1, IA1); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (WO (1), fwoia1, IA1);
+T1 (X (1), fxia1, IA1);
+
+
+#define IARS1 int[restrict static 1]
+#define CIARS1 const int[restrict static 1]
+
+T1 (NONE, fiars1, IARS1);
+T1 (NONE, fciars1, CIARS1);// { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (RO (1), froiars1, IARS1); // { dg-warning "\\\[-Wuninitialized" "" { xfail *-*-* } }
+T1 (RW (1), frwiars1, IARS1); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (WO (1), fwoiars1, IARS1);
+T1 (X (1), fxiars1, IARS1);
+
+
+#define IAS1 int[static 1]
+#define CIAS1 const int[static 1]
+
+T1 (NONE, fias1, IAS1);
+T1 (NONE, fcias1, CIAS1); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (RO (1), froias1, IAS1); // { dg-warning "\\\[-Wuninitialized" "" { xfail *-*-* } }
+T1 (RW (1), frwias1, IAS1); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (WO (1), fwoias1, IAS1);
+T1 (X (1), fxias1, IAS1);
+
+
+#define IAX int[*]
+#define CIAX const int[*]
+
+T1 (NONE, fiax, IAX);
+T1 (NONE, fciax, CIAX); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (RO (1), froiax, IAX); // { dg-warning "\\\[-Wuninitialized" "" { xfail *-*-* } }
+T1 (RW (1), frwiax, IAX); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (WO (1), fwoiax, IAX);
+T1 (X (1), fxiax, IAX);
+
+
+#define IAN int n, int[n]
+#define CIAN int n, const int[n]
+
+T2 (NONE, fian, IAN);
+T2 (NONE, fcian, CIAN); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T2 (RO (2, 1), froian, IAN); // { dg-warning "\\\[-Wuninitialized" "" { xfail *-*-* } }
+T2 (RW (2, 1), frwian, IAN); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T2 (WO (2, 1), fwoian, IAN);
+T2 (X (2, 1), fxian, IAN);
+
+
+typedef int* IP;
+typedef const int* CIP;
+
+T1 (NONE, fip, IP);
+T1 (NONE, fcip, CIP); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (RO (1), froip, IP); // { dg-warning "\\\[-Wuninitialized" "" { xfail *-*-* } }
+T1 (RW (1), frwip, IP); // { dg-warning "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } }
+T1 (WO (1), fwoip, IP);
+T1 (X (1), fxip, IP);
+
+
+/* Verify that the notes printed after the warning mention attribute
+ access only when the attribute is explicitly used in the declaration
+ and not otherwise. */
+
+void test_note_cst_restrict (void)
+{
+ extern void
+ fccar (const char[restrict]); // { dg-message "by argument 1 of type 'const char\\\[restrict]' to 'fccar'" "note" }
+
+ char a[1]; // { dg-message "'a' declared here" "note" }
+ fccar (a); // { dg-warning "'a' may be used uninitialized" }
+}
+
+void test_note_vla (int n)
+{
+ extern void
+ fccvla (const char[n]); // { dg-message "by argument 1 of type 'const char\\\[n]' to 'fccvla'" "note" }
+
+ char a[2]; // { dg-message "'a' declared here" "note" }
+ fccvla (a); // { dg-warning "'a' may be used uninitialized" }
+}
+
+void test_note_ro (void)
+{
+ extern RO (1) void
+ frocar (char[restrict]); // { dg-message "in a call to 'frocar' declared with attribute 'access \\\(read_only, 1\\\)'" "note" }
+
+ char a[3]; // { dg-message "'a' declared here" "note" }
+ frocar (a); // { dg-warning "'a' is used uninitialized" }
+}
+
+void test_note_rw (void)
+{
+ extern RW (1) void
+ frwcar (char[restrict]); // { dg-message "in a call to 'frwcar' declared with attribute 'access \\\(read_write, 1\\\)'" "note" }
+
+ char a[4]; // { dg-message "'a' declared here" "note" }
+ frwcar (a); // { dg-warning "'a' may be used uninitialized" }
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-4.c b/gcc/testsuite/gcc.dg/auto-init-uninit-4.c
new file mode 100644
index 0000000..29ec860
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-4.c
@@ -0,0 +1,10 @@
+/* Spurious uninit variable warnings, case 4.
+ Simplified version of cppexp.c (cpp_parse_expr).
+
+ This one is really fragile, it gets it right if you take out case
+ 1, or if the structure is replaced by an int, or if the structure
+ has fewer members (!) */
+
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+#include "uninit-4.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-5.c b/gcc/testsuite/gcc.dg/auto-init-uninit-5.c
new file mode 100644
index 0000000..65b251a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-5.c
@@ -0,0 +1,6 @@
+/* Spurious uninitialized-variable warnings. */
+/* Disable jump threading, etc to test compiler analysis. */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -fno-tree-dce -fno-tree-vrp -fno-tree-dominator-opts -ftrivial-auto-var-init=zero" } */
+
+#include "uninit-5.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-6.c b/gcc/testsuite/gcc.dg/auto-init-uninit-6.c
new file mode 100644
index 0000000..7c10dfc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-6.c
@@ -0,0 +1,7 @@
+/* Spurious uninitialized variable warnings.
+ This one inspired by java/class.c:build_utf8_ref. */
+
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+
+#include "uninit-6.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-8.c b/gcc/testsuite/gcc.dg/auto-init-uninit-8.c
new file mode 100644
index 0000000..eaa9c0c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-8.c
@@ -0,0 +1,8 @@
+/* Uninitialized variable warning tests...
+ Inspired by part of optabs.c:expand_binop.
+ May be the same as uninit-1.c. */
+
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+
+#include "uninit-8.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-9.c b/gcc/testsuite/gcc.dg/auto-init-uninit-9.c
new file mode 100644
index 0000000..6dccf01
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-9.c
@@ -0,0 +1,8 @@
+/* Spurious uninitialized variable warnings. Slight variant on the
+ documented case, inspired by reg-stack.c:record_asm_reg_life. */
+
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+/* { dg-require-effective-target alloca } */
+
+#include "uninit-9.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-A.c b/gcc/testsuite/gcc.dg/auto-init-uninit-A.c
new file mode 100644
index 0000000..0ef1d92
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-A.c
@@ -0,0 +1,7 @@
+/* Inspired by part of java/parse.y.
+ May be a real bug in CSE. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall -ftrivial-auto-var-init=zero" } */
+
+#include "uninit-A.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-B.c b/gcc/testsuite/gcc.dg/auto-init-uninit-B.c
new file mode 100644
index 0000000..b6d3efd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-B.c
@@ -0,0 +1,17 @@
+/* Origin: PR c/179 from Gray Watson <gray@256.com>, adapted as a testcase
+ by Joseph Myers <jsm28@cam.ac.uk>. */
+/* -ftrivial-auto-var-init will make the uninitialized warning for address
+ taken auto var going away, FIXME later. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */
+extern void foo (int *);
+extern void bar (int);
+
+void
+baz (void)
+{
+ int i;
+ if (i) /* { dg-warning "is used uninitialized" "uninit i warning" { xfail *-*-* } } */
+ bar (i);
+ foo (&i);
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-C.c b/gcc/testsuite/gcc.dg/auto-init-uninit-C.c
new file mode 100644
index 0000000..be19796
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-C.c
@@ -0,0 +1,5 @@
+/* Spurious uninitialized variable warning, inspired by libgcc2.c. */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */
+
+#include "uninit-C.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-H.c b/gcc/testsuite/gcc.dg/auto-init-uninit-H.c
new file mode 100644
index 0000000..e442fab
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-H.c
@@ -0,0 +1,5 @@
+/* PR 14204 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wall -Werror -ftrivial-auto-var-init=zero" } */
+
+#include "uninit-H.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-I.c b/gcc/testsuite/gcc.dg/auto-init-uninit-I.c
new file mode 100644
index 0000000..4f9ae6c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-uninit-I.c
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */
+#include "uninit-H.c"
diff --git a/gcc/testsuite/gcc.dg/builtin-bswap-13.c b/gcc/testsuite/gcc.dg/builtin-bswap-13.c
new file mode 100644
index 0000000..6dc4c15
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtin-bswap-13.c
@@ -0,0 +1,329 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int test_s32_0_1(int x) { return __builtin_bswap32(x) & 1; }
+int test_s32_0_2(int x) { return __builtin_bswap32(x) & 2; }
+int test_s32_0_240(int x) { return __builtin_bswap32(x) & 240; }
+int test_s32_0_255(int x) { return __builtin_bswap32(x) & 255; }
+int test_s32_1_1(int x) { return (__builtin_bswap32(x) >> 1) & 1; }
+int test_s32_7_1(int x) { return (__builtin_bswap32(x) >> 7) & 1; }
+int test_s32_8_1(int x) { return (__builtin_bswap32(x) >> 8) & 1; }
+int test_s32_8_240(int x) { return (__builtin_bswap32(x) >> 8) & 240; }
+int test_s32_8_255(int x) { return (__builtin_bswap32(x) >> 8) & 255; }
+int test_s32_15_1(int x) { return (__builtin_bswap32(x) >> 15) & 1; }
+int test_s32_16_1(int x) { return (__builtin_bswap32(x) >> 16) & 1; }
+int test_s32_16_240(int x) { return (__builtin_bswap32(x) >> 16) & 240; }
+int test_s32_16_255(int x) { return (__builtin_bswap32(x) >> 16) & 255; }
+int test_s32_24_1(int x) { return (__builtin_bswap32(x) >> 24) & 1; }
+int test_s32_24_240(int x) { return (__builtin_bswap32(x) >> 24) & 240; }
+int test_s32_24_255(int x) { return (__builtin_bswap32(x) >> 24) & 255; }
+int test_s32_31_1(int x) { return (__builtin_bswap32(x) >> 31) & 1; }
+
+int test_S32_0_1(int x) { return (int)__builtin_bswap32(x) & 1; }
+int test_S32_0_2(int x) { return (int)__builtin_bswap32(x) & 2; }
+int test_S32_0_240(int x) { return (int)__builtin_bswap32(x) & 240; }
+int test_S32_0_255(int x) { return (int)__builtin_bswap32(x) & 255; }
+int test_S32_1_1(int x) { return ((int)__builtin_bswap32(x) >> 1) & 1; }
+int test_S32_7_1(int x) { return ((int)__builtin_bswap32(x) >> 7) & 1; }
+int test_S32_8_1(int x) { return ((int)__builtin_bswap32(x) >> 8) & 1; }
+int test_S32_8_240(int x) { return ((int)__builtin_bswap32(x) >> 8) & 240; }
+int test_S32_8_255(int x) { return ((int)__builtin_bswap32(x) >> 8) & 255; }
+int test_S32_15_1(int x) { return ((int)__builtin_bswap32(x) >> 15) & 1; }
+int test_S32_16_1(int x) { return ((int)__builtin_bswap32(x) >> 16) & 1; }
+int test_S32_16_240(int x) { return ((int)__builtin_bswap32(x) >> 16) & 240; }
+int test_S32_16_255(int x) { return ((int)__builtin_bswap32(x) >> 16) & 255; }
+int test_S32_24_1(int x) { return ((int)__builtin_bswap32(x) >> 24) & 1; }
+int test_S32_24_240(int x) { return ((int)__builtin_bswap32(x) >> 24) & 240; }
+int test_S32_24_255(int x) { return ((int)__builtin_bswap32(x) >> 24) & 255; }
+int test_S32_31_1(int x) { return ((int)__builtin_bswap32(x) >> 31) & 1; }
+
+unsigned int test_u32_24_255(unsigned int x) {
+ return (__builtin_bswap32(x) >> 24) & 255;
+}
+
+long long test_s64_0_1(long long x) {
+ return __builtin_bswap64(x) & 1;
+}
+long long test_s64_0_2(long long x) {
+ return __builtin_bswap64(x) & 2;
+}
+long long test_s64_0_240(long long x) {
+ return __builtin_bswap64(x) & 240;
+}
+long long test_s64_0_255(long long x) {
+ return __builtin_bswap64(x) & 255;
+}
+long long test_s64_7_1(long long x) {
+ return (__builtin_bswap64(x) >> 7) & 1;
+}
+long long test_s64_8_1(long long x) {
+ return (__builtin_bswap64(x) >> 8) & 1;
+}
+long long test_s64_8_240(long long x) {
+ return (__builtin_bswap64(x) >> 56) & 240;
+}
+long long test_s64_8_255(long long x) {
+ return (__builtin_bswap64(x) >> 8) & 255;
+}
+long long test_s64_9_1(long long x) {
+ return (__builtin_bswap64(x) >> 9) & 1;
+}
+long long test_s64_31_1(long long x) {
+ return (__builtin_bswap64(x) >> 31) & 1;
+}
+long long test_s64_32_1(long long x) {
+ return (__builtin_bswap64(x) >> 32) & 1;
+}
+long long test_s64_32_240(long long x) {
+ return (__builtin_bswap64(x) >> 32) & 240;
+}
+long long test_s64_32_255(long long x) {
+ return (__builtin_bswap64(x) >> 32) & 255;
+}
+long long test_s64_33_1(long long x) {
+ return (__builtin_bswap64(x) >> 33) & 1;
+}
+long long test_s64_48_1(long long x) {
+ return (__builtin_bswap64(x) >> 48) & 1;
+}
+long long test_s64_48_240(long long x) {
+ return (__builtin_bswap64(x) >> 48) & 240;
+}
+long long test_s64_48_255(long long x) {
+ return (__builtin_bswap64(x) >> 48) & 255;
+}
+long long test_s64_56_1(long long x) {
+ return (__builtin_bswap64(x) >> 56) & 1;
+}
+long long test_s64_56_240(long long x) {
+ return (__builtin_bswap64(x) >> 56) & 240;
+}
+long long test_s64_56_255(long long x) {
+ return (__builtin_bswap64(x) >> 56) & 255;
+}
+long long test_s64_57_1(long long x) {
+ return (__builtin_bswap64(x) >> 57) & 1;
+}
+long long test_s64_63_1(long long x) {
+ return (__builtin_bswap64(x) >> 63) & 1;
+}
+
+long long test_S64_0_1(long long x) {
+ return (long long)__builtin_bswap64(x) & 1;
+}
+long long test_S64_0_2(long long x) {
+ return (long long)__builtin_bswap64(x) & 2;
+}
+long long test_S64_0_240(long long x) {
+ return (long long)__builtin_bswap64(x) & 240;
+}
+long long test_S64_0_255(long long x) {
+ return (long long)__builtin_bswap64(x) & 255;
+}
+long long test_S64_7_1(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 7) & 1;
+}
+long long test_S64_8_1(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 8) & 1;
+}
+long long test_S64_8_240(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 56) & 240;
+}
+long long test_S64_8_255(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 8) & 255;
+}
+long long test_S64_9_1(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 9) & 1;
+}
+long long test_S64_31_1(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 31) & 1;
+}
+long long test_S64_32_1(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 32) & 1;
+}
+long long test_S64_32_240(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 32) & 240;
+}
+long long test_S64_32_255(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 32) & 255;
+}
+long long test_S64_33_1(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 33) & 1;
+}
+long long test_S64_48_1(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 48) & 1;
+}
+long long test_S64_48_240(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 48) & 240;
+}
+long long test_S64_48_255(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 48) & 255;
+}
+long long test_S64_56_1(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 56) & 1;
+}
+long long test_S64_56_240(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 56) & 240;
+}
+long long test_S64_56_255(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 56) & 255;
+}
+long long test_S64_57_1(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 57) & 1;
+}
+long long test_S64_63_1(long long x) {
+ return ((long long)__builtin_bswap64(x) >> 63) & 1;
+}
+
+unsigned long long test_u64_56_255(unsigned long long x) {
+ return (__builtin_bswap64(x) >> 56) & 255;
+}
+
+short test_s16_0_1(short x) {
+ return __builtin_bswap16(x) & 1;
+}
+short test_s16_0_240(short x) {
+ return __builtin_bswap16(x) & 240;
+}
+short test_s16_0_255(short x) {
+ return __builtin_bswap16(x) & 255;
+}
+short test_s16_1_1(short x) {
+ return (__builtin_bswap16(x) >> 1) & 1;
+}
+short test_s16_7_1(short x) {
+ return (__builtin_bswap16(x) >> 7) & 1;
+}
+short test_s16_8_1(short x) {
+ return (__builtin_bswap16(x) >> 8) & 1;
+}
+short test_s16_8_240(short x) {
+ return (__builtin_bswap16(x) >> 8) & 240;
+}
+short test_s16_8_255(short x) {
+ return (__builtin_bswap16(x) >> 8) & 255;
+}
+short test_s16_9_1(short x) {
+ return (__builtin_bswap16(x) >> 9) & 1;
+}
+short test_s16_15_1(short x) {
+ return (__builtin_bswap16(x) >> 15) & 1;
+}
+
+short test_S16_0_1(short x) {
+ return (short)__builtin_bswap16(x) & 1;
+}
+short test_S16_0_240(short x) {
+ return (short)__builtin_bswap16(x) & 240;
+}
+short test_S16_0_255(short x) {
+ return (short)__builtin_bswap16(x) & 255;
+}
+short test_S16_1_1(short x) {
+ return ((short)__builtin_bswap16(x) >> 1) & 1;
+}
+short test_S16_7_1(short x) {
+ return ((short)__builtin_bswap16(x) >> 7) & 1;
+}
+short test_S16_8_1(short x) {
+ return ((short)__builtin_bswap16(x) >> 8) & 1;
+}
+short test_S16_8_240(short x) {
+ return ((short)__builtin_bswap16(x) >> 8) & 240;
+}
+short test_S16_8_255(short x) {
+ return ((short)__builtin_bswap16(x) >> 8) & 255;
+}
+short test_S16_9_1(short x) {
+ return ((short)__builtin_bswap16(x) >> 9) & 1;
+}
+short test_S16_15_1(short x) {
+ return ((short)__builtin_bswap16(x) >> 15) & 1;
+}
+
+unsigned short test_u16_8_255(unsigned short x) {
+ return (__builtin_bswap16(x) >> 8) & 255;
+}
+
+
+/* Shifts only */
+int test_s32_24(int x) {
+ return __builtin_bswap32(x) >> 24;
+}
+int test_s32_25(int x) {
+ return __builtin_bswap32(x) >> 25;
+}
+int test_s32_30(int x) {
+ return __builtin_bswap32(x) >> 30;
+}
+int test_s32_31(int x) {
+ return __builtin_bswap32(x) >> 31;
+}
+
+unsigned int test_u32_24(unsigned int x) {
+ return __builtin_bswap32(x) >> 24;
+}
+unsigned int test_u32_25(unsigned int x) {
+ return __builtin_bswap32(x) >> 25;
+}
+unsigned int test_u32_30(unsigned int x) {
+ return __builtin_bswap32(x) >> 30;
+}
+unsigned int test_u32_31(unsigned int x) {
+ return __builtin_bswap32(x) >> 31;
+}
+
+long long test_s64_56(long long x) {
+ return __builtin_bswap64(x) >> 56;
+}
+long long test_s64_57(long long x) {
+ return __builtin_bswap64(x) >> 57;
+}
+long long test_s64_62(long long x) {
+ return __builtin_bswap64(x) >> 62;
+}
+long long test_s64_63(long long x) {
+ return __builtin_bswap64(x) >> 63;
+}
+
+unsigned long long test_u64_56(unsigned long long x) {
+ return __builtin_bswap64(x) >> 56;
+}
+unsigned long long test_u64_57(unsigned long long x) {
+ return __builtin_bswap64(x) >> 57;
+}
+unsigned long long test_u64_62(unsigned long long x) {
+ return __builtin_bswap64(x) >> 62;
+}
+unsigned long long test_u64_63(unsigned long long x) {
+ return __builtin_bswap64(x) >> 63;
+}
+
+short test_s16_8(short x) {
+ return __builtin_bswap16(x) >> 8;
+}
+short test_s16_9(short x) {
+ return __builtin_bswap16(x) >> 9;
+}
+short test_s16_14(short x) {
+ return __builtin_bswap16(x) >> 14;
+}
+short test_s16_15(short x) {
+ return __builtin_bswap16(x) >> 15;
+}
+
+unsigned short test_u16_8(unsigned short x) {
+ return __builtin_bswap16(x) >> 8;
+}
+unsigned short test_u16_9(unsigned short x) {
+ return __builtin_bswap16(x) >> 9;
+}
+unsigned short test_u16_14(unsigned short x) {
+ return __builtin_bswap16(x) >> 14;
+}
+unsigned short test_u16_15(unsigned short x) {
+ return __builtin_bswap16(x) >> 15;
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin_bswap" "optimized" } } */
+
diff --git a/gcc/testsuite/gcc.dg/builtin-bswap-14.c b/gcc/testsuite/gcc.dg/builtin-bswap-14.c
new file mode 100644
index 0000000..62711d8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtin-bswap-14.c
@@ -0,0 +1,302 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+
+__attribute__ ((noinline, noclone))
+static int rt32 (int x, int y, int z) {
+ return (__builtin_bswap32(x) >> y) & z;
+}
+#define TEST32(X,Y,Z) if(((__builtin_bswap32(X)>>Y)&Z)!=rt32(X,Y,Z)) abort()
+void test32(int x)
+{
+ TEST32(x,0,1);
+ TEST32(x,0,255);
+ TEST32(x,1,1);
+ TEST32(x,2,1);
+ TEST32(x,3,1);
+ TEST32(x,4,1);
+ TEST32(x,5,1);
+ TEST32(x,6,1);
+ TEST32(x,7,1);
+ TEST32(x,8,1);
+ TEST32(x,8,255);
+ TEST32(x,9,1);
+ TEST32(x,10,1);
+ TEST32(x,11,1);
+ TEST32(x,12,1);
+ TEST32(x,13,1);
+ TEST32(x,14,1);
+ TEST32(x,15,1);
+ TEST32(x,16,1);
+ TEST32(x,16,255);
+ TEST32(x,17,1);
+ TEST32(x,18,1);
+ TEST32(x,19,1);
+ TEST32(x,20,1);
+ TEST32(x,21,1);
+ TEST32(x,22,1);
+ TEST32(x,23,1);
+ TEST32(x,24,1);
+ TEST32(x,24,255);
+ TEST32(x,25,1);
+ TEST32(x,26,1);
+ TEST32(x,27,1);
+ TEST32(x,28,1);
+ TEST32(x,29,1);
+ TEST32(x,30,1);
+ TEST32(x,31,1);
+}
+
+#if __SIZEOF_LONG_LONG__ == 8
+__attribute__ ((noinline, noclone))
+static long long rt64 (long long x, int y, long long z) {
+ return (__builtin_bswap64(x) >> y) & z;
+}
+#define TEST64(X,Y,Z) if(((__builtin_bswap64(X)>>Y)&Z)!=rt64(X,Y,Z)) abort()
+void test64(long long x)
+{
+ TEST64(x,0,1);
+ TEST64(x,0,255);
+ TEST64(x,1,1);
+ TEST64(x,2,1);
+ TEST64(x,3,1);
+ TEST64(x,4,1);
+ TEST64(x,5,1);
+ TEST64(x,6,1);
+ TEST64(x,7,1);
+ TEST64(x,8,1);
+ TEST64(x,8,255);
+ TEST64(x,9,1);
+ TEST64(x,10,1);
+ TEST64(x,11,1);
+ TEST64(x,12,1);
+ TEST64(x,13,1);
+ TEST64(x,14,1);
+ TEST64(x,15,1);
+ TEST64(x,16,1);
+ TEST64(x,16,255);
+ TEST64(x,17,1);
+ TEST64(x,18,1);
+ TEST64(x,19,1);
+ TEST64(x,20,1);
+ TEST64(x,21,1);
+ TEST64(x,22,1);
+ TEST64(x,23,1);
+ TEST64(x,24,1);
+ TEST64(x,24,255);
+ TEST64(x,25,1);
+ TEST64(x,26,1);
+ TEST64(x,27,1);
+ TEST64(x,28,1);
+ TEST64(x,29,1);
+ TEST64(x,30,1);
+ TEST64(x,31,1);
+ TEST64(x,32,1);
+ TEST64(x,32,255);
+ TEST64(x,33,1);
+ TEST64(x,34,1);
+ TEST64(x,35,1);
+ TEST64(x,36,1);
+ TEST64(x,37,1);
+ TEST64(x,38,1);
+ TEST64(x,39,1);
+ TEST64(x,40,1);
+ TEST64(x,40,255);
+ TEST64(x,41,1);
+ TEST64(x,42,1);
+ TEST64(x,43,1);
+ TEST64(x,44,1);
+ TEST64(x,45,1);
+ TEST64(x,46,1);
+ TEST64(x,47,1);
+ TEST64(x,48,1);
+ TEST64(x,48,255);
+ TEST64(x,49,1);
+ TEST64(x,50,1);
+ TEST64(x,51,1);
+ TEST64(x,52,1);
+ TEST64(x,53,1);
+ TEST64(x,54,1);
+ TEST64(x,55,1);
+ TEST64(x,56,1);
+ TEST64(x,56,255);
+ TEST64(x,57,1);
+ TEST64(x,58,1);
+ TEST64(x,59,1);
+ TEST64(x,60,1);
+ TEST64(x,61,1);
+ TEST64(x,62,1);
+ TEST64(x,63,1);
+}
+#endif
+
+__attribute__ ((noinline, noclone))
+static int rt16 (int x, int y, int z) {
+ return (__builtin_bswap16(x) >> y) & z;
+}
+#define TEST16(X,Y,Z) if(((__builtin_bswap16(X)>>Y)&Z)!=rt16(X,Y,Z)) abort()
+void test16(int x)
+{
+ TEST16(x,0,1);
+ TEST16(x,0,255);
+ TEST16(x,1,1);
+ TEST16(x,2,1);
+ TEST16(x,3,1);
+ TEST16(x,4,1);
+ TEST16(x,5,1);
+ TEST16(x,6,1);
+ TEST16(x,7,1);
+ TEST16(x,8,1);
+ TEST16(x,8,255);
+ TEST16(x,9,1);
+ TEST16(x,10,1);
+ TEST16(x,11,1);
+ TEST16(x,12,1);
+ TEST16(x,13,1);
+ TEST16(x,14,1);
+ TEST16(x,15,1);
+}
+
+int main()
+{
+ test32(0x00000000);
+ test32(0xffffffff);
+ test32(0x00000001);
+ test32(0x00000002);
+ test32(0x00000004);
+ test32(0x00000008);
+ test32(0x00000010);
+ test32(0x00000020);
+ test32(0x00000040);
+ test32(0x00000080);
+ test32(0x00000100);
+ test32(0x00000200);
+ test32(0x00000400);
+ test32(0x00000800);
+ test32(0x00001000);
+ test32(0x00002000);
+ test32(0x00004000);
+ test32(0x00008000);
+ test32(0x00010000);
+ test32(0x00020000);
+ test32(0x00040000);
+ test32(0x00080000);
+ test32(0x00100000);
+ test32(0x00200000);
+ test32(0x00400000);
+ test32(0x00800000);
+ test32(0x01000000);
+ test32(0x02000000);
+ test32(0x04000000);
+ test32(0x08000000);
+ test32(0x10000000);
+ test32(0x20000000);
+ test32(0x40000000);
+ test32(0x80000000);
+ test32(0x12345678);
+ test32(0x87654321);
+ test32(0xdeadbeef);
+ test32(0xcafebabe);
+
+#if __SIZEOF_LONG_LONG__ == 8
+ test64(0x0000000000000000ll);
+ test64(0xffffffffffffffffll);
+ test64(0x0000000000000001ll);
+ test64(0x0000000000000002ll);
+ test64(0x0000000000000004ll);
+ test64(0x0000000000000008ll);
+ test64(0x0000000000000010ll);
+ test64(0x0000000000000020ll);
+ test64(0x0000000000000040ll);
+ test64(0x0000000000000080ll);
+ test64(0x0000000000000100ll);
+ test64(0x0000000000000200ll);
+ test64(0x0000000000000400ll);
+ test64(0x0000000000000800ll);
+ test64(0x0000000000001000ll);
+ test64(0x0000000000002000ll);
+ test64(0x0000000000004000ll);
+ test64(0x0000000000008000ll);
+ test64(0x0000000000010000ll);
+ test64(0x0000000000020000ll);
+ test64(0x0000000000040000ll);
+ test64(0x0000000000080000ll);
+ test64(0x0000000000100000ll);
+ test64(0x0000000000200000ll);
+ test64(0x0000000000400000ll);
+ test64(0x0000000000800000ll);
+ test64(0x0000000001000000ll);
+ test64(0x0000000002000000ll);
+ test64(0x0000000004000000ll);
+ test64(0x0000000008000000ll);
+ test64(0x0000000010000000ll);
+ test64(0x0000000020000000ll);
+ test64(0x0000000040000000ll);
+ test64(0x0000000080000000ll);
+ test64(0x0000000100000000ll);
+ test64(0x0000000200000000ll);
+ test64(0x0000000400000000ll);
+ test64(0x0000000800000000ll);
+ test64(0x0000001000000000ll);
+ test64(0x0000002000000000ll);
+ test64(0x0000004000000000ll);
+ test64(0x0000008000000000ll);
+ test64(0x0000010000000000ll);
+ test64(0x0000020000000000ll);
+ test64(0x0000040000000000ll);
+ test64(0x0000080000000000ll);
+ test64(0x0000100000000000ll);
+ test64(0x0000200000000000ll);
+ test64(0x0000400000000000ll);
+ test64(0x0000800000000000ll);
+ test64(0x0001000000000000ll);
+ test64(0x0002000000000000ll);
+ test64(0x0004000000000000ll);
+ test64(0x0008000000000000ll);
+ test64(0x0010000000000000ll);
+ test64(0x0020000000000000ll);
+ test64(0x0040000000000000ll);
+ test64(0x0080000000000000ll);
+ test64(0x0100000000000000ll);
+ test64(0x0200000000000000ll);
+ test64(0x0400000000000000ll);
+ test64(0x0800000000000000ll);
+ test64(0x1000000000000000ll);
+ test64(0x2000000000000000ll);
+ test64(0x4000000000000000ll);
+ test64(0x8000000000000000ll);
+ test64(0x0123456789abcdefll);
+ test64(0xfedcba9876543210ll);
+ test64(0xdeadbeefdeadbeefll);
+ test64(0xcafebabecafebabell);
+#endif
+
+ test16(0x0000);
+ test16(0xffff);
+ test16(0x0001);
+ test16(0x0002);
+ test16(0x0004);
+ test16(0x0008);
+ test16(0x0010);
+ test16(0x0020);
+ test16(0x0040);
+ test16(0x0080);
+ test16(0x0100);
+ test16(0x0200);
+ test16(0x0400);
+ test16(0x0800);
+ test16(0x1000);
+ test16(0x2000);
+ test16(0x4000);
+ test16(0x8000);
+ test16(0x1234);
+ test16(0x4321);
+ test16(0xdead);
+ test16(0xbeef);
+ test16(0xcafe);
+ test16(0xbabe);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-10.c b/gcc/testsuite/gcc.dg/builtin-object-size-10.c
index 2a212fa..bfcdf5c 100644
--- a/gcc/testsuite/gcc.dg/builtin-object-size-10.c
+++ b/gcc/testsuite/gcc.dg/builtin-object-size-10.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-objsz1-details" } */
+/* { dg-options "-O2 -fdump-tree-early_objsz-details" } */
// { dg-skip-if "packed attribute missing for drone_source_packet" { "epiphany-*-*" } }
typedef struct {
@@ -22,5 +22,5 @@ foo(char *x)
return dpkt;
}
-/* { dg-final { scan-tree-dump "maximum object size 21" "objsz1" } } */
-/* { dg-final { scan-tree-dump "maximum subobject size 16" "objsz1" } } */
+/* { dg-final { scan-tree-dump "maximum object size 21" "early_objsz" } } */
+/* { dg-final { scan-tree-dump "maximum subobject size 16" "early_objsz" } } */
diff --git a/gcc/testsuite/gcc.dg/builtins-70.c b/gcc/testsuite/gcc.dg/builtins-70.c
new file mode 100644
index 0000000..a0c2dc9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtins-70.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 2021 Free Software Foundation.
+
+ Check that constant folding of built-in fmod functions doesn't
+ break anything and produces the expected results.
+
+/* { dg-do link } */
+/* { dg-options "-O2 -ffast-math" } */
+
+extern void link_error(void);
+
+extern double fmod(double,double);
+extern float fmodf(float,float);
+extern long double fmodl(long double,long double);
+
+int main()
+{
+ if (fmod (6.5, 2.3) < 1.8999 || fmod (6.5, 2.3) > 1.9001)
+ link_error ();
+ if (fmod (-6.5, 2.3) < -1.9001 || fmod (-6.5, 2.3) > -1.8999)
+ link_error ();
+ if (fmod (6.5, -2.3) < 1.8999 || fmod (6.5, -2.3) > 1.9001)
+ link_error ();
+ if (fmod (-6.5, -2.3) < -1.9001 || fmod (-6.5, -2.3) > -1.8999)
+ link_error ();
+
+ if (fmodf (6.5f, 2.3f) < 1.8999f || fmodf (6.5f, 2.3f) > 1.9001f)
+ link_error ();
+ if (fmodf (-6.5f, 2.3f) < -1.9001f || fmodf (-6.5f, 2.3f) > -1.8999f)
+ link_error ();
+ if (fmodf (6.5f, -2.3f) < 1.8999f || fmodf (6.5f, -2.3f) > 1.9001f)
+ link_error ();
+ if (fmodf (-6.5f, -2.3f) < -1.9001f || fmodf (-6.5f, -2.3f) > -1.8999f)
+ link_error ();
+
+ if (fmodl (6.5l, 2.3l) < 1.8999l || fmod (6.5l, 2.3l) > 1.9001l)
+ link_error ();
+ if (fmodl (-6.5l, 2.3l) < -1.9001l || fmod (-6.5l, 2.3l) > -1.8999l)
+ link_error ();
+ if (fmodl (6.5l, -2.3l) < 1.8999l || fmod (6.5l, -2.3l) > 1.9001l)
+ link_error ();
+ if (fmodl (-6.5l, -2.3l) < -1.9001l || fmod (-6.5l, -2.3l) > -1.8999l)
+ link_error ();
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/c11-digit-separators-1.c b/gcc/testsuite/gcc.dg/c11-digit-separators-1.c
new file mode 100644
index 0000000..fc83226
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c11-digit-separators-1.c
@@ -0,0 +1,7 @@
+/* Test C2x digit separators not in C11. */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+#define m(x) 0
+
+_Static_assert (m(1'2)+(3'4) == 0, "digit separators");
diff --git a/gcc/testsuite/gcc.dg/c11-qual-1.c b/gcc/testsuite/gcc.dg/c11-qual-1.c
new file mode 100644
index 0000000..f731e06
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c11-qual-1.c
@@ -0,0 +1,11 @@
+/* Test that qualifiers are lost in tertiary operator for pointers to arrays before C2X, PR98397 */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -pedantic-errors -Wno-discarded-array-qualifiers" } */
+
+void foo(void)
+{
+ const int (*u)[1];
+ void *v;
+ _Static_assert(_Generic(1 ? u : v, const void*: 0, void*: 1), "qualifier not lost");
+ _Static_assert(_Generic(1 ? v : u, const void*: 0, void*: 1), "qualifier not lost");
+}
diff --git a/gcc/testsuite/gcc.dg/c11-unproto-1.c b/gcc/testsuite/gcc.dg/c11-unproto-1.c
new file mode 100644
index 0000000..ea9e807
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c11-unproto-1.c
@@ -0,0 +1,24 @@
+/* Test compatibility of unprototyped and prototyped function types (C2x makes
+ the case of types affected by default argument promotions compatible). Test
+ valid-in-C2x usages are not accepted for C11. */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+void f1 (); /* { dg-message "previous declaration" } */
+void f1 (float); /* { dg-error "conflicting types" } */
+/* { dg-message "default promotion" "" { target *-*-* } .-1 } */
+
+void f2 (float); /* { dg-message "previous declaration" } */
+void f2 (); /* { dg-error "conflicting types" } */
+/* { dg-message "default promotion" "" { target *-*-* } .-1 } */
+
+void f3 (); /* { dg-message "previous declaration" } */
+void f3 (char); /* { dg-error "conflicting types" } */
+/* { dg-message "default promotion" "" { target *-*-* } .-1 } */
+
+void f4 (char); /* { dg-message "previous declaration" } */
+void f4 (); /* { dg-error "conflicting types" } */
+/* { dg-message "default promotion" "" { target *-*-* } .-1 } */
+
+/* Built-in function case. */
+float sqrtf (); /* { dg-warning "conflicting types for built-in function" } */
diff --git a/gcc/testsuite/gcc.dg/c11-unproto-2.c b/gcc/testsuite/gcc.dg/c11-unproto-2.c
new file mode 100644
index 0000000..0557ae3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c11-unproto-2.c
@@ -0,0 +1,21 @@
+/* Test compatibility of unprototyped and prototyped function types (C2x makes
+ the case of types affected by default argument promotions compatible). Test
+ invalid-in-C2x usages, in C11 mode. */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+void f1 (); /* { dg-message "previous declaration" } */
+void f1 (int, ...); /* { dg-error "conflicting types" } */
+/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */
+
+void f2 (int, ...); /* { dg-message "previous declaration" } */
+void f2 (); /* { dg-error "conflicting types" } */
+/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */
+
+void f3 (); /* { dg-message "previous declaration" } */
+void f3 (char, ...); /* { dg-error "conflicting types" } */
+/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */
+
+void f4 (char, ...); /* { dg-message "previous declaration" } */
+void f4 (); /* { dg-error "conflicting types" } */
+/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */
diff --git a/gcc/testsuite/gcc.dg/c2x-attr-maybe_unused-1.c b/gcc/testsuite/gcc.dg/c2x-attr-maybe_unused-1.c
index 221ebdd..477f30d 100644
--- a/gcc/testsuite/gcc.dg/c2x-attr-maybe_unused-1.c
+++ b/gcc/testsuite/gcc.dg/c2x-attr-maybe_unused-1.c
@@ -20,7 +20,7 @@ g ([[maybe_unused]] int x, int y)
struct [[maybe_unused]] s { double d; };
-struct s2 { [[__maybe_unused__]] int a; int b [[maybe_unused]]; } x; /* { dg-warning "attribute ignored" } */
+struct s2 { [[__maybe_unused__]] int a; int b [[maybe_unused]]; } x;
enum e { E1 [[maybe_unused]] };
@@ -28,4 +28,4 @@ union [[maybe_unused]] u { int x; };
enum [[maybe_unused]] eu { E2 };
-union u2 { [[maybe_unused]] int a; int b [[maybe_unused]]; } y; /* { dg-warning "attribute ignored" } */
+union u2 { [[maybe_unused]] int a; int b [[maybe_unused]]; } y;
diff --git a/gcc/testsuite/gcc.dg/c2x-digit-separators-1.c b/gcc/testsuite/gcc.dg/c2x-digit-separators-1.c
new file mode 100644
index 0000000..6eadf2e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-digit-separators-1.c
@@ -0,0 +1,39 @@
+/* Test C2x digit separators. Valid usages. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+_Static_assert (123'45'6 == 123456);
+_Static_assert (0'123 == 0123);
+_Static_assert (0x1'23 == 0x123);
+
+#define m(x) 0
+
+_Static_assert (m(1'2)+(3'4) == 34);
+
+_Static_assert (0x0'e-0xe == 0);
+
+#define a0 '.' -
+#define acat(x) a ## x
+_Static_assert (acat (0'.') == 0);
+
+#define c0(x) 0
+#define b0 c0 (
+#define bcat(x) b ## x
+_Static_assert (bcat (0'\u00c0')) == 0);
+
+extern void exit (int);
+extern void abort (void);
+
+int
+main (void)
+{
+ if (314'159e-0'5f != 3.14159f)
+ abort ();
+ exit (0);
+}
+
+#line 0'123
+_Static_assert (__LINE__ == 123);
+
+#line 4'56'7'8'9
+_Static_assert (__LINE__ == 456789);
diff --git a/gcc/testsuite/gcc.dg/c2x-digit-separators-2.c b/gcc/testsuite/gcc.dg/c2x-digit-separators-2.c
new file mode 100644
index 0000000..d72f8ad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-digit-separators-2.c
@@ -0,0 +1,25 @@
+/* Test C2x digit separators. Invalid usages. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+void
+tf (void)
+{
+ int i;
+ i = 1''2; /* { dg-error "adjacent digit separators" } */
+ i = 0x'0; /* { dg-error "digit separator after base indicator" } */
+ i = 0X'1; /* { dg-error "digit separator after base indicator" } */
+ i = 0b'0; /* { dg-error "digit separator after base indicator" } */
+ i = 0B'1; /* { dg-error "digit separator after base indicator" } */
+ i = 1'u; /* { dg-error "digit separator outside digit sequence" } */
+ float f = 1.2e-3'f; /* { dg-error "digit separator outside digit sequence" } */
+ i = 1'2'3'; /* { dg-error "12:missing terminating" } */
+ ;
+ double d;
+ d = 1'.2'3e-4; /* { dg-warning "multi-character" } */
+ /* { dg-error "expected" "parse error" { target *-*-* } .-1 } */
+ d = 1.2''3; /* { dg-error "adjacent digit separators" } */
+ d = 1.23e-4''5; /* { dg-error "adjacent digit separators" } */
+ d = 1.2'3e-4'5'; /* { dg-error "17:missing terminating" } */
+ /* { dg-error "expected" "parse error" { target *-*-* } .-1 } */
+}
diff --git a/gcc/testsuite/gcc.dg/c2x-digit-separators-3.c b/gcc/testsuite/gcc.dg/c2x-digit-separators-3.c
new file mode 100644
index 0000000..cddb88f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-digit-separators-3.c
@@ -0,0 +1,12 @@
+/* Test C2x digit separators. Test token pasting avoided for preprocessed
+ output. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -save-temps" } */
+
+#define ZERO 0
+
+int
+f (void)
+{
+ return ZERO'0'0; /* { dg-error "expected" } */
+}
diff --git a/gcc/testsuite/gcc.dg/c2x-qual-1.c b/gcc/testsuite/gcc.dg/c2x-qual-1.c
new file mode 100644
index 0000000..4d33db1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-qual-1.c
@@ -0,0 +1,30 @@
+/* Tests related to qualifiers and pointers to arrays in C2X, PR98397 */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+/* test that qualifiers are preserved in tertiary operator for pointers to arrays in C2X */
+
+void f(void)
+{
+ const int (*u)[1];
+ void *v;
+ _Static_assert(_Generic(1 ? u : v, const void*: 1, void*: 0), "lost qualifier");
+ _Static_assert(_Generic(1 ? v : u, const void*: 1, void*: 0), "lost qualifier");
+}
+
+/* test that assignment of unqualified to qualified pointers works as expected */
+
+void g(void)
+{
+ int (*x)[3];
+ const int (*p)[3] = x;
+}
+
+/* test that assignment of qualified void pointers works as expected */
+
+void h(void)
+{
+ const void* x;
+ const int (*p)[3] = x;
+}
+
diff --git a/gcc/testsuite/gcc.dg/c2x-qual-2.c b/gcc/testsuite/gcc.dg/c2x-qual-2.c
new file mode 100644
index 0000000..f60a5b1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-qual-2.c
@@ -0,0 +1,30 @@
+/* Tests related to qualifiers and pointers to arrays in C2X, PR98397 */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -Wc11-c2x-compat" } */
+
+/* test that qualifiers are preserved in tertiary operator for pointers to arrays in C2X */
+
+void f(void)
+{
+ const int (*u)[1];
+ void *v;
+ _Static_assert(_Generic(1 ? u : v, const void*: 1, void*: 0), "lost qualifier"); /* { dg-warning "pointer to array loses qualifier in conditional" } */
+ _Static_assert(_Generic(1 ? v : u, const void*: 1, void*: 0), "lost qualifier"); /* { dg-warning "pointer to array loses qualifier in conditional" } */
+}
+
+/* test that assignment of unqualified to qualified pointers works as expected */
+
+void g(void)
+{
+ int (*x)[3];
+ const int (*p)[3] = x; /* { dg-warning "arrays with different qualifiers" } */
+}
+
+/* test that assignment of qualified void pointers works as expected */
+
+void h(void)
+{
+ const void* x;
+ const int (*p)[3] = x; /* { dg-warning "array with qualifier on the element is not qualified before C2X" } */
+}
+
diff --git a/gcc/testsuite/gcc.dg/c2x-qual-3.c b/gcc/testsuite/gcc.dg/c2x-qual-3.c
new file mode 100644
index 0000000..31896fcb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-qual-3.c
@@ -0,0 +1,30 @@
+/* Tests related to qualifiers and pointers to arrays in C2X, PR98397 */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -Wc11-c2x-compat -pedantic-errors" } */
+
+/* test that qualifiers are preserved in tertiary operator for pointers to arrays in C2X */
+
+void f(void)
+{
+ const int (*u)[1];
+ void *v;
+ _Static_assert(_Generic(1 ? u : v, const void*: 1, void*: 0), "lost qualifier"); /* { dg-warning "pointer to array loses qualifier in conditional" } */
+ _Static_assert(_Generic(1 ? v : u, const void*: 1, void*: 0), "lost qualifier"); /* { dg-warning "pointer to array loses qualifier in conditional" } */
+}
+
+/* test that assignment of unqualified to qualified pointers works as expected */
+
+void g(void)
+{
+ int (*x)[3];
+ const int (*p)[3] = x; /* { dg-warning "arrays with different qualifiers" } */
+}
+
+/* test that assignment of qualified void pointers works as expected */
+
+void h(void)
+{
+ const void* x;
+ const int (*p)[3] = x; /* { dg-warning "array with qualifier on the element is not qualified before C2X" } */
+}
+
diff --git a/gcc/testsuite/gcc.dg/c2x-qual-4.c b/gcc/testsuite/gcc.dg/c2x-qual-4.c
new file mode 100644
index 0000000..93b4723
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-qual-4.c
@@ -0,0 +1,105 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c2x" } */
+void tvoid(void* x);
+void transpose0(double* out, const double* in) { }
+void transpose1(double out[2][2], const double in[2][2]) { }
+void transpose2(double out[2][2][2], const double in[2][2][2]) { }
+// return
+int (*y2(const int x[3][3]))[3] { return x; } /* { dg-warning "return discards 'const' qualifier from pointer target type" } */
+const int (*y3(int x[3][3]))[3] { return x; }
+void test(void)
+{
+ double x0[2];
+ double y0[2];
+ const double z0[4];
+ double x1[2][2];
+ double y1[2][2];
+ double o1[2][3];
+ const double z1[2][2];
+ double x2[2][2][2];
+ double y2[2][2][2];
+ double o2[2][2][3];
+ const double z2[2][2][2];
+ // void pointers
+ tvoid(x0);
+ tvoid(x1);
+ tvoid(x2);
+ tvoid(z0); /* { dg-warning "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */
+ tvoid(z1); /* { dg-warning "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */
+ tvoid(z2); /* { dg-warning "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */
+ void* p;
+ const void* pc;
+ p = x0;
+ p = x1;
+ p = x2;
+ p = z0; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ p = z1; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ p = z2; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ pc = x0;
+ pc = x1;
+ pc = x2;
+ pc = z0;
+ pc = z1;
+ pc = z2;
+ transpose0(pc, p); /* { dg-warning "passing argument 1 of 'transpose0' discards 'const' qualifier from pointer target type" } */
+ transpose1(pc, p); /* { dg-warning "passing argument 1 of 'transpose1' discards 'const' qualifier from pointer target type" } */
+ transpose2(pc, p); /* { dg-warning "passing argument 1 of 'transpose2' discards 'const' qualifier from pointer target type" } */
+ transpose0(p, pc);
+ transpose1(p, pc);
+ transpose2(p, pc);
+ // passing as arguments
+ transpose0(y0, x0);
+ transpose1(y1, x1);
+ transpose2(y2, x2);
+ // initialization
+ const double (*u0p) = x0;
+ const double (*u1p)[2] = x1;
+ const double (*u2p)[2][2] = x2;
+ double (*v0p) = z0; /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */
+ double (*v1p)[2] = z1; /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */
+ double (*v2p)[2][2] = z2; /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */
+ // subtraction
+ &(x0[1]) - &(z0[0]);
+ &(x1[1]) - &(z1[0]);
+ &(x2[1]) - &(z2[0]);
+ // comparison
+ x0 == z0;
+ x1 == z1;
+ x2 == z2;
+ x0 < z0;
+ x1 < z1;
+ x2 < z2;
+ x0 > z0;
+ x1 > z1;
+ x2 > z2;
+ // assignment
+ u0p = x0;
+ u1p = x1;
+ u2p = x2;
+ v0p = z0; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = z1; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v2p = z2; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ // conditional expressions
+ (void)(1 ? x0 : z0);
+ (void)(1 ? x1 : z1);
+ (void)(1 ? x2 : z2);
+ (void)(1 ? x0 : x1); /* { dg-warning "pointer type mismatch in conditional expression" } */
+ (void)(1 ? x1 : x2); /* { dg-warning "pointer type mismatch in conditional expression" } */
+ (void)(1 ? x2 : x0); /* { dg-warning "pointer type mismatch in conditional expression" } */
+ v0p = (1 ? z0 : v0p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? z1 : v1p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v2p = (1 ? z2 : v2p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v0p = (1 ? x0 : u0p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? x1 : u1p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v2p = (1 ? x2 : u2p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ (1 ? x0 : z0)[0] = 1; /* { dg-error "assignment of read-only location" } */
+ (1 ? x1 : z1)[0][0] = 1; /* { dg-error "assignment of read-only location" } */
+ (1 ? x2 : z2)[0][0][0] = 1; /* { dg-error "assignment of read-only location" } */
+ v0p = (1 ? p : z0); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? p : z1); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v2p = (1 ? p : z2); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v0p = (1 ? pc : x0); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? pc : x1); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+ v2p = (1 ? pc : x2); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */
+}
+
diff --git a/gcc/testsuite/gcc.dg/c2x-qual-5.c b/gcc/testsuite/gcc.dg/c2x-qual-5.c
new file mode 100644
index 0000000..0801fa0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-qual-5.c
@@ -0,0 +1,101 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+void tvoid(void* x);
+void transpose0(double* out, const double* in) { }
+void transpose1(double out[2][2], const double in[2][2]) { }
+void transpose2(double out[2][2][2], const double in[2][2][2]) { }
+// return
+int (*x2(const int x[3][3]))[3] { return x; } /* { dg-error "return discards" } */
+const int (*x3(int x[3][3]))[3] { return x; }
+void test(void)
+{
+ double x0[2];
+ double y0[2];
+ const double z0[4];
+ double x1[2][2];
+ double y1[2][2];
+ double o1[2][3];
+ const double z1[2][2];
+ double x2[2][2][2];
+ double y2[2][2][2];
+ double o2[2][2][3];
+ const double z2[2][2][2];
+ // void pointers
+ tvoid(z0); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */
+ tvoid(z1); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */
+ tvoid(z2); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */
+ void* p;
+ const void* pc;
+ p = x0;
+ p = x1;
+ p = x2;
+ p = z0; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ p = z1; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ p = z2; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ pc = x0;
+ pc = x1;
+ pc = x2;
+ pc = z0;
+ pc = z1;
+ pc = z2;
+ transpose0(pc, p); /* { dg-error "passing argument 1 of 'transpose0' discards 'const' qualifier from pointer target type" } */
+ transpose1(pc, p); /* { dg-error "passing argument 1 of 'transpose1' discards 'const' qualifier from pointer target type" } */
+ transpose2(pc, p); /* { dg-error "passing argument 1 of 'transpose2' discards 'const' qualifier from pointer target type" } */
+ transpose0(p, pc);
+ transpose1(p, pc);
+ transpose2(p, pc);
+ // passing as arguments
+ transpose0(y0, x0);
+ transpose1(y1, o1); /* { dg-error "passing argument 2 of 'transpose1' from incompatible pointer type" } */
+ transpose1(y1, x1);
+ transpose2(y2, o2); /* { dg-error "passing argument 2 of 'transpose2' from incompatible pointer type" } */
+ transpose2(y2, x2);
+ // initialization
+ const double (*x0p) = x0;
+ const double (*x1p)[2] = x1;
+ const double (*x2p)[2][2] = x2;
+ double (*v0p) = z0; /* { dg-error "initialization discards 'const' qualifier from pointer target type" } */
+ double (*v1p)[2] = z1; /* { dg-error "initialization discards" } */
+ double (*v2p)[2][2] = z2; /* { dg-error "initialization discards" } */
+ // assignment
+ x0p = x0;
+ x1p = x1;
+ x2p = x2;
+ // subtraction
+ &(x0[1]) - &(z0[0]);
+ &(x1[1]) - &(z1[0]);
+ &(x2[1]) - &(z2[0]);
+ // comparison
+ x0 == z0;
+ x1 == z1;
+ x2 == z2;
+ x0 < z0;
+ x1 < z1;
+ x2 < z2;
+ x0 > z0;
+ x1 > z1;
+ x2 > z2;
+ // conditional expressions
+ (void)(1 ? x0 : z0);
+ (void)(1 ? x1 : z1);
+ (void)(1 ? x2 : z2);
+ (void)(1 ? x0 : x1); /* { dg-error "pointer type mismatch in conditional expression" } */
+ (void)(1 ? x1 : x2); /* { dg-error "pointer type mismatch in conditional expression" } */
+ (void)(1 ? x2 : x0); /* { dg-error "pointer type mismatch in conditional expression" } */
+ v0p = (1 ? z0 : v0p); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? z1 : v1p); /* { dg-error "assignment discards" } */
+ v2p = (1 ? z2 : v2p); /* { dg-error "assignment discards" } */
+ v0p = (1 ? x0 : x0p); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? x1 : x1p); /* { dg-error "assignment discards" } */
+ v2p = (1 ? x2 : x2p); /* { dg-error "assignment discards" } */
+ (1 ? x0 : z0)[0] = 1; /* { dg-error "assignment of read-only location" } */
+ (1 ? x1 : z1)[0][0] = 1; /* { dg-error "assignment of read-only location" } */
+ (1 ? x2 : z2)[0][0][0] = 1; /* { dg-error "assignment of read-only location" } */
+ v0p = (1 ? p : z0); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? p : z1); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v2p = (1 ? p : z2); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v0p = (1 ? pc : x0); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? pc : x1); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v2p = (1 ? pc : x2); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+}
+
diff --git a/gcc/testsuite/gcc.dg/c2x-qual-6.c b/gcc/testsuite/gcc.dg/c2x-qual-6.c
new file mode 100644
index 0000000..9c91e20
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-qual-6.c
@@ -0,0 +1,114 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -Wc11-c2x-compat -pedantic-errors" } */
+void tvoid(void* x);
+void transpose0(double* out, const double* in) { }
+void transpose1(double out[2][2], const double in[2][2]) { }
+void transpose2(double out[2][2][2], const double in[2][2][2]) { }
+// return
+int (*x2(const int x[3][3]))[3] { return x; } /* { dg-warning "before C2X" } */
+ /* { dg-error "return discards" "" { target *-*-* } .-1 } */
+const int (*x3(int x[3][3]))[3] { return x; } /* { dg-warning "before C2X" } */
+void test(void)
+{
+ double x0[2];
+ double y0[2];
+ const double z0[4];
+ double x1[2][2];
+ double y1[2][2];
+ double o1[2][3];
+ const double z1[2][2];
+ double x2[2][2][2];
+ double y2[2][2][2];
+ double o2[2][2][3];
+ const double z2[2][2][2];
+ // void pointers
+ tvoid(z0); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */
+ tvoid(z1); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */
+ tvoid(z2); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */
+ void* p;
+ const void* pc;
+ p = x0;
+ p = x1;
+ p = x2;
+ p = z0; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ p = z1; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ p = z2; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ pc = x0;
+ pc = x1;
+ pc = x2;
+ pc = z0;
+ pc = z1;
+ pc = z2;
+ transpose0(pc, p); /* { dg-error "passing argument 1 of 'transpose0' discards 'const' qualifier from pointer target type" } */
+ transpose1(pc, p); /* { dg-error "passing argument 1 of 'transpose1' discards 'const' qualifier from pointer target type" } */
+ transpose2(pc, p); /* { dg-error "passing argument 1 of 'transpose2' discards 'const' qualifier from pointer target type" } */
+ transpose0(p, pc);
+ transpose1(p, pc); /* { dg-warning "before C2X" } */
+ transpose2(p, pc); /* { dg-warning "before C2X" } */
+ // passing as arguments
+ transpose0(y0, x0);
+ transpose1(y1, o1); /* { dg-error "passing argument 2 of 'transpose1' from incompatible pointer type" } */
+ transpose1(y1, x1); /* { dg-warning "before C2X" } */
+ transpose2(y2, o2); /* { dg-error "passing argument 2 of 'transpose2' from incompatible pointer type" } */
+ transpose2(y2, x2); /* { dg-warning "before C2X" } */
+ // initialization
+ const double (*x0p) = x0;
+ const double (*x1p)[2] = x1; /* { dg-warning "before C2X" } */
+ const double (*x2p)[2][2] = x2; /* { dg-warning "before C2X" } */
+ double (*v0p) = z0; /* { dg-error "initialization discards 'const' qualifier from pointer target type" } */
+ double (*v1p)[2] = z1; /* { dg-warning "before C2X" } */
+ /* { dg-error "initialization discards" "" { target *-*-* } .-1 } */
+ double (*v2p)[2][2] = z2; /* { dg-warning "before C2X" } */
+ /* { dg-error "initialization discards" "" { target *-*-* } .-1 } */
+
+ // assignment
+ x0p = x0;
+ x1p = x1; /* { dg-warning "before C2X" } */
+ x2p = x2; /* { dg-warning "before C2X" } */
+
+ // subtraction
+ &(x0[1]) - &(z0[0]);
+ &(x1[1]) - &(z1[0]); /* { dg-warning "before C2X" } */
+ &(x2[1]) - &(z2[0]); /* { dg-warning "before C2X" } */
+ // comparison
+ x0 == z0;
+ x1 == z1; /* { dg-warning "before C2X" } */
+ x2 == z2; /* { dg-warning "before C2X" } */
+ x0 < z0;
+ x1 < z1; /* { dg-warning "before C2X" } */
+ x2 < z2; /* { dg-warning "before C2X" } */
+ x0 > z0;
+ x1 > z1; /* { dg-warning "before C2X" } */
+ x2 > z2; /* { dg-warning "before C2X" } */
+ // conditional expressions
+ (void)(1 ? x0 : z0);
+ (void)(1 ? x1 : z1); /* { dg-warning "before C2X" } */
+ (void)(1 ? x2 : z2); /* { dg-warning "before C2X" } */
+ (void)(1 ? x0 : x1); /* { dg-error "pointer type mismatch in conditional expression" } */
+ (void)(1 ? x1 : x2); /* { dg-error "pointer type mismatch in conditional expression" } */
+ (void)(1 ? x2 : x0); /* { dg-error "pointer type mismatch in conditional expression" } */
+ v0p = (1 ? z0 : v0p); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? z1 : v1p); /* { dg-warning "before C2X" } */
+ /* { dg-error "assignment discards" "" { target *-*-* } .-1 } */
+ v2p = (1 ? z2 : v2p); /* { dg-warning "before C2X" } */
+ /* { dg-error "assignment discards" "" { target *-*-* } .-1 } */
+ v0p = (1 ? x0 : x0p); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? x1 : x1p); /* { dg-error "assignment discards" } */
+ /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */
+ v2p = (1 ? x2 : x2p); /* { dg-error "assignment discards" } */
+ /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */
+ (1 ? x0 : z0)[0] = 1; /* { dg-error "assignment of read-only location" } */
+ (1 ? x1 : z1)[0][0] = 1; /* { dg-error "assignment of read-only location" } */
+ /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */
+ (1 ? x2 : z2)[0][0][0] = 1; /* { dg-error "assignment of read-only location" } */
+ /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */
+ v0p = (1 ? p : z0); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? p : z1); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */
+ v2p = (1 ? p : z2); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */
+ v0p = (1 ? pc : x0); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v1p = (1 ? pc : x1); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+ v2p = (1 ? pc : x2); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */
+}
+
diff --git a/gcc/testsuite/gcc.dg/c2x-qual-7.c b/gcc/testsuite/gcc.dg/c2x-qual-7.c
new file mode 100644
index 0000000..5fe15e1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-qual-7.c
@@ -0,0 +1,16 @@
+/* Tests related to qualifiers and pointers to arrays in C2X, PR98397 */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+/* test that _Atomic qualifier is not preserved in tertiary operator for pointers to arrays in C2X */
+
+void f(void)
+{
+ _Atomic void *u;
+ void *v;
+ _Static_assert(_Generic(1 ? u : v, _Atomic void*: 0, void*: 1), "_Atomic should be removed");
+ _Static_assert(_Generic(1 ? v : u, _Atomic void*: 0, void*: 1), "_Atomic should be removed");
+}
+
+
+
diff --git a/gcc/testsuite/gcc.dg/c2x-unproto-1.c b/gcc/testsuite/gcc.dg/c2x-unproto-1.c
new file mode 100644
index 0000000..45d68f2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-unproto-1.c
@@ -0,0 +1,20 @@
+/* Test compatibility of unprototyped and prototyped function types (C2x makes
+ the case of types affected by default argument promotions compatible). Test
+ valid-in-C2x usages. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+void f1 ();
+void f1 (float);
+
+void f2 (float);
+void f2 ();
+
+void f3 ();
+void f3 (char);
+
+void f4 (char);
+void f4 ();
+
+/* Built-in function case. */
+float sqrtf ();
diff --git a/gcc/testsuite/gcc.dg/c2x-unproto-2.c b/gcc/testsuite/gcc.dg/c2x-unproto-2.c
new file mode 100644
index 0000000..f826b7c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c2x-unproto-2.c
@@ -0,0 +1,21 @@
+/* Test compatibility of unprototyped and prototyped function types (C2x makes
+ the case of types affected by default argument promotions compatible). Test
+ invalid-in-C2x usages. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+void f1 (); /* { dg-message "previous declaration" } */
+void f1 (int, ...); /* { dg-error "conflicting types" } */
+/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */
+
+void f2 (int, ...); /* { dg-message "previous declaration" } */
+void f2 (); /* { dg-error "conflicting types" } */
+/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */
+
+void f3 (); /* { dg-message "previous declaration" } */
+void f3 (char, ...); /* { dg-error "conflicting types" } */
+/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */
+
+void f4 (char, ...); /* { dg-message "previous declaration" } */
+void f4 (); /* { dg-error "conflicting types" } */
+/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */
diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1_generate.c b/gcc/testsuite/gcc.dg/compat/struct-layout-1_generate.c
index 75e902c..35dff89 100644
--- a/gcc/testsuite/gcc.dg/compat/struct-layout-1_generate.c
+++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1_generate.c
@@ -1280,6 +1280,8 @@ subvalues (struct entry *e, char *p, char *letter)
if (e[0].len != 0)
output_FNB ('B', e);
return 1;
+ default:
+ return 0;
}
}
diff --git a/gcc/testsuite/gcc.dg/cpp/c11-elifdef-1.c b/gcc/testsuite/gcc.dg/cpp/c11-elifdef-1.c
new file mode 100644
index 0000000..2d5809a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/c11-elifdef-1.c
@@ -0,0 +1,16 @@
+/* Test #elifdef and #elifndef not in C11. */
+/* { dg-do preprocess } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+#define A
+#undef B
+
+#if 0
+#elifdef A
+#error "#elifdef A applied"
+#endif
+
+#if 0
+#elifndef B
+#error "#elifndef B applied"
+#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/c2x-elifdef-1.c b/gcc/testsuite/gcc.dg/cpp/c2x-elifdef-1.c
new file mode 100644
index 0000000..b23e311
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/c2x-elifdef-1.c
@@ -0,0 +1,57 @@
+/* Test #elifdef and #elifndef in C2x. */
+/* { dg-do preprocess } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+#define A
+#undef B
+
+#if 0
+#elifdef A
+#define M1 1
+#endif
+
+#if M1 != 1
+#error "#elifdef A did not apply"
+#endif
+
+#if 0
+#elifdef B
+#error "#elifdef B applied"
+#endif
+
+#if 0
+#elifndef A
+#error "#elifndef A applied"
+#endif
+
+#if 0
+#elifndef B
+#define M2 2
+#endif
+
+#if M2 != 2
+#error "#elifndef B did not apply"
+#endif
+
+#if 0
+#elifdef A
+#else
+#error "#elifdef A did not apply"
+#endif
+
+#if 0
+#elifndef B
+#else
+#error "#elifndef B did not apply"
+#endif
+
+/* As with #elif, the syntax of the new directives is relaxed after a
+ non-skipped group. */
+
+#if 1
+#elifdef x * y
+#endif
+
+#if 1
+#elifndef !
+#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/c2x-elifdef-2.c b/gcc/testsuite/gcc.dg/cpp/c2x-elifdef-2.c
new file mode 100644
index 0000000..9132832
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/c2x-elifdef-2.c
@@ -0,0 +1,63 @@
+/* Test #elifdef and #elifndef in C2x: erroneous usages. */
+/* { dg-do preprocess } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+#define A
+#undef B
+
+#elifdef A /* { dg-error "#elifdef without #if" } */
+#elifdef B /* { dg-error "#elifdef without #if" } */
+#elifndef A /* { dg-error "#elifndef without #if" } */
+#elifndef B /* { dg-error "#elifndef without #if" } */
+
+#if 1 /* { dg-error "-:began here" } */
+#else
+#elifdef A /* { dg-error "#elifdef after #else" } */
+#endif
+
+#if 1 /* { dg-error "-:began here" } */
+#else
+#elifdef B /* { dg-error "#elifdef after #else" } */
+#endif
+
+#if 1 /* { dg-error "-:began here" } */
+#else
+#elifndef A /* { dg-error "#elifndef after #else" } */
+#endif
+
+#if 1 /* { dg-error "-:began here" } */
+#else
+#elifndef B /* { dg-error "#elifndef after #else" } */
+#endif
+
+#if 0
+#elifdef A = /* { dg-error "extra tokens at end of #elifdef directive" } */
+#endif
+
+#if 0
+#elifdef B = /* { dg-error "extra tokens at end of #elifdef directive" } */
+#endif
+
+#if 0
+#elifndef A = /* { dg-error "extra tokens at end of #elifndef directive" } */
+#endif
+
+#if 0
+#elifndef B = /* { dg-error "extra tokens at end of #elifndef directive" } */
+#endif
+
+#if 0
+#elifdef /* { dg-error "no macro name given in #elifdef directive" } */
+#endif
+
+#if 0
+#elifndef /* { dg-error "no macro name given in #elifndef directive" } */
+#endif
+
+#if 0
+#elifdef , /* { dg-error "macro names must be identifiers" } */
+#endif
+
+#if 0
+#elifndef , /* { dg-error "macro names must be identifiers" } */
+#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/pr100392.c b/gcc/testsuite/gcc.dg/cpp/pr100392.c
new file mode 100644
index 0000000..670ad2b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr100392.c
@@ -0,0 +1,5 @@
+/* PR preprocessor/100392 */
+/* { dg-do compile } */
+/* { dg-options "-save-temps -fdirectives-only" } */
+
+#include "pr100392.h"
diff --git a/gcc/testsuite/gcc.dg/cpp/pr100392.h b/gcc/testsuite/gcc.dg/cpp/pr100392.h
new file mode 100644
index 0000000..340bc92
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr100392.h
@@ -0,0 +1,4 @@
+/* PR preprocessor/100392 */
+
+/* No newline after ; below. */
+int i = 1; \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/cpp/pr100646-1.c b/gcc/testsuite/gcc.dg/cpp/pr100646-1.c
new file mode 100644
index 0000000..8f2caf4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr100646-1.c
@@ -0,0 +1,5 @@
+/* PR preprocessor/100646 */
+/* { dg-do compile } */
+/* { dg-options "-fdirectives-only -save-temps -std=c17" } */
+int main () { return 0; }
+// Not newline terminated \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/cpp/pr100646-2.c b/gcc/testsuite/gcc.dg/cpp/pr100646-2.c
new file mode 100644
index 0000000..a1deba1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr100646-2.c
@@ -0,0 +1,6 @@
+/* PR preprocessor/100646 */
+/* { dg-do compile } */
+/* { dg-options "-fdirectives-only -save-temps -std=c17" } */
+int main () { return 0; }
+/* { dg-warning "backslash-newline at end of file" "" { target *-*-* } .+1 } */
+// Not newline terminated\ \ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/cpp/pr101638.c b/gcc/testsuite/gcc.dg/cpp/pr101638.c
new file mode 100644
index 0000000..1030473
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr101638.c
@@ -0,0 +1,7 @@
+/* PR preprocessor/101638 */
+/* { dg-do preprocess } */
+/* { dg-options "-Wtraditional" } */
+
+#define foo(attr) __has_attribute(attr)
+#if foo(__deprecated__)
+#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/ucnid-4-utf8.c b/gcc/testsuite/gcc.dg/cpp/ucnid-4-utf8.c
index ccc7a1e..0a527ef 100644
--- a/gcc/testsuite/gcc.dg/cpp/ucnid-4-utf8.c
+++ b/gcc/testsuite/gcc.dg/cpp/ucnid-4-utf8.c
@@ -9,9 +9,9 @@
Ö
΄
-Ù© /* { dg-error "not valid at the start of an identifier" } */
+Ù©
AÙ©
0º
0Ù©
-๙ /* { dg-error "not valid at the start of an identifier" } */
+๙
A๙
diff --git a/gcc/testsuite/gcc.dg/cpp/ucnid-4.c b/gcc/testsuite/gcc.dg/cpp/ucnid-4.c
index e41a3f5..dceed66 100644
--- a/gcc/testsuite/gcc.dg/cpp/ucnid-4.c
+++ b/gcc/testsuite/gcc.dg/cpp/ucnid-4.c
@@ -9,9 +9,9 @@
\u00D6
\u0384
-\u0669 /* { dg-error "not valid at the start of an identifier" } */
+\u0669
A\u0669
0\u00BA
0\u0669
-\u0E59 /* { dg-error "not valid at the start of an identifier" } */
+\u0E59
A\u0E59
diff --git a/gcc/testsuite/gcc.dg/cpp/ucnid-5-utf8.c b/gcc/testsuite/gcc.dg/cpp/ucnid-5-utf8.c
new file mode 100644
index 0000000..79767b4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/ucnid-5-utf8.c
@@ -0,0 +1,17 @@
+/* { dg-do preprocess } */
+/* { dg-options "-std=c99 -pedantic" } */
+
+ª
+« /* not a preprocessing error because we lex it into its own token */
+¶ /* not a preprocessing error because we lex it into its own token */
+º
+À
+Ö
+΄ /* not a preprocessing error because we lex it into its own token */
+
+Ù© /* { dg-error "not valid at the start of an identifier" } */
+AÙ©
+0º
+0Ù©
+๙ /* { dg-error "not valid at the start of an identifier" } */
+A๙
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-1.c
new file mode 100644
index 0000000..bcbc949
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-1.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-gbtf" } */
+
+void func(void)
+{
+}
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-2.c b/gcc/testsuite/gcc.dg/debug/btf/btf-2.c
new file mode 100644
index 0000000..70e2ff1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-2.c
@@ -0,0 +1,10 @@
+/* Check the BTF header information. */
+
+/* { dg-do compile } */
+/* { dg-options "-gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "0xeb9f.*btf_magic" 1} } */
+/* { dg-final { scan-assembler-times "0x1.*btf_version" 1 } } */
+/* { dg-final { scan-assembler-times "0.*btf_flags" 1 } } */
+
+int foo;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-struct-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-struct-1.c
new file mode 100644
index 0000000..89a5701
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-struct-1.c
@@ -0,0 +1,23 @@
+/* Test BTF generation of anonymous struct.
+
+ We expect two BTF struct records:
+ - struct foo, with two fields "a" and "bar"
+ - struct <anonymous> with one field "b"
+
+ The anonymous struct should have a name of 0, pointing to the null string
+ at the start of the string table. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* Struct type with 2 members (struct foo). */
+/* { dg-final { scan-assembler-times "\[\t \]0x4000002\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* Struct type with 1 member (anon struct). */
+/* { dg-final { scan-assembler-times "\[\t \]0x4000001\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*btt_name" 1 } } */
+
+struct foo
+{
+ int a;
+ struct { int b; } bar;
+} myfoo;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-union-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-union-1.c
new file mode 100644
index 0000000..f3b120bb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-anonymous-union-1.c
@@ -0,0 +1,23 @@
+/* Test BTF generation of anonymous union.
+
+ We expect a named struct type and an anonymous union type record to
+ be generated. The anonymous union record should have a name of 0,
+ pointing to the null string at the start of the string table. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* Struct type with 1 member. */
+/* { dg-final { scan-assembler-times "\[\t \]0x4000001\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* Union type with 2 members. */
+/* { dg-final { scan-assembler-times "\[\t \]0x5000002\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*btt_name" 1 } } */
+
+struct foo
+{
+ union
+ {
+ int value;
+ char ascii;
+ };
+} myfoo;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-array-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-array-1.c
new file mode 100644
index 0000000..ab55445
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-array-1.c
@@ -0,0 +1,31 @@
+/* BTF generation for array type.
+
+ Unsized arrays are encoded with a 0 for the number of elements.
+
+ In this testcase, 5 distinct BTF records for arrays are expected
+ b1 : cta_nelems = 2
+ c1 : cta_nelems = 3
+ a1 : cta_nelems = 2, 5
+ buf : cta_nelems = 0. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "0x3000000\[\t \]+\[^\n\]*btt_info" 5 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*bta_nelems" 2 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x3\[\t \]+\[^\n\]*bta_nelems" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*bta_nelems" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*bta_nelems" 1 } } */
+
+int b1[2] = {0,1};
+int c1[5] = {0,1,2,3,4};
+int a1[2][3] = { {3,4,5}, {2,3,4} };
+
+/* Variable length struct using arrays. */
+struct my_array
+{
+ int flags;
+ int length;
+ int buf[];
+} my_array_obj;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-1.c
new file mode 100644
index 0000000..c6bf521
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-1.c
@@ -0,0 +1,34 @@
+/* Basic tests for BTF bitfields.
+
+ The structure containing bitfield members should be marked with KIND_FLAG=1
+ The bitfield member offsets should be encoded as:
+ (bit_size << 24) | bit_offset
+ - (0xa << 24) | 0x20
+ - (0x7 << 24) | 0x2a
+ - (0x13 << 24) | 0x40 - note that this is aligned to 0x40. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x84000004\[\t \]+\[^\n\]*btt_info" 1 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0xa000020\[\t \]+\[^\n\]*btm_offset" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x700002a\[\t \]+\[^\n\]*btm_offset" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x13000040\[\t \]+\[^\n\]*btm_offset" 1 } } */
+
+struct bitt {
+ int a;
+ unsigned int bitfield_a : 10;
+ unsigned int bitfield_b : 7;
+ unsigned int bitfield_c : 19;
+} bitty;
+
+struct no_bitt {
+ int a;
+ int b;
+} no_bitty;
+
+int main ()
+{
+ return bitty.bitfield_b + bitty.a;
+}
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-2.c b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-2.c
new file mode 100644
index 0000000..9665ab6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-2.c
@@ -0,0 +1,26 @@
+/* Test BTF generation for struct with 0 size bitfield.
+
+ We expect a struct with 2 members to be generated. The size 0 bitfield
+ should not have any entry in the member list. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* Struct with bitfield members, and 2 members. */
+/* { dg-final { scan-assembler-times "\[\t \]0x84000002\[\t \]+\[^\n\]*btt_info" 1 } } */
+
+/* Bitfield size 31 (0x1f) at offset 0. */
+/* { dg-final { scan-assembler-times "\[\t \]0x1f000000\[\t \]+\[^\n\]*btm_offset" 1 } } */
+
+/* Bitfield size 32 (0x20) at offset 32. */
+/* { dg-final { scan-assembler-times "\[\t \]0x20000020\[\t \]+\[^\n\]*btm_offset" 1 } } */
+
+/* Only 2 members. */
+/* { dg-final { scan-assembler-times "btm_name" 2 } } */
+
+struct foo
+{
+ unsigned a : 31;
+ unsigned : 0;
+ unsigned c : 32;
+} myfoo;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-3.c b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-3.c
new file mode 100644
index 0000000..2984a33
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-3.c
@@ -0,0 +1,38 @@
+/* Test BTF generation for enum-type bitfields
+
+ It is allowed to have a bitfield type be an enum type.
+ We expect the following types:
+
+ [1] enum 'foo'(1U#B) size=4U#B
+ 'BAR' value=0
+ 'BAZ' value=1
+ 'QUZ' value=2
+ 'QUX' value=3
+ [2] int 'unsigned int' size=4 offset=0 bits=32
+ [3] struct 'bitt' size=4
+ member 'f' type=1 bitfield_size=2 bit_offset=0
+ */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* Enum with 4 members. */
+/* { dg-final { scan-assembler-times "\[\t \]0x6000004\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* Struct with 1 bitfield member. */
+/* { dg-final { scan-assembler-times "\[\t \]0x84000001\[\t \]+\[^\n\]*btt_info" 1 } } */
+
+/* Bitfield "f" points to type ID 1. */
+/* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*btm_type" 1 } } */
+
+enum foo
+{
+ BAR = 0,
+ BAZ = 1,
+ QUZ = 2,
+ QUX = 3
+};
+
+struct bitt
+{
+ enum foo f : 2;
+} bitty;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-4.c b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-4.c
new file mode 100644
index 0000000..af91845
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-4.c
@@ -0,0 +1,23 @@
+/* Test BTF generation for non-representable bitfields.
+
+ Due to the limitations of BTF, we only have 24 bits in which to store
+ the bitfield offset (in bits, from the beginning of the struct).
+
+ In this test, we construct a structure such that the bitfield will have
+ an offset so large as to be unrepresentable in BTF. We expect that the
+ resulting BTF will describe the rest of the structure, ignoring the
+ non-representable bitfield. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* Struct with 3 members and no bitfield (kind_flag not set). */
+/* { dg-final { scan-assembler-times "\[\t \]0x4000003\[\t \]+\[^\n\]*btt_info" 1 } } */
+
+struct bigly
+{
+ int a;
+ int b[((0xffffff + 1) / (8 * sizeof (int)))];
+ unsigned unsup : 7;
+ char c;
+} big;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-cvr-quals-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-cvr-quals-1.c
new file mode 100644
index 0000000..33e2f64
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-cvr-quals-1.c
@@ -0,0 +1,53 @@
+/* Test BTF generation of BTF_KIND_{CONST,VOLATILE,RESTRICT} records.
+
+ BTF const, volatile and restrict records are nameless type records pointing
+ to the type they modify.
+
+ Types:
+ [1] int 'int' size=4U offset=0 bits=32 SIGNED
+ [2] const <anonymous> type=1
+ [3] volatile <anonymous> type=1
+ [4] const <anonymous> type=3
+ [5] ptr <anonymous> type=1
+ [6] restrict <anonymous> type=5
+ [7] ptr <anonymous> type=2
+ [8] restrict <anonymous> type=7
+
+ Note:
+ - Type id 3 describes a volatile int.
+ - Type id 2 describes a const int.
+ - Type id 4 describes a const volatile int by modifying id 3.
+ - Type id 6 describes a restrict pointer to int.
+ - Type id 8 describes a restrict pointer to const int.
+ */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+/* { dg-options "-O0 -gbtf -gdwarf-4 -dA" { target { *-*-darwin* } } } */
+
+/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+
+/* types 5 and 7 are pointers, to 'int' and 'const int' respectively. */
+/* { dg-final { scan-assembler-times "\[\t \]0x2000000\[\t \]+\[^\n\]*btt_info" 2 } } */
+
+/* type 3 has VOLATILE qualifier */
+/* { dg-final { scan-assembler-times "\[\t \]0x9000000\[\t \]+\[^\n\]*btt_info" 1 } } */
+
+/* types 2 and 4 have CONST qualifier. */
+/* { dg-final { scan-assembler-times "\[\t \]0xa000000\[\t \]+\[^\n\]*btt_info" 2 } } */
+
+/* types 6 and 8 have RESTRICT qualifier. */
+/* { dg-final { scan-assembler-times "\[\t \]0xb000000\[\t \]+\[^\n\]*btt_info" 2 } } */
+
+const int a = 10;
+
+volatile int b;
+
+int * restrict c;
+
+const volatile int d = 20;
+
+const int * restrict e;
+
+const int * f;
+int const * g;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c
new file mode 100644
index 0000000..f809d93
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c
@@ -0,0 +1,46 @@
+/* BTF generation of BTF_KIND_DATASEC records.
+
+ We expect 3 DATASEC records: one for each of .data, .rodata and .bss.
+ .rodata: the consts; c,e,my_cstruct
+ .bss: a,b,bigarr
+ .data: d
+
+ The type IDs of the variables placed in each section are not deterministic
+ so we cannot check them.
+ */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gbtf -dA" } */
+/* { dg-options "-O0 -gbtf -dA -msdata=none" { target { { powerpc*-*-* } && ilp32 } } } */
+
+/* Check for two DATASEC entries with vlen 3, and one with vlen 1. */
+/* { dg-final { scan-assembler-times "0xf000003\[\t \]+\[^\n\]*btt_info" 2 } } */
+/* { dg-final { scan-assembler-times "0xf000001\[\t \]+\[^\n\]*btt_info" 1 } } */
+
+/* The offset entry for each variable in a DATSEC should be 0 at compile time. */
+/* { dg-final { scan-assembler-times "0\[\t \]+\[^\n\]*bts_offset" 7 } } */
+
+/* Check that strings for each DATASEC have been added to the BTF string table. */
+/* { dg-final { scan-assembler-times "ascii \".data.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \".rodata.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \".bss.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
+
+int a;
+long long b;
+const long unsigned int c;
+
+int d = 137;
+
+const int e = -55;
+
+int bigarr[20][10];
+
+struct c_struct {
+ long x;
+ char c;
+};
+
+const struct c_struct my_cstruct = {
+ 99,
+ '?'
+};
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c
new file mode 100644
index 0000000..728493b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c
@@ -0,0 +1,30 @@
+/* Test BTF generation for enums. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x6000004\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x6000003\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"QAD.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"QED.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"QOD.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"QUD.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"YES.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"NO.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"IDUNNO.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "bte_value" 7 } } */
+
+enum foo
+{
+ QAD,
+ QED,
+ QOD,
+ QUD,
+} a;
+
+enum barsigned
+{
+ YES=1000,
+ NO=-1000,
+ IDUNNO=0,
+} b;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-float-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-float-1.c
new file mode 100644
index 0000000..6876df0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-float-1.c
@@ -0,0 +1,20 @@
+/* Tests for BTF floating point type kinds. We expect a single record for each
+ of the base types: float, double and long double. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x10000000\[\t \]+\[^\n\]*btt_info" 3 } } */
+
+/* { dg-final { scan-assembler-times "ascii \"float.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"double.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"long double.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+
+float a;
+float b = 1.5f;
+
+double c;
+double d = -99.9;
+
+long double e;
+long double f = 1000.01;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-forward-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-forward-1.c
new file mode 100644
index 0000000..c894fa2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-forward-1.c
@@ -0,0 +1,24 @@
+/* Test BTF generation of forwards.
+
+ Check that the KIND_FLAG (bit 31) of btt_info is set (1) for the forward to
+ union, and not set (0) for forward to struct. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x87000000\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x7000000\[\t \]+\[^\n\]*btt_info" 1 } } */
+
+typedef struct _fwd_st
+{
+ struct unk_struct_type *data[4];
+} fwd_st_t;
+
+fwd_st_t struct_container;
+
+typedef struct _fwd_un
+{
+ union unk_union_type *options[4];
+} fwd_un_t;
+
+fwd_un_t union_container;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-function-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-function-1.c
new file mode 100644
index 0000000..9fa1498
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-function-1.c
@@ -0,0 +1,18 @@
+/* Test BTF generation for functions.
+
+ We expect to see one BTF_KIND_FUNC_PROTO with 2 named arguments.
+ The parameter names should appear in the auxilliary string table. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0xd000002\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* { dg-final { scan-assembler-times "farg_name" 2 } } */
+/* { dg-final { scan-assembler-times "farg_type" 2 } } */
+/* { dg-final { scan-assembler-times "ascii \"alpha.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"bravo.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
+
+int funfoo (int alpha, long bravo)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-function-2.c b/gcc/testsuite/gcc.dg/debug/btf/btf-function-2.c
new file mode 100644
index 0000000..3c7fda9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-function-2.c
@@ -0,0 +1,18 @@
+/* Test BTF generation for functions with varargs.
+
+ We expect one BTF_KIND_FUNC_PROTO with two arguments. The second argument
+ should have "farg_name" and "farg_type" both of 0, representing varargs. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0xd000002\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* { dg-final { scan-assembler-times "farg_name" 2 } } */
+/* { dg-final { scan-assembler-times "farg_type" 2 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*farg_name" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*farg_type" 1 } } */
+
+int fmt (const char * format, ...)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-function-3.c b/gcc/testsuite/gcc.dg/debug/btf/btf-function-3.c
new file mode 100644
index 0000000..c83b823
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-function-3.c
@@ -0,0 +1,22 @@
+/* Test BTF generation for a function with an unrepresentable parameter.
+
+ BTF has no encoding for floating point types, among others. Function
+ parameters of unrepresentable types are emitted as 'void' types.
+
+ We expect one BTF_KIND_FUNC_PROTO with 3 parameters, one of which
+ has type_id=0. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0xd000003\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* { dg-final { scan-assembler-times "farg_name" 3 } } */
+/* { dg-final { scan-assembler-times "farg_type" 3 } } */
+
+/* Exactly one function parameter should have type_id=0. */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*farg_type" 1 } } */
+
+int foo (int a, float __attribute__((__vector_size__(16))) f, long b)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c
new file mode 100644
index 0000000..2381dec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-int-1.c
@@ -0,0 +1,44 @@
+/* Tests for BTF integer base types.
+
+ 0 f ff 00 ff
+ | 0 | encoding | offset | 00 | bits |
+ encoding:
+ signed 1 << 24
+ char 2 << 24
+
+ All offsets in this test should be 0.
+ This test does _not_ check number of bits, as it may vary between targets.
+ */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* Check for 8 BTF_KIND_INT types. */
+/* { dg-final { scan-assembler-times "\[\t \]0x1000000\[\t \]+\[^\n\]*btt_info" 8 } } */
+
+/* Check the signed/char flags, but not bit size. */
+/* { dg-final { scan-assembler-times "\[\t \]0x10000..\[\t \]+\[^\n\]*bti_encoding" 3 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x20000..\[\t \]+\[^\n\]*bti_encoding" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x30000..\[\t \]+\[^\n\]*bti_encoding" 1 } } */
+
+/* Check that there is a string entry for each type name. */
+/* { dg-final { scan-assembler-times "ascii \"unsigned char.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"signed char.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"short unsigned int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"short int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"unsigned int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"long unsigned int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"long int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+
+unsigned char a = 11;
+signed char b = -22;
+
+unsigned short c = 33;
+signed short d = 44;
+
+unsigned int e = 55;
+signed int f = -66;
+
+unsigned long int g = 77;
+signed long int h = 88;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-pointers-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-pointers-1.c
new file mode 100644
index 0000000..a14ac0f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-pointers-1.c
@@ -0,0 +1,25 @@
+/* Test BTF generation for pointer types.
+
+ Two pointer types are expected:
+ - int *
+ - struct st *
+ */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x2000000\[\t \]+\[^\n\]*btt_info" 2 } } */
+/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"st.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+
+int foo = 10;
+int *pfoo = &foo;
+
+struct st
+{
+ int a;
+ int *pb;
+ struct st * next;
+};
+
+struct st * bar;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-pointers-2.c b/gcc/testsuite/gcc.dg/debug/btf/btf-pointers-2.c
new file mode 100644
index 0000000..c77b224
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-pointers-2.c
@@ -0,0 +1,13 @@
+/* Test BTF generation for pointers to void.
+
+ In this test, we expect that the pointer references type ID 0, the reserved
+ void typeid, and that no intermediate type is generated for void. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x2000000\[\t \]+\[^\n\]*btt_info" 1 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x1000000\[\t \]+\[^\n\]*btt_info" 0 } } */
+
+void *ptr;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-struct-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-struct-1.c
new file mode 100644
index 0000000..bc32814
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-struct-1.c
@@ -0,0 +1,22 @@
+/* Test BTF generation of struct type.
+
+ Two BTF_KIND_STRUCT records are expected.
+ - struct foo with 3 members
+ - struct data with 2 members */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x4000003\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x4000002\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* { dg-final { scan-assembler-times "btm_name" 5 } } */
+
+struct foo
+{
+ int after;
+ int before;
+ struct {
+ unsigned short n_valid;
+ int set[10];
+ } data;
+} my_foo;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-struct-2.c b/gcc/testsuite/gcc.dg/debug/btf/btf-struct-2.c
new file mode 100644
index 0000000..c3aff09
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-struct-2.c
@@ -0,0 +1,19 @@
+/* Test BTF generation for struct type with a member which refers to an
+ unsupported type.
+
+ BTF does not support floating point types (among other things). When
+ generating BTF for a struct (or union) type, members which refer to
+ unsupported types should be skipped. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* Expect a struct with only 2 members - 'f' should not be present. */
+/* { dg-final { scan-assembler-times "\[\t \]0x4000002\[\t \]+\[^\n\]*btt_info" 1 } } */
+
+struct with_float
+{
+ int a;
+ float __attribute__((__vector_size__(16))) f;
+ char c;
+} instance;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-typedef-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-typedef-1.c
new file mode 100644
index 0000000..472cc63
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-typedef-1.c
@@ -0,0 +1,82 @@
+/* Test BTF generation for BTF_KIND_TYPEDEF records.
+
+ 7 typedef records are expected. We expect the following types (among others):
+ [1] int 'int' size=4 offset=0 bits=32 SIGNED
+ [2] typedef 'my_int' type=1
+ [3] typedef 'foo_int' type=1
+ [4] typedef 'bar_int' type=1
+ ..
+ [6] typedef 'CBAR' type=5
+ ..
+ [8] typedef 'CBARP' type=7
+ [9] struct '_node' size=16
+ ..
+ [11] typedef 'node_t' type=9
+ [12] struct '_arena'
+ ..
+ [15] typedef 'arena_t' type=12
+ [16] var 'a' type=2 linkage=1 (global)
+ [17] var 'suitcase' type=15 linkage=1 (global)
+ [18] var 'b' type=3 linkage=1 (global)
+ [19] var 'c' type=4 linkage=1 (global)
+ [20] var 'd' type=11 linkage=1 (global)
+ [21] var 'destination' type=6 linkage=1 (global)
+ [22] var 'ticket' type=8 linkage=1 (global)
+
+ Note that the order of the variables is not guaranteed, so we do not check
+ particular variables have exactly the right typedef. Instead, we check:
+ 1. 7 typedef records are generated, along with the correct strings for them.
+ 2. There is one variable pointing to each typedef. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x8000000\[\t \]+\[^\n\]*btt_info" 7 } } */
+
+/* { dg-final { scan-assembler-times "ascii \"my_int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"foo_int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"bar_int.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"CBAR.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"CBARP.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"node_t.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"arena_t.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*btv_type" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x3\[\t \]+\[^\n\]*btv_type" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x4\[\t \]+\[^\n\]*btv_type" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x6\[\t \]+\[^\n\]*btv_type" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x8\[\t \]+\[^\n\]*btv_type" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0xb\[\t \]+\[^\n\]*btv_type" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0xf\[\t \]+\[^\n\]*btv_type" 1 } } */
+
+typedef int my_int;
+typedef int foo_int;
+typedef int bar_int;
+
+typedef const bar_int CBAR;
+typedef const bar_int * CBARP;
+
+typedef struct _node
+{
+ foo_int name_off;
+ bar_int info;
+ struct _node * next;
+} node_t;
+
+
+typedef struct _arena
+{
+ node_t nodes[16];
+ my_int vardata;
+ bar_int flags;
+} arena_t;
+
+my_int a;
+foo_int b;
+bar_int c;
+node_t d;
+
+CBAR destination;
+CBARP ticket = &destination;
+
+arena_t suitcase;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-union-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-union-1.c
new file mode 100644
index 0000000..d668437
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-union-1.c
@@ -0,0 +1,16 @@
+/* Test BTF generation for union type. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* One union type with 4 members */
+/* { dg-final { scan-assembler-times "\[\t \]0x5000004\[\t \]+\[^\n\]*btt_info" 1 } } */
+/* { dg-final { scan-assembler-times "btm_name" 4 } } */
+
+union onion
+{
+ int redness;
+ char *name;
+ unsigned short freshness;
+ unsigned short flavor;
+} my_onion;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-variables-1.c b/gcc/testsuite/gcc.dg/debug/btf/btf-variables-1.c
new file mode 100644
index 0000000..a79ed1d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-variables-1.c
@@ -0,0 +1,33 @@
+/* BTF generation for variables. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* We expect 6 variables */
+/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*btv_info" 6 } } */
+
+unsigned int x1;
+
+struct st
+{
+ int a;
+ int b;
+};
+
+union {
+ long int value;
+ struct st * pointer;
+} bar;
+
+enum
+{
+ FOO = 0,
+ BAR = 2,
+ BAZ,
+} lala;
+
+int arr[10][20];
+
+unsigned long * plong;
+
+struct st st_inst;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-variables-2.c b/gcc/testsuite/gcc.dg/debug/btf/btf-variables-2.c
new file mode 100644
index 0000000..db0bdd7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-variables-2.c
@@ -0,0 +1,27 @@
+/* BTF generation for variables with removed type.
+
+ BTF does not support floating point types, so no representation for the type
+ 'float' will be emitted. In this test, we check to also ensure that the
+ variable 'bar' is not emitted, as it references a type that is not supported
+ in BTF. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* We expect only 3 variables. */
+/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*btv_info" 3 } } */
+
+/* { dg-final { scan-assembler-times "ascii \"foo.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"baz.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"myst.0\"\[\t \]+\[^\n\]*btf_string" 1 } } */
+
+int foo;
+float __attribute__((__vector_size__(16))) bar;
+int baz[10];
+
+struct st
+{
+ int a;
+ int b : 6;
+ int c : 2;
+} myst;
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-variables-3.c b/gcc/testsuite/gcc.dg/debug/btf/btf-variables-3.c
new file mode 100644
index 0000000..8cae221
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-variables-3.c
@@ -0,0 +1,36 @@
+/* Test BTF generation for static versus global variables.
+
+ BTF_KIND_VAR types represeting variables are followed by a 32-bit
+ "linkage", which can take one of currently two valid values:
+ 0 = static
+ 1 = global
+
+ In this test, make a few static and a few global variables, and ensure
+ they are noted with the correct "linkage" values. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gbtf -dA" } */
+
+/* Expect 6 variables. */
+/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*btv_info" 6 } } */
+
+/* 3 global, 3 static. */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*btv_linkage" 3 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*btv_linkage" 3 } } */
+
+int a;
+
+static long b;
+
+struct foo {
+ int x;
+ int y;
+};
+
+struct foo g_foo;
+
+static struct foo s_foo;
+
+static unsigned int s_arr [10][5];
+
+unsigned int g_arr [20];
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf.exp b/gcc/testsuite/gcc.dg/debug/btf/btf.exp
new file mode 100644
index 0000000..15593fd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf.exp
@@ -0,0 +1,48 @@
+# Copyright (C) 2002-2019 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# Disable on ptx (in sync with DWARF testsuite)
+if { [istarget nvptx-*-*] } {
+ return
+}
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+set comp_output [gcc_target_compile \
+ "$srcdir/$subdir/../trivial.c" "trivial.S" assembly \
+ "additional_flags=-gbtf"]
+if { ! [string match "*: target system does not support the * debug format*" \
+ $comp_output] } {
+ remove-build-file "trivial.S"
+ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \
+ "" $DEFAULT_CFLAGS
+}
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-1.c
new file mode 100644
index 0000000..6f637df
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-1.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-gctf" } */
+
+void func(void)
+{
+}
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-2.c
new file mode 100644
index 0000000..ccbb109
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-2.c
@@ -0,0 +1,10 @@
+/* A LEVEL of 0 with -gctf turns off CTF debug info generation. */
+
+/* { dg-do compile } */
+/* { dg-options "-gctf0 -dA" } */
+
+/* { dg-final { scan-assembler-times "0xdff2.*CTF preamble magic number" 0} } */
+/* { dg-final { scan-assembler-times "0x4.*CTF preamble version" 0 } } */
+/* { dg-final { scan-assembler-times "0.*CTF preamble flags" 0 } } */
+
+const char * _CONTEXT_NAME = "foobar";
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-struct-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-struct-1.c
new file mode 100644
index 0000000..93547d4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-struct-1.c
@@ -0,0 +1,23 @@
+/* Test compilation and CTF generation of anonymous structs. An anonymous
+ struct type is encoded as no-name CTF struct type.
+
+ For this testcase, a single CTF anonymous struct is expected.
+ struct {} : ctt_name = 0 (point to offset 0 in the CTF string table to
+ denote empty string)
+
+ Two CTF struct records should be generated in total.
+ struct a : ctt_info = 0x1a000002 (2 fields)
+ struct {} : ctt_info = 0x1a000001 (1 field) */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctt_name" 1 } } */
+/* { dg-final { scan-assembler-times "0x1a000002\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "0x1a000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
+
+struct a
+{
+ struct { int b1; } a1;
+ int a2;
+} my_a;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-union-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-union-1.c
new file mode 100644
index 0000000..f45af9b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-union-1.c
@@ -0,0 +1,26 @@
+/* Test compilation and CTF generation of anonymous union. An anonymous union
+ is encoded as no-name CTF union type.
+
+ For this testcase, a single CTF anonymous union is expected.
+ struct {} : ctt_name = 0 (point to offset 0 in the CTF string table to
+ denote empty string)
+
+ Two CTF struct records should be generated in total.
+ struct anon_union : ctt_info = 0x1a000001 (1 field)
+ union {} : ctt_info = 0x1e000002 (2 fields) */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctt_name" 1 } } */
+/* { dg-final { scan-assembler-times "0x1a000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "0x1e000002\[\t \]+\[^\n\]*ctt_info" 1 } } */
+
+struct anon_union
+{
+ union
+ {
+ char name;
+ int value;
+ };
+} my_anon_u;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-1.c
new file mode 100644
index 0000000..006a758
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-1.c
@@ -0,0 +1,31 @@
+/* CTF generation for array type.
+
+ Unsized arrays are encoded with a 0 for the number of elements.
+
+ In this testcase, 5 distinct CTF records for arrays are expected
+ b1 : cta_nelems = 2
+ c1 : cta_nelems = 3
+ a1 : cta_nelems = 2, 5
+ buf : cta_nelems = 0. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 5 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*cta_nelems" 2 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x3\[\t \]+\[^\n\]*cta_nelems" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*cta_nelems" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*cta_nelems" 1 } } */
+
+int b1[2] = {0,1};
+int c1[5] = {0,1,2,3,4};
+int a1[2][3] = { {3,4,5}, {2,3,4} };
+
+/* Variable length struct using arrays. */
+struct my_array
+{
+ int flags;
+ int length;
+ int buf[];
+} my_array_obj;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-2.c
new file mode 100644
index 0000000..2a19da0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-2.c
@@ -0,0 +1,38 @@
+/* CTF generation for unsized arrays.
+
+ Unsized arrays are encoded with a 0 for the number of elements. The type
+ of array index is the INT type.
+
+ TBD_CTF_FORMAT_OPEN_ISSUES (1) -
+ This testcase makes a note of the case of a probable misrepresentation.
+ See Note 1 and Note 2 below.
+
+ In the CTF section, these types are encoded as :
+
+ Variables:
+ _CTF_NEWSTR -> 7: const char [0] (size 0x0)
+ _CTF_SECTION -> 6: const char [5] (size 0x5)
+ b1 -> 2: int [0] (size 0x0)
+ b2 -> 3: int [0] (size 0x0)
+
+ Note 1 : There is misrepresentation in that b1 and b2 are specified
+ differently by the user.
+ Note 2 : It is arguable though whether the representation for
+ _CTF_NEWSTR is incorrect. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 5 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*cta_nelems" 3 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*cta_nelems" 1 } } */
+
+static int b1[] = {};
+
+int b2[0];
+
+const char _CTF_SECTION[] = ".ctf";
+
+extern const char _CTF_NEWSTR[];
+const char _CTF_NEWSTR[] = "ctfinfo";
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-3.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-3.c
new file mode 100644
index 0000000..8def208
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-3.c
@@ -0,0 +1,17 @@
+/* CTF generation for variable length arrays.
+
+ In this testcase, a specific flavor of vla appears in the function
+ signature.
+
+ TBD_CTF_FORMAT_OPEN_ISSUES (1) -
+ This testcase makes a note of another case of a probable misrepresentation.
+ See ctf-array-2.c for some context on how vla's are a case of a probable
+ misrepresentation in CTF. Nevertheless, compilation should not fail. */
+
+/* { dg-do compile } */
+/* { dg-options "-gctf" } */
+
+int foo (int a, int b[a][a])
+{
+ return b[a-1][a-3];
+}
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-4.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-4.c
new file mode 100644
index 0000000..013a8ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-4.c
@@ -0,0 +1,13 @@
+/* CTF generation for array type.
+
+ Test CTF generation for single element arrays. In this testcase, one CTF
+ record for array is expected with cta_nelems = 1. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*cta_nelems" 1 } } */
+
+int b[1];
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-mode-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-mode-1.c
new file mode 100644
index 0000000..c4801a7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-mode-1.c
@@ -0,0 +1,23 @@
+/* Test CTF generation works well with ((mode)) attribute.
+
+ In this testcase, CTF should report type of bqi to be an enum and
+ not an int. Also, CTF for typedef of enum should exist. However, there
+ are no direct and portable methods of checking that a CTF type / CTF
+ variable refers to a specific CTF type, so this testcase merely asserts
+ for existence of individual CTF records. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "ascii \"B1.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"B2.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"B3.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "cte_value" 3} } */
+
+/* There are no better/direct methods to assert that the CTF for typedef of
+ enum has been added. */
+/* { dg-final { scan-assembler-times "\[\t \]0x22000003\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x2a000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+
+typedef enum { B1 = 1, B2 = 2, B3 = 3 } B;
+B __attribute__ ((mode (QI))) bqi;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-used-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-used-1.c
new file mode 100644
index 0000000..61f6b64
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-attr-used-1.c
@@ -0,0 +1,22 @@
+/* Test CTF generation works well with ((used)) function attribute.
+
+ This attribute, attached to a function, means that code must be emitted for
+ the function even if it appears that the function is not referenced. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O2 -gctf -dA" } */
+
+/* These should be true for higher optimization levels. */
+/* { dg-final { scan-assembler-times "ascii \"keep_this.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"lose_this.0\"\[\t \]+\[^\n\]*ctf_string" 0 } } */
+
+static int lose_this(int a)
+{
+ return a + 2;
+}
+
+__attribute__((used))
+static int keep_this(double a)
+{
+ return a * 2;
+}
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-1.c
new file mode 100644
index 0000000..1deac90
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-1.c
@@ -0,0 +1,30 @@
+/* CTF generation for bitfields.
+
+ In this testcase, two slices are expected - one for enum and the other for
+ int. CTF slices are unnamed records. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*cts_bits" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x3\[\t \]+\[^\n\]*cts_bits" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctt_name" 2 } } */
+
+enum color
+{
+ RED,
+ GREEN,
+ BLUE,
+ YELLOW,
+ ORANGE,
+ BLACK
+};
+
+struct quickcolor
+{
+ enum color col:3;
+ int brushid:2;
+ int strokes;
+};
+
+struct quickcolor qc;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-2.c
new file mode 100644
index 0000000..aea0921
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-2.c
@@ -0,0 +1,39 @@
+/* The bitfield type (int) may be shared, but slices are not de-duplicated.
+
+ In this testcase, it is expected to see a total of 6 CTF slices and 2 CTF
+ integer types for the bitfields - unsigned long long and signed long long.
+
+ cts_offset is the offset of the bitfield into a machine word.
+ TBD - hardcoding cts_offset checks into the testcase will cause it to break
+ across targets with different BIT_PER_WORD. Is there a way to add
+ cts_offset related checks in the testcase? */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x6\[\t \]+\[^\n\]*cts_type" 3 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*cts_type" 3 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0xf\[\t \]+\[^\n\]*cts_bits" 2 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x21\[\t \]+\[^\n\]*cts_bits" 2 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x10\[\t \]+\[^\n\]*cts_bits" 2 } } */
+
+/* { dg-final { scan-assembler-times "ascii \"long long unsigned int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"long long int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+struct fields
+{
+ unsigned long long u1 : 15;
+ unsigned long long u2 : 33;
+ unsigned long long u3 : 16;
+ signed long long s1 : 15;
+ signed long long s2 : 33;
+ signed long long s3 : 16;
+} flags;
+
+int i = 33;
+
+int main ()
+{
+ return flags.u1 + i;
+}
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-3.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-3.c
new file mode 100644
index 0000000..8fbcf12
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-3.c
@@ -0,0 +1,16 @@
+/* The bool bitfield type. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*cts_type" 2 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*cts_bits" 2 } } */
+
+/* { dg-final { scan-assembler-times "ascii \"_Bool.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+#include <stdbool.h>
+
+struct open_file {
+ bool mmapped:1;
+ bool released:1;
+} of;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-4.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-4.c
new file mode 100644
index 0000000..012069a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-4.c
@@ -0,0 +1,19 @@
+/* The zero sized bitfield.
+
+ In this testcase, two slices are expected. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*cts_type" 2 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*cts_bits" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0xa\[\t \]+\[^\n\]*cts_bits" 1 } } */
+
+/* { dg-final { scan-assembler-times "ctm_name" 2 } } */
+struct foo
+{
+ int a:5;
+ unsigned:0;
+ int b:10;
+} foome;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-complex-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-complex-1.c
new file mode 100644
index 0000000..a36dd9b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-complex-1.c
@@ -0,0 +1,21 @@
+/* Tests for CTF complex base types.
+
+ CTF does not have representation for complex integer types.
+
+ This testcase has a mix of C constructs containing COMPLEX_TYPE. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-require-effective-target libc_has_complex_functions } */
+
+/* { dg-final { scan-assembler-times "ascii \"complex double.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"complex long double.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"complex float.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+#include <complex.h>
+
+double complex z1 = I * I;
+
+const long double complex z2 = I * I;
+
+float complex z4 = 1+2.11*I;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-1.c
new file mode 100644
index 0000000..0137e9d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-1.c
@@ -0,0 +1,66 @@
+/* Test compilation of stubs with various qualifiers - const, restrict and
+ volatile.
+
+ Testcase includes a std header to allow testing of shared types across
+ files. Only one CTF record for int is expected.
+
+ CTF records for CVR qualifiers are no-name records. In this testcase, there
+ are 5 qualifiers across constructs. 2 more no-name CTF records correspond to
+ CTF pointer records.
+
+ TYPEID: name string (size) -> ref TYPEID : ref name string (size) -> ...
+
+ Types:
+ 1: long int (size 0x8)
+ 2: long unsigned int (size 0x8)
+ 3: size_t (size 0x8) -> 2: long unsigned int (size 0x8)
+ 4: int (size 0x4)
+ 5: const int (size 0x4) -> 4: int (size 0x4)
+ 6: volatile const int (size 0x4) -> 5: const int (size 0x4) -> 4: int (size 0x4)
+ 7: long long int (size 0x8)
+ 8: long double (size 0x10)
+ 9: int * (size 0x8) -> 4: int (size 0x4)
+ a: int *restrict (size 0x8) -> 9: int * (size 0x8) -> 4: int (size 0x4)
+ b: const int * (size 0x8) -> 5: const int (size 0x4) -> 4: int (size 0x4)
+ c: const int *restrict (size 0x8) -> b: const int * (size 0x8) -> 5: const int (size 0x4) -> 4: int (size 0x4)
+ d: INTP (size 0x8) -> 9: int * (size 0x8) -> 4: int (size 0x4)
+ e: const INTP (size 0x8) -> d: INTP (size 0x8) -> 9: int * (size 0x8) -> 4: int (size 0x4)
+ f: void (size 0x0)
+ 10: void (*) (size_t, int *restrict, const int *restrict) (size 0x0)
+ */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-options "-O0 -gctf -gdwarf-4 -dA" { target { *-*-darwin* } } } */
+
+/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctt_name" 7 } } */
+
+/* type id 9, b have POINTER type. */
+/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
+
+/* type id 5, e have CONST qualifier. */
+/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
+
+/* type id a, c have RESTRICT qualifier. */
+/* { dg-final { scan-assembler-times "\[\t \]0x36000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
+
+/* type id 6 has VOLATILE qualifier. */
+/* { dg-final { scan-assembler-times "\[\t \]0x2e000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+
+#include "stddef.h"
+
+const volatile int a = 5;
+int *restrict b;
+
+const int * i;
+int const * j;
+
+typedef int * INTP;
+const INTP int_p;
+
+void foo (size_t n, int *restrict p, const int *restrict q)
+{
+ while (n-- > 0)
+ *p++ = *q++;
+}
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-2.c
new file mode 100644
index 0000000..4f328f3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-2.c
@@ -0,0 +1,30 @@
+/* Test compilation of stubs with various expressions involving const
+ qualifier.
+
+ In this testcase, a single CTF record for const int is expected. A total of
+ two const qualifier CTF records are expected (const int and const struct
+ s1). */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
+
+struct mystruct
+{
+ struct
+ {
+ int a;
+ const int b;
+ } s1;
+ char * name;
+} my_a;
+
+struct s1
+{
+ int i;
+ const int ci;
+} s;
+
+const struct s1 cs;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-3.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-3.c
new file mode 100644
index 0000000..97317a4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-3.c
@@ -0,0 +1,25 @@
+/* Test compilation of stubs with various expressions involving const and
+ volatile qualifiers.
+
+ In this testcase, it is expected to have const and volatile CTF
+ records. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "ascii \"unsigned char.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x2e000000\[\t \]+\[^\n\]*ctt_info" 5 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 3 } } */
+/* Two arrays. */
+/* { dg-final { scan-assembler-times "\[\t \]0x12000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
+
+
+const volatile unsigned char vicar = 11;
+
+const volatile unsigned char * vicarage = &vicar;
+
+volatile float vilify[2];
+
+const volatile char victor = 'Y';
+
+const volatile char vindictive[2];
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-4.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-4.c
new file mode 100644
index 0000000..c1633ee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-4.c
@@ -0,0 +1,23 @@
+/* Test compilation of stubs with various qualifiers - const, restrict and
+ volatile.
+
+ CTF records for CVR qualifiers are no-name records. In this testcase, there
+ is 1 const qualifier. 1 more no-name CTF record corresponds to the CTF
+ pointer record. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctt_name" 2 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+
+typedef const struct howto_struct howto_type;
+
+typedef struct entry
+{
+ int addend;
+ howto_type *howto;
+} how_ent;
+
+how_ent hent;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-1.c
new file mode 100644
index 0000000..1ad5f25
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-1.c
@@ -0,0 +1,7 @@
+/* Verify that CTF debug info can co-exist with dwarf. */
+/* { dg-do compile } */
+/* { dg-options "-gctf -gdwarf -dA" } */
+/* { dg-final { scan-assembler "0xdff2.*CTF preamble magic number" } } */
+
+void func (void)
+{ }
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-2.c
new file mode 100644
index 0000000..df2c1eb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-debug-2.c
@@ -0,0 +1,7 @@
+/* Verify that CTF debug info can co-exist with dwarf. */
+/* { dg-do compile } */
+/* { dg-options "-gdwarf -gctf -dA" } */
+/* { dg-final { scan-assembler "0xdff2.*CTF preamble magic number" } } */
+
+void func (void)
+{ }
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-1.c
new file mode 100644
index 0000000..9693544
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-1.c
@@ -0,0 +1,21 @@
+/* CTF generation for enums. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "ascii \"RED.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"GREEN.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"BLUE.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"YELLOW.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "cte_value" 4} } */
+
+
+enum foo_color
+{
+ RED,
+ GREEN,
+ BLUE,
+ YELLOW
+};
+
+enum foo_color my_color;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-2.c
new file mode 100644
index 0000000..fd8aaec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-2.c
@@ -0,0 +1,27 @@
+/* CTF generation for enums.
+
+ CTF represents enum values with an int32_t. For enum values not
+ representable with int32_t data type, the compiler skips adding CTF for
+ them. This will be fixed soon in the CTF format.
+ TBD_CTF_REPRESENTATION_LIMIT.
+
+ In this testcase, CTF for enumerator GFS_MONOTONIC will not be generated. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "ascii \"GFS_MONOTONIC.0\"\[\t \]+\[^\n\]*ctf_string" 0 } } */
+/* { dg-final { scan-assembler-times "ascii \"GFS_RUNTIME.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"GFS_STATIC.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "cte_value" 2} } */
+
+
+enum gomp_schedule_type
+{
+ GFS_RUNTIME,
+ GFS_STATIC,
+ GFS_MONOTONIC = 0x80000000U
+};
+
+enum gomp_schedule_type gsch_type;
+
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-file-scope-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-file-scope-1.c
new file mode 100644
index 0000000..a683113
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-file-scope-1.c
@@ -0,0 +1,25 @@
+/* CTF is not generated for entities not at file-scope. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "ascii \"SFOO.0\"\[\t \]+\[^\n\]*ctf_string" 0 } } */
+/* { dg-final { scan-assembler-times "ascii \"gfoo.0\"\[\t \]+\[^\n\]*ctf_string" 0 } } */
+/* { dg-final { scan-assembler-times "ascii \"foo.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+int foo (int n)
+{
+ typedef struct { int a[n]; } SFOO;
+
+ SFOO a;
+ __attribute__ ((noinline)) SFOO gfoo (void) { return a; }
+
+ a.a[0] = 1;
+ a.a[9] = 2;
+
+ SFOO b;
+ b = gfoo ();
+
+ return b.a[0] == 1 && b.a[9] == 2;
+}
+
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-float-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-float-1.c
new file mode 100644
index 0000000..9e24b45
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-float-1.c
@@ -0,0 +1,16 @@
+/* Tests for CTF float base types.
+ - Verify that there is a single record for the base types. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-final { scan-assembler-times "ascii \"float.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"double.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"long double.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+float a;
+float b = 33;
+
+double c = 44;
+double d = 45;
+
+long double e;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-1.c
new file mode 100644
index 0000000..fdec743
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-1.c
@@ -0,0 +1,40 @@
+/* CTF forward type is generated for forward declarations of types in C.
+
+ Check that the ctf-kind of CTF_K_FOWARD type is CTF_K_STRUCT or CTF_K_UNION.
+ For forward types, the compiler encodes the CTF kind in the ctt_type field.
+ CTF_K_FORWARD is used as the CTF type as usual in the ctt_info. */
+
+/* Note - A value of 6 in "ctt_size or ctt_type" appears twice in this
+ testcase. This might be misconstrued as 2 CTK_K_FORWARD records of struct
+ type. The second assembler tag is due to a ref type in a CVR CTF record.
+ TBD - perhaps a more robust string pattern is needed. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x26000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x6\[\t \]+\[^\n\]*ctt_size or ctt_type" 2 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x7\[\t \]+\[^\n\]*ctt_size or ctt_type" 2 } } */
+
+typedef struct __locale_struct
+{
+ struct __locale_data *__locales[13]; /* forward struct type. */
+
+ const int *__ctype_toupper;
+ const char *__names[13];
+} *__locale_t;
+
+typedef __locale_t locale_t;
+
+locale_t loc;
+
+typedef struct __inter_struct
+{
+ union __inter_data * __inters[13]; /* forward union type. */
+
+ const int * __ctype_kind;
+} * __inter_t;
+
+typedef __inter_t inter_t;
+
+inter_t inter;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-2.c
new file mode 100644
index 0000000..a3154f2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-2.c
@@ -0,0 +1,16 @@
+/* CTF forward type is generated for forward declarations of enum types in C.
+
+ Check that the ctf-kind of CTF_K_FOWARD type is CTF_K_ENUM.
+ For forward types, the compiler encodes the CTF kind in the ctt_type field.
+ CTF_K_FORWARD is used as the CTF type as usual in the ctt_info. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x26000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x8\[\t \]+\[^\n\]*ctt_size or ctt_type" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"vibgyor.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+enum vibgyor;
+
+char * (*get_color_name) (enum vibgyor);
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-func-index-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-func-index-1.c
new file mode 100644
index 0000000..86ca795
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-func-index-1.c
@@ -0,0 +1,25 @@
+/* CTF function index sub-section.
+
+ A function index sub-section in the CTF section contains the offset to the
+ string name of the global function symbols. The number of entries in the
+ func info section and the func index section are always the same.
+
+ In this testcase, 2 records in the function index section are expected. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "funcinfo_name" 2 } } */
+/* { dg-final { scan-assembler-times "funcinfo_func_type" 2 } } */
+/* { dg-final { scan-assembler-times "ascii \"bar.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"foo.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+int foo (void)
+{
+ return 0;
+}
+
+int bar (int a)
+{
+ return 33 + a;
+}
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-1.c
new file mode 100644
index 0000000..cc1a600a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-1.c
@@ -0,0 +1,24 @@
+/* CTF generation of function pointers. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-final { scan-assembler-times "\[\t \]0x16000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x16000002\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x16000003\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"__foo_fn.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"destroy.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"func.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+int (*func) (int *, char);
+
+typedef int (*__foo_fn) (void *__cookie, char *__buf, int __nbytes);
+
+typedef struct object
+{
+ int myint;
+ char mychar;
+ void (*destroy)(struct object *);
+} object_t;
+
+object_t myobj;
+__foo_fn fooit;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-2.c
new file mode 100644
index 0000000..a4a1104
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-2.c
@@ -0,0 +1,22 @@
+/* CTF generation of function pointers.
+
+ In this testcase, there is a single function type expected for two
+ different function pointer types. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-final { scan-assembler-times "\[\t \]0x16000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"rcu_callback_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"func.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+struct callback_head {
+ struct callback_head *next;
+ void (*func) (struct callback_head *head);
+} __attribute__ (( aligned (sizeof (void *))));
+#define rcu_head callback_head
+
+struct callback_head chead;
+
+typedef void (*rcu_callback_t) (struct rcu_head *head);
+
+rcu_callback_t rcb;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-3.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-3.c
new file mode 100644
index 0000000..fe35d6c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-3.c
@@ -0,0 +1,21 @@
+/* CTF generation of function pointers.
+
+ In this testcase, there is a single function type expected. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-final { scan-assembler-times "\[\t \]0x16000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"foo_init_callback.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"fn.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+struct foo;
+
+typedef void (* foo_init_callback) (struct foo *f1);
+
+struct foo
+{
+ /* Function to call to initialize. */
+ foo_init_callback fn;
+};
+
+struct foo f;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-4.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-4.c
new file mode 100644
index 0000000..b8a7417
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-4.c
@@ -0,0 +1,18 @@
+/* CTF generation of function pointers.
+
+ In this testcase, Type de-duplication of function type is exercised. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-final { scan-assembler-times "\[\t \]0x16000001\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"var_assign_func_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+struct variable;
+
+typedef struct variable *var_assign_func_t (struct variable *);
+
+typedef struct variable {
+ var_assign_func_t *assign_func;
+} shell_var_t;
+
+shell_var_t a;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-functions-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-functions-1.c
new file mode 100644
index 0000000..0b086a5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-functions-1.c
@@ -0,0 +1,34 @@
+/* CTF generation for functions with varargs or otherwise.
+
+ In this testcase, it is expected to see one CTF_K_FUNCTION record with two
+ function arguments. The second function argument with a value of 0
+ corresponds to the ellipsis.
+
+ Example CTF section excerpt on x86_64 :
+
+ .long 0x5 # ctt_name (name = format)
+ .long 0x16000002 # ctt_info (CTF_K_FUNCTION with 2 arguments)
+ .long 0x2 # ctt_size or ctt_type (return typeID)
+ .long 0x2 # dtu_argv (TypeID of the First argument)
+ .long 0 # dtu_argv (TypeID of the second argument)
+ .ascii "\0" # ctf_string
+ .ascii "int\0" # ctf_string
+ .ascii "format\0" # ctf_string
+
+ */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x16000002\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "dtu_argv" 2 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*dtu_argv" 1 } } */
+
+int foo (void);
+
+int bar (int);
+
+int * format (int * fmt, ...)
+{
+ return fmt;
+}
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-int-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-int-1.c
new file mode 100644
index 0000000..8c68b2e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-int-1.c
@@ -0,0 +1,17 @@
+/* Tests for CTF integer base types.
+ - Verify that there is a single record for the base types. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"short int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"long int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+int a;
+int b = 33;
+
+short int c = 44;
+short int d = 45;
+
+long int e = 90;
+long int f;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-objt-index-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-objt-index-1.c
new file mode 100644
index 0000000..ee3481a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-objt-index-1.c
@@ -0,0 +1,30 @@
+/* CTF objext index sub-section.
+
+ An object index sub-section in the CTF section contains the offset to the
+ string name of the global object symbols. The number of entries in the
+ obj info section and objt index section are always the same.
+
+ In this testcase, 4 records in the object index section are expected. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "objtinfo_name" 4 } } */
+/* { dg-final { scan-assembler-times "objtinfo_var_type" 4 } } */
+/* { dg-final { scan-assembler-times "ascii \"a.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"b.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"a1.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"d_instance.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+static int b = 33;
+
+int a = 44;
+int a1[2] = {22, 33};
+
+struct d
+{
+ int d1;
+ int d2;
+};
+
+struct d d_instance;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-1.c
new file mode 100644
index 0000000..e1fccec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-1.c
@@ -0,0 +1,26 @@
+/* CTF generation for pointer types.
+
+ In this testcase, two CTF pointer type records are expected
+ - int *
+ - struct foo_struct *
+ */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "ascii \"foo_struct.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
+
+int b = 44;
+int * a = &b;
+
+struct foo_struct
+{
+ int bar_mem_1;
+ int bar_mem_2;
+ float d;
+ struct foo_struct *next;
+};
+
+struct foo_struct * node;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-2.c
new file mode 100644
index 0000000..e36e5ec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-2.c
@@ -0,0 +1,25 @@
+/* CTF generation for pointer types.
+
+ In this testcase, de-duplication of pointer types is exercised. The
+ compostition of structs in this testcase is such that when adding CTF for
+ pointer type (link), the pointed-to-type type already adds the pointer to
+ struct link.
+
+ In this testcase, one CTF pointer type record is expected. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+
+struct link;
+
+typedef struct items {
+ struct link * link;
+ int str;
+} itemslist;
+
+itemslist il;
+
+struct link { struct link * next; };
+
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-preamble-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-preamble-1.c
new file mode 100644
index 0000000..28547fa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-preamble-1.c
@@ -0,0 +1,11 @@
+/* Verify the CTF preamble in the CTF section. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-final { scan-assembler "0xdff2.*CTF preamble magic number" } } */
+/* { dg-final { scan-assembler "0x4.*CTF preamble version" } } */
+/* { dg-final { scan-assembler "0.*CTF preamble flags" } } */
+
+void func (void)
+{
+}
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-1.c
new file mode 100644
index 0000000..0c51839
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-1.c
@@ -0,0 +1,38 @@
+/* CTF does not have representation for some types at this time. These types
+ are skipped in the CTF generation phase in the compiler.
+
+ An explicit CTF type with kind CTF_K_UNKNOWN is created for types that do
+ not have representation in CTF. */
+
+/* { dg-do compile } */
+/* { dg-options "-gctf -dA" } */
+/* { dg-final { scan-assembler-times "\[\t \]0x2000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"unknown.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+/* { dg-require-effective-target libc_has_complex_functions } */
+
+#include <complex.h>
+
+typedef float La_x86_64_xmm __attribute__ ((__vector_size__ (16)));
+La_x86_64_xmm a1;
+
+/* GCC also supports complex integer data types. */
+complex char a;
+complex signed char b;
+complex unsigned char c;
+complex short int d;
+complex short unsigned int e;
+complex int f;
+complex unsigned int g;
+complex long int h;
+complex long unsigned int i;
+complex long long int j;
+
+enum gomp_schedule_type
+{
+ GFS_RUNTIME,
+ GFS_STATIC,
+ GFS_MONOTONIC = 0x80000000U
+};
+
+enum gomp_schedule_type gsch_type;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-2.c
new file mode 100644
index 0000000..79d5cb2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-2.c
@@ -0,0 +1,18 @@
+/* CTF does not have representation for some types at this time. These types
+ are skipped in the CTF generation phase in the compiler.
+
+ Skip IEEE interchange and extended formats for CTF generation.
+
+ In this testcase, CTF records for types are not added as CTF has no
+ representation for IEEE interchange and extended formats.
+
+ CTF records for variables do exist, however. The referenced type is
+ CTF_TYPE_NULLID. */
+
+/* { dg-do compile } */
+/* { dg-options "-gctf" } */
+
+/* { dg-require-effective-target float16 } */
+/* { dg-add-options float16 } */
+
+_Float16 f16;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-3.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-3.c
new file mode 100644
index 0000000..394fa2f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-3.c
@@ -0,0 +1,20 @@
+/* CTF does not have representation for some types at this time. These types
+ are skipped in the CTF generation phase in the compiler.
+
+ Skip IEEE interchange and extended formats for CTF generation.
+
+ In this testcase, CTF records for types are not added as CTF has no
+ representation for IEEE interchange and extended formats.
+
+ CTF records for variables and pointer do exist, however. The referenced
+ type is CTF_TYPE_NULLID. */
+
+/* { dg-do compile } */
+/* { dg-options "-gctf" } */
+
+/* { dg-require-effective-target float32 } */
+/* { dg-require-effective-target float32x } */
+
+_Float32 f32;
+_Float32x f32x;
+_Float32 * f32p;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-4.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-4.c
new file mode 100644
index 0000000..7033121
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-4.c
@@ -0,0 +1,21 @@
+/* CTF does not have representation for some types at this time. These types
+ are skipped in the CTF generation phase in the compiler.
+
+ Skip IEEE interchange and extended formats for CTF generation.
+
+ In this testcase, CTF records for types are not added as CTF has no
+ representation for IEEE interchange and extended formats.
+
+ CTF records for variables and pointer do exist, however. The referenced
+ type is CTF_TYPE_NULLID. */
+
+/* { dg-do compile } */
+/* { dg-options "-gctf" } */
+
+/* { dg-require-effective-target float64 } */
+/* { dg-require-effective-target float64x } */
+/* { dg-add-options float64 } */
+/* { dg-add-options float64x } */
+
+_Float64 f64;
+_Float64x f64x;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-5.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-5.c
new file mode 100644
index 0000000..026f9e0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-5.c
@@ -0,0 +1,19 @@
+/* CTF does not have representation for some types at this time. These types
+ are skipped in the CTF generation phase in the compiler.
+
+ Skip IEEE interchange and extended formats for CTF generation.
+
+ In this testcase, CTF records for types are not added as CTF has no
+ representation for IEEE interchange and extended formats.
+
+ CTF records for variables and pointer do exist, however. The referenced
+ type is CTF_TYPE_NULLID. */
+
+/* { dg-do compile } */
+/* { dg-options "-gctf" } */
+
+/* { dg-require-effective-target float128 } */
+/* { dg-require-effective-target float128x } */
+
+_Float128 f128;
+_Float128x f128x;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-6.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-6.c
new file mode 100644
index 0000000..f2dbe08
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-6.c
@@ -0,0 +1,18 @@
+/* CTF does not have representation for some types at this time. These types
+ are skipped in the CTF generation phase in the compiler.
+
+ Skip Decimal Floating Point format types for CTF generation.
+
+ In this testcase, CTF records for types are not added as CTF has no
+ representation for Decimal floating point format.
+
+ CTF records for variables do exist, however. The referenced type is
+ CTF_TYPE_NULLID. */
+
+/* { dg-do compile } */
+/* { dg-options "-gctf" } */
+/* { dg-require-effective-target dfp } */
+
+_Decimal32 d32;
+_Decimal64 d64;
+_Decimal128 d128;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-7.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-7.c
new file mode 100644
index 0000000..a9d86de
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-7.c
@@ -0,0 +1,18 @@
+/* CTF does not have representation for some types at this time. These types
+ are skipped in the CTF generation phase in the compiler.
+
+ Skip IEEE interchange and extended formats for CTF generation.
+
+ In this testcase, CTF records for types are not added as CTF has no
+ representation for IEEE interchange and extended formats. This testcase
+ checks that CTF generation skips the 128-bit float gracefully, when code
+ generation is for a 32-bit environment. */
+
+/* { dg-do compile } */
+/* { dg-options "-gctf -m32" } */
+
+/* { dg-require-effective-target float128 } */
+/* { dg-require-effective-target float128x } */
+
+_Float128 f128;
+_Float128x f128x;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-8.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-8.c
new file mode 100644
index 0000000..2413e91
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-skip-types-8.c
@@ -0,0 +1,27 @@
+/* CTF does not have representation for _Atomic qualifier. This qualifier is
+ skipped in the CTF generation phase in the compiler.
+
+ In this testcase, CTF records for the _Atomic qualifier are not added as
+ CTF has no representation for it. CTF records for the underlying type are,
+ however, added. So, CTF records for typedef, const and the underlying
+ struct are expected. */
+
+/* { dg-do compile } */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x2a000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x1a000003\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "ctm_name" 3 } } */
+
+/* { dg-final { scan-assembler-times "ascii \"comp_type.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"comp_type_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"c1.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+typedef struct comp_type
+{
+ int a;
+ float b;
+ char c;
+} comp_type_t;
+
+_Atomic const comp_type_t c1;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-str-table-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-str-table-1.c
new file mode 100644
index 0000000..0a0f1f0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-str-table-1.c
@@ -0,0 +1,26 @@
+/* CTF String Table as generated by the compiler is expected to have only a
+ single empty string. Just an optimization by the compiler, it is not
+ mandated by the CTF format. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-final { scan-assembler-times "ascii \".0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+union wait
+{
+ int w_status;
+ struct
+ {
+ int __w_termsig;
+ int __w_coredump;
+ } __wait_terminated;
+ struct
+ {
+ int __w_stopval;
+ int __w_stopsig;
+ } __wait_stopped;
+};
+
+typedef union { union wait * __uptr; int * iptr; } __WAIT_STATUS;
+
+__WAIT_STATUS waitstatus;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-1.c
new file mode 100644
index 0000000..19711c0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-1.c
@@ -0,0 +1,25 @@
+/* Test compilation of struct type.
+
+ In this testcase, two CTF_K_STRUCT records are expected
+ struct a : ctt_info = 0x1a000004 (4 field members)
+ struct b : ctt_into = 0x1a000002 (2 field members)
+*/
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x1a000004\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x1a000002\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "ctm_name" 6 } } */
+
+struct a
+{
+ int d1;
+ int d2;
+ float c;
+ struct b
+ {
+ int time;
+ int wall;
+ } b1;
+} my_a;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-2.c
new file mode 100644
index 0000000..09b4d2f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-2.c
@@ -0,0 +1,32 @@
+/* Test for compilation of self-referntial structs.
+
+ Further, the compiler is expected to generate a single CTF struct type for
+ struct dmx_dtdef (due to Type de-duplication at CTF generation). */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-final { scan-assembler-times "ascii \"dmx_dtdef.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"dtd_name.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"dtd_type.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"dmx_dtdef_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+struct link
+{
+ struct link * next;
+} * s_link;
+
+typedef long dmx_id_t;
+
+typedef struct dmx_dtdef
+{
+ char * dtd_name;
+ dmx_id_t dtd_type;
+} dmx_dtdef_t;
+
+typedef struct dmx_bundle
+{
+ dmx_id_t dmb_type;
+ dmx_dtdef_t * dmb_dtd;
+} dmx_bundle_t;
+
+dmx_bundle_t dbt;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-1.c
new file mode 100644
index 0000000..d6c6b6b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-1.c
@@ -0,0 +1,65 @@
+/* Test Compilation of mixed constructs containing structs and arrays.
+
+ Further, the compiler is expected to generate a single CTF struct type for
+ struct cmodel (due to Type de-duplication at the time of CTF generation).
+
+ const qualifier in fields of structs should be processed. It appears as a
+ no-name CTF record with appropriate ctt_info. In this testcase, there are
+ two const qualifiers - const char and const struct cmodel. However, due to
+ way the debug information is represented in DWARF die, 3 const qualifier
+ records appear in the CTF section.
+
+ <1><e1>: Abbrev Number: 14 (DW_TAG_typedef)
+ <e2> DW_AT_name : (indirect string, offset: 0x114): cmodel_t
+ <e9> DW_AT_type : <0x9a>
+ <1><ed>: Abbrev Number: 13 (DW_TAG_const_type)
+ <ee> DW_AT_type : <0xe1>
+ <1><f2>: Abbrev Number: 4 (DW_TAG_array_type)
+ <f3> DW_AT_type : <0xed>
+ <f7> DW_AT_sibling : <0x102>
+
+ <2><101>: Abbrev Number: 0
+ <1><102>: Abbrev Number: 13 (DW_TAG_const_type)
+ <103> DW_AT_type : <0xf2>
+ <1><107>: Abbrev Number: 15 (DW_TAG_variable)
+ <108> DW_AT_name : (indirect string, offset: 0x57): _models
+ <10f> DW_AT_type : <0x102>
+ <1><11d>: Abbrev Number: 0
+
+ This results in:
+
+ _models -> e: const const cmodel_t [3] (size 0x30) -> d: const cmodel_t [3] (size 0x30)
+
+ Deemed as acceptable for now. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "ascii \"cmodel.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"cname.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"cpointer.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"cmodel_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+/* 3 const records are expected. */
+/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 3 } } */
+
+struct a
+{
+ int a1[2];
+ struct { int b[3]; } a2;
+};
+
+struct a my_a;
+
+typedef struct cmodel
+{
+ const char *cname;
+ int ccode;
+ int cpointer;
+} cmodel_t;
+
+static const cmodel_t _models[] = {
+ {"ILP32", 0, 4},
+ {"LP64", 0, 8},
+ {"", 0, 0}
+};
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-2.c
new file mode 100644
index 0000000..37094b5d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-2.c
@@ -0,0 +1,15 @@
+/* CTF generation for struct type in presence of DWARF2.
+
+ In case of DWARF2, the data member location is an expression containing
+ the location. CTF generation feeds off DWARF dies; this testcase tests
+ that the location expr is handled. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA -gdwarf-2" } */
+
+/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x4\[\t \]+\[^\n\]*cta_nelems" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctm_offset" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x20\[\t \]+\[^\n\]*ctm_offset" 1 } } */
+
+static struct ranges {int from, to;} lim_regs[] = {{ 16, 7}, { 16, 6}, { 20, 7},{ 20, 6}};
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-1.c
new file mode 100644
index 0000000..22005ed
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-1.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* This tests the following scenario:
+
+ 1. struct foo;
+ 2. struct foo *a_foo;
+ 3. struct foo { int bar; };
+ 4. void baz (struct foo *f) { f->bar = 0; }
+
+ At 2. a forward for struct foo is generated and at 3. the struct
+ type is fully defined. When a pointer to foo is encountered at 4.,
+ an additional CTF type for the completed struct shall be emitted as
+ well. The linker will deduplicate both types. */
+
+struct foo;
+struct foo *a_foo;
+struct foo { int bar; };
+void baz (struct foo *f) { f->bar = 0; }
+
+/* { dg-final { scan-assembler-times "\[\t \]\"bar.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-2.c
new file mode 100644
index 0000000..569e5e2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-pointer-2.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* This tests the following scenario:
+
+ 1. struct foo;
+ 2. struct foo *a_foo;
+ 3. struct foo { int bar; };
+ 4. void baz (struct foo **f) { f->bar = 0; }
+
+ At 2. a forward for struct foo is generated and at 3. the struct
+ type is fully defined. When a pointer to a pointer to foo is
+ encountered at 4., an additional CTF type for the completed struct
+ shall be emitted as well. The linker will deduplicate both
+ types. */
+
+struct foo;
+struct foo *a_foo;
+struct foo { int bar; };
+void baz (struct foo **f) { (*f)->bar = 0; }
+
+/* { dg-final { scan-assembler-times "\[\t \]\"bar.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-1.c
new file mode 100644
index 0000000..aa40ab0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-1.c
@@ -0,0 +1,68 @@
+/* CTF_K_TYPEDEF record generation.
+
+ In this testcase, 7 typedef records are expected.
+
+ Further, the declared variables must be of type typedef
+
+ Variables:
+ a -> 2: my_int (size 0x4) -> 1: int (size 0x4)
+ b -> 3: bar_int (size 0x4) -> 1: int (size 0x4)
+ c -> 4: foo_int (size 0x4) -> 1: int (size 0x4)
+ d -> 7: my_array (size 0x8) -> 5: struct (size 0x8)
+ e -> 9: CINT (size 0x4) -> 8: const int (size 0x4) -> 1: int (size 0x4)
+ f -> c: CINTP (size 0x8) -> b: const int * (size 0x8) -> a: const int (size 0x4) -> 1: int (size 0x4)
+ g -> f: my_node_t (size 0x8) -> d: struct my_node (size 0x8)
+
+ There is no direct way to check that the variables are of type typedef.
+ So in this testcase, we simply check that:
+ 1. The typedef records are generated (Check for 7 specific ctt_info, and
+ check for the ascii strings for the typedef names).
+ 2. The ctv_typeidx are distinct (each pointing to a specfic unique type).
+ Note that if variables were not of type typedef, ctv_typeidx will not be
+ unique (type of a, b, c will all point to int); hence, the check.
+ */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "0x2a000000\[\t \]+\[^\n\]*ctt_info" 7 } } */
+/* { dg-final { scan-assembler-times "ascii \"my_int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"bar_int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"foo_int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"my_array.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"CINT.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"CINTP.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"my_node_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x4\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x5\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x9\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0xa\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0xc\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0xf\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
+
+typedef int my_int;
+typedef int bar_int;
+typedef int foo_int;
+
+typedef struct { int a[2]; } my_array;
+
+typedef const int CINT;
+typedef const int * CINTP;
+
+typedef struct my_node
+{
+ int flags;
+ char value;
+} my_node_t;
+
+my_int a;
+bar_int b;
+foo_int c;
+
+my_array d;
+CINT e = 3;
+CINTP f = &e;
+
+my_node_t g;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-2.c
new file mode 100644
index 0000000..8c9d3bb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-2.c
@@ -0,0 +1,20 @@
+/* CTF_K_TYPEDEF record generation.
+
+ In this testcase, typedef of type void should be generated. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "0x2a000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"foo_void_type.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"void.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+typedef void foo_void_type;
+
+struct bar
+{
+ int a;
+ foo_void_type *b;
+};
+
+struct bar c;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-3.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-3.c
new file mode 100644
index 0000000..93d0845
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-3.c
@@ -0,0 +1,24 @@
+/* Type de-duplication of CTF_K_TYPEDEF records.
+
+ In this testcase, a single CTF record for typedef is expected. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "0x2a000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"foo_type.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+/* { dg-final { scan-assembler-times "ascii \"foo.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
+
+typedef struct foo foo_type;
+
+struct bar
+{
+ struct foo * f1;
+ foo_type * f2;
+};
+
+struct testme {
+ struct bar * b1;
+};
+
+struct testme * t1;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-1.c
new file mode 100644
index 0000000..19e8f49
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+typedef struct my_int
+{
+ int upper;
+ int lower;
+ struct bitmask
+ {
+ int flags;
+ } my_mask;
+} my_int_t;
+
+my_int_t mit;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-2.c
new file mode 100644
index 0000000..deeb85a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-2.c
@@ -0,0 +1,17 @@
+/* Test compilation of typedef composition in structs. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+typedef struct
+{
+ int day, month, year;
+} Date;
+
+typedef struct
+{
+ Date filedDate, fixedDate;
+ int severity;
+} BugRef;
+
+BugRef CR2112;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-3.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-3.c
new file mode 100644
index 0000000..6d6918b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-3.c
@@ -0,0 +1,32 @@
+/* Test CTF generation for a typedef instantiation with CVR quals.
+
+ Caveat: There is no direct way to test that the type of foo is
+ "const my_int_t" via scanning the assembly. This test instead
+ checks for the presence of some of the CTF constructs involved
+ individually. Specifically, it checks for CTF const record and
+ CTF typedef record.
+
+ Variables:
+ foo -> 4: const my_int_t (size 0x8) -> 3: my_int_t (size 0x8) -> 1: struct my_int (size 0x8)
+
+ Types:
+ 1: struct my_int (size 0x8)
+ 2: int (size 0x4)
+ 3: my_int_t (size 0x8) -> 1: struct my_int (size 0x8)
+ 4: const my_int_t (size 0x8) -> 3: my_int_t (size 0x8) -> 1: struct my_int (size 0x8)
+*/
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "\[\t \]0x4\[\t \]+\[^\n\]*ctv_typeidx" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x2a000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+
+typedef struct my_int
+{
+ int upper;
+ int lower;
+} my_int_t;
+
+const my_int_t foo = {10, 20};
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-union-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-union-1.c
new file mode 100644
index 0000000..929d532
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-union-1.c
@@ -0,0 +1,14 @@
+/* CTF generation for union type. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+/* { dg-final { scan-assembler-times "\[\t \]0x1e000004\[\t \]+\[^\n\]*ctt_info" 1 } } */
+/* { dg-final { scan-assembler-times "ctm_name" 4 } } */
+
+union c
+{
+ int c1;
+ int c2;
+ int c3;
+ int c4;
+} my_u_c;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-1.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-1.c
new file mode 100644
index 0000000..8c3ab10
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-1.c
@@ -0,0 +1,25 @@
+/* CTF generation for global variables.
+
+ In this testcase, 7 records in the variable info section are expected. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "ctv_name" 7 } } */
+
+float var1;
+double var2;
+long double var3;
+
+char ascii = 'a';
+
+int a = 33;
+int a1[2] = {22, 33};
+
+struct d
+{
+ int d1;
+ int d2;
+};
+
+struct d d_instance;
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-2.c
new file mode 100644
index 0000000..75c3ed7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-2.c
@@ -0,0 +1,16 @@
+/* CTF generation for static variables inside a function.
+
+ In this testcase, CTF record for bstatic is NOT expected. CTF generation
+ is only carried out for variables at file-scope or global-scope. */
+
+/* { dg-do compile ) */
+/* { dg-options "-O0 -gctf -dA" } */
+
+/* { dg-final { scan-assembler-times "ctv_name" 0 } } */
+/* { dg-final { scan-assembler-times "ascii \"bstatic.0\"\[\t \]+\[^\n\]*ctf_string" 0 } } */
+
+int foo (int a)
+{
+ static int bstatic = 3;
+ return a + bstatic;
+}
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf.exp b/gcc/testsuite/gcc.dg/debug/ctf/ctf.exp
new file mode 100644
index 0000000..7ad6723
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf.exp
@@ -0,0 +1,48 @@
+# Copyright (C) 2002-2019 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# Disable on ptx (in sync with DWARF testsuite)
+if { [istarget nvptx-*-*] } {
+ return
+}
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+set comp_output [gcc_target_compile \
+ "$srcdir/$subdir/../trivial.c" "trivial.S" assembly \
+ "additional_flags=-gctf"]
+if { ! [string match "*: target system does not support the * debug format*" \
+ $comp_output] } {
+ remove-build-file "trivial.S"
+ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \
+ "" $DEFAULT_CFLAGS
+}
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline5.c b/gcc/testsuite/gcc.dg/debug/dwarf2/inline5.c
index bd34f0d..3b50e9f 100644
--- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline5.c
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline5.c
@@ -9,7 +9,7 @@
/* We do not know which is output first so look for both invalid abstract
origins on the lexical blocks (knowing that the abstract instance has
no attribute following the DW_TAG_lexical_block. */
-/* { dg-final { scan-assembler-not "\\(DIE \\(0x(\[0-9a-f\]*)\\) DW_TAG_lexical_block\\)\[^#/!@;\\|\]*\[#/!@;\\|\]+ +\[^(\].*DW_TAG_lexical_block\\)\[^#/!@;\\|x\]*x\\1\[^#/!@;\\|\]*\[#/!@;\\|\] +DW_AT_abstract_origin" { xfail { { *-*-aix* || *-*-solaris2.* } && { ! gas } } } } } */
+/* { dg-final { scan-assembler-not "\\(DIE \\(0x(\[0-9a-f\]*)\\) DW_TAG_lexical_block\\)\[^#/!@;\\|\]*\[#/!@;\\|\]+ +DW_AT.*DW_TAG_lexical_block\\)\[^#/!@;\\|x\]*x\\1\[^#/!@;\\|\]*\[#/!@;\\|\] +DW_AT_abstract_origin" { xfail { { *-*-aix* || *-*-solaris2.* } && { ! gas } } } } } */
/* { dg-final { scan-assembler-not "DW_TAG_lexical_block\\)\[^#/!@;\\|x\]*x(\[0-9a-f\]*)\[^#/!@;\\|\]*\[#/!@;\\|\]+ +DW_AT_abstract_origin.*\\(DIE \\(0x\\1\\) DW_TAG_lexical_block\\)\[^#/!@;\\|\]*\[#/!@;\\|\]+ +DW_AT" } } */
int foo (int i)
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr100515.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr100515.c
new file mode 100644
index 0000000..17f6463
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr100515.c
@@ -0,0 +1,20 @@
+/* PR debug/100515 */
+/* { dg-do compile } */
+/* { dg-require-effective-target fopenmp } */
+/* { dg-options "-g -O2 -fopenmp" } */
+
+void
+foo (int x)
+{
+#pragma omp taskloop
+ for (int i = 0; i < x; i++)
+ ;
+}
+
+void
+bar (int x)
+{
+#pragma omp taskloop
+ for (int i = 0; i < x; i++)
+ ;
+}
diff --git a/gcc/testsuite/gcc.dg/debug/pr57351.c b/gcc/testsuite/gcc.dg/debug/pr57351.c
index 972f3e9..236d74d 100644
--- a/gcc/testsuite/gcc.dg/debug/pr57351.c
+++ b/gcc/testsuite/gcc.dg/debug/pr57351.c
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* { dg-require-effective-target arm_neon } */
+/* { dg-require-effective-target arm_arch_v7a_ok } */
/* { dg-options "-std=c99 -Os -g -march=armv7-a" } */
/* { dg-add-options arm_neon } */
diff --git a/gcc/testsuite/gcc.dg/diagnostic-input-charset-1.c b/gcc/testsuite/gcc.dg/diagnostic-input-charset-1.c
new file mode 100644
index 0000000..4e56833
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/diagnostic-input-charset-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-require-iconv "CP850" } */
+/* { dg-options "-finput-charset=CP850 -fdiagnostics-show-caret" } */
+
+/* Test that diagnostics are converted to UTF-8; this file is encoded in
+ CP850. Why CP850? -finput-charset only supports encodings that are a
+ superset of ASCII. But encodings that look like latin-1 are automatically
+ converted by expect to UTF-8, and hence by the time dg sees them, it can't
+ verify they were actually output in UTF-8. So codepage 850 was chosen as one
+ that is hopefully available and meets the requirements of matching ASCII and
+ not matching latin-1. */
+const char *section = "õ"
+/* { dg-error "expected .* at end of input" "" { target *-*-*} .-1 } */
+/* { dg-begin-multiline-output "" }
+ const char *section = "§"
+ ^~~~~
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/diagnostic-input-utf8-bom.c b/gcc/testsuite/gcc.dg/diagnostic-input-utf8-bom.c
new file mode 100644
index 0000000..1a3f352
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/diagnostic-input-utf8-bom.c
@@ -0,0 +1,14 @@
+int 1;
+/* { dg-do compile } */
+/* { dg-options "-fdiagnostics-show-caret" } */
+
+/* This file begins with a UTF-8 byte order mark. Verify that diagnostics
+ still point to the right place, since the stripping of the BOM happens twice,
+ once when libcpp reads the file, and once when diagnostics infrastucture
+ reads it. */
+
+/* { dg-error "expected .* before numeric constant" "" { target *-*-*} 1 } */
+/* { dg-begin-multiline-output "" }
+ int 1;
+ ^
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges-2.c b/gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges-2.c
index 302e233..1cbcad5 100644
--- a/gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges-2.c
+++ b/gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges-2.c
@@ -3,21 +3,25 @@
int test_uninit_1 (void)
{
- int result;
- return result; /* { dg-warning "uninitialized" } */
-/* { dg-begin-multiline-output "" }
- return result;
- ^~~~~~
+ int result_1; /* { dg-message "declared here" } */
+ return result_1; /* { dg-warning "uninitialized" } */
+ /* { dg-begin-multiline-output "" }
+ return result_1;
+ ^~~~~~~~
+ int result_1;
+ ^~~~~~~~
{ dg-end-multiline-output "" } */
}
int test_uninit_2 (void)
{
- int result;
- result += 3; /* { dg-warning "uninitialized" } */
-/* { dg-begin-multiline-output "" }
- result += 3;
- ~~~~~~~^~~~
+ int result_2; /* { dg-message "declared here" } */
+ result_2 += 3; /* { dg-warning "uninitialized" } */
+ /* { dg-begin-multiline-output "" }
+ result_2 += 3;
+ ~~~~~~~~~^~~~
+ int result_2;
+ ^~~~~~~~
{ dg-end-multiline-output "" } */
- return result;
+ return result_2;
}
diff --git a/gcc/testsuite/gcc.dg/fold-convlshift-1.c b/gcc/testsuite/gcc.dg/fold-convlshift-1.c
new file mode 100644
index 0000000..b6f57f8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-convlshift-1.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+unsigned int foo(unsigned int i)
+{
+ int t1 = i;
+ int t2 = t1 << 8;
+ return t2;
+}
+
+int bar(int i)
+{
+ unsigned int t1 = i;
+ unsigned int t2 = t1 << 8;
+ return t2;
+}
+
+/* { dg-final { scan-tree-dump-not "\\(int\\)" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "\\(unsigned int\\)" "optimized" } } */
+
diff --git a/gcc/testsuite/gcc.dg/fold-convlshift-2.c b/gcc/testsuite/gcc.dg/fold-convlshift-2.c
new file mode 100644
index 0000000..f21358c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-convlshift-2.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+unsigned int foo(unsigned char c)
+{
+ int t1 = c;
+ int t2 = t1 << 8;
+ return t2;
+}
+
+int bar(unsigned char c)
+{
+ unsigned int t1 = c;
+ unsigned int t2 = t1 << 8;
+ return t2;
+}
+
+/* { dg-final { scan-tree-dump-times "\\(int\\)" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\\(unsigned int\\)" 1 "optimized" } } */
+
diff --git a/gcc/testsuite/gcc.dg/fold-convlshift-3.c b/gcc/testsuite/gcc.dg/fold-convlshift-3.c
new file mode 100644
index 0000000..8d01191
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-convlshift-3.c
@@ -0,0 +1,8 @@
+/* PR middle-end/102029 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+int *
+foo (const __PTRDIFF_TYPE__ l)
+{
+ return (int *) (l << 2);
+}
diff --git a/gcc/testsuite/gcc.dg/fold-eqbswap-1.c b/gcc/testsuite/gcc.dg/fold-eqbswap-1.c
new file mode 100644
index 0000000..ed9820b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-eqbswap-1.c
@@ -0,0 +1,113 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int test1(int x, int y)
+{
+#if __SIZEOF_INT__ == 4
+ return __builtin_bswap32(x) == __builtin_bswap32(y);
+#else
+ return x == y;
+#endif
+}
+
+int test2(int x, int y)
+{
+#if __SIZEOF_INT__ == 4
+ return __builtin_bswap32(x) != __builtin_bswap32(y);
+#else
+ return x != y;
+#endif
+}
+
+int test3(int x)
+{
+#if __SIZEOF_INT__ == 4
+ return __builtin_bswap32(x) == 12345;
+#else
+ return x;
+#endif
+}
+
+int test4(int x)
+{
+#if __SIZEOF_INT__ == 4
+ return __builtin_bswap32(x) != 12345;
+#else
+ return x;
+#endif
+}
+
+int test1ll(long long x, long long y)
+{
+#if __SIZEOF_LONG_LONG__ == 8
+ return __builtin_bswap64(x) == __builtin_bswap64(y);
+#else
+ return x == y;
+#endif
+}
+
+int test2ll(long long x, long long y)
+{
+#if __SIZEOF_LONG_LONG__ == 8
+ return __builtin_bswap64(x) != __builtin_bswap64(y);
+#else
+ return x != y;
+#endif
+}
+
+int test3ll(long long x)
+{
+#if __SIZEOF_LONG_LONG__ == 8
+ return __builtin_bswap64(x) == 12345;
+#else
+ return (int)x;
+#endif
+}
+
+int test4ll(long long x)
+{
+#if __SIZEOF_LONG_LONG__ == 8
+ return __builtin_bswap64(x) != 12345;
+#else
+ return (int)x;
+#endif
+}
+
+int test1s(short x, short y)
+{
+#if __SIZEOF_SHORT__ == 2
+ return __builtin_bswap16(x) == __builtin_bswap16(y);
+#else
+ return x == y;
+#endif
+}
+
+int test2s(short x, short y)
+{
+#if __SIZEOF_SHORT__ == 2
+ return __builtin_bswap16(x) != __builtin_bswap16(y);
+#else
+ return x != y;
+#endif
+}
+
+int test3s(short x)
+{
+#if __SIZEOF_SHORT__ == 2
+ return __builtin_bswap16(x) == 12345;
+#else
+ return (int)x;
+#endif
+}
+
+int test4s(short x)
+{
+#if __SIZEOF_SHORT__ == 2
+ return __builtin_bswap16(x) != 12345;
+#else
+ return (int)x;
+#endif
+}
+
+/* { dg-final { scan-tree-dump-times "__builtin_bswap" 0 "optimized" } } */
+
diff --git a/gcc/testsuite/gcc.dg/fold-eqrotate-1.c b/gcc/testsuite/gcc.dg/fold-eqrotate-1.c
new file mode 100644
index 0000000..7d2b637
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-eqrotate-1.c
@@ -0,0 +1,46 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int test1(unsigned int x, unsigned int y)
+{
+#if __SIZEOF_INT__ == 4
+ unsigned int r1 = (x << 16) | (x >> 16);
+ unsigned int r2 = (y << 16) | (y >> 16);
+ return r1 == r2;
+#else
+ return x == y;
+#endif
+}
+
+int test2(unsigned int x)
+{
+#if __SIZEOF_INT__ == 4
+ unsigned int r1 = (x << 16) | (x >> 16);
+ return r1 == 12345;
+#else
+ return x == 12345;
+#endif
+}
+
+int test3(unsigned int x)
+{
+#if __SIZEOF_INT__ == 4
+ unsigned int r1 = (x << 16) | (x >> 16);
+ return r1 == 0;
+#else
+ return x == 0;
+#endif
+}
+
+int test4(unsigned int x)
+{
+#if __SIZEOF_INT__ == 4
+ unsigned int r1 = (x << 16) | (x >> 16);
+ return r1 == ~0;
+#else
+ return x == ~0;
+#endif
+}
+
+/* { dg-final { scan-tree-dump-times "r>>" 0 "optimized" } } */
+
diff --git a/gcc/testsuite/gcc.dg/fold-ior-4.c b/gcc/testsuite/gcc.dg/fold-ior-4.c
new file mode 100644
index 0000000..8f7213e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-ior-4.c
@@ -0,0 +1,61 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+unsigned int test_ior(unsigned char i)
+{
+ return i | (i<<8) | (i<<16) | (i<<24);
+}
+
+unsigned int test_xor(unsigned char i)
+{
+ return i ^ (i<<8) ^ (i<<16) ^ (i<<24);
+}
+
+unsigned int test_ior_1s(unsigned char i)
+{
+ return i | (i<<8);
+}
+
+unsigned int test_ior_1u(unsigned char i)
+{
+ unsigned int t = i;
+ return t | (t<<8);
+}
+
+unsigned int test_xor_1s(unsigned char i)
+{
+ return i ^ (i<<8);
+}
+
+unsigned int test_xor_1u(unsigned char i)
+{
+ unsigned int t = i;
+ return t ^ (t<<8);
+}
+
+unsigned int test_ior_2s(unsigned char i)
+{
+ return (i<<8) | (i<<16);
+}
+
+unsigned int test_ior_2u(unsigned char i)
+{
+ unsigned int t = i;
+ return (t<<8) | (t<<16);
+}
+
+unsigned int test_xor_2s(unsigned char i)
+{
+ return (i<<8) ^ (i<<16);
+}
+
+unsigned int test_xor_2u(unsigned char i)
+{
+ unsigned int t = i;
+ return (t<<8) ^ (t<<16);
+}
+
+/* { dg-final { scan-tree-dump-not " \\^ " "optimized" } } */
+/* { dg-final { scan-tree-dump-not " \\| " "optimized" } } */
+/* { dg-final { scan-tree-dump-times " \\* 16843009" 2 "optimized" } } */
+
diff --git a/gcc/testsuite/gcc.dg/fold-ior-5.c b/gcc/testsuite/gcc.dg/fold-ior-5.c
new file mode 100644
index 0000000..8de5697
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-ior-5.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+unsigned int test_ior(unsigned char i)
+{
+ return (i | (i<<16)) | ((i<<24) | (i<<8));
+}
+
+unsigned int test_xor(unsigned char i)
+{
+ return (i ^ (i<<16)) ^ ((i<<24) ^ (i<<8));
+}
+
+/* { dg-final { scan-tree-dump-not " \\^ " "optimized" } } */
+/* { dg-final { scan-tree-dump-not " \\| " "optimized" } } */
+/* { dg-final { scan-tree-dump-times " \\* 16843009" 2 "optimized" } } */
+
diff --git a/gcc/testsuite/gcc.dg/format/c90-printf-1.c b/gcc/testsuite/gcc.dg/format/c90-printf-1.c
index c8652fc..8ffd63f 100644
--- a/gcc/testsuite/gcc.dg/format/c90-printf-1.c
+++ b/gcc/testsuite/gcc.dg/format/c90-printf-1.c
@@ -240,7 +240,7 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
printf ("%n", cn); /* { dg-warning "3:constant" "%n with const" } */
printf ((const char *)L"foo"); /* { dg-warning "25:wide" "wide string" } */
printf ("%n", (int *)0); /* { dg-warning "3:null" "%n with NULL" } */
- printf ("%s", (char *)0); /* { dg-warning "3:null" "%s with NULL" } */
+ printf ("%s", (char *)0); /* { dg-warning "12:'%s' directive argument is null" "%s with NULL" } */
/* Test for correct column locations within strings with embedded
escape sequences. */
printf ("\\\a\n \"\t%5n\n", n); /* { dg-warning "25:width" "width with %n" } */
diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-10.c b/gcc/testsuite/gcc.dg/format/gcc_diag-10.c
index a2f99fe..dd930f9 100644
--- a/gcc/testsuite/gcc.dg/format/gcc_diag-10.c
+++ b/gcc/testsuite/gcc.dg/format/gcc_diag-10.c
@@ -64,8 +64,8 @@ void test_cdiag (tree t, gimple *gc)
cdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
cdiag ("%E", t);
cdiag ("%F", t); /* { dg-warning ".F. conversion used unquoted" } */
- cdiag ("%G", gc);
- cdiag ("%K", t);
+ cdiag ("%G", gc); /* { dg-warning "format" } */
+ cdiag ("%K", t); /* { dg-warning "format" } */
cdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
cdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
@@ -80,8 +80,8 @@ void test_cdiag (tree t, gimple *gc)
cdiag ("%<%D%>", t);
cdiag ("%<%E%>", t);
cdiag ("%<%F%>", t);
- cdiag ("%<%G%>", gc); /* { dg-warning ".G. conversion used within a quoted sequence" } */
- cdiag ("%<%K%>", t); /* { dg-warning ".K. conversion used within a quoted sequence" } */
+ cdiag ("%<%G%>", gc); /* { dg-warning "format" } */
+ cdiag ("%<%K%>", t); /* { dg-warning "format" } */
cdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
cdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
@@ -103,8 +103,8 @@ void test_tdiag (tree t, gimple *gc)
tdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
tdiag ("%E", t);
- tdiag ("%G", gc);
- tdiag ("%K", t);
+ tdiag ("%G", gc); /* { dg-warning "format" } */
+ tdiag ("%K", t); /* { dg-warning "format" } */
tdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
tdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
@@ -118,8 +118,8 @@ void test_tdiag (tree t, gimple *gc)
tdiag ("%<%D%>", t);
tdiag ("%<%E%>", t);
- tdiag ("%<%G%>", gc); /* { dg-warning ".G. conversion used within a quoted sequence" } */
- tdiag ("%<%K%>", t); /* { dg-warning ".K. conversion used within a quoted sequence" } */
+ tdiag ("%<%G%>", gc); /* { dg-warning "format" } */
+ tdiag ("%<%K%>", t); /* { dg-warning "format" } */
tdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
tdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
@@ -138,8 +138,8 @@ void test_cxxdiag (tree t, gimple *gc)
cxxdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
cxxdiag ("%E", t);
cxxdiag ("%F", t); /* { dg-warning ".F. conversion used unquoted" } */
- cxxdiag ("%G", gc);
- cxxdiag ("%K", t);
+ cxxdiag ("%G", gc); /* { dg-warning "format" } */
+ cxxdiag ("%K", t); /* { dg-warning "format" } */
cxxdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
cxxdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-11.c b/gcc/testsuite/gcc.dg/format/gcc_diag-11.c
index 262e7e5..80d24b6 100644
--- a/gcc/testsuite/gcc.dg/format/gcc_diag-11.c
+++ b/gcc/testsuite/gcc.dg/format/gcc_diag-11.c
@@ -375,7 +375,7 @@ void test_cdiag_identifier (tree t, gimple *gc)
cdiag ("ident z_ with trailing underscore"); /* { dg-warning "unquoted identifier or keyword 'z_'" } */
cdiag ("v_ variable"); /* { dg-warning "unquoted identifier or keyword 'v_'" } */
cdiag ("call foo_bar"); /* { dg-warning "unquoted identifier or keyword 'foo_bar'" } */
- cdiag ("unqoted x_y ident"); /* { dg-warning "unquoted identifier or keyword 'x_y'" } */
+ cdiag ("unquoted x_y ident"); /* { dg-warning "unquoted identifier or keyword 'x_y'" } */
cdiag ("size_t type"); /* { dg-warning "unquoted identifier or keyword 'size_t'" } */
cdiag ("bigger than INT_MAX");/* { dg-warning "unquoted identifier or keyword 'INT_MAX'" } */
diff --git a/gcc/testsuite/gcc.dg/format/strfmon-1.c b/gcc/testsuite/gcc.dg/format/strfmon-1.c
index 934242a..a790db5 100644
--- a/gcc/testsuite/gcc.dg/format/strfmon-1.c
+++ b/gcc/testsuite/gcc.dg/format/strfmon-1.c
@@ -57,7 +57,7 @@ foo (char *s, size_t m, double d, long double ld)
strfmon (s, m, "%n%n", d); /* { dg-warning "matching" "too few args" } */
strfmon (s, m, ""); /* { dg-warning "zero-length" "empty" } */
strfmon (s, m, NULL); /* { dg-warning "null" "null format string" } */
- strfmon (s, m, "%"); /* { dg-warning "trailing" "tailing %" } */
+ strfmon (s, m, "%"); /* { dg-warning "trailing" "trailing %" } */
strfmon (s, m, "%n\0", d); /* { dg-warning "embedded" "embedded NUL" } */
strfmon (s, m, "%^^n", d); /* { dg-warning "repeated" "repeated flag" } */
}
diff --git a/gcc/testsuite/gcc.dg/gcov-info-to-gcda.c b/gcc/testsuite/gcc.dg/gcov-info-to-gcda.c
new file mode 100644
index 0000000..a42a768
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gcov-info-to-gcda.c
@@ -0,0 +1,60 @@
+/* { dg-do run } */
+/* { dg-skip-if "profile-info-section" { powerpc-ibm-aix* } } */
+/* { dg-options "-fprofile-arcs -fprofile-info-section" } */
+
+#define assert(expr) \
+ ((expr) \
+ ? (void)0 \
+ : (__builtin_printf ("%s:%i: Assertion `%s' failed.\n", \
+ __FILE__, __LINE__, #expr), \
+ __builtin_abort ()))
+
+struct gcov_info;
+
+extern void
+__gcov_info_to_gcda (const struct gcov_info *__info,
+ void (*__filename_fn) (const char *, void *),
+ void (*__dump_fn) (const void *, unsigned, void *),
+ void *(*__allocate_fn) (unsigned, void *),
+ void *__arg);
+
+extern const struct gcov_info *my_info;
+
+static unsigned counter;
+
+static void
+filename (const char *f, void *arg)
+{
+ assert (arg == &counter);
+ assert (__builtin_strstr (f, "gcov-info-to-gcda.c") == 0);
+}
+
+static void
+dump (const void *d, unsigned n, void *arg)
+{
+ unsigned *m = (unsigned *)arg;
+ assert (arg == &counter);
+
+ if (*m == 0)
+ {
+ const unsigned *u = d;
+ assert (*u == 0x67636461);
+ }
+
+ *m += n;
+}
+
+static void *
+allocate (unsigned length, void *arg)
+{
+ assert (arg == &counter);
+ return __builtin_malloc (length);
+}
+
+int main()
+{
+ __asm__ volatile (".set my_info, .LPBX2");
+ __gcov_info_to_gcda (my_info, filename, dump, allocate, &counter);
+ assert (counter > 4);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/gimplefe-45.c b/gcc/testsuite/gcc.dg/gimplefe-45.c
new file mode 100644
index 0000000..b1d3cbb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gimplefe-45.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fgimple" } */
+
+/* This used to ICE when simplifying (A & C) != 0 ? D : 0
+ for pointer types. */
+
+int *__GIMPLE ()
+p (int n)
+{
+ int *_2;
+ int *_t;
+ int *_t1;
+ _t = (int*)8;
+ _t1 = 0;
+ n = n & 2;
+ _2 = n != 0 ? _t : _t1;
+ return _2;
+}
+
diff --git a/gcc/testsuite/gcc.dg/gimplefe-error-10.c b/gcc/testsuite/gcc.dg/gimplefe-error-10.c
new file mode 100644
index 0000000..13d86ac
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gimplefe-error-10.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+__GIMPLE
+void foo() {
+ int t1;
+ t1_1 = t1_1(); /* { dg-error "invalid call" } */
+}
diff --git a/gcc/testsuite/gcc.dg/gimplefe-error-11.c b/gcc/testsuite/gcc.dg/gimplefe-error-11.c
new file mode 100644
index 0000000..9c29717
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gimplefe-error-11.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+int bar();
+__GIMPLE
+int foo()
+{
+ if (bar()) /* { dg-error "comparison required" } */
+ goto bb1;
+ else
+ goto bb2;
+}
diff --git a/gcc/testsuite/gcc.dg/gimplefe-error-9.c b/gcc/testsuite/gcc.dg/gimplefe-error-9.c
new file mode 100644
index 0000000..87014c1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gimplefe-error-9.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+void __GIMPLE
+foo()
+{
+bb1:
+bb1:; /* { dg-error "duplicate" } */
+}
diff --git a/gcc/testsuite/gcc.dg/goacc/loop-processing-1.c b/gcc/testsuite/gcc.dg/goacc/loop-processing-1.c
index bd4c07e..78b9aed 100644
--- a/gcc/testsuite/gcc.dg/goacc/loop-processing-1.c
+++ b/gcc/testsuite/gcc.dg/goacc/loop-processing-1.c
@@ -1,5 +1,5 @@
/* Make sure that OpenACC loop processing happens. */
-/* { dg-additional-options "-O2 -fdump-tree-oaccdevlow" } */
+/* { dg-additional-options "-O2 -fdump-tree-oaccloops" } */
extern int place ();
@@ -15,4 +15,4 @@ void vector_1 (int *ary, int size)
}
}
-/* { dg-final { scan-tree-dump {OpenACC loops.*Loop 0\(0\).*Loop 24\(1\).*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_HEAD_MARK, 0, 1, 36\);.*Head-0:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_HEAD_MARK, 0, 1, 36\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_FORK, \.data_dep\.[0-9_]+, 0\);.*Tail-0:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_TAIL_MARK, \.data_dep\.[0-9_]+, 1\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_JOIN, \.data_dep\.[0-9_]+, 0\);.*Loop 6\(6\).*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_HEAD_MARK, 0, 2, 6\);.*Head-0:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_HEAD_MARK, 0, 2, 6\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_FORK, \.data_dep\.[0-9_]+, 1\);.*Head-1:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_HEAD_MARK, \.data_dep\.[0-9_]+, 1\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_FORK, \.data_dep\.[0-9_]+, 2\);.*Tail-1:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_TAIL_MARK, \.data_dep\.[0-9_]+, 2\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_JOIN, \.data_dep\.[0-9_]+, 2\);.*Tail-0:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_TAIL_MARK, \.data_dep\.[0-9_]+, 1\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_JOIN, \.data_dep\.[0-9_]+, 1\);} "oaccdevlow" } } */
+/* { dg-final { scan-tree-dump {OpenACC loops.*Loop 0\(0\).*Loop 24\(1\).*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_HEAD_MARK, 0, 1, 36\);.*Head-0:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_HEAD_MARK, 0, 1, 36\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_FORK, \.data_dep\.[0-9_]+, 0\);.*Tail-0:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_TAIL_MARK, \.data_dep\.[0-9_]+, 1\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_JOIN, \.data_dep\.[0-9_]+, 0\);.*Loop 6\(6\).*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_HEAD_MARK, 0, 2, 6\);.*Head-0:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_HEAD_MARK, 0, 2, 6\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_FORK, \.data_dep\.[0-9_]+, 1\);.*Head-1:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_HEAD_MARK, \.data_dep\.[0-9_]+, 1\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_FORK, \.data_dep\.[0-9_]+, 2\);.*Tail-1:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_TAIL_MARK, \.data_dep\.[0-9_]+, 2\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_JOIN, \.data_dep\.[0-9_]+, 2\);.*Tail-0:.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_TAIL_MARK, \.data_dep\.[0-9_]+, 1\);.*\.data_dep\.[0-9_]+ = \.UNIQUE \(OACC_JOIN, \.data_dep\.[0-9_]+, 1\);} "oaccloops" } } */
diff --git a/gcc/testsuite/gcc.dg/gomp/atomic-5.c b/gcc/testsuite/gcc.dg/gomp/atomic-5.c
index 70cfb35..36d1422 100644
--- a/gcc/testsuite/gcc.dg/gomp/atomic-5.c
+++ b/gcc/testsuite/gcc.dg/gomp/atomic-5.c
@@ -27,7 +27,7 @@ void f1(void)
#pragma omp atomic
bar() += 1; /* { dg-error "lvalue required" } */
#pragma omp atomic a /* { dg-error "expected end of line" } */
- x++; /* { dg-error "expected 'read', 'write', 'update', 'capture', 'seq_cst', 'acq_rel', 'release', 'relaxed' or 'hint' clause" "" { target *-*-* } .-1 } */
+ x++; /* { dg-error "expected 'read', 'write', 'update', 'capture', 'compare', 'weak', 'fail', 'seq_cst', 'acq_rel', 'release', 'relaxed' or 'hint' clause" "" { target *-*-* } .-1 } */
#pragma omp atomic
; /* { dg-error "expected expression" } */
#pragma omp atomic
diff --git a/gcc/testsuite/gcc.dg/gomp/barrier-2.c b/gcc/testsuite/gcc.dg/gomp/barrier-2.c
index c0d62f5..ef605a0 100644
--- a/gcc/testsuite/gcc.dg/gomp/barrier-2.c
+++ b/gcc/testsuite/gcc.dg/gomp/barrier-2.c
@@ -16,8 +16,7 @@ void f1(void)
void f2(void)
{
- label: /* { dg-error "label at end of compound statement" } */
- /* { dg-warning "defined but not used" "" { target *-*-* } .-1 } */
+ label: /* { dg-warning "defined but not used" } */
#pragma omp barrier /* { dg-error "may only be used in compound statements" } */
}
diff --git a/gcc/testsuite/gcc.dg/gomp/clause-1.c b/gcc/testsuite/gcc.dg/gomp/clause-1.c
index 9d34b041..8e7cc95 100644
--- a/gcc/testsuite/gcc.dg/gomp/clause-1.c
+++ b/gcc/testsuite/gcc.dg/gomp/clause-1.c
@@ -56,7 +56,7 @@ foo (int x)
;
#pragma omp p reduction (|:d) /* { dg-error "has invalid type for" } */
;
-#pragma omp p reduction (&&:d) /* { dg-error "has invalid type for" } */
+#pragma omp p reduction (&:d) /* { dg-error "has invalid type for" } */
;
#pragma omp p copyin (d) /* { dg-error "must be 'threadprivate'" } */
;
diff --git a/gcc/testsuite/gcc.dg/gomp/declare-simd-5.c b/gcc/testsuite/gcc.dg/gomp/declare-simd-5.c
index b9a4161..9397820 100644
--- a/gcc/testsuite/gcc.dg/gomp/declare-simd-5.c
+++ b/gcc/testsuite/gcc.dg/gomp/declare-simd-5.c
@@ -15,7 +15,7 @@ f1 (int x)
lab:
#pragma omp declare simd simdlen (8) aligned (b : 8 * sizeof (int))
extern int f5 (int a, int *b, int c); /* { dg-error "must be followed by function declaration or definition" } */
- x++; /* { dg-error "a label can only be part of a statement and a declaration is not a statement" "" { target *-*-* } .-1 } */
+ x++;
}
return x;
}
diff --git a/gcc/testsuite/gcc.dg/gomp/declare-variant-2.c b/gcc/testsuite/gcc.dg/gomp/declare-variant-2.c
index 39c2c1d..3da5dc7 100644
--- a/gcc/testsuite/gcc.dg/gomp/declare-variant-2.c
+++ b/gcc/testsuite/gcc.dg/gomp/declare-variant-2.c
@@ -17,7 +17,7 @@ f1 (int x)
lab:
#pragma omp declare variant (fn0) match (user={condition(0)})
extern int f5 (int a, int *b, int c); /* { dg-error "must be followed by function declaration or definition" } */
- x++; /* { dg-error "a label can only be part of a statement and a declaration is not a statement" "" { target *-*-* } .-1 } */
+ x++;
}
return x;
}
diff --git a/gcc/testsuite/gcc.dg/gomp/nesting-1.c b/gcc/testsuite/gcc.dg/gomp/nesting-1.c
index 52fcda7..ed457ce 100644
--- a/gcc/testsuite/gcc.dg/gomp/nesting-1.c
+++ b/gcc/testsuite/gcc.dg/gomp/nesting-1.c
@@ -19,9 +19,13 @@ f1 (void)
}
#pragma omp single /* { dg-error "may not be closely nested" } */
;
- #pragma omp master /* { dg-error "may not be closely nested" } */
- ;
+ #pragma omp master /* { dg-error "may not be closely nested" } */
+ ;
+ #pragma omp masked /* { dg-error "may not be closely nested" } */
+ ;
#pragma omp barrier /* { dg-error "may not be closely nested" } */
+ #pragma omp scope /* { dg-error "may not be closely nested" } */
+ ;
}
#pragma omp sections
{
@@ -50,6 +54,16 @@ f1 (void)
}
#pragma omp sections
{
+ #pragma omp masked /* { dg-error "may not be closely nested" } */
+ ;
+ }
+ #pragma omp sections
+ {
+ #pragma omp scope /* { dg-error "may not be closely nested" } */
+ ;
+ }
+ #pragma omp sections
+ {
#pragma omp section
;
}
@@ -81,6 +95,15 @@ f1 (void)
#pragma omp section
#pragma omp master /* { dg-error "may not be closely nested" } */
;
+ #pragma omp section
+ #pragma omp masked /* { dg-error "may not be closely nested" } */
+ ;
+ }
+ #pragma omp sections
+ {
+ #pragma omp section
+ #pragma omp scope /* { dg-error "may not be closely nested" } */
+ ;
}
#pragma omp single
{
@@ -97,7 +120,11 @@ f1 (void)
;
#pragma omp master /* { dg-error "may not be closely nested" } */
;
+ #pragma omp masked /* { dg-error "may not be closely nested" } */
+ ;
#pragma omp barrier /* { dg-error "may not be closely nested" } */
+ #pragma omp scope /* { dg-error "may not be closely nested" } */
+ ;
}
#pragma omp master
{
@@ -115,6 +142,27 @@ f1 (void)
#pragma omp master
;
#pragma omp barrier /* { dg-error "may not be closely nested" } */
+ #pragma omp scope /* { dg-error "may not be closely nested" } */
+ ;
+ }
+ #pragma omp masked filter (1)
+ {
+ #pragma omp for /* { dg-error "may not be closely nested" } */
+ for (j = 0; j < 3; j++)
+ ;
+ #pragma omp sections /* { dg-error "may not be closely nested" } */
+ {
+ ;
+ #pragma omp section
+ ;
+ }
+ #pragma omp single /* { dg-error "may not be closely nested" } */
+ ;
+ #pragma omp master
+ ;
+ #pragma omp barrier /* { dg-error "may not be closely nested" } */
+ #pragma omp scope /* { dg-error "may not be closely nested" } */
+ ;
}
#pragma omp task
{
@@ -131,7 +179,11 @@ f1 (void)
;
#pragma omp master /* { dg-error "may not be closely nested" } */
;
+ #pragma omp masked /* { dg-error "may not be closely nested" } */
+ ;
#pragma omp barrier /* { dg-error "may not be closely nested" } */
+ #pragma omp scope /* { dg-error "may not be closely nested" } */
+ ;
}
#pragma omp parallel
{
@@ -148,7 +200,42 @@ f1 (void)
;
#pragma omp master
;
+ #pragma omp masked
+ ;
+ #pragma omp barrier
+ #pragma omp scope
+ ;
+ #pragma omp scope
+ {
+ #pragma omp scope
+ ;
+ }
+ }
+ #pragma omp scope
+ {
+ #pragma omp for
+ for (j = 0; j < 3; j++)
+ ;
+ #pragma omp sections
+ {
+ ;
+ #pragma omp section
+ ;
+ }
+ #pragma omp single
+ ;
+ #pragma omp master
+ ;
+ #pragma omp masked
+ ;
#pragma omp barrier
+ #pragma omp scope
+ ;
+ #pragma omp scope
+ {
+ #pragma omp scope
+ ;
+ }
}
}
@@ -171,7 +258,11 @@ f2 (void)
;
#pragma omp master
;
+ #pragma omp masked
+ ;
#pragma omp barrier /* { dg-error "may not be closely nested" } */
+ #pragma omp scope /* { dg-error "may not be closely nested" } */
+ ;
}
}
@@ -182,6 +273,8 @@ f3 (void)
{
#pragma omp ordered /* { dg-error "may not be closely nested" } */
;
+ #pragma omp scope /* { dg-error "may not be closely nested" } */
+ ;
}
}
@@ -192,6 +285,8 @@ f4 (void)
{
#pragma omp ordered /* { dg-error "may not be closely nested" } */
;
+ #pragma omp scope /* { dg-error "may not be closely nested" } */
+ ;
}
}
diff --git a/gcc/testsuite/gcc.dg/gomp/pr100508.c b/gcc/testsuite/gcc.dg/gomp/pr100508.c
new file mode 100644
index 0000000..c3fa2fc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/pr100508.c
@@ -0,0 +1,14 @@
+/* PR middle-end/100508 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g -fopenmp-simd" } */
+
+typedef int __attribute__((__vector_size__(32))) V;
+V j;
+
+#pragma omp declare simd
+int
+foo (void)
+{
+ V m = j;
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/scan-1.c b/gcc/testsuite/gcc.dg/gomp/scan-1.c
new file mode 100644
index 0000000..807071d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/scan-1.c
@@ -0,0 +1,51 @@
+int baz (void);
+void qux (int);
+int r;
+
+int
+foo (void)
+{
+ int r = 0, i;
+ void bar (void) { r++; }
+ #pragma omp parallel for reduction(inscan, +:r)
+ for (i = 0; i < 64; i++)
+ {
+ r += baz ();
+ #pragma omp scan inclusive(r)
+ qux (r);
+ }
+ #pragma omp parallel for reduction(inscan, +:r)
+ for (i = 0; i < 64; i++)
+ {
+ qux (r);
+ #pragma omp scan exclusive(r)
+ r += baz ();
+ }
+ bar ();
+ return r;
+}
+
+int
+corge (void)
+{
+ int r = 0, i;
+ void bar (void)
+ {
+ #pragma omp parallel for reduction(inscan, +:r)
+ for (i = 0; i < 64; i++)
+ {
+ r += baz ();
+ #pragma omp scan inclusive(r)
+ qux (r);
+ }
+ #pragma omp parallel for reduction(inscan, +:r)
+ for (i = 0; i < 64; i++)
+ {
+ qux (r);
+ #pragma omp scan exclusive(r)
+ r += baz ();
+ }
+ }
+ bar ();
+ return r;
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/simd-clones-2.c b/gcc/testsuite/gcc.dg/gomp/simd-clones-2.c
index 75554de..9f7c84d 100644
--- a/gcc/testsuite/gcc.dg/gomp/simd-clones-2.c
+++ b/gcc/testsuite/gcc.dg/gomp/simd-clones-2.c
@@ -7,6 +7,7 @@ int addit(int a, int b, int *c)
return a + b;
}
/* { dg-warning "GCC does not currently support mixed size types for 'simd' functions" "" { target aarch64*-*-* } .-4 } */
+/* { dg-final { scan-tree-dump {(?n)^__attribute__\(\(omp declare simd \(notinbranch aligned\(2:32\)\), omp declare simd \(inbranch uniform\(2\) linear\(1:66\)\)\)\)$} "optimized" } } */
#pragma omp declare simd uniform(a) aligned(a:32) linear(k:1) notinbranch
float setArray(float *a, float x, int k)
@@ -14,6 +15,7 @@ float setArray(float *a, float x, int k)
a[k] = a[k] + x;
return a[k];
}
+/* { dg-final { scan-tree-dump {(?n)^__attribute__\(\(omp declare simd \(notinbranch uniform\(0\) aligned\(0:32\) linear\(2:1\)\)\)\)$} "optimized" } } */
/* { dg-final { scan-tree-dump "_ZGVbN4ua32vl_setArray" "optimized" { target i?86-*-* x86_64-*-* } } } */
/* { dg-final { scan-tree-dump "_ZGVbN4vvva32_addit" "optimized" { target i?86-*-* x86_64-*-* } } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/fuse-1.c b/gcc/testsuite/gcc.dg/graphite/fuse-1.c
index 204d3b2..527b6e5 100644
--- a/gcc/testsuite/gcc.dg/graphite/fuse-1.c
+++ b/gcc/testsuite/gcc.dg/graphite/fuse-1.c
@@ -1,6 +1,6 @@
/* Check that the two loops are fused and that we manage to fold the two xor
operations. */
-/* { dg-options "-O2 -floop-nest-optimize -fdump-tree-forwprop-all -fdump-tree-graphite-all" } */
+/* { dg-options "-O2 -floop-nest-optimize -fdump-tree-forwprop4 -fdump-tree-graphite-all" } */
/* Make sure we fuse the loops like this:
AST generated by isl:
@@ -12,7 +12,7 @@ for (int c0 = 0; c0 <= 99; c0 += 1) {
/* { dg-final { scan-tree-dump-times "AST generated by isl:.*for \\(int c0 = 0; c0 <= 99; c0 \\+= 1\\) \\{.*S_.*\\(c0\\);.*S_.*\\(c0\\);.*S_.*\\(c0\\);.*\\}" 1 "graphite" } } */
/* Check that after fusing the loops, the scalar computation is also fused. */
-/* { dg-final { scan-tree-dump-times "gimple_simplified to\[^\\n\]*\\^ 12" 1 "forwprop4" } } */
+/* { dg-final { scan-tree-dump-times " \\^ 12;" 2 "forwprop4" } } */
#define MAX 100
int A[MAX];
diff --git a/gcc/testsuite/gcc.dg/guality/example.c b/gcc/testsuite/gcc.dg/guality/example.c
index 26d25c2..6f1c017 100644
--- a/gcc/testsuite/gcc.dg/guality/example.c
+++ b/gcc/testsuite/gcc.dg/guality/example.c
@@ -1,5 +1,6 @@
-/* { dg-do run { xfail *-*-* } } */
+/* { dg-do run { xfail { ! aarch64*-*-* } } } */
/* { dg-options "-g" } */
+/* { dg-xfail-run-if "" aarch64*-*-* "*" { "-O[01g]" } } */
#define GUALITY_DONT_FORCE_LIVE_AFTER -1
diff --git a/gcc/testsuite/gcc.dg/guality/guality.c b/gcc/testsuite/gcc.dg/guality/guality.c
index db015e6..a4de564 100644
--- a/gcc/testsuite/gcc.dg/guality/guality.c
+++ b/gcc/testsuite/gcc.dg/guality/guality.c
@@ -1,4 +1,4 @@
-/* { dg-do run { xfail *-*-* } } */
+/* { dg-do run { xfail { ! aarch64*-*-* } } } */
/* { dg-options "-g" } */
/* { dg-require-effective-target alloca } */
diff --git a/gcc/testsuite/gcc.dg/guality/inline-params.c b/gcc/testsuite/gcc.dg/guality/inline-params.c
index f4c5f15..6be240a 100644
--- a/gcc/testsuite/gcc.dg/guality/inline-params.c
+++ b/gcc/testsuite/gcc.dg/guality/inline-params.c
@@ -3,7 +3,7 @@
inlining inlines the functions too early to test the real IPA passes (such
as IPA-CP). */
/* { dg-options "-g -fno-early-inlining -fno-ipa-sra" } */
-/* { dg-xfail-run-if "" { "*-*-*" } { "-O2" "-O3" "-Os" } } */
+/* { dg-xfail-run-if "" { ! aarch64*-*-* } { "-O2" "-O3" "-Os" } } */
#define GUALITY_DONT_FORCE_LIVE_AFTER -1
diff --git a/gcc/testsuite/gcc.dg/guality/loop-1.c b/gcc/testsuite/gcc.dg/guality/loop-1.c
index 8da447d..1b1f6d3 100644
--- a/gcc/testsuite/gcc.dg/guality/loop-1.c
+++ b/gcc/testsuite/gcc.dg/guality/loop-1.c
@@ -17,6 +17,6 @@ foo (int n)
/* The following works only with final value replacement or with the NOP
but not without (which means -Og). Vectorization breaks it, so disable
that. At -O3 it currently fails, PR89983. */
- __asm__ volatile (NOP : : "g" (i) : "memory"); /* { dg-final { gdb-test . "i" "1" } } */
+ __asm__ volatile (NOP : : "g" (i) : "memory"); /* { dg-final { gdb-test . "i" "1" { xfail { aarch64*-*-* && { any-opts "-ftracer" } } } } } */
}
int main() { foo(1); }
diff --git a/gcc/testsuite/gcc.dg/guality/pr101905.c b/gcc/testsuite/gcc.dg/guality/pr101905.c
new file mode 100644
index 0000000..71b7516
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/guality/pr101905.c
@@ -0,0 +1,15 @@
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
+/* { dg-options "-g -ffixed-r15" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+
+register unsigned long long regVar asm ("r15");
+
+int
+main()
+{
+ regVar = 0xdeadbeefcafebabeULL;
+ asm ("nop" : "+r" (regVar));
+ asm volatile ("nop"); /* { dg-final { gdb-test . "regVar" "0xdeadbeefcafebabeULL" } } */
+ asm volatile ("nop" : : "r" (regVar));
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/guality/pr36728-1.c b/gcc/testsuite/gcc.dg/guality/pr36728-1.c
index 0ab475a..5864c2a 100644
--- a/gcc/testsuite/gcc.dg/guality/pr36728-1.c
+++ b/gcc/testsuite/gcc.dg/guality/pr36728-1.c
@@ -32,7 +32,7 @@ foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7)
/* { dg-final { gdb-test 16 "arg5" "5" } } */
/* { dg-final { gdb-test 16 "arg6" "6" } } */
/* { dg-final { gdb-test 16 "arg7" "30" } } */
-/* { dg-final { gdb-test 16 "y" "2" } } */
+/* { dg-final { gdb-test 16 "y" "2" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" } } } } } */
/* { dg-final { gdb-test 18 "arg1" "1" { target { ! "s390*-*-*" } } } } */
/* { dg-final { gdb-test 18 "arg2" "2" { target { ! "s390*-*-*" } } } } */
/* { dg-final { gdb-test 18 "arg3" "3" } } */
diff --git a/gcc/testsuite/gcc.dg/guality/pr36728-2.c b/gcc/testsuite/gcc.dg/guality/pr36728-2.c
index 7ba8663..6e8d775 100644
--- a/gcc/testsuite/gcc.dg/guality/pr36728-2.c
+++ b/gcc/testsuite/gcc.dg/guality/pr36728-2.c
@@ -25,21 +25,21 @@ foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7)
and arg2. So it is expected that these values are unavailable in
some of these tests. */
-/* { dg-final { gdb-test 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */
-/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */
-/* { dg-final { gdb-test 16 "arg3" "3" } } */
-/* { dg-final { gdb-test 16 "arg4" "4" } } */
-/* { dg-final { gdb-test 16 "arg5" "5" } } */
-/* { dg-final { gdb-test 16 "arg6" "6" } } */
-/* { dg-final { gdb-test 16 "arg7" "30" } } */
-/* { dg-final { gdb-test 16 "y" "2" } } */
-/* { dg-final { gdb-test 18 "arg1" "1" { target { ! "s390*-*-*" } } } } */
-/* { dg-final { gdb-test 18 "arg2" "2" { target { ! "s390*-*-*" } } } } */
-/* { dg-final { gdb-test 18 "arg3" "3" } } */
-/* { dg-final { gdb-test 18 "arg4" "4" } } */
-/* { dg-final { gdb-test 18 "arg5" "5" } } */
-/* { dg-final { gdb-test 18 "arg6" "6" } } */
-/* { dg-final { gdb-test 18 "arg7" "30" } } */
+/* { dg-final { gdb-test 16 "arg1" "1" { target { ! "s390*-*-*" } xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 16 "arg3" "3" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 16 "arg4" "4" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 16 "arg5" "5" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 16 "arg6" "6" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 16 "arg7" "30" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 16 "y" "2" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" } } } } } */
+/* { dg-final { gdb-test 18 "arg1" "1" { target { ! "s390*-*-*" } xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 18 "arg2" "2" { target { ! "s390*-*-*" } xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 18 "arg3" "3" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 18 "arg4" "4" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 18 "arg5" "5" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 18 "arg6" "6" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
+/* { dg-final { gdb-test 18 "arg7" "30" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-O3" } } } } } */
/* { dg-final { gdb-test 18 "*x" "(char) 25" } } */
/* { dg-final { gdb-test 18 "y" "2" } } */
diff --git a/gcc/testsuite/gcc.dg/guality/pr36728-3.c b/gcc/testsuite/gcc.dg/guality/pr36728-3.c
index 4700d50..589009b 100644
--- a/gcc/testsuite/gcc.dg/guality/pr36728-3.c
+++ b/gcc/testsuite/gcc.dg/guality/pr36728-3.c
@@ -30,7 +30,7 @@ foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7)
/* { dg-final { gdb-test 14 "arg5" "5" } } */
/* { dg-final { gdb-test 14 "arg6" "6" } } */
/* { dg-final { gdb-test 14 "arg7" "30" } } */
-/* { dg-final { gdb-test 14 "y" "2" } } */
+/* { dg-final { gdb-test 14 "y" "2" { xfail { aarch64*-*-* && { any-opts "-O3" } } } } } */
/* { dg-final { gdb-test 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */
/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */
/* { dg-final { gdb-test 16 "arg3" "3" } } */
diff --git a/gcc/testsuite/gcc.dg/guality/pr41353-1.c b/gcc/testsuite/gcc.dg/guality/pr41353-1.c
index cd30632..6639a52 100644
--- a/gcc/testsuite/gcc.dg/guality/pr41353-1.c
+++ b/gcc/testsuite/gcc.dg/guality/pr41353-1.c
@@ -22,7 +22,7 @@ f2 (int i, int j)
{
j += i;
/* { dg-final { gdb-test .+4 "i" "37" } } */
- /* { dg-final { gdb-test .+3 "j" "28 + 37" { xfail *-*-* } } } */
+ /* { dg-final { gdb-test .+3 "j" "28 + 37" { xfail { no-opts "-O0" } } } } */
int i1 = 2 * i; /* { dg-final { gdb-test .+2 "i1" "2 * 37" } } */
int i2 = 3 * i; /* { dg-final { gdb-test .+1 "i2" "3 * 37" } } */
return j;
diff --git a/gcc/testsuite/gcc.dg/guality/pr41447-1.c b/gcc/testsuite/gcc.dg/guality/pr41447-1.c
index 308ef94..9fde33e 100644
--- a/gcc/testsuite/gcc.dg/guality/pr41447-1.c
+++ b/gcc/testsuite/gcc.dg/guality/pr41447-1.c
@@ -1,5 +1,6 @@
/* { dg-do run } */
/* { dg-options "-g" } */
+/* { dg-xfail-run-if "" { aarch64*-*-* } { "-O2" "-O3" "-Os" } { "-fno-fat-lto-objects" } } */
#include "guality.h"
diff --git a/gcc/testsuite/gcc.dg/guality/pr43077-1.c b/gcc/testsuite/gcc.dg/guality/pr43077-1.c
index 39bd26a..2d93762 100644
--- a/gcc/testsuite/gcc.dg/guality/pr43077-1.c
+++ b/gcc/testsuite/gcc.dg/guality/pr43077-1.c
@@ -24,7 +24,7 @@ int __attribute__((noinline))
foo (unsigned long *p, unsigned long *q)
{
int ret;
- asm volatile ("" : "=r" (ret), "=r" (*p), "=r" (*q) : "0" (1), "1" (2), "2" (3));
+ asm volatile ("" : "=r" (ret), "=r" (*p), "=r" (*q) : "0" (1), "1" (2l), "2" (3l));
return ret;
}
diff --git a/gcc/testsuite/gcc.dg/guality/pr49888.c b/gcc/testsuite/gcc.dg/guality/pr49888.c
index 4f3a250..919cfc9 100644
--- a/gcc/testsuite/gcc.dg/guality/pr49888.c
+++ b/gcc/testsuite/gcc.dg/guality/pr49888.c
@@ -4,7 +4,7 @@
static int v __attribute__((used));
-static void __attribute__((noinline, noclone))
+static void __attribute__((noipa))
f (int *p)
{
int c = *p;
diff --git a/gcc/testsuite/gcc.dg/guality/pr54200.c b/gcc/testsuite/gcc.dg/guality/pr54200.c
index e873d1b..ba14221 100644
--- a/gcc/testsuite/gcc.dg/guality/pr54200.c
+++ b/gcc/testsuite/gcc.dg/guality/pr54200.c
@@ -17,7 +17,7 @@ foo (int z, int x, int b)
else
{
int a = (x + z) + b;
- return a; /* { dg-final { gdb-test . "z" "3" } } */
+ return a; /* { dg-final { gdb-test . "z" "3" { xfail { aarch64*-*-* && { no-opts "-O0" "-Og" } } } } } */
}
}
diff --git a/gcc/testsuite/gcc.dg/guality/pr54519-1.c b/gcc/testsuite/gcc.dg/guality/pr54519-1.c
index a4105ab..81703eb 100644
--- a/gcc/testsuite/gcc.dg/guality/pr54519-1.c
+++ b/gcc/testsuite/gcc.dg/guality/pr54519-1.c
@@ -16,11 +16,11 @@ fn2 (int x, int y, int z)
{
fn1 (x);
fn1 (x); /* { dg-final { gdb-test .+2 "x" "36" } } */
- if (x == 36) /* { dg-final { gdb-test .+1 "y" "25" } } */
- fn1 (x); /* { dg-final { gdb-test . "z" "6" } } */
+ if (x == 36) /* { dg-final { gdb-test .+1 "y" "25" { xfail { aarch64*-*-* && { any-opts "-flto" } } } } } */
+ fn1 (x); /* { dg-final { gdb-test . "z" "6" { xfail { aarch64*-*-* && { any-opts "-flto" } } } } } */
fn1 (x); /* { dg-final { gdb-test .+2 "x" "98" } } */
- if (x == 98) /* { dg-final { gdb-test .+1 "y" "117" } } */
- fn1 (x); /* { dg-final { gdb-test . "z" "8" } } */
+ if (x == 98) /* { dg-final { gdb-test .+1 "y" "117" { xfail { aarch64*-*-* && { any-opts "-flto" } } } } } */
+ fn1 (x); /* { dg-final { gdb-test . "z" "8" { xfail { aarch64*-*-* && { any-opts "-flto" } } } } } */
fn1 (x);
fn1 (x + a);
}
diff --git a/gcc/testsuite/gcc.dg/guality/pr54519-2.c b/gcc/testsuite/gcc.dg/guality/pr54519-2.c
index 6bc1683..e1368bf 100644
--- a/gcc/testsuite/gcc.dg/guality/pr54519-2.c
+++ b/gcc/testsuite/gcc.dg/guality/pr54519-2.c
@@ -14,7 +14,7 @@ fn2 (int x, int y)
if (y)
{
fn1 (x); /* { dg-final { gdb-test .+1 "x" "6" } } */
- fn1 (x); /* { dg-final { gdb-test . "y" "25" } } */
+ fn1 (x); /* { dg-final { gdb-test . "y" "25" { xfail { aarch64*-*-* && { any-opts "-flto" } } } } } */
fn1 (x);
fn1 (x);
y = -2 + x;
diff --git a/gcc/testsuite/gcc.dg/guality/pr54519-3.c b/gcc/testsuite/gcc.dg/guality/pr54519-3.c
index da18247..fabab96 100644
--- a/gcc/testsuite/gcc.dg/guality/pr54519-3.c
+++ b/gcc/testsuite/gcc.dg/guality/pr54519-3.c
@@ -16,11 +16,11 @@ fn2 (int x, int y, int z)
{
fn1 (x);
fn1 (x); /* { dg-final { gdb-test .+2 "x" "36" } } */
- if (x == 36) /* { dg-final { gdb-test .+1 "y" "25" } } */
- fn1 (x); /* { dg-final { gdb-test . "z" "6" } } */
+ if (x == 36) /* { dg-final { gdb-test .+1 "y" "25" { xfail { aarch64*-*-* && { any-opts "-flto" } } } } } */
+ fn1 (x); /* { dg-final { gdb-test . "z" "6" { xfail { aarch64*-*-* && { any-opts "-flto" } } } } } */
fn1 (x); /* { dg-final { gdb-test .+2 "x" "98" } } */
- if (x == 98) /* { dg-final { gdb-test .+1 "y" "117" } } */
- fn1 (x); /* { dg-final { gdb-test . "z" "8" } } */
+ if (x == 98) /* { dg-final { gdb-test .+1 "y" "117" { xfail { aarch64*-*-* && { any-opts "-flto" } } } } } */
+ fn1 (x); /* { dg-final { gdb-test . "z" "8" { xfail { aarch64*-*-* && { any-opts "-flto" } } } } } */
fn1 (x);
fn1 (x + a);
}
diff --git a/gcc/testsuite/gcc.dg/guality/pr54519-4.c b/gcc/testsuite/gcc.dg/guality/pr54519-4.c
index c82de58..fd8465f 100644
--- a/gcc/testsuite/gcc.dg/guality/pr54519-4.c
+++ b/gcc/testsuite/gcc.dg/guality/pr54519-4.c
@@ -14,7 +14,7 @@ fn2 (int x, int y)
if (y)
{
fn1 (x); /* { dg-final { gdb-test .+1 "x" "6" } } */
- fn1 (x); /* { dg-final { gdb-test . "y" "25" } } */
+ fn1 (x); /* { dg-final { gdb-test . "y" "25" { xfail { aarch64*-*-* && { any-opts "-flto" } } } } } */
fn1 (x);
fn1 (x);
y = -2 + x;
diff --git a/gcc/testsuite/gcc.dg/guality/pr54519-5.c b/gcc/testsuite/gcc.dg/guality/pr54519-5.c
index 0903fbf..76fa1e3 100644
--- a/gcc/testsuite/gcc.dg/guality/pr54519-5.c
+++ b/gcc/testsuite/gcc.dg/guality/pr54519-5.c
@@ -14,7 +14,7 @@ fn2 (int x, int y)
if (y)
{
fn1 (x); /* { dg-final { gdb-test .+1 "x" "6" } } */
- fn1 (x); /* { dg-final { gdb-test . "y" "25" } } */
+ fn1 (x); /* { dg-final { gdb-test . "y" "25" { xfail { aarch64*-*-* && { any-opts "-flto" } } } } } */
fn1 (x);
fn1 (x);
y = -2 + x;
diff --git a/gcc/testsuite/gcc.dg/guality/pr54519-6.c b/gcc/testsuite/gcc.dg/guality/pr54519-6.c
index bb3fb5f..732c268 100644
--- a/gcc/testsuite/gcc.dg/guality/pr54519-6.c
+++ b/gcc/testsuite/gcc.dg/guality/pr54519-6.c
@@ -7,7 +7,7 @@
static inline void
f1 (int x, int y)
{
- asm volatile (NOP); /* { dg-final { gdb-test .+1 "x" "2" } } */
+ asm volatile (NOP); /* { dg-final { gdb-test .+1 "x" "2" { xfail { aarch64*-*-* && { any-opts "-Os" } } } } } */
asm volatile (NOP); /* { dg-final { gdb-test . "y" "0" } } */
}
diff --git a/gcc/testsuite/gcc.dg/guality/pr54693-2.c b/gcc/testsuite/gcc.dg/guality/pr54693-2.c
index 1741a38..68aa6c6 100644
--- a/gcc/testsuite/gcc.dg/guality/pr54693-2.c
+++ b/gcc/testsuite/gcc.dg/guality/pr54693-2.c
@@ -19,7 +19,7 @@ foo (int x, int y, int z)
{ /* { dg-final { gdb-test .+2 "i" "v + 1" } } */
/* { dg-final { gdb-test .+1 "x" "10 - i" } } */
bar (i); /* { dg-final { gdb-test . "y" "20 - 2 * i" } } */
- /* { dg-final { gdb-test .-1 "z" "30 - 3 * i" } } */
+ /* { dg-final { gdb-test .-1 "z" "30 - 3 * i" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" "-Os" } } } } } */
i++, x--, y -= 2, z -= 3;
}
}
diff --git a/gcc/testsuite/gcc.dg/guality/pr54970.c b/gcc/testsuite/gcc.dg/guality/pr54970.c
index 2e0bc57..e60cc04 100644
--- a/gcc/testsuite/gcc.dg/guality/pr54970.c
+++ b/gcc/testsuite/gcc.dg/guality/pr54970.c
@@ -8,39 +8,39 @@
int
main ()
{
- int a[] = { 1, 2, 3 }; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { *-*-* } } } } */
+ int a[] = { 1, 2, 3 }; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { no-opts "-O0" "-Og" } } } } */
int *p = a + 2; /* { dg-final { gdb-test .+3 "a\[1\]" "2" } } */
int *q = a + 1; /* { dg-final { gdb-test .+2 "a\[2\]" "3" } } */
/* { dg-final { gdb-test .+1 "*p" "3" } } */
asm volatile (NOP); /* { dg-final { gdb-test . "*q" "2" } } */
- *p += 10; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { *-*-* } } } } */
+ *p += 10; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { no-opts "-O0" "-Og" } } } } */
/* { dg-final { gdb-test .+3 "a\[1\]" "2" } } */
/* { dg-final { gdb-test .+2 "a\[2\]" "13" } } */
/* { dg-final { gdb-test .+1 "*p" "13" } } */
asm volatile (NOP); /* { dg-final { gdb-test . "*q" "2" } } */
- *q += 10; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { *-*-* } } } } */
+ *q += 10; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { no-opts "-O0" "-Og" } } } } */
/* { dg-final { gdb-test .+3 "a\[1\]" "12" } } */
/* { dg-final { gdb-test .+2 "a\[2\]" "13" } } */
/* { dg-final { gdb-test .+1 "*p" "13" } } */
asm volatile (NOP); /* { dg-final { gdb-test . "*q" "12" } } */
__builtin_memcpy (&a, (int [3]) { 4, 5, 6 }, sizeof (a));
- /* { dg-final { gdb-test .+4 "a\[0\]" "4" { xfail { *-*-* } } } } */
+ /* { dg-final { gdb-test .+4 "a\[0\]" "4" { xfail { no-opts "-O0" "-Og" } } } } */
/* { dg-final { gdb-test .+3 "a\[1\]" "5" } } */
/* { dg-final { gdb-test .+2 "a\[2\]" "6" } } */
/* { dg-final { gdb-test .+1 "*p" "6" } } */
asm volatile (NOP); /* { dg-final { gdb-test . "*q" "5" } } */
- *p += 20; /* { dg-final { gdb-test .+4 "a\[0\]" "4" { xfail { *-*-* } } } } */
+ *p += 20; /* { dg-final { gdb-test .+4 "a\[0\]" "4" { xfail { no-opts "-O0" "-Og" } } } } */
/* { dg-final { gdb-test .+3 "a\[1\]" "5" } } */
/* { dg-final { gdb-test .+2 "a\[2\]" "26" } } */
/* { dg-final { gdb-test .+1 "*p" "26" } } */
asm volatile (NOP); /* { dg-final { gdb-test . "*q" "5" } } */
- *q += 20; /* { dg-final { gdb-test .+8 "a\[0\]" "4" { xfail { *-*-* } } } } */
+ *q += 20; /* { dg-final { gdb-test .+8 "a\[0\]" "4" { xfail { no-opts "-O0" "-Og" } } } } */
/* { dg-final { gdb-test .+7 "a\[1\]" "25" } } */
/* { dg-final { gdb-test .+6 "a\[2\]" "26" } } */
/* { dg-final { gdb-test .+5 "*p" "26" } } */
/* { dg-final { gdb-test .+4 "p\[-1\]" "25" } } */
- /* { dg-final { gdb-test .+3 "p\[-2\]" "4" { xfail { *-*-* } } } } */
- /* { dg-final { gdb-test .+2 "q\[-1\]" "4" { xfail { *-*-* } } } } */
+ /* { dg-final { gdb-test .+3 "p\[-2\]" "4" { xfail { no-opts "-O0" "-Og" } } } } */
+ /* { dg-final { gdb-test .+2 "q\[-1\]" "4" { xfail { no-opts "-O0" "-Og" } } } } */
/* { dg-final { gdb-test .+1 "q\[1\]" "26" } } */
asm volatile (NOP); /* { dg-final { gdb-test . "*q" "25" } } */
return 0;
diff --git a/gcc/testsuite/gcc.dg/guality/pr56154-1.c b/gcc/testsuite/gcc.dg/guality/pr56154-1.c
index 4f02bc9..d6da4a7 100644
--- a/gcc/testsuite/gcc.dg/guality/pr56154-1.c
+++ b/gcc/testsuite/gcc.dg/guality/pr56154-1.c
@@ -17,7 +17,7 @@ foo (int fd, union U x)
asm (NOP : : : "memory"); /* { dg-final { gdb-test pr56154-1.c:17 "x.a" "4" } } */
z = x.a;
x.a = 6;
- asm (NOP : : : "memory"); /* { dg-final { gdb-test pr56154-1.c:20 "x.a" "6" } } */
+ asm (NOP : : : "memory"); /* { dg-final { gdb-test pr56154-1.c:20 "x.a" "6" { xfail { aarch64*-*-* && { any-opts "-Og" } } } } } */
return result;
}
diff --git a/gcc/testsuite/gcc.dg/guality/pr59776.c b/gcc/testsuite/gcc.dg/guality/pr59776.c
index 7c95a9f..0e48559 100644
--- a/gcc/testsuite/gcc.dg/guality/pr59776.c
+++ b/gcc/testsuite/gcc.dg/guality/pr59776.c
@@ -9,14 +9,14 @@ struct S { float f, g; };
__attribute__((noipa)) void
foo (struct S *p)
{
- struct S s1, s2; /* { dg-final { gdb-test pr59776.c:17 "s1.f" "5.0" } } */
- s1 = *p; /* { dg-final { gdb-test pr59776.c:17 "s1.g" "6.0" } } */
- s2 = s1; /* { dg-final { gdb-test pr59776.c:17 "s2.f" "0.0" } } */
- *(int *) &s2.f = 0; /* { dg-final { gdb-test pr59776.c:17 "s2.g" "6.0" { xfail *-*-* } } } */
- asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s1.f" "5.0" } } */
- asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s1.g" "6.0" } } */
- s2 = s1; /* { dg-final { gdb-test pr59776.c:20 "s2.f" "5.0" } } */
- asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s2.g" "6.0" { xfail *-*-* } } } */
+ struct S s1, s2; /* { dg-final { gdb-test pr59776.c:17 "s1.f" "5.0" { xfail { aarch64*-*-* && { any-opts "-Og" } } } } } */
+ s1 = *p; /* { dg-final { gdb-test pr59776.c:17 "s1.g" "6.0" { xfail { aarch64*-*-* && { any-opts "-Og" } } } } } */
+ s2 = s1; /* { dg-final { gdb-test pr59776.c:17 "s2.f" "0.0" { xfail { aarch64*-*-* && { any-opts "-Og" } } } } } */
+ *(int *) &s2.f = 0; /* { dg-final { gdb-test pr59776.c:17 "s2.g" "6.0" { xfail { no-opts "-O0" } } } } */
+ asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s1.f" "5.0" { xfail { aarch64*-*-* && { any-opts "-Og" } } } } } */
+ asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s1.g" "6.0" { xfail { aarch64*-*-* && { any-opts "-Og" } } } } } */
+ s2 = s1; /* { dg-final { gdb-test pr59776.c:20 "s2.f" "5.0" { xfail { aarch64*-*-* && { any-opts "-Og" } } } } } */
+ asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s2.g" "6.0" { xfail { no-opts "-O0" } } } } */
asm volatile (NOP : : : "memory");
}
diff --git a/gcc/testsuite/gcc.dg/guality/pr68860-1.c b/gcc/testsuite/gcc.dg/guality/pr68860-1.c
index 8c8d835..bbd9d6e 100644
--- a/gcc/testsuite/gcc.dg/guality/pr68860-1.c
+++ b/gcc/testsuite/gcc.dg/guality/pr68860-1.c
@@ -31,7 +31,7 @@ foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int a
/* { dg-final { gdb-test 14 "arg6" "6" } } */
/* { dg-final { gdb-test 14 "arg7" "30" } } */
/* { dg-final { gdb-test 14 "arg8" "7" } } */
-/* { dg-final { gdb-test 14 "y" "2" } } */
+/* { dg-final { gdb-test 14 "y" "2" { xfail { aarch64*-*-* && { { any-opts "-O2" "-O3" } && { no-opts "-flto" } } } } } } */
/* { dg-final { gdb-test 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */
/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */
/* { dg-final { gdb-test 16 "arg3" "3" } } */
diff --git a/gcc/testsuite/gcc.dg/guality/pr68860-2.c b/gcc/testsuite/gcc.dg/guality/pr68860-2.c
index 070efbc..a18a04e 100644
--- a/gcc/testsuite/gcc.dg/guality/pr68860-2.c
+++ b/gcc/testsuite/gcc.dg/guality/pr68860-2.c
@@ -31,7 +31,7 @@ foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int a
/* { dg-final { gdb-test 14 "arg6" "6" } } */
/* { dg-final { gdb-test 14 "arg7" "30" } } */
/* { dg-final { gdb-test 14 "arg8" "7" } } */
-/* { dg-final { gdb-test 14 "y" "2" } } */
+/* { dg-final { gdb-test 14 "y" "2" { xfail { aarch64*-*-* && { any-opts "-O3" } } } } } */
/* { dg-final { gdb-test 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */
/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */
/* { dg-final { gdb-test 16 "arg3" "3" } } */
diff --git a/gcc/testsuite/gcc.dg/guality/pr90074.c b/gcc/testsuite/gcc.dg/guality/pr90074.c
index 1294928..2fd8842 100644
--- a/gcc/testsuite/gcc.dg/guality/pr90074.c
+++ b/gcc/testsuite/gcc.dg/guality/pr90074.c
@@ -25,7 +25,7 @@ int main()
debug stmt for the final value of the loop during loop distribution
which would fix the UNSUPPORTED cases.
c is optimized out at -Og for no obvious reason. */
- optimize_me_not(); /* { dg-final { gdb-test . "i + 1" "8" } } */
- /* { dg-final { gdb-test .-1 "c + 1" "2" } } */
+ optimize_me_not(); /* { dg-final { gdb-test . "i + 1" "8" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" } } } } } */
+ /* { dg-final { gdb-test .-1 "c + 1" "2" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" } } } } } */
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/guality/pr90716.c b/gcc/testsuite/gcc.dg/guality/pr90716.c
index b2f5c9d..fe7e556 100644
--- a/gcc/testsuite/gcc.dg/guality/pr90716.c
+++ b/gcc/testsuite/gcc.dg/guality/pr90716.c
@@ -20,6 +20,6 @@ int main()
Instead test j + 1 which will make the test UNSUPPORTED if i
is optimized out. Since the test previously had wrong debug
with j == 0 this is acceptable. */
- optimize_me_not(); /* { dg-final { gdb-test . "j + 1" "9" } } */
+ optimize_me_not(); /* { dg-final { gdb-test . "j + 1" "9" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" } } } } } */
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/guality/sra-1.c b/gcc/testsuite/gcc.dg/guality/sra-1.c
index 8ad57cf..e9b920e 100644
--- a/gcc/testsuite/gcc.dg/guality/sra-1.c
+++ b/gcc/testsuite/gcc.dg/guality/sra-1.c
@@ -18,7 +18,7 @@ f1 (int k)
asm ("" : "+r" (a.i));
a.j++;
bar (a.i); /* { dg-final { gdb-test .+1 "a.i" "4" } } */
- bar (a.j); /* { dg-final { gdb-test . "a.j" "14" } } */
+ bar (a.j); /* { dg-final { gdb-test . "a.j" "14" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" } } } } } */
return a.i + a.j;
}
@@ -29,7 +29,7 @@ f2 (int k)
asm ("" : "+r" (a[0]));
a[1]++;
bar (a[0]); /* { dg-final { gdb-test .+1 "a\[0\]" "4" } } */
- bar (a[1]); /* { dg-final { gdb-test . "a\[1\]" "14" } } */
+ bar (a[1]); /* { dg-final { gdb-test . "a\[1\]" "14" { xfail { aarch64*-*-* && { any-opts "-fno-fat-lto-objects" } } } } } */
return a[0] + a[1];
}
@@ -39,8 +39,8 @@ f3 (int k)
struct B a = { 4, k + 6 };
asm ("" : "+r" (a.i));
a.j++;
- bar (a.i); /* { dg-final { gdb-test .+1 "a.i" "4" } } */
- bar (a.j); /* { dg-final { gdb-test . "a.j" "14" } } */
+ bar (a.i); /* { dg-final { gdb-test .+1 "a.i" "4" { xfail { aarch64*-*-* && { any-opts "-Og" } } } } } */
+ bar (a.j); /* { dg-final { gdb-test . "a.j" "14" { xfail { aarch64*-*-* && { any-opts "-Og" "-fno-fat-lto-objects" } } } } } */
return a.i + a.j;
}
diff --git a/gcc/testsuite/gcc.dg/ipa/inline-8.c b/gcc/testsuite/gcc.dg/ipa/inline-8.c
index 388283c..c51eec2 100644
--- a/gcc/testsuite/gcc.dg/ipa/inline-8.c
+++ b/gcc/testsuite/gcc.dg/ipa/inline-8.c
@@ -6,13 +6,13 @@
#include <math.h>
extern int isnanf (float);
/* Can't be inlined because isnanf will be optimized out. */
-int
+static int
cmp (float a)
{
return isnanf (a);
}
/* Can be inlined. */
-int
+static int
move (int a)
{
return a;
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-sra-1.c b/gcc/testsuite/gcc.dg/ipa/ipa-sra-1.c
index df7e356..4a22e39 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-sra-1.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-sra-1.c
@@ -24,7 +24,7 @@ ox (struct bovid cow)
}
int
-main (int argc, char **argv)
+main (int argc, char *argv[])
{
struct bovid cow;
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-sra-19.c b/gcc/testsuite/gcc.dg/ipa/ipa-sra-19.c
index 8f3bb5d..c34c89e 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-sra-19.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-sra-19.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
/* { dg-options "-O2" } */
/* { dg-additional-options "-msse2" { target ia32 } } */
-/* { dg-additional-options "-Wno-psabi" { target powerpc-ibm-aix* } } */
+/* { dg-additional-options "-Wno-psabi" { target powerpc-ibm-aix* powerpc-wrs-vxworks* } } */
typedef int __attribute__((__vector_size__(16))) vectype;
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-sra-23.c b/gcc/testsuite/gcc.dg/ipa/ipa-sra-23.c
new file mode 100644
index 0000000..f438b50
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-sra-23.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+extern int g;
+
+static int __attribute__((noinline))
+bar (int i, int j)
+{
+ return 2*g + i;
+}
+
+static int __attribute__((noinline))
+foo (int i, int j)
+{
+ if (i > 5)
+ j = 22;
+ return bar (i, j) + 1;
+}
+
+int
+entry (int l, int k)
+{
+ return foo (l, k);
+}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-sra-24.c b/gcc/testsuite/gcc.dg/ipa/ipa-sra-24.c
new file mode 100644
index 0000000..7b5bf08
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-sra-24.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wmaybe-uninitialized -Werror" } */
+
+int *ttmp_1;
+_Bool pt_ins_tipdo, pq_ins_apd, pq_ins_tt2;
+int gtrphdt;
+
+void pl_ins(int, _Bool, _Bool);
+inline void pt_ins(int *, _Bool apdo) {
+ int list = *ttmp_1;
+ pl_ins(list, apdo, pt_ins_tipdo);
+}
+void pq_ins(int *t) {
+ if (pq_ins_tt2)
+ pt_ins(t, pq_ins_apd);
+}
+int gtr_post_hd() {
+ pq_ins(&gtrphdt);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/ipa/modref-1.c b/gcc/testsuite/gcc.dg/ipa/modref-1.c
index 858567d..5314e7d 100644
--- a/gcc/testsuite/gcc.dg/ipa/modref-1.c
+++ b/gcc/testsuite/gcc.dg/ipa/modref-1.c
@@ -10,15 +10,15 @@ void a(char *ptr, char *ptr2)
__attribute__((noinline))
void b(char *ptr)
{
- a(ptr+1,&ptr[2]);
+ a(ptr+1,&ptr[3]);
}
int main()
{
- char c[3]={0,1,0};
+ char c[4]={0,1,0,0};
b(c);
- return c[0]+c[2];
+ return c[0]+c[3];
}
/* Check that both param offsets are determined correctly. */
/* { dg-final { scan-ipa-dump "param offset:1" "modref" } } */
-/* { dg-final { scan-ipa-dump "param offset:2" "modref" } } */
+/* { dg-final { scan-ipa-dump "param offset:3" "modref" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/pr100600.c b/gcc/testsuite/gcc.dg/ipa/pr100600.c
new file mode 100644
index 0000000..8a3d0e1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr100600.c
@@ -0,0 +1,22 @@
+/* PR ipa/100600 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int a, b, c;
+long d(long x, long e, long f, long g) {
+ long h, i;
+ for (; h < e; h++) {
+ i = f;
+ for (; i < g; i++)
+ c = b + a;
+ }
+ return h + i;
+}
+
+long j(long x, long e, long y, long g) {
+ long h, i;
+ for (; h < e; h++)
+ for (; i < g; i++)
+ c = b + a;
+ return h + i;
+}
diff --git a/gcc/testsuite/gcc.dg/ipa/pr101066.c b/gcc/testsuite/gcc.dg/ipa/pr101066.c
new file mode 100644
index 0000000..1ceb6e4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr101066.c
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-options "-Os -fno-ipa-cp -fno-inline" } */
+
+int a = 1, c, d, e;
+int *b = &a;
+static int g(int *h) {
+ c = *h;
+ return d;
+}
+static void f(int *h) {
+ e = *h;
+ *b = 0;
+ g(h);
+}
+int main() {
+ f(b);
+ if (c)
+ __builtin_abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/ipa/pr93385.c b/gcc/testsuite/gcc.dg/ipa/pr93385.c
new file mode 100644
index 0000000..6d1d0d7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr93385.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-dce -fno-ipa-cp -fno-tree-dce" } */
+
+char a, b;
+
+#ifdef __SIZEOF_INT128__
+#define T unsigned __int128
+#else
+#define T unsigned
+#endif
+
+static inline int
+c (T d)
+{
+ char e = 0;
+ d %= (unsigned) d;
+ e -= 0;
+ __builtin_strncpy (&a, &e, 1);
+ return e + b;
+}
+
+int
+main (void)
+{
+ c (~0);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/ipa/propmalloc-4.c b/gcc/testsuite/gcc.dg/ipa/propmalloc-4.c
index 4c40d63..9552b73 100644
--- a/gcc/testsuite/gcc.dg/ipa/propmalloc-4.c
+++ b/gcc/testsuite/gcc.dg/ipa/propmalloc-4.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-local-pure-const-details" } */
+/* { dg-options "-O2 -fdump-tree-local-pure-const-details -fdelete-null-pointer-checks" } */
void *foo(int cond1, int cond2, int cond3)
{
diff --git a/gcc/testsuite/gcc.dg/ipa/remref-3.c b/gcc/testsuite/gcc.dg/ipa/remref-3.c
new file mode 100644
index 0000000..8a82ca6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/remref-3.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-early-inlining -fdump-ipa-cp-details -fdump-tree-optimized" } */
+
+static double global = 0.0;
+
+double foo_temp5;
+
+static void foo(double *ptr) {
+ static double abcd;
+ double v, exp_res;
+ v = *ptr;
+ exp_res = __builtin_exp(v);
+ foo_temp5 = exp_res * abcd;
+ abcd += foo_temp5;
+}
+
+void entry()
+{
+ foo(&global);
+}
+
+/* { dg-final { scan-ipa-dump "Removed a reference" "cp" } } */
+/* { dg-final { scan-tree-dump-not "builtin_exp" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/remref-4.c b/gcc/testsuite/gcc.dg/ipa/remref-4.c
new file mode 100644
index 0000000..5a55437
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/remref-4.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-early-inlining -fdump-ipa-cp-details -fdump-tree-optimized" } */
+
+static double global = 0.0;
+double foo_temp5;
+
+static void foo(double *ptr) {
+ static double abcd;
+ double v, exp_res;
+ v = *ptr;
+ exp_res = __builtin_exp(v);
+ foo_temp5 = exp_res * abcd;
+ abcd += foo_temp5;
+}
+
+double last_value;
+
+static void bar(double *ptr)
+{
+ last_value = *ptr;
+ foo (ptr);
+}
+
+void entry()
+{
+ bar (&global);
+}
+
+/* { dg-final { scan-ipa-dump "Removed a reference" "cp" } } */
+/* { dg-final { scan-ipa-dump "replaced it with LOAD" "cp" } } */
+/* { dg-final { scan-tree-dump-not "builtin_exp" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/remref-5.c b/gcc/testsuite/gcc.dg/ipa/remref-5.c
new file mode 100644
index 0000000..c520e34
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/remref-5.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fno-early-inlining -fdump-ipa-cp-details -fdump-tree-optimized" } */
+
+static double global = 0.0;
+double foo_temp5;
+
+static void foo(double *ptr) {
+ static double abcd;
+ double v, exp_res;
+ v = *ptr;
+ exp_res = __builtin_exp(v);
+ foo_temp5 = exp_res * abcd;
+ abcd += foo_temp5;
+}
+
+double last_value;
+
+static void bar(double *ptr)
+{
+ last_value = *ptr;
+ for (unsigned i = 0; i < 200; i++)
+ foo (ptr);
+}
+
+void entry()
+{
+ bar (&global);
+}
+
+void decoy(double *ptr)
+{
+ bar (ptr);
+}
+
+
+/* { dg-final { scan-ipa-dump "Removed a reference" "cp" } } */
+/* { dg-final { scan-ipa-dump "replaced it with LOAD" "cp" } } */
+/* { dg-final { scan-tree-dump-times "builtin_exp" 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/remref-6.c b/gcc/testsuite/gcc.dg/ipa/remref-6.c
new file mode 100644
index 0000000..7deae31
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/remref-6.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-early-inlining -fno-ipa-cp -fdump-ipa-inline -fdump-tree-optimized" } */
+
+static double global = 0.0;
+
+double foo_temp5;
+
+static void foo(double *ptr) {
+ static double abcd;
+ double v, exp_res;
+ v = *ptr;
+ exp_res = __builtin_exp(v);
+ foo_temp5 = exp_res * abcd;
+ abcd += foo_temp5;
+}
+
+void entry()
+{
+ foo(&global);
+}
+
+/* { dg-final { scan-ipa-dump "Removed a reference" "inline" } } */
+/* { dg-final { scan-ipa-dump "replaced it with LOAD" "inline" } } */
+/* { dg-final { scan-tree-dump-not "builtin_exp" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/local1.c b/gcc/testsuite/gcc.dg/local1.c
index e9f653b..448c71b 100644
--- a/gcc/testsuite/gcc.dg/local1.c
+++ b/gcc/testsuite/gcc.dg/local1.c
@@ -10,7 +10,7 @@
the later daclaration is the same as the linkage specified at
the prior declaration. If no prior declaration is visible,
or if the prior declaration specifies no linkage, then the
- identifer has external linkage.
+ identifier has external linkage.
This is PR 14366. */
diff --git a/gcc/testsuite/gcc.dg/loop-unswitch-2.c b/gcc/testsuite/gcc.dg/loop-unswitch-2.c
index f8d314e..0931f6e 100644
--- a/gcc/testsuite/gcc.dg/loop-unswitch-2.c
+++ b/gcc/testsuite/gcc.dg/loop-unswitch-2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */
+/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details -fdisable-tree-thread2 -fdisable-tree-thread3" } */
void foo (float **a, float **b, float *c, int n, int m, int l)
{
diff --git a/gcc/testsuite/gcc.dg/lto/pr101868_0.c b/gcc/testsuite/gcc.dg/lto/pr101868_0.c
new file mode 100644
index 0000000..c84d19b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr101868_0.c
@@ -0,0 +1,33 @@
+/* { dg-lto-do run } */
+/* { dg-lto-options { "-O2 -fno-strict-aliasing -flto" } } */
+
+typedef unsigned long VALUE;
+
+__attribute__ ((cold))
+void rb_check_type(VALUE, int);
+
+static VALUE
+repro(VALUE dummy, VALUE hash)
+{
+ if (hash == 0) {
+ rb_check_type(hash, 1);
+ }
+ else if (*(long *)hash) {
+ rb_check_type(hash, 1);
+ }
+
+
+ return *(long *)hash;
+}
+
+static VALUE (*that)(VALUE dummy, VALUE hash) = repro;
+
+int
+main(int argc, char **argv)
+{
+ argc--;
+ that(0, argc);
+
+ rb_check_type(argc, argc);
+
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr101868_1.c b/gcc/testsuite/gcc.dg/lto/pr101868_1.c
new file mode 100644
index 0000000..146c14a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr101868_1.c
@@ -0,0 +1,23 @@
+typedef unsigned long VALUE;
+
+
+__attribute__ ((noreturn)) void rexc_raise(VALUE mesg);
+
+VALUE rb_donothing(VALUE klass);
+
+static void
+funexpected_type(VALUE x, int xt, int t)
+{
+ rexc_raise(rb_donothing(0));
+}
+
+__attribute__ ((cold))
+void
+rb_check_type(VALUE x, int t)
+{
+ int xt;
+
+ if (x == 0) {
+ funexpected_type(x, xt, t);
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr101868_2.c b/gcc/testsuite/gcc.dg/lto/pr101868_2.c
new file mode 100644
index 0000000..e6f01b2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr101868_2.c
@@ -0,0 +1,11 @@
+typedef unsigned long VALUE;
+
+static void thing(void) {}
+static void (*ptr)(void) = &thing;
+
+VALUE
+rb_donothing(VALUE klass)
+{
+ ptr();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr101868_3.c b/gcc/testsuite/gcc.dg/lto/pr101868_3.c
new file mode 100644
index 0000000..6121762
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr101868_3.c
@@ -0,0 +1,8 @@
+typedef unsigned long VALUE;
+
+__attribute__((noreturn))
+void
+rexc_raise(VALUE mesg)
+{
+ __builtin_exit(0);
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr101949_0.c b/gcc/testsuite/gcc.dg/lto/pr101949_0.c
new file mode 100644
index 0000000..142dffe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr101949_0.c
@@ -0,0 +1,20 @@
+/* { dg-lto-do run } */
+/* { dg-lto-options { "-O2 -fipa-pta -flto -flto-partition=1to1" } } */
+
+extern int bar (int (*)(int *), int *);
+
+static int x;
+
+static int __attribute__ ((noinline)) foo (int *p)
+{
+ *p = 1;
+ x = 0;
+ return *p;
+}
+
+int main ()
+{
+ if (bar (foo, &x) != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr101949_1.c b/gcc/testsuite/gcc.dg/lto/pr101949_1.c
new file mode 100644
index 0000000..871d15c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr101949_1.c
@@ -0,0 +1,4 @@
+int __attribute__((noinline,noclone)) bar (int (*fn)(int *), int *p)
+{
+ return fn (p);
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr48622_1.c b/gcc/testsuite/gcc.dg/lto/pr48622_1.c
new file mode 100644
index 0000000..4d05bae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr48622_1.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fno-lto" } */
+
+typedef unsigned int u8 __attribute__ ((mode (QI)));
+u8 ashift_qi_1 (u8)
+{
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr99849_0.c b/gcc/testsuite/gcc.dg/lto/pr99849_0.c
new file mode 100644
index 0000000..d489cee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr99849_0.c
@@ -0,0 +1,23 @@
+/* PR lto/99849 */
+/* { dg-lto-do link } */
+/* { dg-require-effective-target fpic } */
+/* { dg-require-effective-target shared } */
+/* { dg-extra-ld-options { -shared } } */
+/* { dg-lto-options { { -flto -flto-partition=1to1 -O2 -Wno-incompatible-pointer-types -Wno-discarded-qualifiers -fPIC } } } */
+
+struct { struct A *a; } *b;
+struct B { int *b; };
+struct C { int *c; };
+const struct D { struct C d; } d;
+struct A { struct { struct C e; }; };
+struct E { void *e; } e = { &( &(const struct D) { (void *) &d })->d };
+struct C f = { &( &(const struct D) { (void *) &d })->d };
+struct A g[] = { &e, &f };
+void foo () { b->a = g; }
+struct E h = { foo };
+void bar ();
+int baz () { bar (h); }
+struct B i = { (int *) baz };
+void qux ();
+void corge () { qux (i); }
+void *j __attribute__((__used__)) = corge;
diff --git a/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-2.c b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-2.c
new file mode 100644
index 0000000..2e93ee5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-2.c
@@ -0,0 +1,15 @@
+/* { dg-require-effective-target global_constructor } */
+/* { dg-options "-O2 -fprofile-generate -fprofile-update=single -fdump-tree-optimized" } */
+
+__attribute__ ((no_profile_instrument_function))
+int foo()
+{
+ return 0;
+}
+
+int bar()
+{
+ return foo();
+}
+
+/* { dg-final { scan-tree-dump-not " = foo \\(\\)" "optimized"} } */
diff --git a/gcc/testsuite/gcc.dg/nonnull-6.c b/gcc/testsuite/gcc.dg/nonnull-6.c
new file mode 100644
index 0000000..8f36870
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/nonnull-6.c
@@ -0,0 +1,15 @@
+/* PR c/100783 - ICE on -Wnonnull and erroneous type
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+__attribute__((nonnull (1))) void
+f1 (char[][n]); // { dg-error "undeclared" }
+
+__attribute__((nonnull (2))) void
+f2 (int n, char[n][m]); // { dg-error "undeclared" }
+
+__attribute__((nonnull (1))) void
+f3 (char[*][n]); // { dg-error "undeclared" }
+
+__attribute__((nonnull (1))) void
+f4 (char[f1]); // { dg-error "size" }
diff --git a/gcc/testsuite/gcc.dg/old-style-asm-1.c b/gcc/testsuite/gcc.dg/old-style-asm-1.c
index 8af0077..f9406ff0 100644
--- a/gcc/testsuite/gcc.dg/old-style-asm-1.c
+++ b/gcc/testsuite/gcc.dg/old-style-asm-1.c
@@ -1,6 +1,9 @@
/* PR inline-asm/8832 */
/* { dg-do compile } */
-/* { dg-options "-O2 -dP" } */
+/* { dg-options "-O2 -dP -fdisable-tree-ethread -fdisable-tree-thread1 -fdisable-tree-thread2 -fdisable-tree-thread3 -fdisable-tree-thread4" } */
+
+/* Note: Threader will duplicate BBs and replace one conditional branch by an
+ unconditional one. */
/* Verify that GCC doesn't optimize
old style asm instructions. */
diff --git a/gcc/testsuite/gcc.dg/optimize-bswapdi-1.c b/gcc/testsuite/gcc.dg/optimize-bswapdi-1.c
index a4a3a79..56a2071b 100644
--- a/gcc/testsuite/gcc.dg/optimize-bswapdi-1.c
+++ b/gcc/testsuite/gcc.dg/optimize-bswapdi-1.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
/* { dg-require-effective-target bswap } */
/* { dg-require-effective-target stdint_types } */
-/* { dg-options "-O2 -fdump-tree-bswap" } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
/* { dg-additional-options "-mzarch" { target s390*-*-* } } */
#include <stdint.h>
@@ -58,4 +58,4 @@ swap64_c (uint64_t x)
}
-/* { dg-final { scan-tree-dump-times "64 bit bswap implementation found at" 3 "bswap" } } */
+/* { dg-final { scan-tree-dump-times "= __builtin_bswap64 \\\(" 3 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/optimize-bswapdi-2.c b/gcc/testsuite/gcc.dg/optimize-bswapdi-2.c
index 89b251f..c6d9604 100644
--- a/gcc/testsuite/gcc.dg/optimize-bswapdi-2.c
+++ b/gcc/testsuite/gcc.dg/optimize-bswapdi-2.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
/* { dg-require-effective-target bswap } */
/* { dg-require-effective-target stdint_types } */
-/* { dg-options "-O2 -fdump-tree-bswap" } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
/* { dg-additional-options "-mzarch" { target s390*-*-* } } */
#include <stdint.h>
@@ -23,4 +23,4 @@ swap64_c (uint64_t x)
}
-/* { dg-final { scan-tree-dump-times "64 bit bswap implementation found at" 1 "bswap" } } */
+/* { dg-final { scan-tree-dump-times "= __builtin_bswap64 \\\(" 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/optimize-bswapsi-1.c b/gcc/testsuite/gcc.dg/optimize-bswapsi-1.c
index c403d04..2d24f43 100644
--- a/gcc/testsuite/gcc.dg/optimize-bswapsi-1.c
+++ b/gcc/testsuite/gcc.dg/optimize-bswapsi-1.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
/* { dg-require-effective-target bswap } */
/* { dg-require-effective-target stdint_types } */
-/* { dg-options "-O2 -fdump-tree-bswap" } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
/* { dg-additional-options "-march=z900" { target s390*-*-* } } */
#include <stdint.h>
@@ -89,4 +89,4 @@ swap32_f (unsigned in)
return in;
}
-/* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 6 "bswap" } } */
+/* { dg-final { scan-tree-dump-times "= __builtin_bswap32 \\\(" 6 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/optimize-bswapsi-3.c b/gcc/testsuite/gcc.dg/optimize-bswapsi-3.c
index 9418a83..7cd1b40 100644
--- a/gcc/testsuite/gcc.dg/optimize-bswapsi-3.c
+++ b/gcc/testsuite/gcc.dg/optimize-bswapsi-3.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
/* { dg-require-effective-target bswap } */
/* { dg-require-effective-target stdint_types } */
-/* { dg-options "-O2 -fdump-tree-bswap" } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
/* { dg-additional-options "-march=z900" { target s390-*-* } } */
typedef int SItype __attribute__ ((mode (SI)));
@@ -20,4 +20,4 @@ swap32 (SItype in)
| (((in >> 24) & 0xFF) << 0);
}
-/* { dg-final { scan-tree-dump-not "32 bit bswap implementation found at" "bswap" } } */
+/* { dg-final { scan-tree-dump-times "= __builtin_bswap32 \\\(" 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/optimize-bswapsi-5.c b/gcc/testsuite/gcc.dg/optimize-bswapsi-5.c
index b4d8b9a..91a5284 100644
--- a/gcc/testsuite/gcc.dg/optimize-bswapsi-5.c
+++ b/gcc/testsuite/gcc.dg/optimize-bswapsi-5.c
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-require-effective-target bswap } */
-/* { dg-options "-O2 -fdump-tree-bswap -fno-inline-functions" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fno-inline-functions" } */
/* { dg-additional-options "-march=z900" { target s390-*-* } } */
struct L { unsigned int l[2]; };
@@ -28,4 +28,4 @@ bar (double a, struct L *p)
foo (a, p);
}
-/* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 2 "bswap" } } */
+/* { dg-final { scan-tree-dump-times "= __builtin_bswap32 \\\(" 2 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/optimize-bswapsi-6.c b/gcc/testsuite/gcc.dg/optimize-bswapsi-6.c
new file mode 100644
index 0000000..3c089b3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/optimize-bswapsi-6.c
@@ -0,0 +1,38 @@
+/* PR tree-optimization/42587 */
+/* { dg-do compile } */
+/* { dg-require-effective-target bswap } */
+/* { dg-options "-O2 -fdump-tree-store-merging" } */
+/* { dg-additional-options "-march=z900" { target s390-*-* } } */
+
+typedef unsigned char u8;
+typedef unsigned int u32;
+union __anonunion_out_195
+{
+ u32 value;
+ u8 bytes[4];
+};
+union __anonunion_in_196
+{
+ u32 value;
+ u8 bytes[4];
+};
+extern void acpi_ut_track_stack_ptr (void);
+u32 acpi_ut_dword_byte_swap (u32 value);
+u32
+acpi_ut_dword_byte_swap (u32 value)
+{
+ union __anonunion_out_195 out;
+ union __anonunion_in_196 in;
+
+ {
+ acpi_ut_track_stack_ptr ();
+ in.value = value;
+ out.bytes[0] = in.bytes[3];
+ out.bytes[1] = in.bytes[2];
+ out.bytes[2] = in.bytes[1];
+ out.bytes[3] = in.bytes[0];
+ return (out.value);
+ }
+}
+
+/* { dg-final { scan-tree-dump "32 bit bswap implementation found at" "store-merging" } } */
diff --git a/gcc/testsuite/gcc.dg/pch/valid-1.c b/gcc/testsuite/gcc.dg/pch/valid-1.c
index d445c47..6e9abda 100644
--- a/gcc/testsuite/gcc.dg/pch/valid-1.c
+++ b/gcc/testsuite/gcc.dg/pch/valid-1.c
@@ -1,7 +1,7 @@
/* { dg-require-effective-target pch_supported_debug } */
/* { dg-options "-I. -Winvalid-pch -g" } */
-#include "valid-1.h"/* { dg-warning "created with -gnone, but used with -g" } */
+#include "valid-1.h"/* { dg-warning "created with .none. debug info, but used with" } */
/* { dg-error "No such file" "no such file" { target *-*-* } 0 } */
/* { dg-error "they were invalid" "invalid files" { target *-*-* } 0 } */
/* { dg-message "terminated" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c b/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c
index 05133d5..61dd490 100644
--- a/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c
@@ -53,13 +53,6 @@ public:
const supernode *node,
const gimple *stmt) const FINAL OVERRIDE;
- void on_condition (sm_context *sm_ctxt,
- const supernode *node,
- const gimple *stmt,
- tree lhs,
- enum tree_code op,
- tree rhs) const FINAL OVERRIDE;
-
bool can_purge_p (state_t s) const FINAL OVERRIDE;
void check_for_pyobject_usage_without_gil (sm_context *sm_ctxt,
@@ -365,20 +358,6 @@ gil_state_machine::on_stmt (sm_context *sm_ctxt,
return false;
}
-/* Implementation of state_machine::on_condition vfunc for
- gil_state_machine. */
-
-void
-gil_state_machine::on_condition (sm_context *sm_ctxt ATTRIBUTE_UNUSED,
- const supernode *node ATTRIBUTE_UNUSED,
- const gimple *stmt ATTRIBUTE_UNUSED,
- tree lhs ATTRIBUTE_UNUSED,
- enum tree_code op ATTRIBUTE_UNUSED,
- tree rhs ATTRIBUTE_UNUSED) const
-{
- // Empty
-}
-
bool
gil_state_machine::can_purge_p (state_t s ATTRIBUTE_UNUSED) const
{
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
index 71e6740..ac72503 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
@@ -115,6 +115,8 @@ plugin_init (struct plugin_name_args *plugin_info,
if (!plugin_default_version_check (version, &gcc_version))
return 1;
+ global_dc->caret_max_width = 80;
+
register_callback (plugin_name,
PLUGIN_PRE_GENERICIZE,
callback,
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c
index 49b78cc..d2bfca0 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c
@@ -133,7 +133,7 @@ test_inlining (gimple *stmt)
return;
}
- warning_at (call->location, 0, "%G%s", call,
+ warning_at (call->location, 0, "%s",
TREE_STRING_POINTER (t_string));
}
@@ -169,6 +169,8 @@ plugin_init (struct plugin_name_args *plugin_info,
if (!plugin_default_version_check (version, &gcc_version))
return 1;
+ global_dc->caret_max_width = 80;
+
pass_info.pass = new pass_test_inlining (g);
pass_info.reference_pass_name = "*warn_function_noreturn";
pass_info.ref_pass_instance_number = 1;
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c
index 7672875..5c2da02 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c
@@ -450,6 +450,8 @@ plugin_init (struct plugin_name_args *plugin_info,
if (!plugin_default_version_check (version, &gcc_version))
return 1;
+ global_dc->caret_max_width = 80;
+
pass_info.pass = make_pass_test_show_path (g);
pass_info.reference_pass_name = "whole-program";
pass_info.ref_pass_instance_number = 1;
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
index cf99697..aa73dca 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
@@ -208,6 +208,8 @@ plugin_init (struct plugin_name_args *plugin_info,
if (!plugin_default_version_check (version, &gcc_version))
return 1;
+ global_dc->caret_max_width = 80;
+
pass_info.pass = new pass_test_string_literals (g);
pass_info.reference_pass_name = "ssa";
pass_info.ref_pass_instance_number = 1;
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
index 89cc95a..4a89d84 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
@@ -89,6 +89,8 @@ plugin_init (struct plugin_name_args *plugin_info,
if (!plugin_default_version_check (version, &gcc_version))
return 1;
+ global_dc->caret_max_width = 130;
+
register_callback (plugin_name,
PLUGIN_PRE_GENERICIZE,
callback,
diff --git a/gcc/testsuite/gcc.dg/pointer-array-quals-1.c b/gcc/testsuite/gcc.dg/pointer-array-quals-1.c
index 921a37e..498ab22 100644
--- a/gcc/testsuite/gcc.dg/pointer-array-quals-1.c
+++ b/gcc/testsuite/gcc.dg/pointer-array-quals-1.c
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* Origin: Martin Uecker <uecker@eecs.berkeley.edu> */
-/* { dg-options "-Wdiscarded-array-qualifiers" } */
+/* { dg-options "" } */
void tvoid(void* x);
void transpose0(double* out, const double* in) { }
void transpose1(double out[2][2], const double in[2][2]) { }
diff --git a/gcc/testsuite/gcc.dg/pointer-array-quals-2.c b/gcc/testsuite/gcc.dg/pointer-array-quals-2.c
index 30689c7..4c95d8a 100644
--- a/gcc/testsuite/gcc.dg/pointer-array-quals-2.c
+++ b/gcc/testsuite/gcc.dg/pointer-array-quals-2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-Wdiscarded-array-qualifiers -pedantic-errors" } */
+/* { dg-options "-pedantic-errors" } */
/* Origin: Martin Uecker <uecker@eecs.berkeley.edu> */
void tvoid(void* x);
void transpose0(double* out, const double* in) { }
diff --git a/gcc/testsuite/gcc.dg/pr100142.c b/gcc/testsuite/gcc.dg/pr100142.c
new file mode 100644
index 0000000..aec146c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100142.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-fpreprocessed" } */
+
+void
+foo (void)
+{
+ assert (1); /* { dg-warning "implicit" } */
+}
diff --git a/gcc/testsuite/gcc.dg/pr100225.c b/gcc/testsuite/gcc.dg/pr100225.c
new file mode 100644
index 0000000..b321634
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100225.c
@@ -0,0 +1,15 @@
+/* PR rtl-optimization/100225 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fmodulo-sched" } */
+
+void
+vorbis_synthesis_lapout (void);
+
+void
+ov_info (int **lappcm, int ov_info_i)
+{
+ while (ov_info_i < 1)
+ lappcm[ov_info_i++] = __builtin_alloca (1);
+
+ vorbis_synthesis_lapout ();
+}
diff --git a/gcc/testsuite/gcc.dg/pr100239.c b/gcc/testsuite/gcc.dg/pr100239.c
new file mode 100644
index 0000000..1ade810
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100239.c
@@ -0,0 +1,12 @@
+/* PR tree-optimization/100239 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+typedef short __attribute__((__vector_size__ (8 * sizeof (short)))) V;
+V v, w;
+
+void
+foo (void)
+{
+ w = __builtin_shuffle (v != v, 0 < (V) {}, (V) {192} >> 5);
+}
diff --git a/gcc/testsuite/gcc.dg/pr100292.c b/gcc/testsuite/gcc.dg/pr100292.c
new file mode 100644
index 0000000..675a60c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100292.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+typedef unsigned char __attribute__((__vector_size__ (4))) V;
+
+extern void bar (V v);
+
+void
+foo (char c)
+{
+ bar (c <= (V) 127);
+}
diff --git a/gcc/testsuite/gcc.dg/pr100349.c b/gcc/testsuite/gcc.dg/pr100349.c
new file mode 100644
index 0000000..dd7977a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100349.c
@@ -0,0 +1,16 @@
+// { dg-do compile }
+// { dg-options "-O2 -w" }
+
+#include <stdint.h>
+uint8_t a;
+b(int8_t c) {
+ int d;
+e:
+ uint32_t f;
+ for (;;)
+ for (c = 10; c; c++)
+ if (0 > (a = c) ?: d) {
+ f = a;
+ goto e;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/pr100373.c b/gcc/testsuite/gcc.dg/pr100373.c
new file mode 100644
index 0000000..d4cd52a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100373.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcompare-debug" } */
+
+int a;
+_Thread_local int b;
+void c()
+{
+ long d = b;
+ a = 0;
+ b = 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr100414.c b/gcc/testsuite/gcc.dg/pr100414.c
new file mode 100644
index 0000000..7876f6b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100414.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-dce -fno-tree-dse -fchecking" } */
+
+int i;
+void
+foo (void)
+{
+ i &= i && __builtin_bswap16 (i);
+}
diff --git a/gcc/testsuite/gcc.dg/pr100464.c b/gcc/testsuite/gcc.dg/pr100464.c
new file mode 100644
index 0000000..46cc37df
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100464.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fcompare-debug" } */
+
+int *a;
+static int b, c, d, e, g, h;
+int f;
+void i() {
+ int *j[] = {&e, &b, &b, &d, &b, &b, &g, &e, &g, &b, &b,
+ &b, &b, &g, &e, &e, &b, &b, &d, &b, &b, &e,
+ &e, &g, &b, &b, &b, &b, &g, &e, &g, &c, &e};
+ int **k = &j[5];
+ for (; f;)
+ b |= *a;
+ *k = &h;
+}
+int main() {}
diff --git a/gcc/testsuite/gcc.dg/pr100509.c b/gcc/testsuite/gcc.dg/pr100509.c
new file mode 100644
index 0000000..9405e2a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100509.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+struct X {
+ int a;
+};
+const int a = 0;
+static struct X A __attribute__((alias("a")));
+void foo() { struct X b = A; }
diff --git a/gcc/testsuite/gcc.dg/pr100512.c b/gcc/testsuite/gcc.dg/pr100512.c
new file mode 100644
index 0000000..70b90e0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100512.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -w" } */
+
+#include <stdint.h>
+int a;
+void b() {
+ int16_t *c;
+ uint16_t d = 2;
+ if (0 == d) {
+ uint64_t e;
+ uint64_t *f = &e;
+ for (;;) {
+ if (e += 0 >= 0)
+ for (;;)
+ ;
+ g:
+ for (; a;) {
+ int16_t i = &d;
+ *c = i && *f;
+ }
+ }
+ }
+ goto g;
+}
+
diff --git a/gcc/testsuite/gcc.dg/pr100521.c b/gcc/testsuite/gcc.dg/pr100521.c
new file mode 100644
index 0000000..fd9f0db
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100521.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int
+__builtin_clz (int a)
+{
+ return __builtin_clz(a);
+}
diff --git a/gcc/testsuite/gcc.dg/pr100547.c b/gcc/testsuite/gcc.dg/pr100547.c
new file mode 100644
index 0000000..2d3da4e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100547.c
@@ -0,0 +1,35 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O -g" } */
+
+typedef int __attribute__((vector_size(
+ ((((((((((((((((((((((((((((((8 * sizeof(short)) * sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)) *
+ sizeof(short)))) V; /* { dg-error "number of vector components" } */
+void k() { V w = { 0 }; }
diff --git a/gcc/testsuite/gcc.dg/pr100563.c b/gcc/testsuite/gcc.dg/pr100563.c
new file mode 100644
index 0000000..f6a5fcd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100563.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-Og -Wno-pointer-to-int-cast" } */
+unsigned long long e(void);
+void f(int);
+void a() {
+ short b = -1, c = (int)&b;
+ unsigned long long d = e();
+ f(b >= d);
+}
diff --git a/gcc/testsuite/gcc.dg/pr100590.c b/gcc/testsuite/gcc.dg/pr100590.c
new file mode 100644
index 0000000..5cd3687
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100590.c
@@ -0,0 +1,13 @@
+/* PR rtl-optimization/100590 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-dce -w" } */
+
+int
+foo (void)
+{
+ int x;
+ asm goto ("" : "+r" (x) : : : lab);
+ return 0;
+ lab:
+ return 1;
+}
diff --git a/gcc/testsuite/gcc.dg/pr100619.c b/gcc/testsuite/gcc.dg/pr100619.c
new file mode 100644
index 0000000..5df02bd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100619.c
@@ -0,0 +1,24 @@
+/* PR c/100619 - ICE on a VLA parameter with too many dimensions
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+extern int n;
+
+#define A10 [n][n][n][n][n][n][n][n][n][n]
+#define A100 A10 A10 A10 A10 A10 A10 A10 A10 A10 A10 A10
+#define A1000 A100 A100 A100 A100 A100 A100 A100 A100 A100 A100 A100
+
+void f10 (int A10);
+void f10 (int A10);
+
+void f100 (int A100);
+void f100 (int A100);
+
+void f1000 (int A1000);
+void f1000 (int A1000);
+
+void fx_1000 (int [ ]A1000);
+void fx_1000 (int [1]A1000); // { dg-warning "-Warray-parameter" }
+
+void fn_1000 (int [n ]A1000);
+void fn_1000 (int [n + 1]A1000); // { dg-warning "-Wvla-parameter" }
diff --git a/gcc/testsuite/gcc.dg/pr100781.c b/gcc/testsuite/gcc.dg/pr100781.c
new file mode 100644
index 0000000..c0e008a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100781.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 --param=evrp-mode=ranger -fcompare-debug " } */
+
+struct a {
+ int b;
+};
+long c(short d, long e, struct a f) {
+g:;
+ int h = f.b <= e, i = d, n = h >= d;
+ if (!n)
+ goto j;
+ goto k;
+j:;
+ long l = 5;
+ if (l)
+ goto m;
+ d = 0;
+m:
+ if (d)
+ return f.b;
+k:
+ goto g;
+}
+int main() { }
+
diff --git a/gcc/testsuite/gcc.dg/pr100788.c b/gcc/testsuite/gcc.dg/pr100788.c
new file mode 100644
index 0000000..6f510ec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100788.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "--coverage -Wno-error=coverage-invalid-line-number" } */
+
+void
+foo() // { dg-warning "function starts on a higher line number than it ends" }
+{
+#line 1
+}
+
+int main()
+{
+ foo ();
+}
diff --git a/gcc/testsuite/gcc.dg/pr100790.c b/gcc/testsuite/gcc.dg/pr100790.c
new file mode 100644
index 0000000..31e0eff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100790.c
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-options "-O2 -w" }
+
+__builtin_clz(int x) { x ? __builtin_clz(x) : 32; }
diff --git a/gcc/testsuite/gcc.dg/pr100791.c b/gcc/testsuite/gcc.dg/pr100791.c
new file mode 100644
index 0000000..96cf34f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100791.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+static inline int __attribute__((__always_inline__))
+foo ()
+{
+ return log_bad_request(0, __builtin_va_arg_pack()); /* { dg-warning "implicit" } */
+}
+void log_bad_request() { foo (0); } /* { dg-warning "conflicting types" } */
diff --git a/gcc/testsuite/gcc.dg/pr100887.c b/gcc/testsuite/gcc.dg/pr100887.c
new file mode 100644
index 0000000..027025f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100887.c
@@ -0,0 +1,14 @@
+/* PR target/100887 */
+/* { dg-do compile } */
+/* { dg-options "-Wno-psabi -w" } */
+/* { dg-additional-options "-mavx512f" { target { i?86-*-* x86_64-*-* } } } */
+
+typedef unsigned long long __attribute__((__vector_size__ (2 * sizeof (long long)))) U;
+typedef unsigned long long __attribute__((__vector_size__ (4 * sizeof (long long)))) V;
+typedef unsigned long long __attribute__((__vector_size__ (8 * sizeof (long long)))) W;
+
+U
+foo (V v)
+{
+ return __builtin_shufflevector ((W){}, v, 0, 8);
+}
diff --git a/gcc/testsuite/gcc.dg/pr101008.c b/gcc/testsuite/gcc.dg/pr101008.c
new file mode 100644
index 0000000..c06208d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101008.c
@@ -0,0 +1,18 @@
+/* PR rtl-optimization/101008 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+
+typedef unsigned __attribute__((__vector_size__(32))) U;
+typedef unsigned __attribute__((__vector_size__(16))) V;
+
+int c, r;
+
+V v;
+
+void
+foo(void)
+{
+ U u = __builtin_shufflevector (v, (V)(v != c) | (V)(c == v),
+ 4, 3, 5, 5, 1, 2, 3, 0);
+ r = ((union { U a; int b; }) u).b;
+}
diff --git a/gcc/testsuite/gcc.dg/pr101028.c b/gcc/testsuite/gcc.dg/pr101028.c
new file mode 100644
index 0000000..501e6af
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101028.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" } */
+
+typedef struct {
+ double x, y;
+} PointInfo;
+
+typedef struct {
+ PointInfo point;
+} PrimitiveInfo;
+
+int TraceBezier_alpha, TraceBezier_i;
+double TraceBezier_weight;
+PointInfo *TraceBezier_points;
+PrimitiveInfo *TraceBezier_primitive_info;
+
+void TracePath() {
+ double *coefficients;
+ PointInfo point;
+ long j;
+ for (; TraceBezier_i; TraceBezier_i++) {
+ point.x = point.y = TraceBezier_alpha = 1.0;
+ j = 0;
+ for (; j < 4; j++) {
+ point.x += TraceBezier_alpha * coefficients[j] *
+ TraceBezier_primitive_info->point.x;
+ point.y += TraceBezier_alpha * TraceBezier_primitive_info->point.y;
+ TraceBezier_alpha *= TraceBezier_weight;
+ TraceBezier_primitive_info++;
+ }
+ TraceBezier_points[TraceBezier_i] = point;
+ TraceBezier_weight += 1.0;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/pr101062.c b/gcc/testsuite/gcc.dg/pr101062.c
new file mode 100644
index 0000000..6c37ed8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101062.c
@@ -0,0 +1,29 @@
+/* PR middle-end/101062 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-toplevel-reorder -frename-registers" } */
+
+union U { signed b : 5; };
+int c;
+volatile union U d[7] = { { 8 } };
+short e = 1;
+
+__attribute__((noipa)) void
+foo ()
+{
+ d[6].b = 0;
+ d[6].b = 0;
+ d[6].b = 0;
+ d[6].b = 0;
+ d[6].b = 0;
+ e = 0;
+ c = 0;
+}
+
+int
+main ()
+{
+ foo ();
+ if (e != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr101156.c b/gcc/testsuite/gcc.dg/pr101156.c
new file mode 100644
index 0000000..5c25bd7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101156.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-fchecking" } */
+
+struct S { int i; };
+void baz(struct S *p)
+{
+ __builtin_setjmp(p--);
+}
diff --git a/gcc/testsuite/gcc.dg/pr101170.c b/gcc/testsuite/gcc.dg/pr101170.c
new file mode 100644
index 0000000..fc81062
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101170.c
@@ -0,0 +1,37 @@
+/* PR middle-end/101170 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+
+#include <stdarg.h>
+
+struct S { int a; int b[4]; } s;
+va_list ap;
+int i;
+long long l;
+
+struct S
+foo (int x)
+{
+ struct S a = {};
+ do
+ if (x)
+ return a;
+ while (1);
+}
+
+__attribute__((noipa)) void
+bar (void)
+{
+ for (; i; i++)
+ l |= va_arg (ap, long long) << s.b[i];
+ if (l)
+ foo (l);
+}
+
+void
+baz (int v, ...)
+{
+ va_start (ap, v);
+ bar ();
+ va_end (ap);
+}
diff --git a/gcc/testsuite/gcc.dg/pr101171.c b/gcc/testsuite/gcc.dg/pr101171.c
new file mode 100644
index 0000000..8d2bcab
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101171.c
@@ -0,0 +1,13 @@
+/* PR c/101171 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+extern void foo (void);
+int x = 0x1234;
+
+void
+bar (void)
+{
+ if (x != (sizeof ((enum T) 0x1234))) /* { dg-error "conversion to incomplete type" } */
+ foo ();
+}
diff --git a/gcc/testsuite/gcc.dg/pr101172.c b/gcc/testsuite/gcc.dg/pr101172.c
new file mode 100644
index 0000000..b9d098b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101172.c
@@ -0,0 +1,20 @@
+/* PR middle-end/101172 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+union U
+{
+ int a[3];
+ struct
+ {
+ int a : 3;
+ struct this_struct var; /* { dg-error "field 'var' has incomplete type" } */
+ } b;
+};
+
+const union U hello = {.a = {1, 2, 3}};
+
+void foo()
+{
+ int x = hello.b.a;
+}
diff --git a/gcc/testsuite/gcc.dg/pr101223.c b/gcc/testsuite/gcc.dg/pr101223.c
new file mode 100644
index 0000000..6d5a247
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101223.c
@@ -0,0 +1,44 @@
+/* PR tree-optimization/101223 */
+/* { dg-do run } */
+/* { dg-options "-O2 " } */
+
+struct {
+ int a : 1;
+} b;
+int c = 1, d;
+int foo1() {
+ for (; d < 2; d++) {
+ int e = ~c, f = 0, g;
+ if (e) {
+ f = c;
+ g = b.a;
+ b.a = f;
+ if (b.a >= g)
+ __builtin_abort();
+ }
+ c = f;
+ b.a = g;
+ }
+ return 0;
+}
+
+int foo2() {
+ for (; d < 2; d++) {
+ int e = ~c, f = 0, g;
+ if (e) {
+ f = c;
+ g = b.a;
+ b.a = f;
+ if (g <= b.a)
+ __builtin_abort();
+ }
+ c = f;
+ b.a = g;
+ }
+ return 0;
+}
+int main ()
+{
+ return foo1() + foo2();
+}
+
diff --git a/gcc/testsuite/gcc.dg/pr101254.c b/gcc/testsuite/gcc.dg/pr101254.c
new file mode 100644
index 0000000..b2460ed
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101254.c
@@ -0,0 +1,27 @@
+/* PR tree-optimization/101254 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fwrapv" } */
+
+int
+foo (long long imin, long long imax)
+{
+ if (imin > imax)
+ return 0;
+ else if (imax - imin < 0 || (imax - imin) + 1 < 0)
+ return 0;
+ return 1;
+}
+
+int
+main ()
+{
+ long long imax = __LONG_LONG_MAX__;
+ long long imin = -imax - 1;
+ if (!foo (-10, 10))
+ __builtin_abort ();
+ if (foo (-10, imax))
+ __builtin_abort ();
+ if (foo (imin, imax))
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr101266.c b/gcc/testsuite/gcc.dg/pr101266.c
new file mode 100644
index 0000000..d198089
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101266.c
@@ -0,0 +1,8 @@
+/* PR debug/101266 */
+/* { dg-do compile } */
+/* { dg-options "-g -O2" } */
+
+void
+foo (int (*p)[(int){1}])
+{
+}
diff --git a/gcc/testsuite/gcc.dg/pr101294.c b/gcc/testsuite/gcc.dg/pr101294.c
new file mode 100644
index 0000000..ca59b35
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101294.c
@@ -0,0 +1,15 @@
+/* PR middle-end/101294 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+/* { dg-additional-options "-mavx" { target avx } } */
+
+typedef __attribute__((__vector_size__ (sizeof (unsigned long long)))) unsigned long long U;
+typedef __attribute__((__vector_size__ (4 * sizeof (unsigned long long)))) unsigned long long V;
+
+extern U x;
+
+void
+foo (void)
+{
+ x = __builtin_shufflevector ((U){}, (V){}, 3);
+}
diff --git a/gcc/testsuite/gcc.dg/pr101384.c b/gcc/testsuite/gcc.dg/pr101384.c
new file mode 100644
index 0000000..7030c0a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101384.c
@@ -0,0 +1,39 @@
+/* PR target/101384 */
+/* { dg-do run } */
+/* { dg-options "-O2 -Wno-psabi -w" } */
+
+typedef unsigned char __attribute__((__vector_size__ (16))) U;
+typedef unsigned short __attribute__((__vector_size__ (8 * sizeof (short)))) V;
+
+U u;
+V v;
+
+__attribute__((noipa)) U
+foo (void)
+{
+ U y = (U) { 0x80, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff,
+ 0x80, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff } + u;
+ return y;
+}
+
+__attribute__((noipa)) V
+bar (void)
+{
+ V y = (V) { 0x8000, 0xffff, 0x8000, 0xffff,
+ 0x8000, 0xffff, 0x8000, 0xffff } + v;
+ return y;
+}
+
+int
+main ()
+{
+ U x = foo ();
+ for (unsigned i = 0; i < 16; i++)
+ if (x[i] != ((i & 3) ? 0xff : 0x80))
+ __builtin_abort ();
+ V y = bar ();
+ for (unsigned i = 0; i < 8; i++)
+ if (y[i] != ((i & 1) ? 0xffff : 0x8000))
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr101403.c b/gcc/testsuite/gcc.dg/pr101403.c
new file mode 100644
index 0000000..88df112
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101403.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+unsigned int foo (unsigned int a)
+{
+ unsigned int u = 0;
+ unsigned short b = __builtin_bswap16 (a);
+ return b >> (u, 12);
+}
+
+int main (void)
+{
+ unsigned int x = foo (0x80);
+ if (x != 0x0008)
+ __builtin_abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/pr101419.c b/gcc/testsuite/gcc.dg/pr101419.c
new file mode 100644
index 0000000..2cce383
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101419.c
@@ -0,0 +1,62 @@
+/* PR tree-optimization/101419 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef __SIZE_TYPE__ size_t;
+void baz (int, int) __attribute__((__warning__("detected overflow")));
+
+union U {
+ int i;
+ char c;
+};
+
+static void
+foo (union U *u)
+{
+ if (__builtin_object_size (&u->c, 1) < sizeof (u->c))
+ baz (__builtin_object_size (&u->c, 1), sizeof (u->c)); /* { dg-bogus "detected overflow" } */
+ __builtin_memset (&u->c, 0, sizeof (u->c));
+
+ if (__builtin_object_size (&u->i, 1) < sizeof (u->i))
+ baz (__builtin_object_size (&u->i, 1), sizeof (u->i)); /* { dg-bogus "detected overflow" } */
+ __builtin_memset (&u->i, 0, sizeof (u->i));
+}
+
+void
+bar (union U *u)
+{
+ int i, j;
+ for (i = 0; i < 1; i++)
+ {
+ foo (u);
+ for (j = 0; j < 2; j++)
+ asm volatile ("");
+ }
+}
+
+static void
+qux (void *p, size_t q)
+{
+ if (__builtin_object_size (p, 1) < q)
+ baz (__builtin_object_size (p, 1), q); /* { dg-bogus "detected overflow" } */
+ __builtin_memset (p, 0, q);
+}
+
+static void
+corge (union U *u)
+{
+ qux (&u->c, sizeof (u->c));
+ qux (&u->i, sizeof (u->i));
+}
+
+void
+garply (union U *u)
+{
+ int i, j;
+ for (i = 0; i < 1; i++)
+ {
+ corge (u);
+ for (j = 0; j < 2; j++)
+ asm volatile ("");
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/pr101496.c b/gcc/testsuite/gcc.dg/pr101496.c
new file mode 100644
index 0000000..091d4ad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101496.c
@@ -0,0 +1,22 @@
+/* PR tree-optimization/101496 */
+/* { dg-do compile } */
+/* { dg-options "-O2 " } */
+
+int c_1, li_2, us_3, func_14_s_5;
+
+void func_14() {
+ {
+ unsigned uli_8 = 0;
+ lbl1806324B:
+ if (uli_8 /= us_3 |= func_14_s_5 < 0 | func_14_s_5 != c_1) {
+ uli_8 += c_1 >= us_3;
+ if (uli_8)
+ ;
+ else
+ li_2 &&func_14_s_5 <= c_1 ?: 0;
+ unsigned *ptr_9 = &uli_8;
+ }
+ }
+ goto lbl1806324B;
+}
+
diff --git a/gcc/testsuite/gcc.dg/pr101497.c b/gcc/testsuite/gcc.dg/pr101497.c
new file mode 100644
index 0000000..fcfe059
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101497.c
@@ -0,0 +1,13 @@
+/* PR tree-optimization/101497 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-div-by-zero" } */
+
+char uc_1;
+int i_4, func_12_uli_6;
+void func_12() {
+ int *ptr_8 = &func_12_uli_6;
+ *ptr_8 = 0 >= 211 - uc_1 <= 0;
+ i_4 %= 0;
+ i_4 *= *ptr_8;
+}
+
diff --git a/gcc/testsuite/gcc.dg/pr101741.c b/gcc/testsuite/gcc.dg/pr101741.c
new file mode 100644
index 0000000..6587dca
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101741.c
@@ -0,0 +1,16 @@
+/* PR tree-optimization/101741 */
+/* { dg-do compile } */
+/* { dg-options "-O2 " } */
+
+int
+foo (void);
+
+unsigned int
+toupper (int c)
+{
+ c = foo ();
+ while (c)
+ c = toupper (c);
+
+ return c;
+}
diff --git a/gcc/testsuite/gcc.dg/pr101858.c b/gcc/testsuite/gcc.dg/pr101858.c
new file mode 100644
index 0000000..61fcca6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101858.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+int foo(int a)
+{
+ if (a < (int*)((__INTPTR_TYPE__)1 << a))
+ a = 0;
+ return a;
+}
diff --git a/gcc/testsuite/gcc.dg/pr101938.c b/gcc/testsuite/gcc.dg/pr101938.c
new file mode 100644
index 0000000..8277755
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101938.c
@@ -0,0 +1,28 @@
+// { dg-do run }
+// { dg-require-effective-target lp64 }
+// { dg-options "-O2 -fwrapv" }
+
+typedef long long int int64;
+#define INT64CONST(x) (x##LL)
+/* -9223372036854775808ULL */
+#define INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1)
+
+static void __attribute__((noipa)) foo(int64 arg1, int64 arg2) {
+ int64 a1 = -arg1;
+ int64 a2 = (arg2 < 0) ? arg2 : -arg2;
+
+ if (a1 > a2) {
+ int64 swap = arg1;
+ arg1 = arg2;
+ arg2 = swap;
+ }
+
+ if (arg1 == INT64_MIN && arg2 == -1) return;
+
+ __builtin_abort();
+}
+
+int main() {
+ foo(-1, INT64_MIN);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr102141.c b/gcc/testsuite/gcc.dg/pr102141.c
new file mode 100644
index 0000000..f3fc8d8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr102141.c
@@ -0,0 +1,11 @@
+/* PR tree-optimization/102141 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+unsigned int __attribute__((__vector_size__ (4))) v;
+
+void
+foo (unsigned long long x)
+{
+ v &= (unsigned) (x >> 56 | x >> 40 & 0xff00);
+}
diff --git a/gcc/testsuite/gcc.dg/pr102152.c b/gcc/testsuite/gcc.dg/pr102152.c
new file mode 100644
index 0000000..4e0c1f5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr102152.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -ftree-loop-vectorize -fno-tree-fre" } */
+/* { dg-additional-options "-march=armv8-a+sve" { target aarch64-*-* } } */
+
+
+
+signed char i;
+
+void
+foo (void)
+{
+ for (i = 0; i < 6; i += 5)
+ ;
+}
diff --git a/gcc/testsuite/gcc.dg/pr102207.c b/gcc/testsuite/gcc.dg/pr102207.c
new file mode 100644
index 0000000..08540d0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr102207.c
@@ -0,0 +1,24 @@
+/* PR tree-optimization/102207 */
+/* { dg-do run { target int128 } } */
+/* { dg-options "-O2" } */
+
+typedef unsigned __int128 u128;
+
+u128
+foo (unsigned short a)
+{
+ u128 g;
+ __builtin_sub_overflow ((unsigned long long) -a, 1, &g);
+ return g;
+}
+
+int
+main ()
+{
+ if (__SIZEOF_LONG_LONG__ * __CHAR_BIT__ != 64
+ || __SIZEOF_SHORT__ * __CHAR_BIT__ != 16)
+ return 0;
+ if (foo (1) != 0xfffffffffffffffeULL)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr102224.c b/gcc/testsuite/gcc.dg/pr102224.c
new file mode 100644
index 0000000..9f09ba5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr102224.c
@@ -0,0 +1,49 @@
+/* PR target/102224 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+__attribute__((noipa)) float
+foo (float x)
+{
+ return x * __builtin_copysignf (1.0f, x);
+}
+
+__attribute__((noipa)) float
+bar (float x, float y)
+{
+ return x * __builtin_copysignf (1.0f, y);
+}
+
+__attribute__((noipa)) float
+baz (float z, float x)
+{
+ return x * __builtin_copysignf (1.0f, x);
+}
+
+__attribute__((noipa)) float
+qux (float z, float x, float y)
+{
+ return x * __builtin_copysignf (1.0f, y);
+}
+
+int
+main ()
+{
+ if (foo (1.0f) != 1.0f
+ || foo (-4.0f) != 4.0f)
+ __builtin_abort ();
+ if (bar (1.25f, 7.25f) != 1.25f
+ || bar (1.75f, -3.25f) != -1.75f
+ || bar (-2.25f, 7.5f) != -2.25f
+ || bar (-3.0f, -4.0f) != 3.0f)
+ __builtin_abort ();
+ if (baz (5.5f, 1.0f) != 1.0f
+ || baz (4.25f, -4.0f) != 4.0f)
+ __builtin_abort ();
+ if (qux (1.0f, 1.25f, 7.25f) != 1.25f
+ || qux (2.0f, 1.75f, -3.25f) != -1.75f
+ || qux (3.0f, -2.25f, 7.5f) != -2.25f
+ || qux (4.0f, -3.0f, -4.0f) != 3.0f)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr102269.c b/gcc/testsuite/gcc.dg/pr102269.c
new file mode 100644
index 0000000..9d41b8f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr102269.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-ftrivial-auto-var-init=zero" } */
+
+void fn() { int a[0]; }
diff --git a/gcc/testsuite/gcc.dg/pr102273.c b/gcc/testsuite/gcc.dg/pr102273.c
new file mode 100644
index 0000000..568e44e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr102273.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-ftrivial-auto-var-init=zero" } */
+
+void bar();
+
+struct A { char d; };
+void foo()
+{
+ struct A e;
+ void baz() { bar(e); }
+}
diff --git a/gcc/testsuite/gcc.dg/pr20126.c b/gcc/testsuite/gcc.dg/pr20126.c
index 257832a..10aeec7 100644
--- a/gcc/testsuite/gcc.dg/pr20126.c
+++ b/gcc/testsuite/gcc.dg/pr20126.c
@@ -1,5 +1,5 @@
-/* dg-do run */
-/* dg-options "-O2" */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
/* PR target/20126 was not really target-specific, but rather a loop's
failure to take into account the possibility that a DEST_ADDR giv
@@ -34,6 +34,10 @@ foo (S *x, S *y)
while (e <= g)
{
const char *t = e + 1;
+ /* The pointer E below increases but the bound H stays constant,
+ letting the latter exceed the size remaining in the argument
+ pointed to by the formed, which might be detected by
+ -Wstringop-overread. */
if (__builtin_memcmp (e, f, h) == 0)
return 1;
e = t;
@@ -48,3 +52,5 @@ main (void)
abort ();
return 0;
}
+
+/* { dg-prune-output "-Wstringop-overread" } */
diff --git a/gcc/testsuite/gcc.dg/pr43864-4.c b/gcc/testsuite/gcc.dg/pr43864-4.c
index 3c6cc50..8a25b0f 100644
--- a/gcc/testsuite/gcc.dg/pr43864-4.c
+++ b/gcc/testsuite/gcc.dg/pr43864-4.c
@@ -22,7 +22,7 @@ int f(int c, int b, int d)
return r - r2;
}
-/* { dg-final { scan-tree-dump-times "if " 0 "pre"} } */
-/* { dg-final { scan-tree-dump-times "(?n)_.*\\+.*_" 1 "pre"} } */
-/* { dg-final { scan-tree-dump-times "(?n)_.*-.*_" 2 "pre"} } */
+/* During PRE elimination we should simplify this to return b * 2. */
+/* { dg-final { scan-tree-dump-times "if " 0 "pre" } } */
+/* { dg-final { scan-tree-dump "_\[0-9\]+ = b_\[0-9\]+\\(D\\) \\* 2;\[\\r\\n\]\[^\\r\\n\]*return _\[0-9\]+;" "pre" } } */
/* { dg-final { scan-tree-dump-not "Invalid sum" "pre"} } */
diff --git a/gcc/testsuite/gcc.dg/pr48552-1.c b/gcc/testsuite/gcc.dg/pr48552-1.c
index 11ee401..4cd7c59 100644
--- a/gcc/testsuite/gcc.dg/pr48552-1.c
+++ b/gcc/testsuite/gcc.dg/pr48552-1.c
@@ -15,7 +15,7 @@ f2 (void *x)
{
__asm volatile ("" : "=r" (*x)); /* { dg-warning "dereferencing" "deref" } */
} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */
- /* { dg-error "invalid lvalue in 'asm' output 0" "invalid lvalue" { target *-*-* } .-2 } */
+
void
f3 (void *x)
{
@@ -39,7 +39,7 @@ f6 (void *x)
{
__asm volatile ("" : "=g" (*x)); /* { dg-warning "dereferencing" "deref" } */
} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */
- /* { dg-error "invalid lvalue in 'asm' output 0" "invalid lvalue" { target *-*-* } .-2 } */
+
void
f7 (struct S *x)
{
diff --git a/gcc/testsuite/gcc.dg/pr48552-2.c b/gcc/testsuite/gcc.dg/pr48552-2.c
index 2d2a00c..e22600a 100644
--- a/gcc/testsuite/gcc.dg/pr48552-2.c
+++ b/gcc/testsuite/gcc.dg/pr48552-2.c
@@ -15,7 +15,7 @@ f2 (void *x)
{
__asm ("" : "=r" (*x)); /* { dg-warning "dereferencing" "deref" } */
} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */
- /* { dg-error "invalid lvalue in 'asm' output 0" "invalid lvalue" { target *-*-* } .-2 } */
+
void
f3 (void *x)
{
@@ -39,7 +39,7 @@ f6 (void *x)
{
__asm ("" : "=g" (*x)); /* { dg-warning "dereferencing" "deref" } */
} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */
- /* { dg-error "invalid lvalue in 'asm' output 0" "invalid lvalue" { target *-*-* } .-2 } */
+
void
f7 (struct S *x)
{
diff --git a/gcc/testsuite/gcc.dg/pr56727-2.c b/gcc/testsuite/gcc.dg/pr56727-2.c
index c54369e..77fdf4b 100644
--- a/gcc/testsuite/gcc.dg/pr56727-2.c
+++ b/gcc/testsuite/gcc.dg/pr56727-2.c
@@ -18,4 +18,4 @@ void h ()
/* { dg-final { scan-assembler "@(PLT|plt)" { target i?86-*-* x86_64-*-* } } } */
/* { dg-final { scan-assembler "@(PLT|plt)" { target { powerpc*-*-linux* && ilp32 } } } } */
-/* { dg-final { scan-assembler "bl f\n\\s*nop" { target { powerpc*-*-linux* && lp64 } } } } */
+/* { dg-final { scan-assembler "(bl f\n\\s*nop)|(bl f@notoc)" { target { powerpc*-*-linux* && lp64 } } } } */
diff --git a/gcc/testsuite/gcc.dg/pr68217.c b/gcc/testsuite/gcc.dg/pr68217.c
index c5b0d1f..eb4f15e 100644
--- a/gcc/testsuite/gcc.dg/pr68217.c
+++ b/gcc/testsuite/gcc.dg/pr68217.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1 -fno-tree-ccp" } */
int foo (void)
{
diff --git a/gcc/testsuite/gcc.dg/pr68317.c b/gcc/testsuite/gcc.dg/pr68317.c
index 891d129..bd053a7 100644
--- a/gcc/testsuite/gcc.dg/pr68317.c
+++ b/gcc/testsuite/gcc.dg/pr68317.c
@@ -1,5 +1,7 @@
/* { dg-do compile } */
-/* { dg-options "-O2" } */
+/* { dg-options "-O2 -fdisable-tree-ethread" } */
+
+/* Note: Threader will collapse loop. */
typedef int int32_t __attribute__((mode (__SI__)));
diff --git a/gcc/testsuite/gcc.dg/pr78213.c b/gcc/testsuite/gcc.dg/pr78213.c
index ebc2cce..04bf038 100644
--- a/gcc/testsuite/gcc.dg/pr78213.c
+++ b/gcc/testsuite/gcc.dg/pr78213.c
@@ -1,12 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fself-test" } */
-
-/* When this test was written -fself-test took no argument, but it
- has subsequently gained a mandatory argument, giving the path
- to selftest support files (within the srcdir).
- It's not clear how to provide this path sanely from
- within DejaGnu, so for now, this test is disabled. */
-/* { dg-skip-if "" { *-*-* } } */
+/* { dg-options "-fself-test=$srcdir/selftests" } */
/* Verify that -fself-test does not fail on a non empty source. */
@@ -15,4 +8,5 @@ int i;
while (i--)
bar();
}
-/* { dg-message "fself\-test: " "-fself-test" { target *-*-* } 0 } */
+
+/* { dg-regexp {^-fself-test: [0-9]+ pass\(es\) in [.0-9]+ seconds$|.*: note: self-tests are not enabled in this build$} } */
diff --git a/gcc/testsuite/gcc.dg/pr78888.c b/gcc/testsuite/gcc.dg/pr78888.c
new file mode 100644
index 0000000..77a130c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr78888.c
@@ -0,0 +1,29 @@
+/* PR tree-optimization/78888 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
+
+void kill (void);
+void keep (void);
+
+void g (int x)
+{
+ if (__builtin_toupper ((unsigned char)x) == 'a')
+ kill ();
+ if (__builtin_toupper ((unsigned char)x) == 'z')
+ kill ();
+ if (__builtin_tolower ((unsigned char)x) == 'A')
+ kill ();
+ if (__builtin_tolower ((unsigned char)x) == 'Z')
+ kill ();
+
+ if (__builtin_toupper ((unsigned char)x) == 'A')
+ keep ();
+ if (__builtin_toupper ((unsigned char)x) == 'Z')
+ keep ();
+ if (__builtin_tolower ((unsigned char)x) == 'a')
+ keep ();
+ if (__builtin_tolower ((unsigned char)x) == 'z')
+ keep ();
+}
+/* { dg-final { scan-tree-dump-not "kill" "evrp" } } */
+/* { dg-final { scan-tree-dump-times "keep" 4 "evrp"} } */
diff --git a/gcc/testsuite/gcc.dg/pr79214.c b/gcc/testsuite/gcc.dg/pr79214.c
index 3f5d935..2f93eed 100644
--- a/gcc/testsuite/gcc.dg/pr79214.c
+++ b/gcc/testsuite/gcc.dg/pr79214.c
@@ -22,67 +22,67 @@ static size_t range (void)
void test_bzero (void)
{
- bzero (d, range ()); /* { dg-warning ".__builtin_(bzero|memset). writing 4 or more bytes into a region of size 3 overflows the destination" } */
+ bzero (d, range ()); /* { dg-warning ".__builtin_(bzero|memset). writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
}
void test_memcpy (void)
{
- memcpy (d, s, range ()); /* { dg-warning ".__builtin_memcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
+ memcpy (d, s, range ()); /* { dg-warning ".__builtin_memcpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
}
void test_memmove (void)
{
- memmove (d, d + 1, range ()); /* { dg-warning ".__builtin_memmove. writing 4 or more bytes into a region of size 3 overflows the destination" } */
+ memmove (d, d + 1, range ()); /* { dg-warning ".__builtin_memmove. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
}
void test_mempcpy (void)
{
- mempcpy (d, s, range ()); /* { dg-warning ".__builtin_mempcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
+ mempcpy (d, s, range ()); /* { dg-warning ".__builtin_mempcpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
}
void test_memset (int n)
{
- memset (d, n, range ()); /* { dg-warning ".__builtin_memset. writing 4 or more bytes into a region of size 3 overflows the destination" } */
+ memset (d, n, range ()); /* { dg-warning ".__builtin_memset. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
}
void test_strcat (int i)
{
const char *s = i < 0 ? "123" : "4567";
- strcat (d, s); /* { dg-warning ".__builtin_strcat. writing between 4 and 5 bytes into a region of size 3 overflows the destination" } */
+ strcat (d, s); /* { dg-warning ".__builtin_strcat. writing between 4 and 5 bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
}
char* test_stpcpy (int i)
{
const char *s = i < 0 ? "123" : "4567";
- return stpcpy (d, s); /* { dg-warning ".__builtin_stpcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" } */
+ return stpcpy (d, s); /* { dg-warning ".__builtin_stpcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
}
char* test_stpncpy (int i)
{
const char *s = i < 0 ? "123" : "4567";
- return stpncpy (d, s, range ()); /* { dg-warning ".__builtin_stpncpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
+ return stpncpy (d, s, range ()); /* { dg-warning ".__builtin_stpncpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
}
char* test_strcpy (int i)
{
const char *s = i < 0 ? "123" : "4567";
- return strcpy (d, s); /* { dg-warning ".__builtin_strcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" } */
+ return strcpy (d, s); /* { dg-warning ".__builtin_strcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
}
char* test_strncpy (int i)
{
const char *s = i < 0 ? "123" : "4567";
- return strncpy (d, s, range ()); /* { dg-warning ".__builtin_strncpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
+ return strncpy (d, s, range ()); /* { dg-warning ".__builtin_strncpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */
}
char* test_strncat (int i)
{
const char *s = i < 0 ? "123" : "4567";
- return strncat (d, s, range ()); /* { dg-warning ".__builtin_strncat. specified bound \\\[4, \[0-9\]+] exceeds destination size 3" } */
+ return strncat (d, s, range ()); /* { dg-warning ".__builtin_strncat. specified bound \\\[4, \[0-9\]+] exceeds destination size 3" "pr?????" { xfail { *-*-* } } } */
}
diff --git a/gcc/testsuite/gcc.dg/pr79412.c b/gcc/testsuite/gcc.dg/pr79412.c
new file mode 100644
index 0000000..b60d5e1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr79412.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+int a;
+/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } .-1 } */
+void fn1 ()
+{
+ a++;
+}
+int a[] = {2}; /* { dg-error "conflicting types" } */
diff --git a/gcc/testsuite/gcc.dg/pr79972.c b/gcc/testsuite/gcc.dg/pr79972.c
index 1d2b8be..4d3064f 100644
--- a/gcc/testsuite/gcc.dg/pr79972.c
+++ b/gcc/testsuite/gcc.dg/pr79972.c
@@ -6,7 +6,8 @@
int
f (int dim, int *b, int *c)
{
- int newcentroid[3][dim]; /* { dg-warning "unbounded use of variable-length array" } */
+ /* -Wvla-larger-than is only issued with optimization (see PR 100510). */
+ int newcentroid[3][dim];
int *a = newcentroid[2];
int i, dist = 0;
__builtin_memcpy (newcentroid, c, sizeof (newcentroid));
diff --git a/gcc/testsuite/gcc.dg/pr80776-1.c b/gcc/testsuite/gcc.dg/pr80776-1.c
index af41c0c..b9bce62 100644
--- a/gcc/testsuite/gcc.dg/pr80776-1.c
+++ b/gcc/testsuite/gcc.dg/pr80776-1.c
@@ -17,7 +17,15 @@ Foo (void)
__builtin_unreachable ();
if (! (0 <= i && i <= 999999))
__builtin_unreachable ();
- /* The correctness bits for [E]VRP cannot handle chained conditionals
- when deciding to ignore a unreachable branch for setting SSA range info. */
- sprintf (number, "%d", i); /* { dg-bogus "writing" "" { xfail *-*-* } } */
+
+ /* Legacy evrp sets the range of i to [0, MAX] *before* the first conditional,
+ and to [0,999999] *before* the second conditional. This is because both
+ evrp and VRP use trickery to set global ranges when this particular use of
+ a __builtin_unreachable is in play (see uses of
+ assert_unreachable_fallthru_edge_p).
+
+ Setting these ranges at the definition site, causes VRP to remove the
+ unreachable code altogether, leaving the following sprintf unguarded. This
+ causes the bogus warning below. */
+ sprintf (number, "%d", i); /* { dg-bogus "writing" "" } */
}
diff --git a/gcc/testsuite/gcc.dg/pr81192.c b/gcc/testsuite/gcc.dg/pr81192.c
index 71bbc13..6cab605 100644
--- a/gcc/testsuite/gcc.dg/pr81192.c
+++ b/gcc/testsuite/gcc.dg/pr81192.c
@@ -1,4 +1,4 @@
-/* { dg-options "-Os -fdump-tree-pre-details -fdisable-tree-evrp" } */
+/* { dg-options "-Os -fdump-tree-pre-details -fdisable-tree-evrp -fno-tree-dse" } */
/* Disable tree-evrp because the new version of evrp sees
<bb 3> :
@@ -16,6 +16,8 @@ produces
# iftmp.2_12 = PHI <2147483647(3), iftmp.2_11(4)>
which causes the situation being tested to dissapear before we get to PRE. */
+/* Likewise disable DSE which also elides the tail merging "opportunity". */
+
#if __SIZEOF_INT__ == 2
#define unsigned __UINT32_TYPE__
#define int __INT32_TYPE__
diff --git a/gcc/testsuite/gcc.dg/pr84877.c b/gcc/testsuite/gcc.dg/pr84877.c
index 8a34dd4..234fcd2 100644
--- a/gcc/testsuite/gcc.dg/pr84877.c
+++ b/gcc/testsuite/gcc.dg/pr84877.c
@@ -1,4 +1,4 @@
-/* { dg-do run } */
+/* { dg-do run { xfail { cris-*-* sparc*-*-* } } } */
/* { dg-options "-O2" } */
#include <inttypes.h>
diff --git a/gcc/testsuite/gcc.dg/pr86058.c b/gcc/testsuite/gcc.dg/pr86058.c
new file mode 100644
index 0000000..89628c9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr86058.c
@@ -0,0 +1,19 @@
+/* PR middle-end/86058 - TARGET_MEM_REF causing incorrect message for
+ -Wmaybe-uninitialized warning
+ The test fails on a number of non-x86 targets due to pr100073.
+ { dg-do compile { target i?86-*-* x86_64-*-* } }
+ { dg-options "-O2 -Wuninitialized -Wmaybe-uninitialized" } */
+
+extern void foo (int *);
+
+void zip (int *out, int indx)
+{
+ int arr[10];
+
+ for (int i = 0; i < indx; ++i)
+ out[i] = arr[i] + 1; // { dg-warning "'arr\\\[i]' may be used uninitialized" "pr99944" { xfail *-*-* } }
+ // { dg-warning "'arr' may be used uninitialized" "actual" { target *-*-* } .-1 }
+
+ foo (arr);
+ foo (out);
+}
diff --git a/gcc/testsuite/gcc.dg/pr86723.c b/gcc/testsuite/gcc.dg/pr86723.c
new file mode 100644
index 0000000..e3fd6b9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr86723.c
@@ -0,0 +1,63 @@
+/* PR tree-optimization/86723 */
+/* { dg-do run { target { ilp32 || lp64 } } } */
+/* { dg-options "-O2" } */
+
+__attribute__((noipa)) int
+foo (unsigned long long value)
+{
+ return (((value & 0x00000000000000ffull) << 56)
+ | ((value & 0x000000000000ff00ull) << 40)
+ | ((value & 0x0000000000ff0000ull) << 24)
+ | ((value & 0x00000000ff000000ull) << 8)
+ | ((value & 0x000000ff00000000ull) >> 8)
+ | ((value & 0x0000ff0000000000ull) >> 24)
+ | ((value & 0x00ff000000000000ull) >> 40)
+ | ((value & 0xff00000000000000ull) >> 56));
+}
+
+__attribute__((noipa)) int
+bar (unsigned long long value)
+{
+ return (((value & 0x000000ff00000000ull) >> 8)
+ | ((value & 0x0000ff0000000000ull) >> 24)
+ | ((value & 0x00ff000000000000ull) >> 40)
+ | ((value & 0xff00000000000000ull) >> 56));
+}
+
+__attribute__((noipa)) unsigned long long
+baz (unsigned long long value)
+{
+ return (((value & 0x00000000000000ffull) << 56)
+ | ((value & 0x000000000000ff00ull) << 40)
+ | ((value & 0x00000000ff000000ull) << 8)
+ | ((value & 0x000000ff00000000ull) >> 8)
+ | ((value & 0x0000ff0000000000ull) >> 24)
+ | ((value & 0xff00000000000000ull) >> 56));
+}
+
+__attribute__((noipa)) unsigned int
+qux (unsigned int value)
+{
+ return (((value & 0x000000ff) << 24)
+ | ((value & 0x00ff0000) >> 8)
+ | ((value & 0xff000000) >> 24));
+}
+
+__attribute__((noipa)) unsigned int
+corge (unsigned int value)
+{
+ return (((value & 0x000000ff) << 24)
+ | ((value & 0xff000000) >> 24));
+}
+
+int
+main ()
+{
+ if (foo (0x0102030405060708ull) != 0x04030201
+ || bar (0x0102030405060708ull) != 0x04030201
+ || baz (0x0102030405060708ull) != 0x0807000504030001ull
+ || qux (0x01020304) != 0x04000201
+ || corge (0x01020304) != 0x04000001)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr89984.c b/gcc/testsuite/gcc.dg/pr89984.c
new file mode 100644
index 0000000..471fe92
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr89984.c
@@ -0,0 +1,20 @@
+/* PR target/89984 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+__attribute__((noipa)) float
+foo (float x, float y)
+{
+ return x * __builtin_copysignf (1.0f, y) + y;
+}
+
+int
+main ()
+{
+ if (foo (1.25f, 7.25f) != 1.25f + 7.25f
+ || foo (1.75f, -3.25f) != -1.75f + -3.25f
+ || foo (-2.25f, 7.5f) != -2.25f + 7.5f
+ || foo (-3.0f, -4.0f) != 3.0f + -4.0f)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr93210.c b/gcc/testsuite/gcc.dg/pr93210.c
index ec4194b..134d32b 100644
--- a/gcc/testsuite/gcc.dg/pr93210.c
+++ b/gcc/testsuite/gcc.dg/pr93210.c
@@ -1,7 +1,7 @@
/* PR tree-optimization/93210 */
/* { dg-do run } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
-/* { dg-final { scan-tree-dump-times "return \[0-9]\[0-9a-fA-FxX]*;" 31 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?:return|<retval> =) \[0-9]\[0-9a-fA-FxX]*;" 31 "optimized" } } */
#ifdef __SIZEOF_INT128__
typedef unsigned __int128 L;
diff --git a/gcc/testsuite/gcc.dg/pr94589-1.c b/gcc/testsuite/gcc.dg/pr94589-1.c
new file mode 100644
index 0000000..de404ea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr94589-1.c
@@ -0,0 +1,35 @@
+/* PR tree-optimization/94589 */
+/* { dg-do compile } */
+/* { 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\\) (?:<|<=|==|!=|>|>=) \[45]" 14 "optimized" } } */
+
+#define A __attribute__((noipa))
+A int f1 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c == 0; }
+A int f2 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c != 0; }
+A int f3 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c > 0; }
+A int f4 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c < 0; }
+A int f5 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c >= 0; }
+A int f6 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c <= 0; }
+A int f7 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c == -1; }
+A int f8 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c != -1; }
+A int f9 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c > -1; }
+A int f10 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c <= -1; }
+A int f11 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c == 1; }
+A int f12 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c != 1; }
+A int f13 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c < 1; }
+A int f14 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c >= 1; }
+A int f15 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c == 0; }
+A int f16 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c != 0; }
+A int f17 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c > 0; }
+A int f18 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c < 0; }
+A int f19 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c >= 0; }
+A int f20 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c <= 0; }
+A int f21 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c == -1; }
+A int f22 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c != -1; }
+A int f23 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c > -1; }
+A int f24 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c <= -1; }
+A int f25 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c == 1; }
+A int f26 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c != 1; }
+A int f27 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c < 1; }
+A int f28 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c >= 1; }
diff --git a/gcc/testsuite/gcc.dg/pr94589-2.c b/gcc/testsuite/gcc.dg/pr94589-2.c
new file mode 100644
index 0000000..9481b76
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr94589-2.c
@@ -0,0 +1,35 @@
+/* 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" } } */
+
+#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; }
diff --git a/gcc/testsuite/gcc.dg/pr94589-3.c b/gcc/testsuite/gcc.dg/pr94589-3.c
new file mode 100644
index 0000000..df82fab
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr94589-3.c
@@ -0,0 +1,97 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -g" } */
+
+#include "pr94589-1.c"
+
+#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort ()
+#define D(fn, i, r) if (fn (i) != r) __builtin_abort ()
+
+int
+main ()
+{
+ C (f1, 7, 8, 0);
+ C (f1, 8, 8, 1);
+ C (f1, 9, 8, 0);
+ C (f2, 7, 8, 1);
+ C (f2, 8, 8, 0);
+ C (f2, 9, 8, 1);
+ C (f3, 7, 8, 0);
+ C (f3, 8, 8, 0);
+ C (f3, 9, 8, 1);
+ C (f4, 7, 8, 1);
+ C (f4, 8, 8, 0);
+ C (f4, 9, 8, 0);
+ C (f5, 7, 8, 0);
+ C (f5, 8, 8, 1);
+ C (f5, 9, 8, 1);
+ C (f6, 7, 8, 1);
+ C (f6, 8, 8, 1);
+ C (f6, 9, 8, 0);
+ C (f7, 7, 8, 1);
+ C (f7, 8, 8, 0);
+ C (f7, 9, 8, 0);
+ C (f8, 7, 8, 0);
+ C (f8, 8, 8, 1);
+ C (f8, 9, 8, 1);
+ C (f9, 7, 8, 0);
+ C (f9, 8, 8, 1);
+ C (f9, 9, 8, 1);
+ C (f10, 7, 8, 1);
+ C (f10, 8, 8, 0);
+ C (f10, 9, 8, 0);
+ C (f11, 7, 8, 0);
+ C (f11, 8, 8, 0);
+ C (f11, 9, 8, 1);
+ C (f12, 7, 8, 1);
+ C (f12, 8, 8, 1);
+ C (f12, 9, 8, 0);
+ C (f13, 7, 8, 1);
+ C (f13, 8, 8, 1);
+ C (f13, 9, 8, 0);
+ C (f14, 7, 8, 0);
+ C (f14, 8, 8, 0);
+ C (f14, 9, 8, 1);
+ D (f15, 4, 0);
+ D (f15, 5, 1);
+ D (f15, 6, 0);
+ D (f16, 4, 1);
+ D (f16, 5, 0);
+ D (f16, 6, 1);
+ D (f17, 4, 0);
+ D (f17, 5, 0);
+ D (f17, 6, 1);
+ D (f18, 4, 1);
+ D (f18, 5, 0);
+ D (f18, 6, 0);
+ D (f19, 4, 0);
+ D (f19, 5, 1);
+ D (f19, 6, 1);
+ D (f20, 4, 1);
+ D (f20, 5, 1);
+ D (f20, 6, 0);
+ D (f21, 4, 1);
+ D (f21, 5, 0);
+ D (f21, 6, 0);
+ D (f22, 4, 0);
+ D (f22, 5, 1);
+ D (f22, 6, 1);
+ D (f23, 4, 0);
+ D (f23, 5, 1);
+ D (f23, 6, 1);
+ D (f24, 4, 1);
+ D (f24, 5, 0);
+ D (f24, 6, 0);
+ D (f25, 4, 0);
+ D (f25, 5, 0);
+ D (f25, 6, 1);
+ D (f26, 4, 1);
+ D (f26, 5, 1);
+ D (f26, 6, 0);
+ D (f27, 4, 1);
+ D (f27, 5, 1);
+ D (f27, 6, 0);
+ D (f28, 4, 0);
+ D (f28, 5, 0);
+ D (f28, 6, 1);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr94589-4.c b/gcc/testsuite/gcc.dg/pr94589-4.c
new file mode 100644
index 0000000..b2557fb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr94589-4.c
@@ -0,0 +1,97 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -g -ffast-math" } */
+
+#include "pr94589-2.c"
+
+#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort ()
+#define D(fn, i, r) if (fn (i) != r) __builtin_abort ()
+
+int
+main ()
+{
+ C (f1, 7.0, 8.0, 0);
+ C (f1, 8.0, 8.0, 1);
+ C (f1, 9.0, 8.0, 0);
+ C (f2, 7.0, 8.0, 1);
+ C (f2, 8.0, 8.0, 0);
+ C (f2, 9.0, 8.0, 1);
+ C (f3, 7.0, 8.0, 0);
+ C (f3, 8.0, 8.0, 0);
+ C (f3, 9.0, 8.0, 1);
+ C (f4, 7.0, 8.0, 1);
+ C (f4, 8.0, 8.0, 0);
+ C (f4, 9.0, 8.0, 0);
+ C (f5, 7.0, 8.0, 0);
+ C (f5, 8.0, 8.0, 1);
+ C (f5, 9.0, 8.0, 1);
+ C (f6, 7.0, 8.0, 1);
+ C (f6, 8.0, 8.0, 1);
+ C (f6, 9.0, 8.0, 0);
+ C (f7, 7.0, 8.0, 1);
+ C (f7, 8.0, 8.0, 0);
+ C (f7, 9.0, 8.0, 0);
+ C (f8, 7.0, 8.0, 0);
+ C (f8, 8.0, 8.0, 1);
+ C (f8, 9.0, 8.0, 1);
+ C (f9, 7.0, 8.0, 0);
+ C (f9, 8.0, 8.0, 1);
+ C (f9, 9.0, 8.0, 1);
+ C (f10, 7.0, 8.0, 1);
+ C (f10, 8.0, 8.0, 0);
+ C (f10, 9.0, 8.0, 0);
+ C (f11, 7.0, 8.0, 0);
+ C (f11, 8.0, 8.0, 0);
+ C (f11, 9.0, 8.0, 1);
+ C (f12, 7.0, 8.0, 1);
+ C (f12, 8.0, 8.0, 1);
+ C (f12, 9.0, 8.0, 0);
+ C (f13, 7.0, 8.0, 1);
+ C (f13, 8.0, 8.0, 1);
+ C (f13, 9.0, 8.0, 0);
+ C (f14, 7.0, 8.0, 0);
+ C (f14, 8.0, 8.0, 0);
+ C (f14, 9.0, 8.0, 1);
+ D (f15, 4.0, 0);
+ D (f15, 5.0, 1);
+ D (f15, 6.0, 0);
+ D (f16, 4.0, 1);
+ D (f16, 5.0, 0);
+ D (f16, 6.0, 1);
+ D (f17, 4.0, 0);
+ D (f17, 5.0, 0);
+ D (f17, 6.0, 1);
+ D (f18, 4.0, 1);
+ D (f18, 5.0, 0);
+ D (f18, 6.0, 0);
+ D (f19, 4.0, 0);
+ D (f19, 5.0, 1);
+ D (f19, 6.0, 1);
+ D (f20, 4.0, 1);
+ D (f20, 5.0, 1);
+ D (f20, 6.0, 0);
+ D (f21, 4.0, 1);
+ D (f21, 5.0, 0);
+ D (f21, 6.0, 0);
+ D (f22, 4.0, 0);
+ D (f22, 5.0, 1);
+ D (f22, 6.0, 1);
+ D (f23, 4.0, 0);
+ D (f23, 5.0, 1);
+ D (f23, 6.0, 1);
+ D (f24, 4.0, 1);
+ D (f24, 5.0, 0);
+ D (f24, 6.0, 0);
+ D (f25, 4.0, 0);
+ D (f25, 5.0, 0);
+ D (f25, 6.0, 1);
+ D (f26, 4.0, 1);
+ D (f26, 5.0, 1);
+ D (f26, 6.0, 0);
+ D (f27, 4.0, 1);
+ D (f27, 5.0, 1);
+ D (f27, 6.0, 0);
+ D (f28, 4.0, 0);
+ D (f28, 5.0, 0);
+ D (f28, 6.0, 1);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr95580.c b/gcc/testsuite/gcc.dg/pr95580.c
index 330a313..77d8150 100644
--- a/gcc/testsuite/gcc.dg/pr95580.c
+++ b/gcc/testsuite/gcc.dg/pr95580.c
@@ -1,6 +1,6 @@
/* PR c/95580 */
/* { dg-do compile } */
-/* { dg-options "-O1 -W -fno-tree-dce" } */
+/* { dg-options "-O1 -W -fno-tree-dce -fno-tree-dse" } */
void bar (void);
diff --git a/gcc/testsuite/gcc.dg/pr96392.c b/gcc/testsuite/gcc.dg/pr96392.c
new file mode 100644
index 0000000..662bacb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr96392.c
@@ -0,0 +1,33 @@
+/* PR tree-optimization/96392 */
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+double plus0(int x)
+{
+ return x + 0.0;
+}
+
+double sub0(int x)
+{
+ return x - 0.0;
+}
+
+double mult0(int x)
+{
+ return 0.0 * x;
+}
+
+double negate(int x)
+{
+ return 0.0 - x;
+}
+
+double subtract(int x)
+{
+ return (double)x - (double)x;
+}
+
+/* { dg-final { scan-tree-dump-not " \\+ " "optimized" } } */
+/* { dg-final { scan-tree-dump-not " \\- " "optimized" } } */
+/* { dg-final { scan-tree-dump-not " \\* " "optimized" } } */
+
diff --git a/gcc/testsuite/gcc.dg/pr96542.c b/gcc/testsuite/gcc.dg/pr96542.c
new file mode 100644
index 0000000..5014f2a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr96542.c
@@ -0,0 +1,27 @@
+/* { dg-do compile} */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
+
+
+unsigned char
+foo (unsigned int x)
+{
+ _Bool y = x;
+ return (((unsigned char) ~0) >> y) * 2;
+}
+
+unsigned char
+bar (unsigned int x)
+{
+ return (((unsigned char) ~0) >> (_Bool) x) * 2;
+}
+
+unsigned
+baz (unsigned int x)
+{
+ if (x >= 4) return 32;
+ return (-1U >> x) * 16;
+}
+
+/* { dg-final { scan-tree-dump-times "254" 2 "evrp" } } */
+/* { dg-final { scan-tree-dump "= PHI <32.*, 4294967280" "evrp" } } */
+
diff --git a/gcc/testsuite/gcc.dg/pr96573.c b/gcc/testsuite/gcc.dg/pr96573.c
new file mode 100644
index 0000000..c7d8f9e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr96573.c
@@ -0,0 +1,20 @@
+/* PR tree-optimization/96573 */
+/* { dg-do compile { target { lp64 || ilp32 } } } */
+/* { dg-require-effective-target bswap } */
+/* { dg-options "-O3 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump "__builtin_bswap\|VEC_PERM_EXPR\[^\n\r]*7, 6, 5, 4, 3, 2, 1, 0" "optimized" { xfail vect_variable_length } } } */
+
+typedef __SIZE_TYPE__ size_t;
+
+void *
+foo (void * const p)
+{
+ const size_t m = sizeof (p) - 1;
+ const unsigned char * const o = (unsigned char*) &p;
+ void *n;
+ unsigned char * const q = (unsigned char *) &n;
+ unsigned char i;
+ for (i = 0; i <= m; ++i)
+ q[m - i] = o[i];
+ return n;
+}
diff --git a/gcc/testsuite/gcc.dg/pr97567-2.c b/gcc/testsuite/gcc.dg/pr97567-2.c
index dee31c6..c3ead54 100644
--- a/gcc/testsuite/gcc.dg/pr97567-2.c
+++ b/gcc/testsuite/gcc.dg/pr97567-2.c
@@ -1,5 +1,5 @@
/* { dg-do compile} */
-/* { dg-options "-O2 -fdump-tree-evrp" } */
+/* { dg-options "-O2 -fdump-tree-evrp -fdisable-tree-ethread" } */
char a[2];
diff --git a/gcc/testsuite/gcc.dg/pr98099.c b/gcc/testsuite/gcc.dg/pr98099.c
index 12e52f2..c78d43e 100644
--- a/gcc/testsuite/gcc.dg/pr98099.c
+++ b/gcc/testsuite/gcc.dg/pr98099.c
@@ -1,8 +1,9 @@
/* PR middle-end/98099 */
/* Reported by G. Steinmetz <gscfq@t-online.de> */
-/* { dg-do compile { target dfp } } */
-/* { dg-options "-fsso-struct=big-endian" } */
+/* { dg-do compile { target { dfp && { be || le } } } } */
+/* { dg-options "-fsso-struct=big-endian" { target le } } */
+/* { dg-options "-fsso-struct=little-endian" { target be } } */
struct S { _Decimal128 a; };
diff --git a/gcc/testsuite/gcc.dg/pr99122-3.c b/gcc/testsuite/gcc.dg/pr99122-3.c
index 6aa5b29..6a908ad 100644
--- a/gcc/testsuite/gcc.dg/pr99122-3.c
+++ b/gcc/testsuite/gcc.dg/pr99122-3.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -g -fno-ipa-cp -w" } */
+/* { dg-options "-O2 -g -w" } */
static int foo ();
diff --git a/gcc/testsuite/gcc.dg/pr99230.c b/gcc/testsuite/gcc.dg/pr99230.c
new file mode 100644
index 0000000..eb3f982
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr99230.c
@@ -0,0 +1,40 @@
+/* PR debug/99230 */
+/* { dg-do compile } */
+/* { dg-options "-O2 --param logical-op-non-short-circuit=0 -fcompare-debug --param=jump-table-max-growth-ratio-for-speed=5000" } */
+
+extern void fn2 (void);
+extern void fn3 (int);
+int a, b;
+void
+fn1 (void)
+{
+ int c;
+ short d;
+ switch (a) {
+ case 22000:
+ fn2 ();
+ case 22300:
+ b = 0;
+ case 22600:
+ case 22601:
+ case 22900:
+ fn3 (1);
+ case 20100:
+ fn3 (2);
+ case 20200:
+ fn3 (3);
+ case 20300:
+ fn3 (4);
+ case 20400:
+ fn3 (5);
+ case 20310:
+ fn3 (4);
+ case 20410:
+ fn3 (5);
+ }
+ if (d || c) {
+ do
+ ;
+ while (0);
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/pr99296.c b/gcc/testsuite/gcc.dg/pr99296.c
new file mode 100644
index 0000000..4a0b3f0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr99296.c
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-O2 -fno-tree-bit-ccp" }
+
+struct {
+ signed a : 1;
+} b, c;
+void d() { b.a |= c.a |= 0 != 2; }
diff --git a/gcc/testsuite/gcc.dg/pr99830.c b/gcc/testsuite/gcc.dg/pr99830.c
new file mode 100644
index 0000000..75226f5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr99830.c
@@ -0,0 +1,10 @@
+/* PR debug/99830 */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O2 -fno-expensive-optimizations -fno-split-wide-types -g" } */
+
+int foo (long a, __int128 b, short c, int d, unsigned e, __int128 f)
+{
+ __builtin_memmove (2 + (char *) &f, foo, 1);
+ c >>= (char) f;
+ return c;
+}
diff --git a/gcc/testsuite/gcc.dg/pr99882.c b/gcc/testsuite/gcc.dg/pr99882.c
new file mode 100644
index 0000000..ebc074f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr99882.c
@@ -0,0 +1,37 @@
+/* PR tree-optimization/99882 */
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+void
+foo (char *p, void *q)
+{
+ __INTPTR_TYPE__ i = (__INTPTR_TYPE__) q;
+ p[2] = i;
+ i >>= 8;
+ p[3] = i;
+ i >>= 8;
+ p[4] = i;
+ i >>= 8;
+ p[5] = i;
+ i >>= 8;
+ p[6] = i;
+ i >>= 8;
+ p[7] = i;
+ i >>= 8;
+ p[8] = i;
+ i >>= 8;
+ p[9] = i;
+}
+
+void
+bar (char *p, void *q)
+{
+ __INTPTR_TYPE__ i = (__INTPTR_TYPE__) q;
+ p[2] = i;
+ i >>= 8;
+ p[3] = i;
+ i >>= 8;
+ p[4] = i;
+ i >>= 8;
+ p[5] = i;
+}
diff --git a/gcc/testsuite/gcc.dg/pr99990.c b/gcc/testsuite/gcc.dg/pr99990.c
new file mode 100644
index 0000000..6878b00
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr99990.c
@@ -0,0 +1,12 @@
+/* PR c/99990 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+#include <stdarg.h>
+
+void
+foo ()
+{
+ va_arg (0, long); /* { dg-error "first argument to 'va_arg' not of type 'va_list'" } */
+ void *b[] = 0; /* { dg-error "invalid initializer" } */
+}
diff --git a/gcc/testsuite/gcc.dg/pragma-diag-10.c b/gcc/testsuite/gcc.dg/pragma-diag-10.c
new file mode 100644
index 0000000..127b299
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pragma-diag-10.c
@@ -0,0 +1,20 @@
+/* PR middle-end/98512 - #pragma GCC diagnostic ignored ineffective
+ in conjunction with alias attribute
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+void *
+__rawmemchr_ppc (const void *s, int c)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#pragma GCC diagnostic ignored "-Wstringop-overread"
+ if (c != 0)
+ return __builtin_memchr (s, c, (unsigned long)-1); // { dg-bogus "specified bound \\d+ exceeds maximum object size" }
+#pragma GCC diagnostic pop
+
+ return (char *)s + __builtin_strlen (s);
+}
+
+extern __typeof (__rawmemchr_ppc) __EI___rawmemchr_ppc
+ __attribute__((alias ("__rawmemchr_ppc")));
diff --git a/gcc/testsuite/gcc.dg/pragma-diag-9.c b/gcc/testsuite/gcc.dg/pragma-diag-9.c
new file mode 100644
index 0000000..9aac379
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pragma-diag-9.c
@@ -0,0 +1,141 @@
+/* Verify that #pragma GCC diagnostic down the inlining stack suppresses
+ a warning that would otherwise be issued for inlined calls higher up
+ the inlining stack.
+ { dg-do compile }
+ { dg-options "-O2 -Wall -Wno-array-bounds" } */
+
+extern void* memset (void*, int, __SIZE_TYPE__);
+
+static void warn0 (int *p)
+{
+ memset (p, __LINE__, 3); // { dg-warning "\\\[-Wstringop-overflow" }
+}
+
+static void warn1 (int *p)
+{
+ warn0 (p + 1);
+}
+
+static void warn2 (int *p)
+{
+ warn1 (p + 1);
+}
+
+int a2[2]; // { dg-message "at offset 12 into destination object 'a2' of size 8" }
+
+void warn3 (void)
+{
+ warn2 (a2 + 1);
+}
+
+
+// Verify suppression at the innermost frame of the inlining stack.
+
+static void ignore0 (int *p)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+ memset (p, __LINE__, 3);
+#pragma GCC diagnostic pop
+}
+
+static void nowarn1_ignore0 (int *p)
+{
+ ignore0 (p + 1);
+}
+
+static void nowarn2_ignore0 (int *p)
+{
+ nowarn1_ignore0 (p + 1);
+}
+
+int b2[2];
+
+void nowarn3_ignore0 (void)
+{
+ nowarn2_ignore0 (b2 + 1);
+}
+
+
+// Verify suppression at the second innermost frame of the inlining stack.
+
+static void nowarn0_ignore1 (int *p)
+{
+ memset (p, __LINE__, 3);
+}
+
+static void ignore1 (int *p)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+ nowarn0_ignore1 (p + 1);
+#pragma GCC diagnostic pop
+}
+
+void nowarn2_ignore1 (int *p)
+{
+ ignore1 (p + 1);
+}
+
+int c2[2];
+
+void nowarn3_ignore1 (void)
+{
+ nowarn2_ignore1 (c2 + 1);
+}
+
+
+// Verify suppression at the third innermost frame of the inlining stack.
+
+static void nowarn0_ignore2 (int *p)
+{
+ memset (p, __LINE__, 3);
+}
+
+static void nowarn1_ignore2 (int *p)
+{
+ nowarn0_ignore2 (p + 1);
+}
+
+static void ignore2 (int *p)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+ nowarn1_ignore2 (p + 1);
+#pragma GCC diagnostic pop
+}
+
+int d2[2];
+
+void nowarn3_ignore2 (void)
+{
+ ignore2 (c2 + 1);
+}
+
+
+// Verify suppression at the outermost frame of the inlining stack.
+
+static void nowarn0_ignore3 (int *p)
+{
+ memset (p, __LINE__, 3);
+}
+
+static void nowarn1_ignore3 (int *p)
+{
+ nowarn0_ignore3 (p + 1);
+}
+
+static void nowarn2_ignore3 (int *p)
+{
+ nowarn1_ignore3 (p + 1);
+}
+
+int e2[2];
+
+void ignore3 (void)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+ nowarn2_ignore3 (e2 + 1);
+#pragma GCC diagnostic pop
+}
diff --git a/gcc/testsuite/gcc.dg/predict-1.c b/gcc/testsuite/gcc.dg/predict-1.c
index 9e5605a..d2e753e 100644
--- a/gcc/testsuite/gcc.dg/predict-1.c
+++ b/gcc/testsuite/gcc.dg/predict-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-profile_estimate" } */
+/* { dg-options "-O2 -fdump-tree-profile_estimate --disable-tree-evrp" } */
extern int global;
diff --git a/gcc/testsuite/gcc.dg/predict-9.c b/gcc/testsuite/gcc.dg/predict-9.c
index f491c51..cb68a21 100644
--- a/gcc/testsuite/gcc.dg/predict-9.c
+++ b/gcc/testsuite/gcc.dg/predict-9.c
@@ -1,5 +1,7 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-profile_estimate -fno-finite-loops" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-profile_estimate -fno-finite-loops -fdisable-tree-ethread" } */
+
+/* Note: Threader causes removal of for loop. */
extern int global;
extern int global2;
diff --git a/gcc/testsuite/gcc.dg/sancov/attribute.c b/gcc/testsuite/gcc.dg/sancov/attribute.c
new file mode 100644
index 0000000..7cfa913
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sancov/attribute.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize-coverage=trace-pc -fdump-tree-optimized" } */
+
+void foo(void)
+{
+}
+
+void
+__attribute__((no_sanitize_coverage))
+bar(void)
+{
+}
+
+static void inline
+__attribute__((always_inline))
+inline_fn(void)
+{
+}
+
+void
+__attribute__((no_sanitize_coverage))
+baz(void)
+{
+ inline_fn();
+}
+
+/* { dg-final { scan-tree-dump-times "__builtin___sanitizer_cov_trace_pc \\(\\)" 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/shrink-wrap-loop.c b/gcc/testsuite/gcc.dg/shrink-wrap-loop.c
index 52dfc27..6e1be893 100644
--- a/gcc/testsuite/gcc.dg/shrink-wrap-loop.c
+++ b/gcc/testsuite/gcc.dg/shrink-wrap-loop.c
@@ -1,6 +1,58 @@
/* { dg-do compile { target { { { i?86-*-* x86_64-*-* } && lp64 } || { arm_thumb2 } } } } */
/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue" } */
+/*
+Our new threader is threading things a bit too early, and causing the
+testcase in gcc.dg/shrink-wrap-loop.c to fail.
+
+ The gist is this BB inside a loop:
+
+ <bb 6> :
+ # p_2 = PHI <p2_6(D)(2), p_12(5)>
+ if (p_2 != 0B)
+ goto <bb 3>; [INV]
+ else
+ goto <bb 7>; [INV]
+
+Our threader can move this check outside of the loop (good). This is
+done before branch probabilities are calculated and causes the probs
+to be calculated as:
+
+<bb 2> [local count: 216361238]:
+ if (p2_6(D) != 0B)
+ goto <bb 7>; [54.59%]
+ else
+ goto <bb 6>; [45.41%]
+
+Logically this seems correct to me. A simple check outside of a loop
+should slightly but not overwhelmingly favor a non-zero value.
+
+Interestingly however, the old threader couldn't get this, but the IL
+ended up identical, albeit with different probabilities. What happens
+is that, because the old code could not thread this, the p2 != 0 check
+would remain inside the loop and probs would be calculated thusly:
+
+ <bb 6> [local count: 1073741824]:
+ # p_2 = PHI <p2_6(D)(2), p_12(5)>
+ if (p_2 != 0B)
+ goto <bb 3>; [94.50%]
+ else
+ goto <bb 7>; [5.50%]
+
+Then when the loop header copying pass ("ch") shuffled things around,
+the IL would end up identical to my early threader code, but with the
+probabilities would remain as 94.5/5.5.
+
+The above discrepancy causes the RTL ifcvt pass to generate different
+code, and by the time we get to the shrink wrapping pass, things look
+sufficiently different such that the legacy code can actually shrink
+wrap, whereas our new code does not.
+
+IMO, if the loop-ch pass moves conditionals outside of a loop, the
+probabilities should be adjusted, but that does mean the shrink wrap
+won't happen for this contrived testcase.
+ */
+
int foo (int *p1, int *p2);
int
@@ -16,4 +68,4 @@ test (int *p1, int *p2)
return 1;
}
-/* { dg-final { scan-rtl-dump "Performing shrink-wrapping" "pro_and_epilogue" } } */
+/* { dg-final { scan-rtl-dump "Performing shrink-wrapping" "pro_and_epilogue" { xfail *-*-* } } } */
diff --git a/gcc/testsuite/gcc.dg/sibcall-1.c b/gcc/testsuite/gcc.dg/sibcall-1.c
index e8a9551..367ee43 100644
--- a/gcc/testsuite/gcc.dg/sibcall-1.c
+++ b/gcc/testsuite/gcc.dg/sibcall-1.c
@@ -7,6 +7,9 @@
/* { dg-do run } */
/* { dg-options "-O2 -foptimize-sibling-calls" } */
+/* See note in recurser_void() as to why we disable threading. */
+/* { dg-additional-options "-fdisable-tree-thread1" } */
+
/* The option -foptimize-sibling-calls is the default, but serves as
marker. Self-recursion tail calls are optimized for all targets,
regardless of presence of sibcall patterns. */
@@ -26,6 +29,13 @@ int main ()
void
recurser_void (int n)
{
+ /* In some architectures like ppc64*, jump threading may thread
+ paths such that there are two calls into track(), one for
+ track(0) and one for track(7). The track(7) call can be
+ transformed into a jump instead of a call, which means that
+ different calls into track() may end up with a different
+ &stackpos. This is the reason we disable jump threading for this
+ test. */
if (n == 0 || n == 7)
track (n);
diff --git a/gcc/testsuite/gcc.dg/sms-1.c b/gcc/testsuite/gcc.dg/sms-1.c
index 26868c3..098e1aa 100644
--- a/gcc/testsuite/gcc.dg/sms-1.c
+++ b/gcc/testsuite/gcc.dg/sms-1.c
@@ -40,5 +40,3 @@ main ()
return 0;
}
-/* { dg-final { scan-rtl-dump-times "SMS succeeded" 1 "sms" { target powerpc*-*-* } } } */
-
diff --git a/gcc/testsuite/gcc.dg/sms-10.c b/gcc/testsuite/gcc.dg/sms-10.c
index d85e8e2..df3bba2 100644
--- a/gcc/testsuite/gcc.dg/sms-10.c
+++ b/gcc/testsuite/gcc.dg/sms-10.c
@@ -113,6 +113,3 @@ main ()
return 0;
}
-
-/* { dg-final { scan-rtl-dump-times "SMS succeeded" 1 "sms" { target powerpc*-*-* } } } */
-
diff --git a/gcc/testsuite/gcc.dg/sms-2.c b/gcc/testsuite/gcc.dg/sms-2.c
index 7b96f55..f8375f9 100644
--- a/gcc/testsuite/gcc.dg/sms-2.c
+++ b/gcc/testsuite/gcc.dg/sms-2.c
@@ -31,5 +31,3 @@ fun (nb)
sy = 0;
}
}
-
-/* { dg-final { scan-rtl-dump-times "SMS loop many exits" 1 "sms" { target powerpc*-*-* } } } */
diff --git a/gcc/testsuite/gcc.dg/sms-3.c b/gcc/testsuite/gcc.dg/sms-3.c
index 822b516..5e56ecf 100644
--- a/gcc/testsuite/gcc.dg/sms-3.c
+++ b/gcc/testsuite/gcc.dg/sms-3.c
@@ -38,6 +38,3 @@ main ()
foo (6, 3);
return 0;
}
-
-/* { dg-final { scan-rtl-dump-times "SMS succeeded" 1 "sms" { target powerpc*-*-* } } } */
-
diff --git a/gcc/testsuite/gcc.dg/sms-4.c b/gcc/testsuite/gcc.dg/sms-4.c
index f5ebb55..8416b8b 100644
--- a/gcc/testsuite/gcc.dg/sms-4.c
+++ b/gcc/testsuite/gcc.dg/sms-4.c
@@ -34,6 +34,3 @@ main ()
foo (5, a, b, c, dst);
return 0;
}
-
-/* { dg-final { scan-rtl-dump-times "SMS succeeded" 1 "sms" { target powerpc*-*-* } } } */
-
diff --git a/gcc/testsuite/gcc.dg/sms-6.c b/gcc/testsuite/gcc.dg/sms-6.c
index e57e015..d6fa45a 100644
--- a/gcc/testsuite/gcc.dg/sms-6.c
+++ b/gcc/testsuite/gcc.dg/sms-6.c
@@ -41,5 +41,3 @@ int main()
return 0;
}
-
-/* { dg-final { scan-rtl-dump-times "SMS succeeded" 3 "sms" { target powerpc*-*-* } } } */
diff --git a/gcc/testsuite/gcc.dg/sms-8.c b/gcc/testsuite/gcc.dg/sms-8.c
index 7ccaa45..dc0a3fc 100644
--- a/gcc/testsuite/gcc.dg/sms-8.c
+++ b/gcc/testsuite/gcc.dg/sms-8.c
@@ -34,7 +34,3 @@ main ()
res = foo (3, 4);
return 0;
}
-
-/* { dg-final { scan-rtl-dump-times "SMS succeeded" 1 "sms" { target powerpc*-*-* } } } */
-
-
diff --git a/gcc/testsuite/gcc.dg/spellcheck-options-23.c b/gcc/testsuite/gcc.dg/spellcheck-options-23.c
new file mode 100644
index 0000000..575a28d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/spellcheck-options-23.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize-coverage=tracecmp" } */
+
+/* { dg-error "unrecognized argument in option '-fsanitize-coverage=tracecmp'" "" { target *-*-* } 0 } */
+/* { dg-message "valid arguments to '-fsanitize-coverage=' are: trace-cmp trace-pc; did you mean 'trace-cmp'?" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/gcc.dg/spellcheck-stdlib.c b/gcc/testsuite/gcc.dg/spellcheck-stdlib.c
index 1ae3b5e..7297a92 100644
--- a/gcc/testsuite/gcc.dg/spellcheck-stdlib.c
+++ b/gcc/testsuite/gcc.dg/spellcheck-stdlib.c
@@ -38,6 +38,16 @@ void test_stdio_h (void)
/* { dg-message "'EOF' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'?" "" { target *-*-* } .-1 } */
}
+/* Missing <stdlib.h>. */
+
+void test_stdlib (int i)
+{
+ i = EXIT_SUCCESS; /* { dg-error "'EXIT_SUCCESS' undeclared" } */
+ /* { dg-message "'EXIT_SUCCESS' is defined in header '<stdlib.h>'; did you forget to '#include <stdlib.h>'?" "" { target *-*-* } .-1 } */
+ i = EXIT_FAILURE; /* { dg-error "'EXIT_FAILURE' undeclared" } */
+ /* { dg-message "'EXIT_FAILURE' is defined in header '<stdlib.h>'; did you forget to '#include <stdlib.h>'?" "" { target *-*-* } .-1 } */
+}
+
/* Missing <errno.h>. */
int test_errno_h (void)
diff --git a/gcc/testsuite/gcc.dg/sso-12.c b/gcc/testsuite/gcc.dg/sso-12.c
new file mode 100644
index 0000000..3bed280
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sso-12.c
@@ -0,0 +1,27 @@
+/* Test scalar_storage_order attribute and pointer fields */
+
+/* { dg-do run } */
+/* { dg-options "-Wno-pedantic" } */
+
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+struct __attribute__((scalar_storage_order("big-endian"))) Rec
+{
+ int *p;
+};
+#else
+struct __attribute__((scalar_storage_order("little-endian"))) Rec
+{
+ int *p;
+};
+#endif
+
+int main (int argc)
+{
+ struct Rec r = { &argc };
+ int *p = &argc;
+
+ if (__builtin_memcmp (&r.p, &p, sizeof (int *)) != 0)
+ __builtin_abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/sso-13.c b/gcc/testsuite/gcc.dg/sso-13.c
new file mode 100644
index 0000000..ddfde00
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sso-13.c
@@ -0,0 +1,24 @@
+/* Test support of scalar_storage_order attribute */
+
+/* { dg-do compile } */
+
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define REV_ENDIANNESS __attribute__((scalar_storage_order("big-endian")))
+#else
+#define REV_ENDIANNESS __attribute__((scalar_storage_order("little-endian")))
+#endif
+
+typedef struct tIp6Addr
+{
+ unsigned int s6_addr32[4];
+} tIp6Addr;
+
+struct _tBeTimNetAddr
+{
+ unsigned char isIPv4;
+ union
+ {
+ unsigned int addr;
+ tIp6Addr addr6; /* { dg-warning "type punning toggles" } */
+ } REV_ENDIANNESS u;
+} REV_ENDIANNESS;
diff --git a/gcc/testsuite/gcc.dg/sso-14.c b/gcc/testsuite/gcc.dg/sso-14.c
new file mode 100644
index 0000000..aeff3fb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sso-14.c
@@ -0,0 +1,56 @@
+/* PR c/100920 */
+/* Testcase by George Thopas <george.thopas@gmail.com> */
+
+/* { dg-do compile } */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define REV_ENDIANNESS __attribute__((scalar_storage_order("big-endian")))
+#else
+#define REV_ENDIANNESS __attribute__((scalar_storage_order("little-endian")))
+#endif
+
+struct s_1 {
+ int val;
+} REV_ENDIANNESS;
+
+typedef struct s_1 t_1;
+
+struct s_2 {
+ char val;
+} REV_ENDIANNESS;
+
+typedef struct s_2 t_2;
+
+struct s12 {
+ t_1 a[1];
+ t_2 b[1];
+} REV_ENDIANNESS;
+
+typedef struct s12 t_s12;
+
+union u12 {
+ t_1 a[1];
+ t_2 b[1];
+} REV_ENDIANNESS;
+
+typedef union u12 t_u12;
+
+int main(void)
+{
+ t_s12 *msg1 = __builtin_alloca(10);
+ t_u12 *msg2 = __builtin_alloca(10);
+ int same;
+
+ msg1 = malloc (sizeof (t_s12));
+ msg2 = malloc (sizeof (t_s12));
+
+ memset (msg1, 0, sizeof (t_s12));
+ memcpy (msg2, msg1, sizeof (t_s12));
+ same = memcmp (msg1, msg2, sizeof (t_s12));
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/sso-15.c b/gcc/testsuite/gcc.dg/sso-15.c
new file mode 100644
index 0000000..d8a711d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sso-15.c
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define REV_ENDIANNESS __attribute__((scalar_storage_order("big-endian")))
+#else
+#define REV_ENDIANNESS __attribute__((scalar_storage_order("little-endian")))
+#endif
+
+struct X { int *p; } REV_ENDIANNESS;
+
+struct X x;
+
+struct X __attribute__((noinline)) foo (int *p)
+{
+ struct X x;
+ x.p = p;
+ return x;
+}
+
+void __attribute((noinline)) bar (void)
+{
+ *x.p = 1;
+}
+
+extern void abort (void);
+
+int main (void)
+{
+ int i = 0;
+ x = foo(&i);
+ bar();
+ if (i != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/sso-16.c b/gcc/testsuite/gcc.dg/sso-16.c
new file mode 100644
index 0000000..7bf8938
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sso-16.c
@@ -0,0 +1,100 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+/* { dg-options "-O3" } */
+
+typedef __INT32_TYPE__ int32_t;
+
+#define BIG_ENDIAN __attribute__((scalar_storage_order("big-endian")))
+
+/* host order version (little endian)*/
+struct _ip6_addr {
+ union {
+ char addr8[16];
+ int32_t addr32[4];
+ } u;
+};
+
+typedef struct _ip6_addr t_ip6_addr;
+
+struct _net_addr {
+ char is_v4;
+ union {
+ int32_t addr;
+ t_ip6_addr addr6;
+ } u;
+};
+
+typedef struct _net_addr t_net_addr;
+
+/* big endian version */
+struct _be_ip6_addr {
+ union {
+ char addr8[16];
+ } BIG_ENDIAN u;
+} BIG_ENDIAN;
+
+typedef struct _be_ip6_addr t_be_ip6_addr;
+
+struct _be_net_addr {
+ char is_v4;
+ union {
+ t_be_ip6_addr addr6;
+ int32_t addr;
+ } BIG_ENDIAN u;
+} BIG_ENDIAN;
+
+typedef struct _be_net_addr t_be_net_addr;
+
+/* convert */
+t_be_ip6_addr be_ip6_addr(const t_ip6_addr ip6)
+{
+ t_be_ip6_addr rc = {
+ .u.addr8[0] = ip6.u.addr8[0],
+ .u.addr8[1] = ip6.u.addr8[1],
+ .u.addr8[2] = ip6.u.addr8[2],
+ .u.addr8[3] = ip6.u.addr8[3],
+ .u.addr8[4] = ip6.u.addr8[4],
+ .u.addr8[5] = ip6.u.addr8[5],
+ .u.addr8[6] = ip6.u.addr8[6],
+ .u.addr8[7] = ip6.u.addr8[7],
+ .u.addr8[8] = ip6.u.addr8[8],
+ .u.addr8[9] = ip6.u.addr8[9],
+ .u.addr8[10] = ip6.u.addr8[10],
+ .u.addr8[11] = ip6.u.addr8[11],
+ .u.addr8[12] = ip6.u.addr8[12],
+ .u.addr8[13] = ip6.u.addr8[13],
+ .u.addr8[14] = ip6.u.addr8[14],
+ .u.addr8[15] = ip6.u.addr8[15],
+ };
+ return rc;
+}
+
+t_be_net_addr __attribute__((noipa)) be_net_addr(const t_net_addr ip)
+{
+ t_be_net_addr rc = {.is_v4 = ip.is_v4 };
+ if (ip.is_v4) {
+ rc.u.addr = ip.u.addr;
+ } else {
+ rc.u.addr6 = be_ip6_addr(ip.u.addr6);
+ }
+ return rc;
+}
+
+int main(void)
+{
+ t_be_net_addr out = { };
+
+ t_net_addr in = {
+ .is_v4 = 0,
+ .u.addr6.u.addr8 =
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
+ };
+
+ out = be_net_addr(in);
+
+ // actually first 4 bytes are swapped
+ if (in.u.addr6.u.addr8[0] != out.u.addr6.u.addr8[0])
+ __builtin_abort();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/sso-9.c b/gcc/testsuite/gcc.dg/sso-9.c
deleted file mode 100644
index 765f16a..0000000
--- a/gcc/testsuite/gcc.dg/sso-9.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Test support of scalar_storage_order attribute */
-
-/* { dg-do compile } */
-
-#include <stdarg.h>
-
-int x;
-
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-struct __attribute__((scalar_storage_order("big-endian"))) Rec
-{
- va_list v;
-};
-#else
-struct __attribute__((scalar_storage_order("little-endian"))) Rec
-{
- va_list v;
-};
-#endif
-
-void foo (int i, ...)
-{
- struct Rec a;
- va_start (a.v, i);
- a.v = 0, x = va_arg (a.v, int); /* { dg-error "type|reverse storage order" } */
- va_end (a.v);
-}
diff --git a/gcc/testsuite/gcc.dg/strlenopt-73.c b/gcc/testsuite/gcc.dg/strlenopt-73.c
index 6523949..170b66a 100644
--- a/gcc/testsuite/gcc.dg/strlenopt-73.c
+++ b/gcc/testsuite/gcc.dg/strlenopt-73.c
@@ -69,6 +69,13 @@ void test_copy_cond_equal_length (void)
T ( 0 ==, 33, 1, (i0 ? a32 : b32) + 32);
}
+#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) \
+ || defined(__s390__) || defined(__powerpc64__)
+
+/* The following tests assume GCC transforms the memcpy calls into
+ long long assignments which it does only on targets that define
+ the MOVE_MAX macro to 8 or higher. Enable on a set of targets
+ known to do that. */
const char a4[16] = "0123";
const char b4[16] = "3210";
@@ -84,12 +91,14 @@ void test_copy_cond_unequal_length_i64 (void)
T (0 <, 16, 8, i0 ? a4 + 2 : b4 + 3);
}
+#endif
+
-#if __i386__ && __SIZEOF_INT128__ == 16
+#if defined(__x86_64__) && __SIZEOF_INT128__ == 16
/* The following tests assume GCC transforms the memcpy calls into
int128_t assignments which it does only on targets that define
- the MOVE_MAX macro to 16. That's only s390 and i386 with
+ the MOVE_MAX macro to 16. That's only s390 and x86_64 with
int128_t support. */
const char a8[32] = "01234567";
diff --git a/gcc/testsuite/gcc.dg/strlenopt-80.c b/gcc/testsuite/gcc.dg/strlenopt-80.c
index 9124fe4..a853402 100644
--- a/gcc/testsuite/gcc.dg/strlenopt-80.c
+++ b/gcc/testsuite/gcc.dg/strlenopt-80.c
@@ -3,7 +3,7 @@
The optimization is only implemented for MEM_REF stores and other
targets than those below may not transform the memcpy call into
such a store.
- { dg-do compile { target aarch64*-*-* i?86-*-* powerpc*-*-* x86_64-*-* } }
+ { dg-do compile { target { { aarch64*-*-* i?86-*-* x86_64-*-* } || { { powerpc*-*-* } && lp64 } } } }
{ dg-options "-O2 -Wall -fdump-tree-optimized" } */
diff --git a/gcc/testsuite/gcc.dg/strlenopt-95.c b/gcc/testsuite/gcc.dg/strlenopt-95.c
new file mode 100644
index 0000000..6e0a79d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/strlenopt-95.c
@@ -0,0 +1,65 @@
+/* Verify strlen results of vector assignments.
+ { dg-do compile }
+ { dg-options "-O2 -Wall -fdump-tree-optimized" } */
+
+#include "strlenopt.h"
+
+#define V(N) __attribute__ ((vector_size (N)))
+
+typedef V (1) char VC1;
+typedef V (2) char VC2;
+typedef V (4) char VC4;
+typedef V (8) char VC8;
+typedef V (16) char VC16;
+
+extern char a[];
+
+#define A(expr) ((expr) ? (void)0 : abort ())
+
+void test_fold (int i)
+{
+ *(VC4*)a = (VC4){ };
+ A (strlen (a) == 0);
+ A (!a[1] && !a[2] && !a[3]);
+
+ *(VC4*)a = (VC4){ 0, 1 };
+ A (strlen (a) == 0);
+ A (a[1] == 1 && !a[2] && !a[3]);
+
+ *(VC4*)a = (VC4){ 1 };
+ A (strlen (a) == 1);
+ A (!a[1] && !a[2] && !a[3]);
+
+ *(VC4*)a = (VC4){ 1, 0, 3 };
+ A (strlen (a) == 1);
+ A (!a[1] && a[2] == 3 && !a[3]);
+
+ *(VC4*)a = (VC4){ 1, 2 };
+ A (strlen (a) == 2);
+ A (!a[2] && !a[3]);
+
+ *(VC4*)a = (VC4){ 1, 2, 0, 4 };
+ A (strlen (a) == 2);
+ A (!a[2] && a[3] == 4);
+
+ *(VC4*)a = (VC4){ 1, 2, 3 };
+ A (strlen (a) == 3);
+ A (!a[3]);
+
+ *(VC8*)a = (VC8){ 1, 2, 3, 0, 5 };
+ A (strlen (a) == 3);
+
+ *(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6 };
+ A (strlen (a) == 3);
+
+ *(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6, 7, 8 };
+ A (strlen (a) == 3);
+ A (strlen (a + 1) == 2);
+ A (strlen (a + 2) == 1);
+ A (strlen (a + 3) == 0);
+
+ A (a[4] == 5 && a[5] == 6 && a[6] == 7 && a[7] == 8);
+}
+
+/* { dg-final { scan-tree-dump-not "abort \\(" "optimized" } }
+ { dg-final { scan-tree-dump-not "strlen \\(" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tls/pr99466-1.c b/gcc/testsuite/gcc.dg/tls/pr99466-1.c
new file mode 100644
index 0000000..446850e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tls/pr99466-1.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-require-weak "" } */
+/* { dg-require-effective-target tls_emulated } */
+/* { dg-add-options tls } */
+__attribute__((weak))
+__thread int tlsvar = 3;
+/* { dg-final { scan-assembler ".weak_definition ___emutls_t.tlsvar" { target *-*-darwin* } } } */
+/* { dg-final { scan-assembler-not ".private_extern ___emutls_t.tlsvar" { target *-*-darwin* } } } */
diff --git a/gcc/testsuite/gcc.dg/tls/pr99466-2.c b/gcc/testsuite/gcc.dg/tls/pr99466-2.c
new file mode 100644
index 0000000..86ffaad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tls/pr99466-2.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-require-weak "" } */
+/* { dg-require-visibility "" } */
+/* { dg-require-effective-target tls_emulated } */
+/* { dg-add-options tls } */
+__attribute__((weak))
+__attribute__((visibility ("hidden")))
+__thread int tlsvar = 3;
+/* { dg-final { scan-assembler ".weak_definition ___emutls_t.tlsvar" { target *-*-darwin* } } } */
+/* { dg-final { scan-assembler ".private_extern ___emutls_t.tlsvar" { target *-*-darwin* } } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr100053.c b/gcc/testsuite/gcc.dg/torture/pr100053.c
new file mode 100644
index 0000000..3d17675
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100053.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+
+int __attribute__((returns_twice,noipa)) x() { return 0; }
+void __attribute__((noipa)) ar() {}
+void __attribute__((noipa)) as() { __builtin_abort (); }
+int a1, a2, a3;
+void __attribute__((noipa)) v(int init)
+{
+ if (!init) {
+ as();
+ if (a1)
+ goto aq;
+ x ();
+ }
+ ar();
+aq:
+ if (!init)
+ as();
+}
+
+int main()
+{
+ v(1);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr100329.c b/gcc/testsuite/gcc.dg/torture/pr100329.c
new file mode 100644
index 0000000..2a4331b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100329.c
@@ -0,0 +1,16 @@
+/* { dg-do compile { target lra } } */
+/* { dg-additional-options "--param tree-reassoc-width=2" } */
+
+unsigned int a0;
+
+unsigned int
+foo (unsigned int a1, unsigned int a2)
+{
+ unsigned int x;
+
+ asm goto ("" : "=r" (x) : : : lab);
+ a0 = x;
+
+ lab:
+ return x + a1 + a2 + 1;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr100398.c b/gcc/testsuite/gcc.dg/torture/pr100398.c
new file mode 100644
index 0000000..41eadde
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100398.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+int
+test5_limit (void)
+{
+ int addr;
+
+ asm goto ("" : "+r" (addr) : : : t_err);
+ return 0;
+
+ t_err:
+ return 1;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr100492.c b/gcc/testsuite/gcc.dg/torture/pr100492.c
new file mode 100644
index 0000000..75229c8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100492.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-loop-distribution" } */
+
+extern void abort (void);
+
+signed char a, c;
+int b, d, *e = &d, g;
+signed static char f;
+int main() {
+ int h = 0;
+ int a_ = a;
+ for (; a_ < 1; a = ++a_) {
+ int *i[5], **j = &i[4], ***k[3][2] = {{&j}}, ****l = &k[2][1], *****m = &l;
+ char *n = &c;
+ f = *e = g = 0;
+ for (; g < 2; g++) {
+ for (b = 0; b < 3; b++)
+ h = (h && (*n = 0)) == 0;
+ if (g)
+ break;
+ }
+ }
+ if (f != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr100519.c b/gcc/testsuite/gcc.dg/torture/pr100519.c
new file mode 100644
index 0000000..89dff66
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100519.c
@@ -0,0 +1,13 @@
+/* { dg-do compile { target lra } } */
+/* { dg-additional-options "--param tree-reassoc-width=2" } */
+
+unsigned int foo_a1, foo_a2;
+
+unsigned int foo()
+{
+ unsigned int v0, x;
+ asm goto("" : "=r"(x) : : : lab);
+lab:
+ v0 += x + x;
+ return v0 + x + foo_a1 + foo_a2;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr100566.c b/gcc/testsuite/gcc.dg/torture/pr100566.c
new file mode 100644
index 0000000..ed85691
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100566.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+
+volatile int s, c;
+
+__attribute__((noipa)) void
+foo (void)
+{
+ if (c++ > 1)
+ __builtin_abort ();
+}
+
+__attribute__((noipa)) int
+bar (void)
+{
+ int i = 0, j = s;
+ if (j == 0)
+ goto lab;
+ for (i = 0; i < j; i++)
+ {
+ lab:
+ foo ();
+ if (!j)
+ goto lab;
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ s = 1;
+ bar ();
+ if (c != 1)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr100672.c b/gcc/testsuite/gcc.dg/torture/pr100672.c
new file mode 100644
index 0000000..cc62e71
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100672.c
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+/* { dg-additional-options "-w -Wno-psabi" } */
+
+typedef long long __attribute__((__vector_size__ (4 * sizeof (long long)))) V;
+
+V
+foo (V v)
+{
+ return -(v >> 1);
+}
+
+int
+main (void)
+{
+ V v = foo ((V) { -2, -4, -6, -8 });
+ if (v[0] != 1 || v[1] != 2 || v[2] != 3 || v[3] != 4)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr100778.c b/gcc/testsuite/gcc.dg/torture/pr100778.c
new file mode 100644
index 0000000..7997f2f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100778.c
@@ -0,0 +1,31 @@
+/* { dg-do run { target *-*-*gnu* } } */
+/* { dg-additional-options "-fno-tree-sink -fno-math-errno -ftree-vectorize -D_GNU_SOURCE" } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#include <fenv.h>
+
+double a[2];
+void __attribute__((noipa)) foo ()
+{
+ double x = a[0];
+ double y = a[1];
+ double norm = __builtin_sqrt (x*x + y*y);
+ if (norm > 1.)
+ {
+ x = x / norm;
+ y = y / norm;
+ }
+ a[0] = x;
+ a[1] = y;
+}
+
+int main()
+{
+ feenableexcept (FE_INVALID);
+ a[0] = 0.;
+ a[1] = 0.;
+ foo ();
+ if (a[0] != 0. || a[1] != 0.)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr100923.c b/gcc/testsuite/gcc.dg/torture/pr100923.c
new file mode 100644
index 0000000..05a6341
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100923.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+
+int a = 1, b, c, *d = &a, *e = &a, f;
+void g(int h) {}
+void k(int *l)
+{
+ int ***j;
+ if (c)
+ {
+ *j = &l;
+ ***j;
+ }
+ g(*l);
+ *e = f;
+ if (*l)
+ {
+ int i = b / a;
+ a = i;
+ }
+}
+int main()
+{
+ k(d);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr100934.c b/gcc/testsuite/gcc.dg/torture/pr100934.c
new file mode 100644
index 0000000..43b7884
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100934.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+
+int a, b, c, d, e;
+int main()
+{
+ int f = 0, g = 0;
+ for (; f < 2; f++)
+ {
+ int h, i;
+ for (h = 0; h < 2; h++)
+ {
+ b = e = g ? a % g : 0;
+ c = d;
+ for (i = 0; i < 1; i++)
+ g = 0;
+ for (; g < 2; g++)
+ ;
+ }
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101009.c b/gcc/testsuite/gcc.dg/torture/pr101009.c
new file mode 100644
index 0000000..2bbed1d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101009.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-additional-options "-fno-tree-sra -fno-tree-pre -ftree-loop-distribution" } */
+
+struct a {
+ unsigned b;
+ unsigned c;
+} e, *f = &e;
+int d = 1;
+int main() {
+ for (; d; d--) {
+ struct a g[] = {{2, 1}, {2, 1}};
+ *f = g[1];
+ }
+ if (e.c != 1)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101025.c b/gcc/testsuite/gcc.dg/torture/pr101025.c
new file mode 100644
index 0000000..483e0ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101025.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+
+int a[10];
+int b, d, g;
+volatile char c;
+short e;
+volatile int f;
+int main()
+{
+ for (; d <= 9; d++) {
+ b = e = 0;
+ for (; e < 4; e++)
+ a[e] = 4;
+ for (; b <= 3; b++)
+ if (g)
+ f = 0;
+ else
+ a[b] = c;
+ }
+ if (a[1] != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101031.c b/gcc/testsuite/gcc.dg/torture/pr101031.c
new file mode 100644
index 0000000..daf3bcf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101031.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+int a;
+char b, e;
+static char *c = &b;
+static long d;
+void f(void);
+void __attribute__((noipa)) h() {
+ int g = 0;
+ for (; g < 2; ++g) {
+ d = *c;
+ *c = 1;
+ b = 0;
+ }
+ f();
+}
+void __attribute__((noipa)) f() {
+ if (d++)
+ c = &e;
+ for (; a;)
+ ;
+}
+int main() {
+ h();
+ if (b != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101088.c b/gcc/testsuite/gcc.dg/torture/pr101088.c
new file mode 100644
index 0000000..00fce39
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101088.c
@@ -0,0 +1,45 @@
+/* { dg-do compile } */
+
+int bh, on, h0;
+
+void
+qw (int n2)
+{
+ int *e5;
+
+ if (n2 == 0)
+ {
+ n2 = 1;
+ while (n2 != 0)
+ for (n2 = 0; n2 < 1; ++n2)
+ {
+ }
+
+ e5 = &n2;
+ }
+ else
+ e5 = &on;
+
+ while (h0 < 1)
+ {
+ if (on == 0)
+ {
+ ++*e5;
+ bh = 0;
+ }
+ else
+ {
+ bh = 0;
+ ++on;
+ *e5 = on;
+ h0 = *e5;
+ if (h0 == 0)
+ {
+ *e5 = 0;
+ ++h0;
+ }
+ }
+
+ ++h0;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101105.c b/gcc/testsuite/gcc.dg/torture/pr101105.c
new file mode 100644
index 0000000..9222351
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101105.c
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+
+short a;
+int b[5][4] = {2, 2};
+int d;
+short e(int f) { return f == 0 || a && f == 1 ? 0 : a; }
+int main() {
+ int g, h;
+ g = 3;
+ for (; g >= 0; g--) {
+ h = 3;
+ for (; h >= 0; h--)
+ b[g][h] = b[0][1] && e(1);
+ }
+ d = b[0][1];
+ if (d != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101151.c b/gcc/testsuite/gcc.dg/torture/pr101151.c
new file mode 100644
index 0000000..15c9a7b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101151.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+int a, *b = &a, c, d;
+int main() {
+ *b;
+ if (a) {
+ L1:
+ a = 0;
+ L2:
+ if (d) {
+ while (b)
+ ;
+ goto L1;
+ }
+ }
+ if (c)
+ goto L2;
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101173.c b/gcc/testsuite/gcc.dg/torture/pr101173.c
new file mode 100644
index 0000000..0c9090d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101173.c
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+/* { dg-additional-options "-floop-interchange" } */
+
+int a[6][9];
+int main()
+{
+ a[1][3] = 8;
+ for (int b = 1; b <= 5; b++)
+ for (int d = 0; d <= 5; d++)
+#pragma GCC unroll 0
+ for (int c = 0; c <= 5; c++)
+ a[b][c] = a[b][c + 2] & 216;
+ for (int e = 0; e < 6; e++)
+ for (int f = 0; f < 9; f++)
+ if (a[e][f] != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101202.c b/gcc/testsuite/gcc.dg/torture/pr101202.c
new file mode 100644
index 0000000..e76c908
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101202.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-vectorize" } */
+
+int printf(const char *, ...);
+unsigned a, b, d;
+int c, e, f;
+int main()
+{
+ while (a)
+ if (b)
+ {
+ f = a;
+ while (e)
+ {
+ int h, i;
+ if (d)
+ {
+ h = a;
+ i = d;
+L:
+ d = a | d && c;
+ if (a)
+ {
+ printf("%d", a);
+ goto L;
+ }
+ }
+ a = h;
+ d = i;
+ }
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101229.c b/gcc/testsuite/gcc.dg/torture/pr101229.c
new file mode 100644
index 0000000..3708031
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101229.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+int a[1024];
+void foo()
+{
+ for (int i; i; i += 4) {
+ int suma = a[i];
+ int sumb = a[i + 1];
+ int sumc;
+ for (unsigned j = 0; j < 77; ++j) {
+ suma = (suma ^ i) + 1;
+ sumb = (sumb ^ i) + 2;
+ sumc = suma ^ i;
+ }
+ a[i] = suma;
+ a[i + 1] = sumb;
+ a[i + 2] = sumc;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101230-1.c b/gcc/testsuite/gcc.dg/torture/pr101230-1.c
new file mode 100644
index 0000000..f10ca8b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101230-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-signed-zeros" } */
+
+
+double distance3d_sqr_pt4d_pt4d(void);
+
+int update_r_k_curr_cluster;
+void update_r_k(void) {
+ double curr_distance = distance3d_sqr_pt4d_pt4d();
+ for (int cluster; cluster; cluster++)
+ if (0 < curr_distance) {
+ curr_distance = 0;
+ update_r_k_curr_cluster = cluster;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101278.c b/gcc/testsuite/gcc.dg/torture/pr101278.c
new file mode 100644
index 0000000..1d25658
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101278.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+
+struct X { int counter; };
+
+struct X __attribute__((noipa)) foo (struct X x)
+{
+ x.counter++;
+ if (x.counter == 5)
+ __builtin_exit (0);
+ return x;
+}
+
+int
+main ()
+{
+ struct X x;
+ x.counter = 0;
+ for (int i = 0; i < 10; ++i)
+ x = foo (x);
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101394.c b/gcc/testsuite/gcc.dg/torture/pr101394.c
new file mode 100644
index 0000000..87fbdad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101394.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+int a, b, c, d;
+void h();
+int e() __attribute__((returns_twice));
+void f() {
+ int *g = (int *)(__INTPTR_TYPE__)c;
+ if (b) {
+ h();
+ g--;
+ if (a)
+ if (d)
+ h();
+ }
+ if (g++)
+ e();
+ c = (__INTPTR_TYPE__)g;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr101512.c b/gcc/testsuite/gcc.dg/torture/pr101512.c
new file mode 100644
index 0000000..a25da2a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101512.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-w -Wno-psabi" } */
+
+int n();
+typedef unsigned long V __attribute__ ((vector_size (64)));
+V
+foo (int i, V v)
+{
+ i = ((V)(V){n()})[n()];
+ return v + i;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr102124.c b/gcc/testsuite/gcc.dg/torture/pr102124.c
new file mode 100644
index 0000000..a158b4a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr102124.c
@@ -0,0 +1,27 @@
+/* PR tree-optimization/102124 */
+
+int
+foo (const unsigned char *a, const unsigned char *b, unsigned long len)
+{
+ int ab, ba;
+ unsigned long i;
+ for (i = 0, ab = 0, ba = 0; i < len; i++)
+ {
+ ab |= a[i] - b[i];
+ ba |= b[i] - a[i];
+ }
+ return (ab | ba) >= 0;
+}
+
+int
+main ()
+{
+ unsigned char a[32] = { 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a' };
+ unsigned char b[32] = { 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a' };
+ unsigned char c[32] = { 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b' };
+ if (!foo (a, b, 16))
+ __builtin_abort ();
+ if (foo (a, c, 16))
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr102139.c b/gcc/testsuite/gcc.dg/torture/pr102139.c
new file mode 100644
index 0000000..06c1357
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr102139.c
@@ -0,0 +1,43 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-slp-vectorize" } */
+
+typedef double aligned_double __attribute__((aligned(2*sizeof(double))));
+
+void __attribute__((noipa))
+bar (int aligned, double *p)
+{
+ if (aligned)
+ {
+ *(aligned_double *)p = 3.;
+ p[1] = 4.;
+ }
+ else
+ {
+ p[2] = 0.;
+ p[3] = 1.;
+ }
+}
+
+void __attribute__((noipa))
+foo (int i)
+{
+ if (i)
+ __builtin_exit (0);
+}
+void __attribute__((noipa))
+baz (double *p)
+{
+ p[0] = 0.;
+ p[1] = 1.;
+ foo (1);
+ *(aligned_double *)p = 3.;
+ p[1] = 4.;
+}
+
+double x[8] __attribute__((aligned(2*sizeof (double))));
+int main()
+{
+ bar (0, &x[1]);
+ baz (&x[1]);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr102149.c b/gcc/testsuite/gcc.dg/torture/pr102149.c
new file mode 100644
index 0000000..34a8c21
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr102149.c
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+/* { dg-additional-options "-fno-vect-cost-model" } */
+
+int a[8];
+int *b = &a[6];
+char c;
+int main()
+{
+ int d = 7;
+ for (; d >= 0; d--)
+ {
+ *b = 1;
+ c = a[d] >> 3;
+ a[d] = c;
+ }
+ if (a[6] != 1)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr69170.c b/gcc/testsuite/gcc.dg/torture/pr69170.c
index 2af0bde..a39125a 100644
--- a/gcc/testsuite/gcc.dg/torture/pr69170.c
+++ b/gcc/testsuite/gcc.dg/torture/pr69170.c
@@ -6,7 +6,7 @@ typedef struct {
char buf[];
} hash_state;
int a;
-hash_state b;
+extern hash_state b;
void fn1()
{
a = 0;
diff --git a/gcc/testsuite/gcc.dg/torture/pr70025.c b/gcc/testsuite/gcc.dg/torture/pr70025.c
index 6c43a0a..7cf28c4 100644
--- a/gcc/testsuite/gcc.dg/torture/pr70025.c
+++ b/gcc/testsuite/gcc.dg/torture/pr70025.c
@@ -80,3 +80,8 @@ main ()
__builtin_abort ();
return 0;
}
+
+/* At -O3 the loop in bar() is vectorized and results in a (possibly
+ unreachable) out-of-bounds store to p.d7[8]:
+ _22(D)->d7[8] = _122;
+ { dg-prune-output "-Wstringop-overflow" } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr79334-0.c b/gcc/testsuite/gcc.dg/torture/pr79334-0.c
new file mode 100644
index 0000000..fa45a6d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr79334-0.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-additional-sources "pr79334-1.c" } */
+
+extern int d[][8];
+
+static void __attribute__((noinline))
+func_that_exits (int flag)
+{
+ if (!flag)
+ __builtin_exit (0);
+}
+
+int main ()
+{
+ int e = 0;
+ while (1)
+ {
+ func_that_exits (e);
+ /* We do not know whether d[1024][0] will trap. */
+ e = d[1024][0];
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr79334-1.c b/gcc/testsuite/gcc.dg/torture/pr79334-1.c
new file mode 100644
index 0000000..b1c8a27
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr79334-1.c
@@ -0,0 +1 @@
+int d[1][8];
diff --git a/gcc/testsuite/gcc.dg/torture/pr93491.c b/gcc/testsuite/gcc.dg/torture/pr93491.c
new file mode 100644
index 0000000..2cb4c0c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr93491.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+
+extern void exit (int);
+
+__attribute__((noipa))
+void f(int i)
+{
+ exit(i);
+}
+
+__attribute__((const,noipa))
+int g(int i)
+{
+ return 1 / i;
+}
+
+int main()
+{
+ while (1)
+ {
+ f(0);
+ f(g(0));
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr94947-1.c b/gcc/testsuite/gcc.dg/torture/pr94947-1.c
index ab8b488..832e40d 100644
--- a/gcc/testsuite/gcc.dg/torture/pr94947-1.c
+++ b/gcc/testsuite/gcc.dg/torture/pr94947-1.c
@@ -1,6 +1,7 @@
/* { dg-do run } */
/* { dg-additional-sources "pr94947-2.c" } */
/* { dg-additional-options "-fipa-pta -flto-partition=1to1" } */
+/* { dg-prune-output "warning: using serial compilation" } */
extern void abort ();
extern void baz ();
diff --git a/gcc/testsuite/gcc.dg/torture/pr96513.c b/gcc/testsuite/gcc.dg/torture/pr96513.c
new file mode 100644
index 0000000..5ee040e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr96513.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+
+typedef struct {
+ short a;
+ short b;
+} c;
+c *d;
+int e, f, i, j, k, l, m, n, o, p;
+c g, h;
+void q() {
+ do {
+ if (o) {
+ (*d).a = (*d).b = d[e].a = d[e].a * 3 + 1 >> 15;
+ d[e].b = d[e].b * 3 + 1 >> 15;
+ }
+ n = -(d[e].b * g.b) >> 5;
+ m = d[e].b * g.a + 1 >> 5;
+ l = d[f].a * -d[f].b * h.b + 1 >> 5;
+ k = d[f].a * h.b + d[f].b * h.a + 1 >> 5;
+ j = n + l;
+ i = m - k;
+ (*d).a += j;
+ d[e].a -= i;
+ ++d;
+ } while (--p);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr98601.c b/gcc/testsuite/gcc.dg/torture/pr98601.c
new file mode 100644
index 0000000..ee9d076
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr98601.c
@@ -0,0 +1,14 @@
+/* PR rtl-optimization/98601 */
+/* { dg-do compile } */
+
+void
+foo (void *p)
+{
+ asm ("" : "=m" (*p)); /* { dg-warning "dereferencing 'void \\*' pointer" } */
+}
+
+void
+bar (void *p)
+{
+ asm volatile ("" : : "m" (*p)); /* { dg-warning "dereferencing 'void \\*' pointer" } */
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr99652-1.c b/gcc/testsuite/gcc.dg/torture/pr99652-1.c
new file mode 100644
index 0000000..c2395ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr99652-1.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-mgeneral-regs-only" } */
+
+inline double
+foo (void)
+{
+ return 1.0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr99652-2.c b/gcc/testsuite/gcc.dg/torture/pr99652-2.c
new file mode 100644
index 0000000..beefad8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr99652-2.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-mno-80387" } */
+
+inline double
+foo (void)
+{
+ return 1.0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr99694.c b/gcc/testsuite/gcc.dg/torture/pr99694.c
new file mode 100644
index 0000000..df31696
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr99694.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-w" } */
+
+#include <stdint.h>
+
+int a, b, c;
+void d() {
+ uint16_t e;
+ int32_t *f;
+ int32_t *g;
+ if (a) {
+ int32_t *k;
+ for (;; *k += 1) {
+ int32_t **i = &f;
+ int32_t **l = &g;
+ for (e = 6; e; e++) {
+ g = k = f;
+ j:
+ **l = 0;
+ }
+ *i = c;
+ }
+ }
+ uint16_t i = &e;
+ b = i / 0;
+ goto j;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr99824.c b/gcc/testsuite/gcc.dg/torture/pr99824.c
new file mode 100644
index 0000000..9022d4a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr99824.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+
+unsigned int
+strlenx(char *s)
+{
+ char *orig_s = s;
+ for (; *s; ++s)
+ ;
+ return s - orig_s;
+}
+
+struct i2c_adapter {
+ char name[48];
+};
+
+struct {
+ int instance;
+ struct i2c_adapter i2c_adap[];
+} * init_cx18_i2c_cx;
+
+const struct i2c_adapter cx18_i2c_adap_template = {""};
+int init_cx18_i2c___trans_tmp_1;
+
+void
+init_cx18_i2c()
+{
+ int i = 0;
+ for (;; i++) {
+ init_cx18_i2c_cx->i2c_adap[i] = cx18_i2c_adap_template;
+ init_cx18_i2c___trans_tmp_1
+ = strlenx(init_cx18_i2c_cx->i2c_adap[i].name);
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr99880.c b/gcc/testsuite/gcc.dg/torture/pr99880.c
new file mode 100644
index 0000000..7e09899
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr99880.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-vectorize" } */
+
+unsigned a;
+int b, c, d, e;
+void f() {
+ b = 5;
+ for (; b <= 51; b++)
+ ;
+ unsigned int g = -8;
+ while (g) {
+ g += 5;
+ int h = 10;
+ do {
+ h -= a = 1;
+ for (; a; a++)
+ ;
+ c *= c >= d >= b;
+ } while (h);
+ c -= e;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr99947.c b/gcc/testsuite/gcc.dg/torture/pr99947.c
new file mode 100644
index 0000000..2cf3ec6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr99947.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+int a, b, d, e;
+short c;
+void f() {
+ for (; e; e++) {
+ int g = 6;
+ for (; g > 2; g--) {
+ int i = -8;
+ while (i < 20) {
+ i += 5;
+ a += b;
+ }
+ c *= d;
+ }
+ b--;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr99954.c b/gcc/testsuite/gcc.dg/torture/pr99954.c
new file mode 100644
index 0000000..7d44703
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr99954.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+
+#include <assert.h>
+
+#define CONTAINER_KIND union
+
+typedef CONTAINER_KIND container { int value; } container;
+
+void move(container* end, container* start) {
+ container* p;
+ for (p = end; p > start; p--) {
+ (p)->value = (p-1)->value;
+ }
+}
+
+#define N 100
+
+int main(int argc, char* argv[]) {
+ container vals[N];
+ int i;
+ for (i=0; i<N; i++) {
+ vals[i].value = argc + i;
+ }
+ move(&vals[N-1], &vals[0]);
+ assert(vals[0].value == argc + 0);
+ for (i=1; i<N; i++) {
+ assert(vals[i].value == argc + i - 1);
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/vshuf-4.inc b/gcc/testsuite/gcc.dg/torture/vshuf-4.inc
index d041b33..fb35df8 100644
--- a/gcc/testsuite/gcc.dg/torture/vshuf-4.inc
+++ b/gcc/testsuite/gcc.dg/torture/vshuf-4.inc
@@ -25,7 +25,9 @@ T (21, 2, 6, 3, 7) \
T (22, 1, 2, 3, 0) \
T (23, 2, 1, 0, 3) \
T (24, 2, 5, 6, 3) \
-T (25, 0, 1, 4, 5)
+T (25, 0, 1, 4, 5) \
+T (26, 1, 5, 3, 7) \
+T (27, 0, 5, 2, 7)
#define EXPTESTS \
T (116, 1, 2, 4, 3) \
T (117, 7, 3, 3, 0) \
diff --git a/gcc/testsuite/gcc.dg/torture/vshuf-8.inc b/gcc/testsuite/gcc.dg/torture/vshuf-8.inc
index de358f3..d628039 100644
--- a/gcc/testsuite/gcc.dg/torture/vshuf-8.inc
+++ b/gcc/testsuite/gcc.dg/torture/vshuf-8.inc
@@ -27,7 +27,9 @@ T (23, 6, 5, 4, 3, 2, 1, 0, 7) \
T (24, 0, 1, 2, 3, 8, 9, 10, 11) \
T (25, 0, 1, 2, 3, 12, 13, 14, 15) \
T (26, 0, 1, 8, 9, 10, 11, 12, 13) \
-T (27, 0, 8, 9, 10, 11, 12, 13, 14)
+T (27, 0, 8, 9, 10, 11, 12, 13, 14) \
+T (28, 1, 9, 3, 11, 5, 13, 7, 15) \
+T (29, 0, 9, 2, 11, 4, 13, 6, 15)
#define EXPTESTS \
T (116, 9, 3, 9, 4, 7, 0, 0, 6) \
T (117, 4, 14, 12, 8, 9, 6, 0, 10) \
diff --git a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof-2.c b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof-2.c
index bbba052..594c3f3 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof-2.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof-2.c
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fno-early-inlining -fdump-ipa-profile-optimized -fdump-ipa-afdo" } */
+/* { dg-options "-O2 -fno-early-inlining -fdump-ipa-profile-optimized -fdump-tree-einline-optimized" } */
volatile int one;
static int
add1 (int val)
@@ -22,7 +22,7 @@ int
main (void)
{
int i, val = 0;
- for (i = 0; i < 100000; i++)
+ for (i = 0; i < 10000000; i++)
{
val = do_op (val, add1);
val = do_op (val, sub1);
@@ -31,5 +31,5 @@ main (void)
}
/* { dg-final-use-not-autofdo { scan-ipa-dump "Indirect call -> direct call.* add1 .will resolve by ipa-profile" "profile"} } */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Indirect call -> direct call.* sub1 .will resolve by ipa-profile" "profile"} } */
-/* { dg-final-use-autofdo { scan-ipa-dump "Indirect call -> direct call.* add1 .will resolve by ipa-profile" "afdo"} } */
-/* { dg-final-use-autofdo { scan-ipa-dump "Indirect call -> direct call.* sub1 .will resolve by ipa-profile" "afdo"} } */
+/* { dg-final-use-autofdo { scan-tree-dump "Inlining add1/1 into main/4." "einline"} } */
+/* { dg-final-use-autofdo { scan-tree-dump "Inlining sub1/2 into main/4." "einline"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c
index 138b85a..7020452 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized -fdump-ipa-afdo" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized -fdump-ipa-afdo-optimized" } */
static int a1 (void)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-snprintf-11.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-snprintf-11.c
new file mode 100644
index 0000000..73117c4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-snprintf-11.c
@@ -0,0 +1,32 @@
+/* PR middle-end/100732 - ICE on sprintf %s with integer argument
+ { dg-do compile }
+ { dg-options "-O2 -Wall -fdump-tree-optimized" } */
+
+char d[32];
+
+void gb (_Bool b)
+{
+ __builtin_snprintf (d, 32, "%s", b); // { dg-warning "\\\[-Wformat" }
+}
+
+void gi (int i)
+{
+ __builtin_snprintf (d, 32, "%s", i); // { dg-warning "\\\[-Wformat" }
+}
+
+void gd (char *d, double x)
+{
+ __builtin_snprintf (d, 32, "%s", x); // { dg-warning "\\\[-Wformat" }
+}
+
+
+struct X { int i; };
+
+void gx (char *d, struct X x)
+{
+ __builtin_snprintf (d, 32, "%s", x); // { dg-warning "\\\[-Wformat" }
+}
+
+/* Also verify that the invalid sprintf call isn't folded to strcpy.
+ { dg-final { scan-tree-dump-times "snprintf" 4 "optimized" } }
+ { dg-final { scan-tree-dump-not "strcpy" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-snprintf-12.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-snprintf-12.c
new file mode 100644
index 0000000..9e26356
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-snprintf-12.c
@@ -0,0 +1,36 @@
+/* PR middle-end/100732 - ICE on sprintf %s with integer argument
+ { dg-do compile }
+ { dg-options "-O2 -Wall -fdump-tree-optimized" } */
+
+#define snprintf(d, n, f, ...) \
+ __builtin___snprintf_chk (d, n, 0, 32, f, __VA_ARGS__)
+
+int n;
+
+void gb (char *d, _Bool b)
+{
+ snprintf (d, n, "%s", b); // { dg-warning "\\\[-Wformat" }
+}
+
+void gi (char *d, int i)
+{
+ snprintf (d, n, "%s", i); // { dg-warning "\\\[-Wformat" }
+}
+
+void gd (char *d, double x)
+{
+ snprintf (d, n, "%s", x); // { dg-warning "\\\[-Wformat" }
+}
+
+
+struct X { int i; };
+
+void gx (char *d, struct X x)
+{
+ snprintf (d, n, "%s", x); // { dg-warning "\\\[-Wformat" }
+}
+
+
+/* Also verify that the invalid sprintf call isn't folded to strcpy.
+ { dg-final { scan-tree-dump-times "snprintf_chk" 4 "optimized" } }
+ { dg-final { scan-tree-dump-not "strcpy" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-28.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-28.c
new file mode 100644
index 0000000..c1d0083
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-28.c
@@ -0,0 +1,30 @@
+/* PR middle-end/100732 - ICE on sprintf %s with integer argument
+ { dg-do compile }
+ { dg-options "-O2 -Wall -fdump-tree-optimized" } */
+
+void gb (char *d, _Bool b)
+{
+ __builtin_sprintf (d, "%s", b); // { dg-warning "\\\[-Wformat" }
+}
+
+void gi (char *d, int i)
+{
+ __builtin_sprintf (d, "%s", i); // { dg-warning "\\\[-Wformat" }
+}
+
+void gd (char *d, double x)
+{
+ __builtin_sprintf (d, "%s", x); // { dg-warning "\\\[-Wformat" }
+}
+
+
+struct X { int i; };
+
+void gx (char *d, struct X x)
+{
+ __builtin_sprintf (d, "%s", x); // { dg-warning "\\\[-Wformat" }
+}
+
+/* Also verify that the invalid sprintf call isn't folded to strcpy.
+ { dg-final { scan-tree-dump-times "sprintf" 4 "optimized" } }
+ { dg-final { scan-tree-dump-not "strcpy" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-29.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-29.c
new file mode 100644
index 0000000..d0f7db2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-29.c
@@ -0,0 +1,40 @@
+/* PR middle-end/100732 - ICE on sprintf %s with integer argument
+ { dg-do compile }
+ { dg-options "-O2 -Wall -fdump-tree-optimized" } */
+
+#define sprintf(d, f, ...) \
+ __builtin___sprintf_chk (d, 0, 32, f, __VA_ARGS__)
+
+
+void fi (int i, const char *s)
+{
+ sprintf (i, "%s", s); // { dg-warning "\\\[-Wint-conversion" }
+}
+
+void gb (char *d, _Bool b)
+{
+ sprintf (d, "%s", b); // { dg-warning "\\\[-Wformat" }
+}
+
+void gi (char *d, int i)
+{
+ sprintf (d, "%s", i); // { dg-warning "\\\[-Wformat" }
+}
+
+void gd (char *d, double x)
+{
+ sprintf (d, "%s", x); // { dg-warning "\\\[-Wformat" }
+}
+
+
+struct X { int i; };
+
+void gx (char *d, struct X x)
+{
+ sprintf (d, "%s", x); // { dg-warning "\\\[-Wformat" }
+}
+
+
+/* Also verify that the invalid sprintf call isn't folded to strcpy.
+ { dg-final { scan-tree-dump-times "sprintf_chk" 5 "optimized" } }
+ { dg-final { scan-tree-dump-not "strcpy" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-3.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-3.c
index fae2a1b..ec55f26 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-3.c
@@ -15,7 +15,7 @@ extern void string_lt_0_fail ();
extern void string_eq_0_fail ();
extern void string_gt_0_fail ();
-void test_string (char *d, const char *s)
+void test_string_eq_min (char *d, const char *s)
{
int n = __builtin_sprintf (d, "%-s", s);
@@ -23,13 +23,36 @@ void test_string (char *d, const char *s)
or INT_MAX. (This is a white box test based on knowing that
the optimization computes its own values of the two constants.) */
if (n == INT_MIN) string_eq_min_fail ();
+}
+
+void test_string_eq_max (char *d, const char *s)
+{
+ int n = __builtin_sprintf (d, "%-s", s);
+
if (n == INT_MAX) string_eq_max_fail ();
+}
+
+void test_string_lt_0 (char *d, const char *s)
+{
+ int n = __builtin_sprintf (d, "%-s", s);
/* The return value could be negative when strlen(s) is in excess
of 4095 (the maximum number of bytes a single directive is required
to handle). */
if (n < 0) string_lt_0_fail ();
+}
+
+void test_string_eq_0 (char *d, const char *s)
+{
+ int n = __builtin_sprintf (d, "%-s", s);
+
if (n == 0) string_eq_0_fail ();
+}
+
+void test_string_gt_0 (char *d, const char *s)
+{
+ int n = __builtin_sprintf (d, "%-s", s);
+
if (n > 0) string_gt_0_fail ();
}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-26.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-26.c
new file mode 100644
index 0000000..677b634
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-26.c
@@ -0,0 +1,38 @@
+/* PR middle-end/100307 - spurious -Wplacement-new with negative pointer
+ offset
+ { dg-do compile }
+ { dg-options "-O0 -Wall" } */
+
+extern int sprintf (char*, const char*, ...);
+
+char a[4];
+
+void nowarn_1m1 ()
+{
+ char *p = a + 1;
+ sprintf (p - 1, "%i", 123); // { dg-bogus "-Wformat-overflow" }
+}
+
+void nowarn_4m3 ()
+{
+ char *p = a + 4;
+ sprintf (p - 3, "%i", 12); // { dg-bogus "-Wformat-overflow" }
+}
+
+void warn_2m1 ()
+{
+ char *p = a + 2;
+ sprintf (p - 1, "%i", 123); // { dg-warning "-Wformat-overflow" "pr100325" }
+}
+
+void warn_3m1 ()
+{
+ char *p = a + 3;
+ sprintf (p - 1, "%i", 12); // { dg-warning "-Wformat-overflow" "pr100325" }
+}
+
+void warn_4m1 ()
+{
+ char *p = a + 4;
+ sprintf (p - 1, "%i", 1); // { dg-warning "-Wformat-overflow" "pr100325" }
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-27.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-27.c
new file mode 100644
index 0000000..8188dd8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-27.c
@@ -0,0 +1,20 @@
+/* PR middle-end/100325 - missing warning with -O0 on sprintf overflow with
+ pointer plus offset
+ { dg-do compile }
+ { dg-options "-O0 -Wall" } */
+
+#define S(n) (&"0123456789"[10 - n])
+
+extern int sprintf (char*, const char*, ...);
+
+char d[10];
+
+void nowarn_d10_s9 ()
+{
+ sprintf (d, "%s", S (9)); // { dg-bogus "-Wformat-overflow" }
+}
+
+void warn_d10_s10 ()
+{
+ sprintf (d, "%s", S (10)); // { dg-warning "-Wformat-overflow" }
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp-trans.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp-trans.c
new file mode 100644
index 0000000..8ee8e3c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp-trans.c
@@ -0,0 +1,144 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
+
+/* Simple tests to make sure transitives are working. */
+void keep();
+void kill();
+
+void
+f1 (int x, int y, int z)
+{
+ if (x > y)
+ if (y > z)
+ {
+ if (x > z)
+ keep ();
+ else
+ kill ();
+ }
+}
+
+void
+f2 (int w, int x, int y, int z)
+{
+ // Test one equivalence.
+ if (w == z)
+ if (x > y)
+ if (y > z)
+ {
+ if (x > w)
+ keep ();
+ else
+ kill ();
+ }
+}
+
+void
+f3 (int a, int w, int x, int y, int z)
+{
+ // Test two equivlaences.
+ if (a == x)
+ if (w == z)
+ if (x > y)
+ if (y > z)
+ {
+ if (a > w)
+ keep ();
+ else
+ kill ();
+ }
+}
+
+void
+f4 (int x, int y, int z)
+{
+ // test X > Y >= Z
+ if (x > y)
+ if (y >= z)
+ {
+ if (x > z)
+ keep ();
+ else
+ kill ();
+ }
+}
+void
+f5 (int x, int y, int z)
+{
+ // test X >= Y > Z
+ if (x >= y)
+ if (y > z)
+ {
+ if (x > z)
+ keep ();
+ else
+ kill ();
+ }
+}
+
+void
+f6 (int x, int y, int z)
+{
+ // test X >= Y >= Z
+ if (x >= y)
+ if (y >= z)
+ {
+ if (x > z)
+ keep ();
+ else if (x == z)
+ keep ();
+ else
+ kill ();
+ }
+}
+
+void
+f7 (int x, int y, int z)
+{
+ // test Y <= X , Z <= Y
+ if (y <= x)
+ if (z <= y)
+ {
+ if (x > z)
+ keep ();
+ else if (x == z)
+ keep ();
+ else
+ kill ();
+ }
+}
+
+void
+f8 (int x, int y, int z)
+{
+ // test X >= Y, Z <= Y
+ if (x >= y)
+ if (z <= y)
+ {
+ if (x > z)
+ keep ();
+ else if (x == z)
+ keep ();
+ else
+ kill ();
+ }
+}
+
+void
+f9 (int x, int y, int z)
+{
+ // test Y <= X Y >= Z
+ if (y <= x)
+ if (y >= z)
+ {
+ if (x > z)
+ keep ();
+ else if (x == z)
+ keep ();
+ else
+ kill ();
+ }
+}
+
+/* { dg-final { scan-tree-dump-not "kill" "evrp" } } */
+/* { dg-final { scan-tree-dump-times "keep" 13 "evrp"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp1.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp1.c
index 8c6e4e6..f5f38c4 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/evrp1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-evrp" } */
+/* { dg-options "-O2 -fdump-tree-evrp-details" } */
int foo (int i);
int bar (int j)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp11.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp11.c
index f1373bd..d791305 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/evrp11.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp11.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-evrp" } */
+/* { dg-options "-O2 -fdump-tree-evrp -fdelete-null-pointer-checks" } */
extern void link_error ();
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp2.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp2.c
index e6d4235..fc92cdf 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/evrp2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-evrp" } */
+/* { dg-options "-O2 -fdump-tree-evrp-details" } */
int foo (int i);
int bar2 (int j)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp3.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp3.c
index 1a3bbd5..805652b 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/evrp3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp3.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-evrp" } */
+/* { dg-options "-O2 -fdump-tree-evrp-details" } */
int foo (int i);
void bar (int j)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp30.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp30.c
new file mode 100644
index 0000000..2c5ff41
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp30.c
@@ -0,0 +1,16 @@
+/* Confirm the ranger is picking up a relationship with equivalences. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
+
+extern void foo ();
+
+void f (unsigned int a, unsigned int b)
+{
+ if (a == b)
+ for (unsigned i = 0; i < a; i++)
+ if (i == b) // Confirm i < a also means i < b.
+ foo (); /* Unreachable */
+}
+
+/* { dg-final { scan-tree-dump-times "foo\\(" 0 "evrp"} } */
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp4.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp4.c
index 6710e6b..e3f4531 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/evrp4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp4.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-evrp" } */
+/* { dg-options "-O2 -fdump-tree-evrp-details" } */
int foo (int *p);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp6.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp6.c
index 35d4d74..aaeec68 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/evrp6.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp6.c
@@ -1,6 +1,5 @@
-
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-evrp" } */
+/* { dg-options "-O2 -fdump-tree-evrp-details" } */
extern void abort (void);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-33.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-33.c
index 9e0cedf..67846a5 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ldist-33.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-33.c
@@ -1,5 +1,8 @@
/* { dg-do compile { target size32plus } } */
-/* { dg-options "-O2 -ftree-loop-distribution -ftree-loop-distribute-patterns -fdump-tree-ldist-details" } */
+/* The desire is to show we can generate a memset from the outer loop
+ store. Both store motion and PRE expose a DSE opportunity for this
+ zeroing - while desirable this defeats the purpose of this testcase. */
+/* { dg-options "-O2 -fno-tree-loop-im -fno-tree-pre -ftree-loop-distribution -ftree-loop-distribute-patterns -fdump-tree-ldist-details" } */
#define N (1024)
double a[N][N], b[N][N], c[N][N];
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-interchange-16.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-interchange-16.c
new file mode 100644
index 0000000..781555e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-interchange-16.c
@@ -0,0 +1,22 @@
+/* PR/101280 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-linterchange-details" } */
+
+void dummy (double *, double *);
+#define LEN_2D 32
+double aa[LEN_2D][LEN_2D], bb[LEN_2D][LEN_2D];
+double s231(int iterations)
+{
+// loop interchange
+// loop with data dependency
+ for (int nl = 0; nl < 100*(iterations/LEN_2D); nl++) {
+ for (int i = 0; i < LEN_2D; ++i) {
+ for (int j = 1; j < LEN_2D; j++) {
+ aa[j][i] = aa[j - 1][i] + bb[j][i];
+ }
+ }
+ dummy(aa[0],bb[0]);
+ }
+}
+
+/* { dg-final { scan-tree-dump "loops interchanged" "linterchange" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/modref-4.c b/gcc/testsuite/gcc.dg/tree-ssa/modref-4.c
index 3ac217b..a277c70 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/modref-4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/modref-4.c
@@ -10,17 +10,17 @@ void a(char *ptr, char *ptr2)
__attribute__((noinline))
void b(char *ptr)
{
- a(ptr+1,&ptr[2]);
+ a(ptr+1,&ptr[3]);
}
int main()
{
- char c[4]={0,1,2,0};
+ char c[5]={0,1,2,0,0};
b(c);
- return c[0]+c[3];
+ return c[0]+c[4];
}
/* Check that both param offsets are determined correctly and the computation
is optimized out. */
/* { dg-final { scan-tree-dump "param offset:1" "modref1" } } */
-/* { dg-final { scan-tree-dump "param offset:2" "modref1" } } */
+/* { dg-final { scan-tree-dump "param offset:3" "modref1" } } */
/* { dg-final { scan-tree-dump "return 0" "modref1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/modref-6.c b/gcc/testsuite/gcc.dg/tree-ssa/modref-6.c
new file mode 100644
index 0000000..2d97a49
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/modref-6.c
@@ -0,0 +1,37 @@
+/* { dg-options "-O2 -fdump-tree-modref1 -fdump-tree-optimized" } */
+/* { dg-do compile } */
+int c;
+__attribute__ ((noinline))
+int *test (int *b)
+{
+ c++;
+ return *b ? &c : 0;
+}
+__attribute__ ((noinline, pure))
+int *pure_test (int *b)
+{
+ return *b && c ? &c : 0;
+}
+__attribute__ ((noinline, const))
+int *const_test (int *b)
+{
+ return b ? &c : 0;
+}
+void escape (int *);
+
+int test2()
+{
+ int a = 42;
+ escape (test (&a));
+ escape (pure_test (&a));
+ escape (const_test (&a));
+ return a;
+}
+/* Flags for normal call. */
+/* { dg-final { scan-tree-dump "parm 0 flags: direct noclobber noescape nodirectescape not_returned" "modref1" } } */
+/* Flags for pure call. */
+/* { dg-final { scan-tree-dump "parm 0 flags: direct not_returned" "modref1" } } */
+/* Flags for const call. */
+/* { dg-final { scan-tree-dump "parm 0 flags: not_returned" "modref1" } } */
+/* Overall we want to make "int a" non escaping. */
+/* { dg-final { scan-tree-dump "return 42" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/modref-7.c b/gcc/testsuite/gcc.dg/tree-ssa/modref-7.c
new file mode 100644
index 0000000..53ffa1c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/modref-7.c
@@ -0,0 +1,13 @@
+/* { dg-options "-O2 --param modref-max-accesses=1 -fdump-tree-modref1" } */
+/* { dg-do compile } */
+struct a {
+ int array[10];
+ int tail;
+};
+int test(struct a *a, int p)
+{
+ a->array[p] = 0;
+ a->array[0] = 1;
+}
+/* All three accesses combine to one bigger access. */
+/* { dg-final { scan-tree-dump-not "param=modref-max-accesses" "modref1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/modref-8.c b/gcc/testsuite/gcc.dg/tree-ssa/modref-8.c
new file mode 100644
index 0000000..15ae4ac
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/modref-8.c
@@ -0,0 +1,25 @@
+/* { dg-options "-O2 --param modref-max-adjustments=8 -fdump-tree-modref1" } */
+/* { dg-do compile } */
+void
+set (char *p)
+{
+ p[1]=1;
+ p[0]=0;
+ p[2]=2;
+ p[4]=4;
+ p[3]=3;
+}
+
+void
+recurse (char *p, int n)
+{
+ *p = 0;
+ if (n)
+ recurse (p+1,n-1);
+}
+/* { dg-final { scan-tree-dump-not "param=modref-max-accesses" "modref1" } } */
+/* { dg-final { scan-tree-dump "param=modref-max-adjustments" "modref1" } } */
+/* In set all accesses should merge together. */
+/* { dg-final { scan-tree-dump "access: Parm 0 param offset:0 offset:0 size:8 max_size:40" "modref1" } } */
+/* In recurse we should cap the recrusion after 8 attempts and set max_size to -1. */
+/* { dg-final { scan-tree-dump "access: Parm 0 param offset:0 offset:0 size:8 max_size:-1 adjusted 8 times" "modref1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/modref-9.c b/gcc/testsuite/gcc.dg/tree-ssa/modref-9.c
new file mode 100644
index 0000000..02de2f0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/modref-9.c
@@ -0,0 +1,15 @@
+/* { dg-options "-O2 --param modref-max-accesses=2 -fdump-tree-modref1" } */
+/* { dg-do compile } */
+void
+test(char *a)
+{
+ a[0] = 0;
+ a[1] = 1;
+ a[3] = 3;
+ a[7] = 7;
+ a[9] = 9;
+}
+/* We allow only two accesses per function.
+ It is best to group together {0,1,3} and {7,9}. */
+/* { dg-final { scan-tree-dump "access: Parm 0 param offset:0 offset:0 size:8 max_size:32" "modref1" } } */
+/* { dg-final { scan-tree-dump "access: Parm 0 param offset:7 offset:0 size:8 max_size:24" "modref1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c
index 4c190e6..3681fa7 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c
@@ -7,4 +7,4 @@ int eqm1_phi (unsigned long a) { return a ? 0 : -1; }
int spaceship1 (long a) { return a > 0 ? 1 : a < 0 ? -1 : 0; }
int spaceship2 (long a) { return a > 0 ? 1 : a == 0 ? 0 : -1; }
-/* { dg-final { scan-tree-dump-times " = -\[^\r\n\]*_.;" 4 "optimized"} } */
+/* { dg-final { scan-tree-dump-times " = -\[^\r\n\]*_\[0-9\]*;" 4 "optimized"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-15.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-15.c
index ac3018e..6aec689 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-15.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-15.c
@@ -9,4 +9,6 @@ foo (int i)
return i;
}
-/* { dg-final { scan-tree-dump-not "ABS" "optimized" } } */
+/* We should not have ABS_EXPR but ABSU_EXPR instead. */
+/* { dg-final { scan-tree-dump-not "ABS_EXPR" "optimized" } } */
+/* { dg-final { scan-tree-dump "ABSU" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-23.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-23.c
new file mode 100644
index 0000000..ff658cd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-23.c
@@ -0,0 +1,44 @@
+/* { dg-options "-O2 -fdump-tree-phiopt" } */
+
+int f0(int A)
+{
+// A == 0? A : -A same as -A
+ if (A == 0) return A;
+ return -A;
+}
+
+int f1(int A)
+{
+// A != 0? A : -A same as A
+ if (A != 0) return A;
+ return -A;
+}
+int f2(int A)
+{
+// A >= 0? A : -A same as abs (A)
+ if (A >= 0) return A;
+ return -A;
+}
+int f3(int A)
+{
+// A > 0? A : -A same as abs (A)
+ if (A > 0) return A;
+ return -A;
+}
+int f4(int A)
+{
+// A <= 0? A : -A same as -abs (A)
+ if (A <= 0) return A;
+ return -A;
+}
+int f5(int A)
+{
+// A < 0? A : -A same as -abs (A)
+ if (A < 0) return A;
+ return -A;
+}
+
+/* These should be optimized in phiopt1 but is confused by predicts. */
+/* { dg-final { scan-tree-dump-not "if" "phiopt1" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-not "if" "phiopt2" } } */
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-24.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-24.c
new file mode 100644
index 0000000..eb89dec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-24.c
@@ -0,0 +1,44 @@
+/* { dg-options "-O2 -fno-signed-zeros -fdump-tree-phiopt" } */
+
+float f0(float A)
+{
+// A == 0? A : -A same as -A
+ if (A == 0) return A;
+ return -A;
+}
+
+float f1(float A)
+{
+// A != 0? A : -A same as A
+ if (A != 0) return A;
+ return -A;
+}
+float f2(float A)
+{
+// A >= 0? A : -A same as abs (A)
+ if (A >= 0) return A;
+ return -A;
+}
+float f3(float A)
+{
+// A > 0? A : -A same as abs (A)
+ if (A > 0) return A;
+ return -A;
+}
+float f4(float A)
+{
+// A <= 0? A : -A same as -abs (A)
+ if (A <= 0) return A;
+ return -A;
+}
+float f5(float A)
+{
+// A < 0? A : -A same as -abs (A)
+ if (A < 0) return A;
+ return -A;
+}
+
+/* These should be optimized in phiopt1 but is confused by predicts. */
+/* { dg-final { scan-tree-dump-not "if" "phiopt1" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-not "if" "phiopt2" } } */
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25.c
new file mode 100644
index 0000000..c52c92e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25.c
@@ -0,0 +1,83 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+unsigned short test_bswap16(unsigned short x)
+{
+ return x ? __builtin_bswap16(x) : 0;
+}
+
+unsigned int test_bswap32(unsigned int x)
+{
+ return x ? __builtin_bswap32(x) : 0;
+}
+
+unsigned long long test_bswap64(unsigned long long x)
+{
+ return x ? __builtin_bswap64(x) : 0;
+}
+
+int test_clrsb(int x)
+{
+ return x ? __builtin_clrsb(x) : (__SIZEOF_INT__*8-1);
+}
+
+int test_clrsbl(long x)
+{
+ return x ? __builtin_clrsbl(x) : (__SIZEOF_LONG__*8-1);
+}
+
+int test_clrsbll(long long x)
+{
+ return x ? __builtin_clrsbll(x) : (__SIZEOF_LONG_LONG__*8-1);
+}
+
+#if 0
+/* BUILT_IN_FFS is transformed by match.pd */
+int test_ffs(unsigned int x)
+{
+ return x ? __builtin_ffs(x) : 0;
+}
+
+int test_ffsl(unsigned long x)
+{
+ return x ? __builtin_ffsl(x) : 0;
+}
+
+int test_ffsll(unsigned long long x)
+{
+ return x ? __builtin_ffsll(x) : 0;
+}
+#endif
+
+int test_parity(int x)
+{
+ return x ? __builtin_parity(x) : 0;
+}
+
+int test_parityl(long x)
+{
+ return x ? __builtin_parityl(x) : 0;
+}
+
+int test_parityll(long long x)
+{
+ return x ? __builtin_parityll(x) : 0;
+}
+
+int test_popcount(int x)
+{
+ return x ? __builtin_popcount(x) : 0;
+}
+
+int test_popcountl(long x)
+{
+ return x ? __builtin_popcountl(x) : 0;
+}
+
+int test_popcountll(long long x)
+{
+ return x ? __builtin_popcountll(x) : 0;
+}
+
+/* { dg-final { scan-tree-dump-not "goto" "optimized" } } */
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c
index 18ecbd5..51e1f6d 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c
@@ -18,5 +18,5 @@ int f(int t, int c)
/* There should be one ifs as one of them should be changed into
a conditional and the other should be there still. */
/* { dg-final { scan-tree-dump-times "if" 1 "optimized" } }*/
-/* { dg-final { scan-tree-dump-times "\[^\r\n\]*_. = c_\[0-9\]*.D. != 0" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\[^\r\n\]*_\[0-9\]* = c_\[0-9\]*.D. != 0" 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/popcount4l.c b/gcc/testsuite/gcc.dg/tree-ssa/popcount4l.c
index 69fb2d1..269e56e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/popcount4l.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/popcount4l.c
@@ -25,6 +25,7 @@ int popcount64c(unsigned long x)
return (x * h01) >> shift;
}
-/* { dg-final { scan-tree-dump-times "\.POPCOUNT" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\.POPCOUNT" 1 "optimized" { target int32plus } } } */
+/* { dg-final { scan-tree-dump "\.POPCOUNT" "optimized" { target { ! int32plus } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/popcount4ll.c b/gcc/testsuite/gcc.dg/tree-ssa/popcount4ll.c
index c1588be..7abadf6 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/popcount4ll.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/popcount4ll.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { lp64 } } } */
+/* { dg-do compile } */
/* { dg-require-effective-target popcountll } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
@@ -16,4 +16,5 @@ int popcount64c(unsigned long long x)
return (x * h01) >> shift;
}
-/* { dg-final { scan-tree-dump-times "\.POPCOUNT" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\.POPCOUNT" 1 "optimized" { target { lp64 } } } } */
+/* { dg-final { scan-tree-dump-times "\.POPCOUNT" 2 "optimized" { target { ! lp64 } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/popcount5ll.c b/gcc/testsuite/gcc.dg/tree-ssa/popcount5ll.c
index edb191b..2afe081 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/popcount5ll.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/popcount5ll.c
@@ -1,5 +1,5 @@
/* PR tree-optimization/94800 */
-/* { dg-do compile { target { lp64 } } } */
+/* { dg-do compile } */
/* { dg-require-effective-target popcountll } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
@@ -19,4 +19,5 @@ int popcount64c(unsigned long long x)
return x >> shift;
}
-/* { dg-final { scan-tree-dump-times "\.POPCOUNT" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\.POPCOUNT" 1 "optimized" { target { lp64 } } } } */
+/* { dg-final { scan-tree-dump-times "\.POPCOUNT" 2 "optimized" { target { ! lp64 } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr100278.c b/gcc/testsuite/gcc.dg/tree-ssa/pr100278.c
new file mode 100644
index 0000000..8d70228
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr100278.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void a()
+{
+#if defined __s390__
+ register int b asm("r5");
+#elif defined __x86_64__
+ register int b asm("eax");
+#else
+ volatile int b;
+#endif
+ if (b)
+ b = 1;
+ for (; b;)
+ ;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr100453.c b/gcc/testsuite/gcc.dg/tree-ssa/pr100453.c
new file mode 100644
index 0000000..0cf0ad2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr100453.c
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+
+struct a {
+ int b : 4;
+} d;
+static int c, e;
+static const struct a f;
+static void g(const struct a h) {
+ for (; c < 1; c++)
+ d = h;
+ e = h.b;
+ c = h.b;
+}
+int main() {
+ g(f);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr100794.c b/gcc/testsuite/gcc.dg/tree-ssa/pr100794.c
new file mode 100644
index 0000000..6f707ae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr100794.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-loop-vectorize -fdump-tree-pcom-details -fdisable-tree-vect" } */
+
+extern double arr[100];
+extern double foo (double, double);
+extern double sum;
+
+void
+test (int i_0, int i_n)
+{
+ int i;
+ for (i = i_0; i < i_n - 1; i++)
+ {
+ double a = arr[i];
+ double b = arr[i + 1];
+ sum += a * b;
+ }
+}
+
+/* { dg-final { scan-tree-dump "Executing predictive commoning without unrolling" "pcom" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr101189.c b/gcc/testsuite/gcc.dg/tree-ssa/pr101189.c
new file mode 100644
index 0000000..5730708
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr101189.c
@@ -0,0 +1,17 @@
+/* PR tree-optimization/101189 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+static int a, b;
+int main() {
+ int d = 0, e, f = 5;
+ if (a)
+ f = 0;
+ for (; f < 4; f++)
+ ;
+ e = f ^ -f;
+ e && d;
+ if (!e)
+ e || b;
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr101335.c b/gcc/testsuite/gcc.dg/tree-ssa/pr101335.c
new file mode 100644
index 0000000..921362c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr101335.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+unsigned a = 0xFFFFFFFF;
+int b;
+int main()
+{
+ int c = ~a;
+ unsigned d = c - 10;
+ if (d > c)
+ c = 20;
+ b = -(c | 0);
+ if (b > -8)
+ __builtin_abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr101824.c b/gcc/testsuite/gcc.dg/tree-ssa/pr101824.c
new file mode 100644
index 0000000..d5987e1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr101824.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-pcom-details -fdump-tree-optimized" } */
+
+int main()
+{
+ volatile int y;
+ void bar()
+ {
+ __builtin_printf ("%d", y);
+ }
+ while (y)
+ ;
+ return 0;
+}
+
+/* Make sure the load from y is correctly interpreted as volatile, even
+ when going through FRAME. */
+/* { dg-final { scan-tree-dump-not "Executing predictive commoning" "pcom" } } */
+/* { dg-final { scan-tree-dump " ={v} FRAME" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr20739.c b/gcc/testsuite/gcc.dg/tree-ssa/pr20739.c
index c1e7b58..d7fff14 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr20739.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr20739.c
@@ -1,7 +1,7 @@
/* PR middle-end/20739 */
-/* dg-do compile */
-/* dg-options "-O" */
+/* { dg-do compile } */
+/* { dg-options "-O" } */
/* We used to fail to compile this because gimplification dropped the
conversion that added the const qualifier to the sub-expression
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21001.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21001.c
index 719360a..4ea5f21 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr21001.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21001.c
@@ -6,6 +6,7 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fno-tree-dominator-opts -fno-tree-fre -fdisable-tree-evrp -fdump-tree-vrp1-details" } */
+/* { dg-additional-options "-fdisable-tree-ethread -fdisable-tree-thread1" } */
int
foo (int a)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21294.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21294.c
index cc7d4cd..b9edabc 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr21294.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21294.c
@@ -5,6 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fno-tree-dominator-opts -fdisable-tree-evrp -fdump-tree-vrp1-details" } */
+/* { dg-additional-options "-fdisable-tree-ethread -fdisable-tree-thread1" } */
struct f {
int i;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21417.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21417.c
index 4845119..b934c9c 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr21417.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21417.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-thread4-details" } */
+/* { dg-options "-O2 -fdisable-tree-thread3 -fdump-tree-thread4-details" } */
struct tree_common
{
@@ -49,5 +49,5 @@ L23:
/* We should thread the backedge to the top of the loop; ie we only
execute the if (expr->common.code != 142) test once per loop
iteration. */
-/* { dg-final { scan-tree-dump-times "FSM jump thread" 1 "thread4" } } */
+/* { dg-final { scan-tree-dump-times "jump thread" 1 "thread4" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c
index 2aee42f..f8d7353 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-evrp-details" } */
+/* { dg-options "-O2 -fdump-tree-evrp-details -fdisable-tree-ethread" } */
extern void g (void);
extern void bar (int);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21563.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21563.c
index 9c67a3a..72dce83 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr21563.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21563.c
@@ -2,7 +2,7 @@
Make sure VRP folds the second "if" statement. */
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-dominator-opts -fdisable-tree-evrp -fdump-tree-vrp1-details" } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fdisable-tree-evrp -fdump-tree-vrp1-details -fdisable-tree-ethread -fdisable-tree-thread1" } */
int
foo (int a)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr49039.c b/gcc/testsuite/gcc.dg/tree-ssa/pr49039.c
index 4bc0a81..a2044d0 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr49039.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr49039.c
@@ -1,6 +1,6 @@
/* PR tree-optimization/49039 */
/* { dg-do compile } */
-/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1 -fdisable-tree-ethread -fdisable-tree-thread1" } */
extern void bar (void);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61839_1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61839_1.c
index d44c7dc..ddc53fb 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr61839_1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61839_1.c
@@ -1,6 +1,6 @@
/* PR tree-optimization/61839. */
/* { dg-do run } */
-/* { dg-options "-O2 -fdump-tree-vrp1 -fdisable-tree-evrp -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-vrp1 -fdisable-tree-evrp -fdump-tree-optimized -fdisable-tree-ethread -fdisable-tree-thread1" } */
/* { dg-require-effective-target int32plus } */
__attribute__ ((noinline))
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61839_2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61839_2.c
index cfec54d..0e0f4c0 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr61839_2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61839_2.c
@@ -45,10 +45,40 @@ int bar2 ()
return 0;
}
+/* Ensure we are folding modulus sub-ranges properly. */
+__attribute__ ((noinline))
+int mod (int a, int b)
+{
+ int v1, v2;
+ v1 = (a < 10) ? 12 : 24;
+ v2 = (b > 20) ? 3 : 6;
+
+ if (a > 20)
+ v1 = v1 * 2;
+ if (b > 20)
+ v2 = v2 * 2;
+
+ if (a == b)
+ v2 = 0;
+
+ /* v1 == 12, 24, or 48. v2 == 0, 3, 6, or 12. */
+ int c = v1 % v2;
+ if (c == 0)
+ ;
+ else
+ __builtin_abort ();
+ return 0;
+}
+
+/* EVRP now makes transformations in all functions, leaving a single
+ * builtin_abort call in bar2. */
+/* { dg-final { scan-tree-dump-times "__builtin_abort" 1 "evrp" } } */
-/* Dont optimize 972195717 / 0 in function foo. */
-/* { dg-final { scan-tree-dump-times "972195717 / " 1 "evrp" } } */
-/* Dont optimize 972195717 % 0 in function bar. */
-/* { dg-final { scan-tree-dump-times "972195717 % " 1 "evrp" } } */
-/* May optimize in function bar2, but EVRP doesn't perform this yet. */
+/* Make sure to optimize 972195717 / 0 in function foo. */
+/* { dg-final { scan-tree-dump-times "972195717 / " 0 "evrp" } } */
+/* Make sure to optimize 972195717 % 0 in function bar. */
+/* { dg-final { scan-tree-dump-times "972195717 % " 0 "evrp" } } */
+/* Make sure to optimize 972195717 % [1,2] function bar2. */
/* { dg-final { scan-tree-dump-times "972195715 % " 0 "evrp" } } */
+/* [12,12][24,24][48,48] % [0,0][3,3][6,6][12,12] == [0,0] */
+/* { dg-final { scan-tree-dump-times "%" 0 "evrp" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61839_3.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61839_3.c
index 5ceb073..cc322d6 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr61839_3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61839_3.c
@@ -1,6 +1,6 @@
/* PR tree-optimization/61839. */
/* { dg-do run } */
-/* { dg-options "-O2 -fdump-tree-vrp1 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-vrp1 -fdump-tree-optimized -fdisable-tree-ethread -fdisable-tree-thread1" } */
__attribute__ ((noinline))
int foo (int a, unsigned b)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr64130.c b/gcc/testsuite/gcc.dg/tree-ssa/pr64130.c
index 28ffbb7..b694ec1 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr64130.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr64130.c
@@ -1,6 +1,5 @@
-
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-evrp" } */
+/* { dg-options "-O2 -fdump-tree-evrp-details" } */
__extension__ typedef __UINT32_TYPE__ uint32_t;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr66752-3.c b/gcc/testsuite/gcc.dg/tree-ssa/pr66752-3.c
index 896c8bf..e1464e2 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr66752-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr66752-3.c
@@ -32,9 +32,9 @@ foo (int N, int c, int b, int *a)
pt--;
}
-/* There are 4 FSM jump threading opportunities, all of which will be
+/* There are 4 jump threading opportunities, all of which will be
realized, which will eliminate testing of FLAG, completely. */
-/* { dg-final { scan-tree-dump-times "Registering FSM" 4 "thread1"} } */
+/* { dg-final { scan-tree-dump-times "Registering jump" 4 "thread1"} } */
/* There should be no assignments or references to FLAG, verify they're
eliminated as early as possible. */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c b/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c
index 59d562e..af8b7a5 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c
@@ -37,5 +37,5 @@ c_finish_omp_clauses (tree clauses)
}
}
-/* There are 3 FSM jump threading opportunities. */
-/* { dg-final { scan-tree-dump-times "Registering FSM" 3 "thread1"} } */
+/* There are 3 jump threading opportunities. */
+/* { dg-final { scan-tree-dump-times "Registering jump" 3 "thread1"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c
index 960491f..dfabb48 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c
@@ -1,7 +1,7 @@
/* { dg-do compile { target sparc*-*-* i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -fdump-tree-thread1-details -fdisable-tree-ethread" } */
-/* { dg-final { scan-tree-dump "FSM did not thread around loop and would copy too many statements" "thread1" } } */
+/* { dg-final { scan-tree-dump "Did not thread around loop and would copy too many statements" "thread1" } } */
typedef __builtin_va_list __gnuc_va_list;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr70232.c b/gcc/testsuite/gcc.dg/tree-ssa/pr70232.c
index 6cc987a..d636672 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr70232.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr70232.c
@@ -1,12 +1,12 @@
/* { dg-do compile } */
/* { dg-options "-O2 -w -fdump-tree-vrp1-details -fdump-tree-vrp2-details -fdump-tree-dom2-details -fdump-tree-dom3-details" } */
-/* All the threads found by the FSM threader should have too
- many statements to be profitable. */
-/* { dg-final { scan-tree-dump-not "Registering FSM " "dom2"} } */
-/* { dg-final { scan-tree-dump-not "Registering FSM " "dom3"} } */
-/* { dg-final { scan-tree-dump-not "Registering FSM " "vrp1"} } */
-/* { dg-final { scan-tree-dump-not "Registering FSM " "vrp2"} } */
+/* All the threads found by the threader should have too many
+ statements to be profitable. */
+/* { dg-final { scan-tree-dump-not "Registering jump " "dom2"} } */
+/* { dg-final { scan-tree-dump-not "Registering jump " "dom3"} } */
+/* { dg-final { scan-tree-dump-not "Registering jump " "vrp1"} } */
+/* { dg-final { scan-tree-dump-not "Registering jump " "vrp2"} } */
typedef _Bool bool;
typedef unsigned char uint8_t;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr77445-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr77445-2.c
index cf74e15..f9fc212 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr77445-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr77445-2.c
@@ -124,7 +124,7 @@ enum STATES FMS( u8 **in , u32 *transitions) {
to change decisions in switch expansion which in turn can expose new
jump threading opportunities. Skip the later tests on aarch64. */
/* { dg-final { scan-tree-dump "Jumps threaded: 1\[1-9\]" "thread1" } } */
-/* { dg-final { scan-tree-dump-times "Invalid sum" 3 "thread1" } } */
+/* { dg-final { scan-tree-dump-times "Invalid sum" 4 "thread1" } } */
/* { dg-final { scan-tree-dump-not "optimizing for size" "thread1" } } */
/* { dg-final { scan-tree-dump-not "optimizing for size" "thread2" } } */
/* { dg-final { scan-tree-dump-not "optimizing for size" "thread3" { target { ! aarch64*-*-* } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr77445.c b/gcc/testsuite/gcc.dg/tree-ssa/pr77445.c
index 98eb0f2..883a63d 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr77445.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr77445.c
@@ -25,5 +25,5 @@ main (int argc)
if (b)
test2 ();
}
-/* { dg-final { scan-tree-dump-times "Registering FSM jump thread" 2 "thread3" } } */
+/* { dg-final { scan-tree-dump-times "Registering jump thread" 2 "thread3" } } */
/* { dg-final { scan-tree-dump-not "Invalid sum" "thread3" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr83403-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr83403-1.c
index 748375b..bfc703d 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr83403-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr83403-1.c
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O3 -funroll-loops -fdump-tree-lim2-details" } */
+/* { dg-additional-options "--param max-completely-peeled-insns=200" { target { s390*-*-* } } } */
#define TYPE unsigned int
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr83403-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr83403-2.c
index ca2e6bb..9130d9b 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr83403-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr83403-2.c
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O3 -funroll-loops -fdump-tree-lim2-details" } */
+/* { dg-additional-options "--param max-completely-peeled-insns=200" { target { s390*-*-* } } } */
#define TYPE int
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr84512.c b/gcc/testsuite/gcc.dg/tree-ssa/pr84512.c
index 3c02701..496c78b 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr84512.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr84512.c
@@ -13,4 +13,4 @@ int foo()
}
/* Listed targets xfailed due to PR84958. */
-/* { dg-final { scan-tree-dump "return 285;" "optimized" { xfail { amdgcn*-*-* } } } } */
+/* { dg-final { scan-tree-dump "return 285;" "optimized" { xfail { amdgcn*-*-* || vect_variable_length } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr88087.c b/gcc/testsuite/gcc.dg/tree-ssa/pr88087.c
index d0061b6..c48dba5 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr88087.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr88087.c
@@ -1,17 +1,17 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-pre-stats" } */
+/* { dg-options "-O2 -fno-code-hoisting -fdump-tree-pre-stats" } */
int f();
int d;
-void c()
+void c(int x)
{
- for (;;)
- {
- f();
- int (*fp)() __attribute__((const)) = (void *)f;
- d = fp();
- }
+ int (*fp)() __attribute__((const)) = (void *)f;
+ if (x)
+ d = fp ();
+ int tem = fp ();
+ f();
+ d = tem;
}
-/* We shouldn't ICE and hoist the const call of fp out of the loop. */
+/* We shouldn't ICE and PRE the const call. */
/* { dg-final { scan-tree-dump "Eliminated: 1" "pre" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-1.c
index 8ee1850..d9fb2ed 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-cselim-details" } */
+/* { dg-options "-O2 -ftree-cselim -fdump-tree-cselim-details" } */
unsigned test(unsigned k, unsigned b) {
unsigned a[2];
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-2.c
index 9b96875..bb39df2 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-cselim-details" } */
+/* { dg-options "-O2 -ftree-cselim -fdump-tree-cselim-details" } */
int c;
unsigned test(unsigned k, unsigned b) {
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-3.c b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-3.c
index 0fac9f9..0016637 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-3.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-cselim-details" } */
+/* { dg-options "-O2 -ftree-cselim -fdump-tree-cselim-details" } */
unsigned a[2];
unsigned test(unsigned k, unsigned b) {
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-4.c b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-4.c
index 54b8c11..127cbdf 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-4.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-cselim-details" } */
+/* { dg-options "-O2 -ftree-cselim -fdump-tree-cselim-details" } */
int *p;
unsigned test(unsigned k, unsigned b) {
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-5.c b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-5.c
index b2d0411..6a00f54 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-5.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-5.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-cselim-details" } */
+/* { dg-options "-O2 -ftree-cselim -fdump-tree-cselim-details" } */
int test(int b, int k) {
struct {
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-6.c b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-6.c
index 8d3c4f7..ecc083e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-6.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-6.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-cselim-details" } */
+/* { dg-options "-O2 -ftree-cselim -fdump-tree-cselim-details" } */
int test(int b, int k) {
typedef struct {
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-7-comp-ref.c b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-7-comp-ref.c
index c35a2af..4fad2d1 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-7-comp-ref.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-7-comp-ref.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-cselim-details" } */
+/* { dg-options "-O2 -ftree-cselim -fdump-tree-cselim-details" } */
typedef union {
int i;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-8-mem-ref-size.c b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-8-mem-ref-size.c
index f9e66ae..5f93112 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr89430-8-mem-ref-size.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr89430-8-mem-ref-size.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-cselim-details" } */
+/* { dg-options "-O2 -ftree-cselim -fdump-tree-cselim-details" } */
int *t;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr93781-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr93781-1.c
index 5ebd805..b2505f3 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr93781-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr93781-1.c
@@ -12,7 +12,9 @@ void foo (unsigned int arg)
if (a < 0)
b = x;
- /* In the fullness of time, we will delete this call. */
if (b >= 5)
kill ();;
}
+
+/* { dg-final { scan-tree-dump-not "kill" "evrp" } } */
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr94589-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr94589-1.c
new file mode 100644
index 0000000..7e1aaaa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr94589-1.c
@@ -0,0 +1,21 @@
+/* PR tree-optimization/94589 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int
+foo (int x)
+{
+ return (x & 23) == x;
+/* { dg-final { scan-tree-dump " & -24;" "optimized" } } */
+/* { dg-final { scan-tree-dump-not " & 23;" "optimized" } } */
+/* { dg-final { scan-tree-dump " == 0" "optimized" } } */
+}
+
+int
+bar (int x)
+{
+ return (x | 137) != 137;
+/* { dg-final { scan-tree-dump " & -138;" "optimized" } } */
+/* { dg-final { scan-tree-dump-not " \\| 137;" "optimized" } } */
+/* { dg-final { scan-tree-dump " != 0" "optimized" } } */
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr95527-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr95527-2.c
new file mode 100644
index 0000000..b4ae2be
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr95527-2.c
@@ -0,0 +1,57 @@
+/* PR tree-optimization/95527 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-original" } */
+/* { dg-final { scan-tree-dump "a & 7\\) == 0" "original" } } */
+/* { dg-final { scan-tree-dump "b & 63\\) != 0" "original" } } */
+/* { dg-final { scan-tree-dump-times "return 0;" 2 "original" } } */
+/* { dg-final { scan-tree-dump-times "return 1;" 2 "original" } } */
+/* { dg-final { scan-tree-dump "g & 15\\) == 8" "original" } } */
+/* { dg-final { scan-tree-dump "h & 255\\) != 128" "original" } } */
+
+int
+f1 (int a)
+{
+ return __builtin_ctz (a) >= 3;
+}
+
+int
+f2 (int b)
+{
+ return __builtin_ctz (b) < 6;
+}
+
+int
+f3 (int c)
+{
+ return __builtin_ctz (c) < 0;
+}
+
+int
+f4 (int d)
+{
+ return __builtin_ctz (d) >= 0;
+}
+
+int
+f5 (int e)
+{
+ return __builtin_ctz (e) >= __SIZEOF_INT__ * __CHAR_BIT__;
+}
+
+int
+f6 (int f)
+{
+ return __builtin_ctz (f) < __SIZEOF_INT__ * __CHAR_BIT__;
+}
+
+int
+f7 (int g)
+{
+ return __builtin_ctz (g) == 3;
+}
+
+int
+f8 (int h)
+{
+ return __builtin_ctz (h) != 7;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96789.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96789.c
index 5704952..4d4d4c8 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr96789.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96789.c
@@ -58,4 +58,4 @@ bar (int16_t res[16], uint8_t *val1, uint8_t *val2)
}
}
-/* { dg-final { scan-tree-dump {Deleted dead store:.*tmp} "dse3" } } */
+/* { dg-final { scan-tree-dump {Deleted dead store:.*tmp} "dse4" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
new file mode 100644
index 0000000..9e505ac
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
@@ -0,0 +1,51 @@
+/* PR tree-optimization/96928 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-phiopt2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times " = a_\[0-9]*\\\(D\\\) >> " 5 "phiopt2" } } */
+/* The following check is done at optimized because a ^ (~b) is rewritten as ~(a^b)
+ and in the case of match.pd optimizing these ?:, the ~ is moved out already
+ by the time we get to phiopt2. */
+/* { dg-final { scan-tree-dump-times "c_\[0-9]*\\\(D\\\) \\\^" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times " = ~" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times " = \[abc_0-9\\\(\\\)D]* \\\^ " 5 "phiopt2" } } */
+/* { dg-final { scan-tree-dump-not "a < 0" "phiopt2" } } */
+
+int
+foo (int a)
+{
+ if (a < 0)
+ return ~a;
+ return a;
+}
+
+int
+bar (int a, int b)
+{
+ if (a < 0)
+ return ~b;
+ return b;
+}
+
+unsigned
+baz (int a, unsigned int b)
+{
+ if (a < 0)
+ return ~b;
+ return b;
+}
+
+unsigned
+qux (int a, unsigned int c)
+{
+ if (a >= 0)
+ return ~c;
+ return c;
+}
+
+int
+corge (int a, int b)
+{
+ if (a >= 0)
+ return b;
+ return ~b;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96928.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96928.c
index 2091357..e8fd82f 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr96928.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96928.c
@@ -1,8 +1,11 @@
/* PR tree-optimization/96928 */
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-phiopt2" } */
+/* { dg-options "-O2 -fdump-tree-phiopt2 -fdump-tree-optimized" } */
/* { dg-final { scan-tree-dump-times " = a_\[0-9]*\\\(D\\\) >> " 5 "phiopt2" } } */
-/* { dg-final { scan-tree-dump-times " = ~c_\[0-9]*\\\(D\\\);" 1 "phiopt2" } } */
+/* The following check is done at optimized because a ^ (~b) is rewritten as ~(a^b)
+ and in the case of match.pd optimizing these ?:, the ~ is moved out already
+ by the time we get to phiopt2. */
+/* { dg-final { scan-tree-dump-times "\\\^ c_\[0-9]*\\\(D\\\);" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times " = ~" 1 "phiopt2" } } */
/* { dg-final { scan-tree-dump-times " = \[abc_0-9\\\(\\\)D]* \\\^ " 5 "phiopt2" } } */
/* { dg-final { scan-tree-dump-not "a < 0" "phiopt2" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr97009.c b/gcc/testsuite/gcc.dg/tree-ssa/pr97009.c
new file mode 100644
index 0000000..741dbc2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr97009.c
@@ -0,0 +1,66 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+
+static int __attribute__((noipa))
+get_5 (void)
+{
+ return 5;
+}
+
+static int __attribute__((noipa))
+verify_5 (int v)
+{
+ if (v != 5)
+ __builtin_abort ();
+}
+
+struct T
+{
+ int w;
+ int a[4];
+};
+
+struct S
+{
+ int v;
+ int x;
+ struct T t[2];
+ char alotofstuff[128];
+};
+
+volatile int vol;
+
+void __attribute__((noipa))
+consume_t (struct T t)
+{
+ vol = t.a[0];
+}
+
+int __attribute__((noipa))
+foo (int l1, int l2)
+{
+ struct S s1, s2, s3;
+ int i, j;
+
+ s1.v = get_5 ();
+ for (i = 0; i < l1; i++)
+ {
+ for (j = 0; j < l2; j++)
+ s1.t[i].a[j] = get_5 ();
+ consume_t(s1.t[i]);
+ }
+
+ s2 = s1;
+
+ s3 = s2;
+ for (i = 0; i < l1; i++)
+ for (j = 0; j < l2; j++)
+ verify_5 (s3.t[i].a[j]);
+}
+
+int
+main (int argc, char *argv[])
+{
+ foo (2, 4);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr98265.C b/gcc/testsuite/gcc.dg/tree-ssa/pr98265.C
new file mode 100644
index 0000000..9c798e6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr98265.C
@@ -0,0 +1,348 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+extern void __assert_fail(const char*, const char*, int, const char*);
+namespace Eigen {
+enum { AutoAlign };
+template <int, typename>
+struct conditional;
+template <typename Else>
+struct conditional<false, Else> {
+ typedef Else type;
+};
+template <typename T>
+struct remove_reference {
+ typedef T type;
+};
+struct is_arithmetic {
+ enum { value };
+};
+template <typename>
+struct traits;
+template <typename T>
+struct traits<const T> : traits<T> {};
+template <typename>
+struct evaluator;
+template <typename>
+struct EigenBase;
+template <typename>
+class PlainObjectBase;
+template <typename, int _Rows, int _Cols, int = AutoAlign, int = _Rows,
+ int = _Cols>
+class Matrix;
+template <typename>
+class MatrixBase;
+template <typename, typename>
+class CwiseNullaryOp;
+template <typename, typename, typename>
+class CwiseBinaryOp;
+template <typename>
+struct scalar_constant_op;
+template <int _Rows>
+struct size_at_compile_time {
+ enum { ret = _Rows };
+};
+struct ref_selector {
+ typedef const Matrix<float, 3, 1>& type;
+};
+template <typename Derived>
+struct dense_xpr_base {
+ typedef MatrixBase<Derived> type;
+};
+template <typename Derived, typename = typename traits<Derived>::XprKind>
+struct generic_xpr_base {
+ typedef typename dense_xpr_base<Derived>::type type;
+};
+template <typename Expr, typename Scalar = typename Expr::Scalar>
+struct plain_constant_type {
+ ;
+ typedef CwiseNullaryOp<scalar_constant_op<Scalar>,
+ Matrix<Scalar, traits<Expr>::ColsAtCompileTime,
+ traits<Expr>::MaxRowsAtCompileTime,
+ traits<Expr>::MaxColsAtCompileTime>>
+ type;
+};
+struct scalar_product_op {
+ float operator()(float a, float b) { return a * b; }
+};
+template <typename>
+struct scalar_constant_op {
+ scalar_constant_op(float other) : m_other(other) {}
+ float operator()() { return m_other; }
+ float m_other;
+};
+struct assign_op {
+ void assignCoeff(float& a, float b) { a = b; }
+};
+template <typename Derived>
+class DenseCoeffsBase : public EigenBase<Derived> {
+ public:
+ typedef typename traits<Derived>::Scalar Scalar;
+ typedef
+ typename conditional<is_arithmetic::value, Scalar>::type CoeffReturnType;
+};
+template <typename Derived>
+class DenseBase : public DenseCoeffsBase<Derived> {
+ public:
+ enum {
+ RowsAtCompileTime = traits<Derived>::RowsAtCompileTime,
+ SizeAtCompileTime = size_at_compile_time<RowsAtCompileTime>::ret,
+ MaxSizeAtCompileTime
+ };
+};
+template <typename Derived>
+class MatrixBase : public DenseBase<Derived> {
+ public:
+ using DenseBase<Derived>::derived;
+ template <typename T>
+ CwiseBinaryOp<scalar_product_op, const Derived,
+ const typename plain_constant_type<Derived, T>::type>
+ operator*(T& scalar) {
+ return CwiseBinaryOp<scalar_product_op, const Derived,
+ const typename plain_constant_type<Derived>::type>(
+ derived(), typename plain_constant_type<Derived>::type(derived().rows(),
+ 0, scalar));
+ }
+};
+template <typename Derived>
+struct EigenBase {
+ const Derived& derived() const { return *static_cast<const Derived*>(this); }
+ Derived& const_cast_derived() const {
+ return *static_cast<Derived*>(const_cast<EigenBase*>(this));
+ }
+};
+template <typename>
+struct binary_evaluator;
+template <typename T>
+struct evaluator<const T> : evaluator<T> {
+ evaluator(const T& xpr) : evaluator<T>(xpr) {}
+};
+template <typename Derived>
+struct evaluator {
+ typedef Derived PlainObjectType;
+ typedef typename PlainObjectType::Scalar Scalar;
+ evaluator(const PlainObjectType& m) : m_data(m.data()) {}
+ typename PlainObjectType::CoeffReturnType coeff(long row, long) {
+ return m_data[row];
+ }
+ Scalar& coeffRef(long row, long) { return const_cast<Scalar*>(m_data)[row]; }
+ const Scalar* m_data;
+};
+template <typename Scalar, int Rows, int Cols, int Options, int MaxRows,
+ int MaxCols>
+struct evaluator<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>
+ : evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols>>> {
+ typedef Matrix<Scalar, Rows, Cols> XprType;
+ evaluator(const XprType& m) : evaluator<PlainObjectBase<XprType>>(m) {}
+};
+struct nullary_wrapper {
+ template <typename IndexType>
+ float operator()(scalar_constant_op<float> op, IndexType, IndexType) const {
+ return op();
+ }
+};
+template <typename NullaryOp, typename PlainObjectType>
+struct evaluator<CwiseNullaryOp<NullaryOp, PlainObjectType>> {
+ typedef CwiseNullaryOp<NullaryOp, PlainObjectType> XprType;
+ evaluator(XprType n) : m_functor(n.functor()) {}
+ template <typename IndexType>
+ typename XprType::CoeffReturnType coeff(IndexType row, IndexType col) {
+ return m_wrapper(m_functor, row, col);
+ }
+ NullaryOp m_functor;
+ nullary_wrapper m_wrapper;
+};
+template <typename BinaryOp, typename Lhs, typename Rhs>
+struct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>>
+ : binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
+ evaluator(CwiseBinaryOp<BinaryOp, Lhs, Rhs> xpr)
+ : binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>>(xpr) {}
+};
+template <typename BinaryOp, typename Lhs, typename Rhs>
+struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
+ typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
+ binary_evaluator(XprType xpr) : m_lhsImpl(xpr.lhs()), m_rhsImpl(xpr.rhs()) {}
+ typename XprType::CoeffReturnType coeff(long row, long col) {
+ return m_functor(m_lhsImpl.coeff(row, col), m_rhsImpl.coeff(row, col));
+ }
+ BinaryOp m_functor;
+ evaluator<Lhs> m_lhsImpl;
+ evaluator<Rhs> m_rhsImpl;
+};
+template <typename Kernel, int Index, int Stop>
+struct copy_using_evaluator_DefaultTraversal_CompleteUnrolling {
+ enum { outer, inner = Index };
+ static void run(Kernel kernel) {
+ kernel.assignCoeffByOuterInner(outer, inner);
+ copy_using_evaluator_DefaultTraversal_CompleteUnrolling<Kernel, Index + 1,
+ Stop>::run(kernel);
+ }
+};
+template <typename Kernel, int Stop>
+struct copy_using_evaluator_DefaultTraversal_CompleteUnrolling<Kernel, Stop,
+ Stop> {
+ static void run(Kernel) {}
+};
+template <typename Kernel>
+struct dense_assignment_loop {
+ static void run(Kernel kernel) {
+ typedef typename Kernel::DstEvaluatorType::XprType DstXprType;
+ enum { size = DstXprType::SizeAtCompileTime, alignedSize = 0 };
+ copy_using_evaluator_DefaultTraversal_CompleteUnrolling<Kernel, alignedSize,
+ size>::run(kernel);
+ }
+};
+template <typename DstEvaluatorTypeT, typename SrcEvaluatorTypeT,
+ typename Functor>
+class generic_dense_assignment_kernel {
+ typedef typename DstEvaluatorTypeT::XprType DstXprType;
+
+ public:
+ typedef DstEvaluatorTypeT DstEvaluatorType;
+ typedef SrcEvaluatorTypeT SrcEvaluatorType;
+ generic_dense_assignment_kernel(DstEvaluatorType dst, SrcEvaluatorType src,
+ Functor, DstXprType& dstExpr)
+ : m_dst(dst), m_src(src), m_dstExpr(dstExpr) {}
+ long assignCoeff_col;
+ void assignCoeffByOuterInner(long, long inner) {
+ long __trans_tmp_1 = inner;
+ m_functor.assignCoeff(m_dst.coeffRef(__trans_tmp_1, assignCoeff_col),
+ m_src.coeff(__trans_tmp_1, assignCoeff_col));
+ }
+ DstEvaluatorType m_dst;
+ SrcEvaluatorType m_src;
+ Functor m_functor;
+ DstXprType& m_dstExpr;
+};
+template <typename DstXprType, typename SrcXprType, typename Functor>
+void call_dense_assignment_loop(DstXprType& dst, SrcXprType src, Functor func) {
+ typedef evaluator<DstXprType> DstEvaluatorType;
+ typedef evaluator<SrcXprType> SrcEvaluatorType;
+ SrcEvaluatorType srcEvaluator(src);
+ DstEvaluatorType dstEvaluator(dst);
+ typedef generic_dense_assignment_kernel<DstEvaluatorType, SrcEvaluatorType,
+ Functor>
+ Kernel;
+ Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived());
+ dense_assignment_loop<Kernel>::run(kernel);
+}
+template <typename Dst, typename Src, typename Func>
+void call_assignment_no_alias(Dst& dst, Src src, Func func) {
+ enum { NeedToTranspose };
+ typename conditional<NeedToTranspose, Dst&>::type actualDst(dst);
+ CwiseBinaryOp<scalar_product_op, const Matrix<float, 3, 1>,
+ const CwiseNullaryOp<scalar_constant_op<float>,
+ const Matrix<float, 3, 1, 0, 2, 3>>>
+ __trans_tmp_4 = src;
+ call_dense_assignment_loop(actualDst, __trans_tmp_4, func);
+}
+template <int Size>
+struct plain_array {
+ float array[Size];
+};
+template <int Size, int _Rows>
+class DenseStorage {
+ plain_array<Size> m_data;
+
+ public:
+ DenseStorage() {}
+ DenseStorage(const DenseStorage&);
+ static long rows() { return _Rows; }
+ const float* data() const { return m_data.array; }
+ float* data() { return m_data.array; }
+};
+template <typename Derived>
+class PlainObjectBase : public dense_xpr_base<Derived>::type {
+ public:
+ typedef typename dense_xpr_base<Derived>::type Base;
+ typedef typename traits<Derived>::Scalar Scalar;
+ DenseStorage<Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime> m_storage;
+ long rows() const { return m_storage.rows(); }
+ const Scalar* data() const { return m_storage.data(); }
+ PlainObjectBase() {}
+ template <typename OtherDerived>
+ PlainObjectBase(const DenseBase<OtherDerived>& other) {
+ _set_noalias(other);
+ }
+ template <typename OtherDerived>
+ void _set_noalias(const DenseBase<OtherDerived>& other) {
+ call_assignment_no_alias(this->derived(), other.derived(), assign_op());
+ }
+};
+template <typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows,
+ int _MaxCols>
+struct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>> {
+ typedef _Scalar Scalar;
+ typedef int XprKind;
+ enum {
+ RowsAtCompileTime = _Rows,
+ ColsAtCompileTime,
+ MaxRowsAtCompileTime,
+ MaxColsAtCompileTime,
+ };
+};
+template <typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows,
+ int _MaxCols>
+class Matrix
+ : public PlainObjectBase<
+ Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>> {
+ public:
+ typedef PlainObjectBase<Matrix> Base;
+ typedef typename traits<Matrix>::Scalar Scalar;
+ Matrix(Scalar& x, Scalar& y, Scalar& z) {
+ m_storage.data()[0] = x;
+ m_storage.data()[1] = y;
+ m_storage.data()[2] = z;
+ }
+ template <typename OtherDerived>
+ Matrix(const EigenBase<OtherDerived>& other) : Base(other.derived()) {}
+ using Base::m_storage;
+};
+template <typename BinaryOp, typename Lhs, typename Rhs>
+struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
+ typedef typename traits<Lhs>::XprKind XprKind;
+ enum { RowsAtCompileTime };
+ typedef float Scalar;
+};
+template <typename>
+class CwiseBinaryOpImpl;
+template <typename, typename, typename RhsType>
+class CwiseBinaryOp : public CwiseBinaryOpImpl<RhsType> {
+ public:
+ typedef ref_selector::type LhsNested;
+ typedef RhsType RhsNested;
+ CwiseBinaryOp(const Matrix<float, 3, 1>& aLhs, RhsType& aRhs)
+ : m_lhs(aLhs), m_rhs(aRhs) {}
+ remove_reference<LhsNested>::type& lhs() { return m_lhs; }
+ typename remove_reference<RhsNested>::type& rhs() { return m_rhs; }
+ LhsNested m_lhs;
+ RhsNested m_rhs;
+};
+template <typename>
+class CwiseBinaryOpImpl
+ : public generic_xpr_base<CwiseBinaryOp<
+ scalar_product_op, const Matrix<float, 3, 1>,
+ const CwiseNullaryOp<scalar_constant_op<float>,
+ const Matrix<float, 3, 1, 0, 2, 3>>>>::type {};
+template <typename NullaryOp, typename PlainObjectType>
+struct traits<CwiseNullaryOp<NullaryOp, PlainObjectType>>
+ : traits<PlainObjectType> {};
+template <typename, typename PlainObjectType>
+class CwiseNullaryOp
+ : public dense_xpr_base<CwiseNullaryOp<int, PlainObjectType>>::type {
+ public:
+ CwiseNullaryOp(long rows, long, scalar_constant_op<float> func)
+ : m_functor(func) {
+ rows ? void() : __assert_fail("", "", 1, __PRETTY_FUNCTION__);
+ }
+ scalar_constant_op<float> functor() { return m_functor; }
+ scalar_constant_op<float> m_functor;
+};
+} // namespace Eigen
+Eigen::Matrix<float, 3, 1> should_inline(float x, float y, float z,
+ float scale) {
+ return Eigen::Matrix<float, 3, 1>(x, y, z) * scale;
+}
+
+// We should inline everything to should_inline
+
+/* { dg-final { scan-tree-dump-times "Function" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr99473-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr99473-1.c
new file mode 100644
index 0000000..0fda566
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr99473-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-cselim -fallow-store-data-races -fdump-tree-cselim-details" } */
+
+void f (int*);
+
+void g3 (int i)
+{
+ int x = 0;
+ if (i)
+ x = i;
+ f (&x);
+}
+
+/* { dg-final { scan-tree-dump "Conditional store replacement happened" "cselim" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c
index 4bc2ea5..f68be2b 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-do run } */
-/* { dg-options "-O2 -funroll-loops --param max-unroll-times=8 -fpredictive-commoning -fdump-tree-pcom-details -fno-tree-pre" } */
+/* { dg-options "-O2 -funroll-loops --param max-unroll-times=8 -fpredictive-commoning -fdump-tree-pcom-details" } */
void abort (void);
@@ -45,6 +45,5 @@ int main(void)
/* Verify that both loops were transformed and unrolled. */
/* { dg-final { scan-tree-dump-times "Unrolling 2 times." 2 "pcom"} } */
-/* Also check that we undid the transformation previously made by PRE.
- ??? PRE now does the predictive commoning in count_averages. */
-/* dg-final { scan-tree-dump-times "looparound ref" 1 "pcom" } */
+/* Also check that we undid the transformation previously made by PRE. */
+/* { dg-final { scan-tree-dump-times "looparound ref" 1 "pcom" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-1.c
new file mode 100644
index 0000000..c3ccb5d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-1.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-thread1-details --param logical-op-non-short-circuit=1" } */
+
+// Copied from ssa-dom-thread-11.c
+
+static int *bb_ticks;
+extern void frob (void);
+void
+mark_target_live_regs (int b, int block, int bb_tick)
+{
+ if (b == block && b != -1 && bb_tick == bb_ticks[b])
+ return;
+ if (b != -1)
+ frob ();
+}
+
+/* When the first two conditionals in the first IF are true, but
+ the third conditional is false, then there's a jump threading
+ opportunity to bypass the second IF statement. */
+/* { dg-final { scan-tree-dump-times "Registering.*jump thread" 1 "thread1"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-2.c b/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-2.c
new file mode 100644
index 0000000..d2689b6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-2.c
@@ -0,0 +1,39 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-thread2-details -w" } */
+
+// Copied from ssa-dom-thread-12.c.
+
+typedef long unsigned int size_t;
+union tree_node;
+typedef union tree_node *tree;
+typedef union gimple_statement_d *gimple;
+typedef const union gimple_statement_d *const_gimple;
+union gimple_statement_d
+{
+ unsigned num_ops;
+ tree exp;
+};
+
+unsigned int x;
+static inline tree
+gimple_op (const_gimple gs, unsigned i)
+{
+ if (!(i < gs->num_ops))
+ abort ();
+ return gs->exp;
+}
+
+unsigned char
+scan_function (gimple stmt)
+{
+ unsigned i;
+ for (i = 0; i < stmt->num_ops - 3 ; i++)
+ gimple_call_arg (stmt, i);
+ gimple_op (stmt, 1);
+}
+
+/* The test which bypasses the loop is simplified prior to DOM to check
+ that stmt->num_ops - 3 != 0. When that test is false, we can derive
+ a value for stmt->num_ops. That in turn allows us to thread the jump
+ for the conditional at the start of the call to gimple_op. */
+/* { dg-final { scan-tree-dump-times "Registering.*jump thread" 1 "thread2"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-3.c b/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-3.c
new file mode 100644
index 0000000..79ec067
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-3.c
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-ethread-details -w --param logical-op-non-short-circuit=1" } */
+
+// Copied from ssa-dom-thread-14.c
+
+enum optab_methods
+{
+ OPTAB_DIRECT,
+ OPTAB_LIB,
+ OPTAB_WIDEN,
+ OPTAB_LIB_WIDEN,
+ OPTAB_MUST_WIDEN
+};
+struct optab_d { };
+typedef struct optab_d *optab;
+void
+expand_shift_1 (int code, int unsignedp, int rotate,
+ optab lshift_optab, optab rshift_arith_optab)
+{
+ int left = (code == 42 || code == 0xde);
+ int attempt;
+ enum optab_methods methods;
+ if (attempt == 0)
+ methods = OPTAB_DIRECT;
+ else if (attempt == 1)
+ methods = OPTAB_WIDEN;
+ if ((!unsignedp || (!left && methods == OPTAB_WIDEN)))
+ {
+ enum optab_methods methods1 = methods;
+ if (unsignedp)
+ methods1 = OPTAB_MUST_WIDEN;
+ expand_binop (left ? lshift_optab : rshift_arith_optab,
+ unsignedp, methods1);
+ }
+}
+
+/* When UNSIGNEDP is true, LEFT is false and METHOD == OPTAB_WIDEN
+ we will enter the TRUE arm of the conditional and we can thread
+ the test to compute the first first argument of the expand_binop
+ call if we look backwards through the boolean logicals. */
+/* { dg-final { scan-tree-dump-times "Registering.*jump thread" 1 "ethread"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-4.c b/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-4.c
new file mode 100644
index 0000000..d5aa2e8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-4.c
@@ -0,0 +1,83 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O2 -fdump-tree-vrp-details -fdump-tree-thread1-details --param logical-op-non-short-circuit=1" } */
+/* { dg-final { scan-tree-dump-times "Registering jump" 8 "thread1" } } */
+
+/* Copied from ssa-thread-14. */
+
+void foo (void);
+void bar (void);
+void blah (void);
+
+/* One jump threaded here. */
+
+void
+baz_1 (int a, int b, int c)
+{
+ if (a && b)
+ foo ();
+ if (!b && c)
+ bar ();
+}
+
+/* One jump threaded here. */
+
+void
+baz_2 (int a, int b, int c)
+{
+ if (a && b)
+ foo ();
+ if (b || c)
+ bar ();
+}
+
+/* One jump threaded here. */
+
+void
+baz_3 (int a, int b, int c)
+{
+ if (a && b > 10)
+ foo ();
+ if (b < 5 && c)
+ bar ();
+}
+
+/* Two jumps threaded here. */
+
+void
+baz_4 (int a, int b, int c)
+{
+ if (a && b)
+ {
+ foo ();
+ if (c)
+ bar ();
+ }
+ if (b && c)
+ blah ();
+}
+
+/* Two jumps threaded here. */
+
+void
+baz_5 (int a, int b, int c)
+{
+ if (a && b)
+ {
+ foo ();
+ if (c)
+ bar ();
+ }
+ if (!b || !c)
+ blah ();
+}
+
+/* One jump threaded here. */
+
+void
+baz_6 (int a, int b, int c)
+{
+ if (a == 39 && b == 41)
+ foo ();
+ if (c == 12 || b == 41)
+ bar ();
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-5.c b/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-5.c
new file mode 100644
index 0000000..b7ca99a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ranger-threader-5.c
@@ -0,0 +1,80 @@
+// { dg-do compile }
+// { dg-options "-fgimple -O2 -fdump-tree-thread1-details" }
+
+/* This tests that we can thread BB4->BB999 coming in through the
+ following path:
+
+ latch many insns
+ | |
+ V V
+ 6 -> 7 -> 3 -> 4 -> 999
+
+ The ranger based threader cannot thread this because BB4 has too
+ many instructions so it gives up looking back. However, if we were
+ able to looking further, we would notice that a profitable path
+ passing through the loop latch (BB7) exists.
+
+ That is, 3->4->N in isolation is not profitable, but 6->7->3->4->N is.
+
+ It is not clear whether handling this case in the backwards
+ threader is profitable, as it would increase the search space
+ considerably. The test is being added to note a regression from
+ the old backward threader code.
+
+ This test has been distilled from libphobos/src/std/net/isemail.d.
+
+ The ranger threader stops at the 3->4 subpath with: "did not thread
+ around loop and would copy too many statements". */
+
+
+extern void bar();
+extern int random();
+
+int __GIMPLE (ssa,startwith("thread1"))
+foo (int key)
+{
+ int context;
+ int _1454;
+
+ __BB(2):
+ goto __BB3;
+
+ // Loop header.
+ __BB(3):
+ context_448 = __PHI (__BB2: 0, __BB7: context_450);
+ if (key_5(D) > 0)
+ goto __BB999;
+ else
+ goto __BB4;
+
+ __BB(4):
+ bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar();
+ bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar();
+ bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar();
+ bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar();
+ bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar();
+ bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar();
+ switch (context_448) {default: L5; case 0: L999; }
+
+ __BB(5):
+ L5:
+ goto __BB6;
+
+ __BB(6):
+ context_450 = __PHI (__BB5: 0);
+ _1454 = random ();
+ if (_1454 > 0)
+ goto __BB999;
+ else
+ goto __BB7;
+
+ // Loop latch.
+ __BB(7):
+ goto __BB3;
+
+ __BB(999):
+ L999:
+ return 5;
+}
+
+// { dg-final { scan-tree-dump-times "Registering.*jump thread.*incoming edge; \\(6, 7\\) \\(7, 3\\) \\(3, 4\\) \\(4, 999\\) nocopy" 1 "thread1" { xfail *-*-* } } }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/split-path-4.c b/gcc/testsuite/gcc.dg/tree-ssa/split-path-4.c
index dac931c..8ef7646 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/split-path-4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/split-path-4.c
@@ -1,5 +1,7 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fsplit-paths -fdump-tree-split-paths-details -w" } */
+/* { dg-options "-O2 -fsplit-paths -fdump-tree-split-paths-details -w -fdisable-tree-thread1 -fdisable-tree-thread2" } */
+
+/* Note: Threader causes the infinite loop in val & 1 sooner. */
powi_cost (long n)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-40.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-40.c
new file mode 100644
index 0000000..aa7349e1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-40.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int foo(int x)
+{
+ int p = 7;
+ int q = p - (x & 5);
+ return q & 2;
+}
+
+/* { dg-final { scan-tree-dump "return 2;" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-41.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-41.c
new file mode 100644
index 0000000..d2b054e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-41.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int foo(int x)
+{
+ int p = x & 24;
+ int r = 1 << p;
+ return r & (1<<17);
+}
+
+/* { dg-final { scan-tree-dump "return 0;" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dce-3.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dce-3.c
index 863aa79..fdfe37e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dce-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dce-3.c
@@ -21,11 +21,12 @@ int main(void)
return 0;
}
-/* We now can prove the infiniteness of the loop during CCP and fail
- to eliminate the code inside the infinite loop because we start
- by marking the j % 7 condition as useful. See PR45178. */
+/* We now can prove the infiniteness of the loop during CCP but we
+ still want to eliminate the code inside the infinite loop. See PR45178. */
/* We should eliminate the inner condition, but the loop must be preserved
- as it is infinite. Therefore there should be just one goto and no PHI. */
+ as it is infinite. Therefore there should be just one goto and no PHI
+ and no if. */
/* { dg-final { scan-tree-dump-times "PHI " 0 "cddce1" } } */
+/* { dg-final { scan-tree-dump-times "if " 0 "cddce1" } } */
/* { dg-final { scan-tree-dump-times "goto" 1 "cddce1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-11.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-11.c
index 5f90613..856ab38 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-11.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-11.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-dom2-details --param logical-op-non-short-circuit=1" } */
+/* { dg-options "-O2 -fdump-tree-dom2-details --param logical-op-non-short-circuit=1 -fdisable-tree-thread1 -fdisable-tree-thread2" } */
static int *bb_ticks;
extern void frob (void);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-12.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-12.c
index 63bd12a..bad5e0a 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-12.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-12.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-dom2-details -w" } */
+/* { dg-options "-O2 -fdump-tree-dom2-details -w -fdisable-tree-thread2" } */
typedef long unsigned int size_t;
union tree_node;
typedef union tree_node *tree;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-14.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-14.c
index 4e6a911..3bc4b37 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-14.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-14.c
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dom2-details -w --param logical-op-non-short-circuit=1" } */
+/* { dg-additional-options "-fdisable-tree-thread1 -fdisable-tree-ethread -fdisable-tree-thread2" } */
enum optab_methods
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-18.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-18.c
index d4759b8..60d4f76 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-18.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-18.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1-details -fdump-tree-dom2-details -std=gnu89 --param logical-op-non-short-circuit=0" } */
+/* { dg-options "-O2 -fdump-tree-vrp1-details -fdump-tree-thread1-details -std=gnu89 --param logical-op-non-short-circuit=0" } */
#include "ssa-dom-thread-4.c"
@@ -21,4 +21,5 @@
condition.
All the cases are picked up by VRP1 as jump threads. */
-/* { dg-final { scan-tree-dump-times "Threaded" 4 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Registering jump" 6 "thread1" } } */
+/* { dg-final { scan-tree-dump-times "Threaded" 2 "vrp1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c
index e1c33e8..823ada9 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-thread1-stats -fdump-tree-dom2-stats -fdisable-tree-ethread" } */
+/* { dg-options "-O2 -fdump-tree-thread3-stats -fdump-tree-dom2-stats -fdisable-tree-ethread" } */
void foo();
void bla();
@@ -26,4 +26,4 @@ void thread_latch_through_header (void)
case. And we want to thread through the header as well. These
are both caught by threading in DOM. */
/* { dg-final { scan-tree-dump-not "Jumps threaded" "dom2"} } */
-/* { dg-final { scan-tree-dump-times "Jumps threaded: 1" 1 "thread1"} } */
+/* { dg-final { scan-tree-dump-times "Jumps threaded: 1" 1 "thread3"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-6.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-6.c
index 16a9ef4..b0a7d42 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-6.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-6.c
@@ -1,41 +1,8 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-thread1-details -fdump-tree-thread2-details" } */
+/* { dg-options "-O2 -fdump-tree-thread1-details -fdump-tree-thread3-details" } */
-/* All the threads in the thread1 dump start on a X->BB12 edge, as can
- be seen in the dump:
-
- Registering FSM jump thread: (x, 12) incoming edge; ...
- etc
- etc
-
- Before the new evrp, we were threading paths that started at the
- following edges:
-
- Registering FSM jump thread: (10, 12) incoming edge
- Registering FSM jump thread: (6, 12) incoming edge
- Registering FSM jump thread: (9, 12) incoming edge
-
- This was because the PHI at BB12 had constant values coming in from
- BB10, BB6, and BB9:
-
- # state_10 = PHI <state_11(7), 0(10), state_11(5), 1(6), state_11(8), 2(9), state_11(11)>
-
- Now with the new evrp, we get:
-
- # state_10 = PHI <0(7), 0(10), state_11(5), 1(6), 0(8), 2(9), 1(11)>
-
- Thus, we have 3 more paths that are known to be constant and can be
- threaded. Which means that by the second threading pass, we can
- only find one profitable path.
-
- For the record, all these extra constants are better paths coming
- out of switches. For example:
-
- SWITCH_BB -> BBx -> BBy -> BBz -> PHI
-
- We now know the value of the switch index at PHI. */
-/* { dg-final { scan-tree-dump-times "FSM" 6 "thread1" } } */
-/* { dg-final { scan-tree-dump-times "FSM" 1 "thread2" } } */
+/* { dg-final { scan-tree-dump-times "Registering jump" 6 "thread1" } } */
+/* { dg-final { scan-tree-dump-times "Registering jump" 1 "thread3" } } */
int sum0, sum1, sum2, sum3;
int foo (char *s, char **ret)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c
index bad5bc1..e3d4b31 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c
@@ -1,23 +1,8 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-thread1-stats -fdump-tree-thread2-stats -fdump-tree-dom2-stats -fdump-tree-thread3-stats -fdump-tree-dom3-stats -fdump-tree-vrp2-stats -fno-guess-branch-probability" } */
-/* Here we have the same issue as was commented in ssa-dom-thread-6.c.
- The PHI coming into the threader has a lot more constants, so the
- threader can thread more paths.
-
-$ diff clean/a.c.105t.mergephi2 a.c.105t.mergephi2
-252c252
-< # s_50 = PHI <s_49(10), 5(14), s_51(18), s_51(22), 1(26), 1(29), 1(31), s_51(5), 4(12), 1(15), 5(17), 1(19), 3(21), 1(23), 6(25), 7(28), s_51(30)>
----
-> # s_50 = PHI <s_49(10), 5(14), 4(18), 5(22), 1(26), 1(29), 1(31), s_51(5), 4(12), 1(15), 5(17), 1(19), 3(21), 1(23), 6(25), 7(28), 7(30)>
-272a273
-
- I spot checked a few and they all have the same pattern. We are
- basically tracking the switch index better through multiple
- paths. */
-
-/* { dg-final { scan-tree-dump "Jumps threaded: 19" "thread1" } } */
-/* { dg-final { scan-tree-dump "Jumps threaded: 8" "thread2" } } */
+/* { dg-final { scan-tree-dump "Jumps threaded: 18" "thread1" } } */
+/* { dg-final { scan-tree-dump "Jumps threaded: 8" "thread3" { target { ! aarch64*-*-* } } } } */
/* { dg-final { scan-tree-dump-not "Jumps threaded" "dom2" } } */
/* aarch64 has the highest CASE_VALUES_THRESHOLD in GCC. It's high enough
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-26.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-26.c
index 271e666..e3c33f49 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-26.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-26.c
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dse1-details -fno-short-enums -fno-tree-fre" } */
-/* { dg-skip-if "temporary variable for constraint_expr is never used" { msp430-*-* } } */
+/* { dg-skip-if "we want a BIT_FIELD_REF from fold_truth_andor" { ! lp64 } } */
+/* { dg-skip-if "temporary variable names are not x and y" { mmix-knuth-mmixware } } */
enum constraint_expr_type
{
@@ -30,15 +31,5 @@ constraint_equal (struct constraint a, struct constraint b)
&& constraint_expr_equal (a.rhs, b.rhs);
}
-/* Most targets should be using this test. */
-/* { dg-final { scan-tree-dump-times "Deleted dead store: x = " 1 "dse1" { target { ! { tic6x-*-* mmix-knuth-mmixware } } } } } */
-/* { dg-final { scan-tree-dump-times "Deleted dead store: y = " 1 "dse1" { target { ! { tic6x-*-* mmix-knuth-mmixware } } } } } */
-
-/* The c6x port generates significantly different gimple which
- changes the SRA and DSE decisions. Verify we remove all
- dead stores. Similarly for mmix. */
-/* { dg-final { scan-tree-dump-times "Deleted dead store: \[ax\].. = " 2 "dse1" { target tic6x-*-* } } } */
-/* { dg-final { scan-tree-dump-times "Deleted dead store: \[by\].. = " 2 "dse1" { target tic6x-*-* } } } */
-/* { dg-final { scan-tree-dump-times "Deleted dead store: x::. = " 1 "dse1" { target mmix-knuth-mmixware } } } */
-/* { dg-final { scan-tree-dump-times "Deleted dead store: y::. = " 1 "dse1" { target mmix-knuth-mmixware } } } */
-
+/* { dg-final { scan-tree-dump-times "Deleted dead store: x = " 1 "dse1" } } */
+/* { dg-final { scan-tree-dump-times "Deleted dead store: y = " 1 "dse1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c
index b81cabe..3bf4e76 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c
@@ -17,5 +17,6 @@ int foo (int *p, int b)
/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse1"} } */
/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse2"} } */
-/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse4"} } */
+/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse3"} } */
+/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse5"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-29.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-29.c
index f4ef89c..4990ae0 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-29.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-29.c
@@ -22,5 +22,6 @@ foo(int cond, struct z *s)
/* { dg-final { scan-tree-dump-times "Deleted dead store" 3 "dse1"} } */
/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse2"} } */
-/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse4"} } */
+/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse3"} } */
+/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse5"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-41.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-41.c
new file mode 100644
index 0000000..9128eea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-41.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-dse1" } */
+
+int a[2];
+void foo(int i, int k)
+{
+ a[0] = i;
+ if (k)
+ a[0] = a[i] + k;
+ else
+ a[0] = a[i] + 3;
+ a[0] = 0;
+}
+
+/* Only the last store remains. */
+/* { dg-final { scan-tree-dump-times " = " 1 "dse1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-42.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-42.c
new file mode 100644
index 0000000..34108c8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-42.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-dse1" } */
+
+int a[2];
+void foo(int i, int k, int j)
+{
+ a[0] = i;
+ if (k)
+ a[0] = a[i] + k;
+ else
+ {
+ if (j)
+ a[1] = 1;
+ a[0] = a[i] + 3;
+ }
+ a[0] = 0;
+}
+
+/* The last stores to a[0] and a[1] remain. */
+/* { dg-final { scan-tree-dump-times " = " 2 "dse1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-43.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-43.c
new file mode 100644
index 0000000..f8785e9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-43.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-dse1-details" } */
+
+struct X { int x; };
+struct X x;
+
+extern struct X foo (void);
+void bar()
+{
+ x = foo();
+ x = (struct X){};
+}
+
+extern struct X __attribute__((const)) foo2 (int);
+void bar2()
+{
+ x = foo2 (1);
+ x = foo2 (2);
+}
+
+/* { dg-final { scan-tree-dump-times "Deleted dead store in call LHS: x = foo " 1 "dse1" } } */
+/* { dg-final { scan-tree-dump-times "Deleted dead store: x = foo2 " 1 "dse1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-48.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-48.c
index b3d6102..5e74c78 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-48.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-48.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-fre1-details" } */
+/* { dg-options "-O -fdump-tree-fre1-details -fdisable-tree-ethread" } */
int foo (int i)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-91.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-91.c
new file mode 100644
index 0000000..4999a3b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-91.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-fre4" } */
+
+extern void foo(void);
+
+static int a[2], b, *c[2];
+
+int main() {
+ for (b = 0; b < 2; b++)
+ c[b] = &a[1];
+ if (!c[0])
+ foo();
+ return 0;
+}
+
+/* Even when vectorizing we should eliminate the call to foo. */
+/* { dg-final { scan-tree-dump-not "foo" "fre4" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-92.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-92.c
new file mode 100644
index 0000000..c67fcea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-92.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-fre1" } */
+
+extern void foo(void);
+int a, c, *f, **d = &f;
+char b;
+int main()
+{
+ if (a) {
+ b = 0;
+ int *g = &c;
+ *g = 0;
+ f = *d;
+ *d = f;
+ if ((2 ^ b) == 0)
+ foo();
+ }
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-not "foo" "fre1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-93.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-93.c
new file mode 100644
index 0000000..7f66b7e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-93.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-fre1" } */
+
+void bar ();
+void foo (int pred, int *other)
+{
+ *other = 0;
+ if (*other)
+ goto cnt;
+ if (pred)
+ {
+ *other = 1;
+cnt:
+ if (!pred)
+ bar ();
+ }
+}
+
+/* The first VN pass should figure that if (!pred) is false because
+ if (*other) is and thus the predicate test is redundant. */
+/* { dg-final { scan-tree-dump-not "bar" "fre1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-94.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-94.c
new file mode 100644
index 0000000..99c7375
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-94.c
@@ -0,0 +1,17 @@
+/* PR tree-optimization/79333 */
+/* { dg-do compile } */
+/* { dg-require-effective-target c99_runtime } */
+/* { dg-options "-O -ffinite-math-only -fdump-tree-fre1" } */
+
+extern __inline __attribute__ ((__always_inline__,__gnu_inline__))
+double __attribute__ ((__nothrow__ , __leaf__))
+fabs (double __x) { return __builtin_fabs (__x); }
+
+double f(float f)
+{
+ double t1 = fabs(f);
+ double t2 = f / t1;
+ return t2;
+}
+
+/* { dg-final { scan-tree-dump "copysign" "fre1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-15.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-15.c
new file mode 100644
index 0000000..5efb956
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-15.c
@@ -0,0 +1,18 @@
+/* PR/101293 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-lim2-details" } */
+
+struct X { int i; int j; };
+
+void foo(struct X *x, int n)
+{
+ for (int i = 0; i < n; ++i)
+ {
+ int *p = &x->j;
+ int tem = *p;
+ x->j += tem * i;
+ }
+}
+
+/* Make sure LIM can handle unifying MEM[x, 4] and MEM[x].j */
+/* { dg-final { scan-tree-dump "Executing store motion" "lim2" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-16.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-16.c
new file mode 100644
index 0000000..741582b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-16.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-lim2-details" } */
+
+volatile int flag, bar;
+double foo (double *valp)
+{
+ double sum = 0;
+ for (int i = 0; i < 256; ++i)
+ {
+ for (int j = 0; j < 256; ++j)
+ bar = flag;
+ if (flag)
+ sum += 1.;
+ sum += *valp; // we should move the load of *valp out of the loop
+ }
+ return sum;
+}
+
+/* { dg-final { scan-tree-dump-times "Moving statement" 1 "lim2" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-17.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-17.c
new file mode 100644
index 0000000..1c840e5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-17.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-lim2-details" } */
+
+volatile int flag, bar;
+double foo (double *valp)
+{
+ double sum = 0;
+ for (int i = 0; i < 256; ++i)
+ {
+ if (flag)
+ for (int j = 0; j < 256; ++j)
+ bar = flag;
+ if (flag)
+ sum += 1.;
+ sum += *valp; // we should move the load of *valp out of the loop
+ }
+ return sum;
+}
+
+/* { dg-final { scan-tree-dump-times "Moving statement" 1 "lim2" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-1.c
index 411585a..57b5016 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-1.c
@@ -7,4 +7,4 @@ foo (int a, int b, int c)
return c ? x : a;
}
/* We should sink the x = a * b calculation into the branch that returns x. */
-/* { dg-final { scan-tree-dump-times "Sunk statements: 1" 1 "sink" } } */
+/* { dg-final { scan-tree-dump-times "Sunk statements: 1" 1 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-10.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-10.c
index 37e4d2f..535cb32 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-10.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-10.c
@@ -16,4 +16,4 @@ void foo (void)
}
}
-/* { dg-final { scan-tree-dump-times "Sinking # VUSE" 4 "sink" } } */
+/* { dg-final { scan-tree-dump-times "Sinking # VUSE" 4 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-13.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-13.c
index a65ba35..584fd91 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-13.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-13.c
@@ -21,5 +21,5 @@ void test ()
/* We should sink/merge all stores and end up with a single BB. */
-/* { dg-final { scan-tree-dump-times "MEM\[^\n\r\]* = 0;" 3 "sink" } } */
-/* { dg-final { scan-tree-dump-times "<bb " 1 "sink" } } */
+/* { dg-final { scan-tree-dump-times "MEM\[^\n\r\]* = 0;" 3 "sink1" } } */
+/* { dg-final { scan-tree-dump-times "<bb " 1 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-14.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-14.c
index 771cd44..f5418b0 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-14.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-14.c
@@ -13,5 +13,5 @@ void foo (int b)
/* We should have sunk the store and inserted a PHI to merge the
stored values. */
-/* { dg-final { scan-tree-dump-times " = PHI" 1 "sink" } } */
-/* { dg-final { scan-tree-dump-times "x = " 1 "sink" } } */
+/* { dg-final { scan-tree-dump-times " = PHI" 1 "sink1" } } */
+/* { dg-final { scan-tree-dump-times "x = " 1 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-16.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-16.c
index 610c8d6..012b165 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-16.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-16.c
@@ -10,5 +10,5 @@ int f(int n)
return j;
}
-/* { dg-final { scan-tree-dump "Sinking j_. = __builtin_ffs" "sink" } } */
+/* { dg-final { scan-tree-dump "Sinking j_. = __builtin_ffs" "sink1" } } */
/* { dg-final { scan-tree-dump "return 2;" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-17.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-17.c
index cf2e2a0..d0aeeb3 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-17.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-17.c
@@ -12,4 +12,4 @@ int my_f(int a, int b)
}
/* We should sink the call to pure_f to the if block. */
-/* { dg-final { scan-tree-dump "Sinking # VUSE" "sink" } } */
+/* { dg-final { scan-tree-dump "Sinking # VUSE" "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-18.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-18.c
new file mode 100644
index 0000000..421c78e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-18.c
@@ -0,0 +1,212 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-sink-stats" } */
+
+#include <stdint.h>
+
+#define HLOG 16
+#define MAX_LIT (1 << 5)
+typedef const uint8_t *LZF_HSLOT;
+typedef LZF_HSLOT LZF_STATE[1 << (HLOG)];
+
+int
+compute_on_bytes (uint8_t *in_data, int in_len, uint8_t *out_data, int out_len)
+{
+ LZF_STATE htab;
+
+ uint8_t *ip = in_data;
+ uint8_t *op = out_data;
+ uint8_t *in_end = ip + in_len;
+ uint8_t *out_end = op + out_len;
+ uint8_t *ref;
+
+ unsigned long off;
+ unsigned int hval;
+ int lit;
+
+ if (!in_len || !out_len)
+ return 0;
+
+ lit = 0;
+ op++;
+ hval = (((ip[0]) << 8) | ip[1]);
+
+ while (ip < in_end - 2)
+ {
+ uint8_t *hslot;
+
+ hval = (((hval) << 8) | ip[2]);
+ hslot = (uint8_t*)(htab + (((hval >> (3 * 8 - 16)) - hval * 5) & ((1 << (16)) - 1)));
+
+ ref = *hslot + in_data;
+ *hslot = ip - in_data;
+
+ if (1 && (off = ip - ref - 1) < (1 << 13) && ref > in_data
+ && ref[2] == ip[2]
+ && ((ref[1] << 8) | ref[0]) == ((ip[1] << 8) | ip[0]))
+ {
+ unsigned int len = 2;
+ unsigned int maxlen = in_end - ip - len;
+ maxlen
+ = maxlen > ((1 << 8) + (1 << 3)) ? ((1 << 8) + (1 << 3)) : maxlen;
+
+ if ((op + 3 + 1 >= out_end) != 0)
+ if (op - !lit + 3 + 1 >= out_end)
+ return 0;
+
+ op[-lit - 1] = lit - 1;
+ op -= !lit;
+
+ for (;;)
+ {
+ if (maxlen > 16)
+ {
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ len++;
+ if (ref[len] != ip[len])
+ break;
+ }
+
+ do
+ {
+ len++;
+ }
+ while (len < maxlen && ip[len] == ref[len]);
+
+ break;
+ }
+
+ len -= 2;
+ ip++;
+
+ if (len < 7)
+ {
+ *op++ = (off >> 8) + (len << 5);
+ }
+ else
+ {
+ *op++ = (off >> 8) + (7 << 5);
+ *op++ = len - 7;
+ }
+ *op++ = off;
+ lit = 0;
+ op++;
+ ip += len + 1;
+
+ if (ip >= in_end - 2)
+ break;
+
+ --ip;
+ --ip;
+
+ hval = (((ip[0]) << 8) | ip[1]);
+ hval = (((hval) << 8) | ip[2]);
+ htab[(((hval >> (3 * 8 - 16)) - hval * 5) & ((1 << (16)) - 1))]
+ = (LZF_HSLOT)(ip - in_data);
+ ip++;
+
+ hval = (((hval) << 8) | ip[2]);
+ htab[(((hval >> (3 * 8 - 16)) - hval * 5) & ((1 << (16)) - 1))]
+ = (LZF_HSLOT)(ip - in_data);
+ ip++;
+ }
+ else
+ {
+ if (op >= out_end)
+ return 0;
+
+ lit++;
+ *op++ = *ip++;
+
+ if (lit == (1 << 5))
+ {
+ op[-lit - 1] = lit - 1;
+ lit = 0;
+ op++;
+ }
+ }
+ }
+ if (op + 3 > out_end) /* at most 3 bytes can be missing here */
+ return 0;
+
+ while (ip < in_end)
+ {
+ lit++;
+ *op++ = *ip++;
+ if (lit == MAX_LIT)
+ {
+ op[-lit - 1] = lit - 1; /* stop run */
+ lit = 0;
+ op++; /* start run */
+ }
+ }
+
+ op[-lit - 1] = lit - 1; /* end run */
+ op -= !lit; /* undo run if length is zero */
+
+ return op - out_data;
+ }
+
+ /* For this case, pass sink2 sinks statements from hot loop header to loop
+ exits after gimple loop optimizations, which generates instructions executed
+ each iteration in loop, but the results are used outside of loop:
+ With -m64,
+ "Sinking _367 = (uint8_t *) _320;
+ from bb 31 to bb 90
+ Sinking _320 = _321 + ivtmp.25_326;
+ from bb 31 to bb 90
+ Sinking _321 = (unsigned long) ip_229;
+ from bb 31 to bb 90
+ Sinking len_158 = _322 + 4294967295;
+ from bb 31 to bb 33"
+ When -m32, Power and X86 will sink 3 instructions, but arm ilp32 couldn't
+ sink due to ivopts chooses two IV candidates instead of one, which is
+ expected, so this case is restricted to lp64 only so far. */
+
+ /* { dg-final { scan-tree-dump-times "Sunk statements: 4" 1 "sink2" { target lp64 } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-2.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-2.c
index 6aa5a18..a0b4734 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-2.c
@@ -9,4 +9,4 @@ bar (int a, int b, int c)
return y;
}
/* We should sink the x = a * b calculation into the else branch */
-/* { dg-final { scan-tree-dump-times "Sunk statements: 1" 1 "sink" } } */
+/* { dg-final { scan-tree-dump-times "Sunk statements: 1" 1 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-3.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-3.c
index 599997e..ad88ccc 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-3.c
@@ -12,4 +12,4 @@ main (int argc)
}
}
/* We should sink the a = argc + 1 calculation into the if branch */
-/* { dg-final { scan-tree-dump-times "Sunk statements: 1" 1 "sink" } } */
+/* { dg-final { scan-tree-dump-times "Sunk statements: 1" 1 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-4.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-4.c
index 784edd2..1e3cfa9 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-4.c
@@ -17,4 +17,4 @@ main (int argc)
foo2 (a);
}
/* We should sink the first a = b + c calculation into the else branch */
-/* { dg-final { scan-tree-dump-times "Sunk statements: 1" 1 "sink" } } */
+/* { dg-final { scan-tree-dump-times "Sunk statements: 1" 1 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-5.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-5.c
index dbdde39..f04da5d 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-5.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-5.c
@@ -44,4 +44,4 @@ void foo(int16_t runs[], uint8_t alpha[], int x, int count)
}
/* We should not sink the next_runs = runs + x calculation after the loop. */
-/* { dg-final { scan-tree-dump-times "Sunk statements:" 0 "sink" } } */
+/* { dg-final { scan-tree-dump-times "Sunk statements:" 0 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-6.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-6.c
index 1abae9f..31f5af3 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-6.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-6.c
@@ -14,4 +14,4 @@ int foo(int *a, int r)
/* *a = 1 should be sunk to the else block. */
-/* { dg-final { scan-tree-dump-times "Sinking" 1 "sink" } } */
+/* { dg-final { scan-tree-dump-times "Sinking" 1 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-7.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-7.c
index ec3288f..bd74844 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-7.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-7.c
@@ -15,4 +15,4 @@ int foo(int *a, int r, short *b)
/* *a = 1 should be sunk to the else block. */
-/* { dg-final { scan-tree-dump-times "Sinking" 1 "sink" } } */
+/* { dg-final { scan-tree-dump-times "Sinking" 1 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-8.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-8.c
index 48af421..4b23b56 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-8.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-8.c
@@ -24,4 +24,4 @@ int foo(int *a, int r, short *b)
/* *a = 1 should be sunk into the default case. */
-/* { dg-final { scan-tree-dump-times "Sinking" 1 "sink" } } */
+/* { dg-final { scan-tree-dump-times "Sinking" 1 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-9.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-9.c
index 509a763..32bfc81 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-9.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-9.c
@@ -15,4 +15,4 @@ int foo(int *a, int r, int *b)
/* *a = 1 should be sunk to the else block. */
-/* { dg-final { scan-tree-dump-times "Sinking" 1 "sink" } } */
+/* { dg-final { scan-tree-dump-times "Sinking" 1 "sink1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-11.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-11.c
index 67e1e89..672a54e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-11.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-11.c
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp2-details --param logical-op-non-short-circuit=1" } */
+/* { dg-additional-options "-fdisable-tree-ethread -fdisable-tree-thread1 -fdisable-tree-thread2" } */
/* { dg-final { scan-tree-dump-not "IRREDUCIBLE_LOOP" "vrp2" } } */
void abort (void);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-12.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-12.c
index fb9840e..08c0b8d 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-12.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-12.c
@@ -1,8 +1,7 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-thread2-details -fdump-tree-thread3-details -fdump-tree-thread4-details -fno-finite-loops --param early-inlining-insns=14 -fno-inline-functions" } */
-/* { dg-final { scan-tree-dump "FSM" "thread2" } } */
-/* { dg-final { scan-tree-dump "FSM" "thread3" } } */
-/* { dg-final { scan-tree-dump "FSM" "thread4" { xfail *-*-* } } } */
+/* { dg-options "-O2 -fdump-tree-thread3-details -fdump-tree-thread4-details -fno-finite-loops --param early-inlining-insns=14 -fno-inline-functions" } */
+/* { dg-final { scan-tree-dump "Registering jump thread" "thread3" } } */
+/* { dg-final { scan-tree-dump "Registering jump thread" "thread4" } } */
typedef struct bitmap_head_def *bitmap;
typedef const struct bitmap_head_def *const_bitmap;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c
index 061f223..ad38b89 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-ethread-details" } */
-/* { dg-final { scan-tree-dump "FSM" "ethread" } } */
+/* { dg-final { scan-tree-dump "Registering jump thread" "ethread" } } */
typedef struct rtx_def *rtx;
typedef const struct rtx_def *const_rtx;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c
index 38661c8..f9152b9 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* { dg-additional-options "-O2 -fdump-tree-vrp-details --param logical-op-non-short-circuit=1" } */
+/* { dg-additional-options "-fdisable-tree-thread1" } */
/* { dg-final { scan-tree-dump-times "Threaded jump" 8 "vrp1" } } */
void foo (void);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/tailcall-10.c b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-10.c
new file mode 100644
index 0000000..484dcc1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-10.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-tailc-details" } */
+
+struct A {};
+
+struct A goo(void);
+struct A foo(void)
+{
+ return goo();
+}
+
+/* { dg-final { scan-tree-dump-times "Found tail call" 1 "tailc"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/tailcall-11.c b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-11.c
new file mode 100644
index 0000000..36e4417
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-11.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-tailc-details" } */
+
+struct A {};
+
+void goo(void);
+struct A foo(void)
+{
+ goo();
+}
+
+/* { dg-final { scan-tree-dump-times "Found tail call" 1 "tailc"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/tailcall-12.c b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-12.c
new file mode 100644
index 0000000..0eeb3ab
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-12.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-tailc-details" } */
+
+struct A {};
+
+struct A goo(void);
+void foo(void)
+{
+ goo();
+}
+
+/* { dg-final { scan-tree-dump-times "Found tail call" 1 "tailc"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/tailcall-13.c b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-13.c
new file mode 100644
index 0000000..855b3312
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-13.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-tailc-details" } */
+
+struct A {};
+struct B{};
+
+struct B goo(void);
+struct A foo(void)
+{
+ struct A a;
+ goo();
+ return a;
+}
+
+/* { dg-final { scan-tree-dump-times "Found tail call" 1 "tailc"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/tailrecursion-8.c b/gcc/testsuite/gcc.dg/tree-ssa/tailrecursion-8.c
new file mode 100644
index 0000000..ecde499
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/tailrecursion-8.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -foptimize-sibling-calls -fdump-tree-tailr1-details" } */
+
+struct A {};
+
+struct A foo()
+{
+ return foo();
+}
+
+/* { dg-final { scan-tree-dump-times "Eliminated tail recursion" 1 "tailr1"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c
index 4be538f..2285c55 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks -fdisable-tree-evrp" } */
+/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks -fdisable-tree-evrp -fdisable-tree-ethread -fdisable-tree-thread1" } */
struct A
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp03.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp03.c
index bafb65a..1d7ea4e8 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp03.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp03.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1 -fdisable-tree-ethread -fdisable-tree-thread1" } */
struct A
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp05.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp05.c
index 8c611e9..c17cd1b 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp05.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp05.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1 -fno-early-inlining" } */
+/* { dg-options "-O2 -fdump-tree-vrp1 -fno-early-inlining -fdisable-tree-ethread -fdisable-tree-thread1" } */
inline int ten()
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp06.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp06.c
index a872bc4..acb03c2 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp06.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp06.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1 -fdisable-tree-ethread -fdisable-tree-thread1" } */
int baz (void);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp07.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp07.c
index 0f3f280..31a5415 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp07.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp07.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-fre -fdisable-tree-evrp -fdump-tree-vrp1-details -fdelete-null-pointer-checks" } */
+/* { dg-options "-O2 -fno-tree-fre -fdisable-tree-evrp -fdump-tree-vrp1-details -fdelete-null-pointer-checks -fdisable-tree-ethread -fdisable-tree-thread1" } */
int
foo (int i, int *p)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp09.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp09.c
index 56cc50c..fad0051 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp09.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp09.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-fre -fdisable-tree-evrp -fdump-tree-vrp1 -std=gnu89" } */
+/* { dg-options "-O2 -fno-tree-fre -fdisable-tree-evrp -fdump-tree-vrp1 -std=gnu89 -fdisable-tree-ethread -fdisable-tree-thread1" } */
foo (int *p)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp19.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp19.c
index 40373fd..98a8da6 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp19.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp19.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fwrapv -O1 -ftree-vrp -fdisable-tree-evrp -fdump-tree-vrp1" } */
+/* { dg-options "-fwrapv -O1 -ftree-vrp -fdisable-tree-evrp -fdump-tree-vrp1 -fdisable-tree-ethread -fdisable-tree-thread1" } */
#include <limits.h>
extern void abort ();
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp20.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp20.c
index 4a3b0d7..f9df67f 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp20.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp20.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fwrapv -O1 -fno-tree-fre -fdisable-tree-evrp -ftree-vrp -fdump-tree-vrp1" } */
+/* { dg-options "-fwrapv -O1 -fno-tree-fre -fdisable-tree-evrp -ftree-vrp -fdump-tree-vrp1 -fdisable-tree-ethread -fdisable-tree-thread1" } */
extern void abort ();
extern void exit (int);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c
index dfe44b3..91015da 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-evrp-details -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-evrp-details -fdump-tree-optimized -fno-tree-ccp" } */
struct rtx_def;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp33.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp33.c
index f1d3863..88833eb 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp33.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp33.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1 -fno-tree-fre -fdisable-tree-evrp" } */
+/* { dg-options "-O2 -fdump-tree-vrp1 -fno-tree-fre -fdisable-tree-evrp -fdisable-tree-ethread -fdisable-tree-thread1" } */
/* This is from PR14052. */
diff --git a/gcc/testsuite/gcc.dg/typedef-var-2.c b/gcc/testsuite/gcc.dg/typedef-var-2.c
index 716d29c..bc119a0 100644
--- a/gcc/testsuite/gcc.dg/typedef-var-2.c
+++ b/gcc/testsuite/gcc.dg/typedef-var-2.c
@@ -4,12 +4,13 @@
int f (void)
{
extern float v;
-
+/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } .-1 } */
return (v > 0.0f);
}
extern int t;
+/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } .-1 } */
typedef float t; /* { dg-error "redeclared as different kind of symbol" } */
-t v = 4.5f;
+t v = 4.5f; /* { dg-error "conflicting types" } */
diff --git a/gcc/testsuite/gcc.dg/ucnid-5-utf8.c b/gcc/testsuite/gcc.dg/ucnid-5-utf8.c
index 8e10467..43310b6 100644
--- a/gcc/testsuite/gcc.dg/ucnid-5-utf8.c
+++ b/gcc/testsuite/gcc.dg/ucnid-5-utf8.c
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-skip-if "No dollar in identfiers" { avr-*-* powerpc-ibm-aix* } } */
+/* { dg-skip-if "No dollar in identifiers" { avr-*-* powerpc-ibm-aix* } } */
/* { dg-skip-if "" { ! ucn } } */
/* { dg-options "-std=c99 -fdollars-in-identifiers -g" } */
void abort (void);
diff --git a/gcc/testsuite/gcc.dg/ucnid-5.c b/gcc/testsuite/gcc.dg/ucnid-5.c
index dc282a7..6f0f475 100644
--- a/gcc/testsuite/gcc.dg/ucnid-5.c
+++ b/gcc/testsuite/gcc.dg/ucnid-5.c
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-skip-if "No dollar in identfiers" { avr-*-* powerpc-ibm-aix* } } */
+/* { dg-skip-if "No dollar in identifiers" { avr-*-* powerpc-ibm-aix* } } */
/* { dg-options "-std=c99 -fdollars-in-identifiers -g" } */
void abort (void);
diff --git a/gcc/testsuite/gcc.dg/uninit-15-O0.c b/gcc/testsuite/gcc.dg/uninit-15-O0.c
index a3fd2b63..1ddddee 100644
--- a/gcc/testsuite/gcc.dg/uninit-15-O0.c
+++ b/gcc/testsuite/gcc.dg/uninit-15-O0.c
@@ -14,7 +14,7 @@ void baz();
void bar()
{
- int j; /* { dg-message "was declared here" {} { xfail *-*-* } } */
- for (; foo(j); ++j)
+ int j; /* { dg-message "declared here" } */
+ for (; foo(j); ++j) /* { dg-warning "is used uninitialized" } */
baz();
}
diff --git a/gcc/testsuite/gcc.dg/uninit-15.c b/gcc/testsuite/gcc.dg/uninit-15.c
index 8ee10c2..7352662 100644
--- a/gcc/testsuite/gcc.dg/uninit-15.c
+++ b/gcc/testsuite/gcc.dg/uninit-15.c
@@ -1,7 +1,7 @@
/* PR tree-optimization/17506
- We issue an uninitialized variable warning at a wrong location at
+ We used to issue an uninitialized variable warning at a wrong location at
line 11, which is very confusing. Make sure we print out a note to
- make it less confusing. (not xfailed alternative)
+ make it less confusing. (xfailed alternative)
But it is of course ok if we warn in bar about uninitialized use
of j. (not xfailed alternative) */
/* { dg-do compile } */
@@ -10,7 +10,7 @@
inline int
foo (int i)
{
- if (i) /* { dg-warning "used uninitialized" } */
+ if (i) /* { dg-warning "used uninitialized" "" { xfail *-*-* } } */
return 1;
return 0;
}
@@ -20,7 +20,7 @@ void baz (void);
void
bar (void)
{
- int j; /* { dg-message "note: 'j' was declared here" "" } */
- for (; foo (j); ++j) /* { dg-warning "'j' is used uninitialized" "" { xfail *-*-* } } */
+ int j; /* { dg-message "note: 'j' was declared here" } */
+ for (; foo (j); ++j) /* { dg-warning "'j' is used uninitialized" } */
baz ();
}
diff --git a/gcc/testsuite/gcc.dg/uninit-23.c b/gcc/testsuite/gcc.dg/uninit-23.c
index d64eb7d..87b4e98 100644
--- a/gcc/testsuite/gcc.dg/uninit-23.c
+++ b/gcc/testsuite/gcc.dg/uninit-23.c
@@ -18,7 +18,7 @@ ql (void)
int *t4 = go; /* { dg-warning "is used uninitialized" } */
l1:
- *t4 = (*t4 != 0) ? 0 : 2;
+ *t4 = (*t4 != 0) ? 0 : 2; /* { dg-warning "is used uninitialized" } */
}
if (ij != 0)
diff --git a/gcc/testsuite/gcc.dg/uninit-38.c b/gcc/testsuite/gcc.dg/uninit-38.c
index 8dacc8c..0d70bcd 100644
--- a/gcc/testsuite/gcc.dg/uninit-38.c
+++ b/gcc/testsuite/gcc.dg/uninit-38.c
@@ -1,5 +1,5 @@
-/* Verify that dereferencing uninitialized allocated objects and VLAs
- correctly reflects offsets into the objects.
+/* Verify that dereferencing uninitialized VLAs correctly reflects
+ offsets into the objects.
The test's main purpose is to exercise the formatting of MEM_REFs.
If -Wuninitialized gets smarter and detects uninitialized accesses
before they're turned into MEM_REFs the test will likely need to
@@ -18,41 +18,6 @@ extern void* malloc (size_t);
void sink (void*, ...);
-#undef T
-#define T(Type, idx, off) \
- __attribute__ ((noipa)) \
- void UNIQ (test_)(int n) \
- { \
- void *p = malloc (n); \
- Type *q = (Type*)((char*)p + off); \
- sink (p, q[idx]); \
- } \
- typedef void dummy_type
-
-T (int, 0, 0); // { dg-warning "'\\*\\(int \\*\\)p' is used uninitialized" }
-T (int, 0, 1); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)'" }
-T (int, 0, 2); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)p \\+ 2\\)'" }
-T (int, 0, 3); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)p \\+ 3\\)'" }
-T (int, 0, 4); // { dg-warning "'\\(\\(int \\*\\)p\\)\\\[1]'" }
-T (int, 0, 5); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)\\)\\\[1]'" }
-T (int, 0, 6); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 2\\)\\)\\\[1]'" }
-T (int, 0, 7); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 3\\)\\)\\\[1]'" }
-T (int, 0, 8); // { dg-warning "'\\(\\(int \\*\\)p\\)\\\[2]'" }
-T (int, 0, 9); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)\\)\\\[2]'" }
-
-
-T (int, 1, 0); // { dg-warning "'\\(\\(int \\*\\)p\\)\\\[1]' is used uninitialized" }
-T (int, 1, 1); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)\\)\\\[1]'" }
-T (int, 1, 2); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 2\\)\\)\\\[1]'" }
-T (int, 1, 3); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 3\\)\\)\\\[1]'" }
-T (int, 1, 4); // { dg-warning "'\\(\\(int \\*\\)p\\)\\\[2]'" }
-T (int, 1, 5); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)\\)\\\[2]'" }
-T (int, 1, 6); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 2\\)\\)\\\[2]'" }
-T (int, 1, 7); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 3\\)\\)\\\[2]'" }
-T (int, 1, 8); // { dg-warning "'\\(\\(int \\*\\)p\\)\\\[3]'" }
-T (int, 1, 9); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)\\)\\\[3]'" }
-
-#undef T
#define T(Type, idx, off) \
__attribute__ ((noipa)) \
void UNIQ (test_)(int n) \
diff --git a/gcc/testsuite/gcc.dg/uninit-41.c b/gcc/testsuite/gcc.dg/uninit-41.c
new file mode 100644
index 0000000..b485611
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-41.c
@@ -0,0 +1,121 @@
+/* Verify that calls to non-modifying built-ins aren't considered
+ potentially modifying.
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+void* alloca (size_t);
+void* calloc (size_t, size_t);
+void* malloc (size_t);
+int printf (const char *, ...);
+int scanf (const char *, ...);
+int sprintf (char *, const char *, ...);
+int snprintf (char *, size_t, const char *, ...);
+int puts (const char *);
+char* strcpy (char*, const char*);
+size_t strlen (const char*);
+
+void noproto ();
+
+void sink (int, ...);
+
+extern char a[];
+
+void nowarn_noproto (const char *fmt)
+{
+ int i;
+ noproto (&i);
+ sink (i);
+}
+
+void nowarn_scanf (const char *fmt)
+{
+ int i;
+ scanf ("%i", &i);
+ sink (i);
+}
+
+void test_puts_sprintf_alloca (const char *fmt)
+{
+ char *p;
+ {
+ p = alloca (8);
+ sprintf (a, fmt, p); // fmt might contain %n
+ puts (p);
+ }
+
+ {
+ p = alloca (8);
+ snprintf (0, 0, fmt, p); // same as above
+ puts (p);
+ }
+}
+
+void test_puts_alloca (const char *s)
+{
+ char *p = alloca (8);
+
+ {
+ char a[] = "foo";
+ puts (a);
+ }
+
+ puts (p); // { dg-warning "-Wuninitialized" }
+
+ {
+ p = alloca (strlen (s) + 1);
+ strcpy (p, s);
+ puts (p);
+ }
+
+ {
+ /* Verify that the puts() calls above isn't considered to have
+ potentially modified *P, and same for the one below. */
+ p = alloca (strlen (s));
+ puts (p); // { dg-warning "-Wuninitialized" }
+ puts (p + 1); // { dg-warning "-Wuninitialized" }
+ }
+}
+
+
+void test_puts_malloc (const char *s, const char *t)
+{
+ char *p;
+
+ {
+ p = malloc (strlen (s) + 1);
+ strcpy (p, s);
+ puts (p);
+ }
+
+ {
+ p = malloc (strlen (t));
+ puts (p); // { dg-warning "-Wuninitialized" }
+ }
+}
+
+
+void test_puts_vla (const char *s, const char *t)
+{
+ {
+ char a[strlen (s) + 1];
+ strcpy (a, s);
+ puts (a);
+ }
+
+ {
+ char b[strlen (t)];
+ puts (b); // { dg-warning "-Wuninitialized" }
+ }
+}
+
+
+void test_printf_puts (const char *s)
+{
+ char *p = __builtin_malloc (1);
+
+ printf ("%s", s);
+
+ puts (p); // { dg-warning "-Wuninitialized" }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-42.c b/gcc/testsuite/gcc.dg/uninit-42.c
new file mode 100644
index 0000000..efaaacd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-42.c
@@ -0,0 +1,87 @@
+/* PR middle-end/101734 - missing warning reading from a write-only object
+ Verify that reading objects pointed to by arguments
+ declared with attribute access none or write-only is diagnosed by
+ -Wmaybe-uninitialized.
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+#define A(mode, ...) __attribute__ ((access (mode, __VA_ARGS__)))
+
+void sink (void *, ...);
+
+
+A (write_only, 1, 2)
+int nowarn_wo_assign_r0 (int *p, int n)
+{
+ *p = n;
+ return *p;
+}
+
+A (write_only, 1, 2)
+int nowarn_wo_sink_r0 (int *p, int n)
+{
+ sink (p, p + 1, p + n);
+ return *p;
+}
+
+A (write_only, 1, 2)
+int warn_wo_r0 (int *p, int n)
+{
+ return *p; // { dg-warning "'\\*p' may be used uninitialized \\\[-Wmaybe-uninitialized" }
+}
+
+
+A (write_only, 1, 2)
+int nowarn_wo_w1_r1 (int *p, int n)
+{
+ p[1] = n;
+ return p[1];
+}
+
+A (write_only, 1, 2)
+int warn_wo_r1 (int *p, int n)
+{
+ return p[1]; // { dg-warning "'p\\\[1]' may be used uninitialized" }
+}
+
+
+A (write_only, 1, 2)
+int nowarn_wo_rwi_rj (int *p, int n, int i, int j)
+{
+ p[i] = n;
+ return p[j];
+}
+
+A (write_only, 1, 2)
+ int warn_wo_ri (int *p, int n, int i)
+{
+ return p[i]; // { dg-warning " may be used uninitialized" }
+}
+
+
+
+A (none, 1, 2)
+int* nowarn_none_sink_return (int *p, int n)
+{
+ sink (p, p + 1, p + n);
+ return p;
+}
+
+A (none, 1, 2)
+int warn_none_r0 (int *p, int n)
+{
+ (void)&n;
+ return *p; // { dg-warning "'\\*p' may be used uninitialized" }
+}
+
+A (none, 1, 2)
+int warn_none_r1 (int *p, int n)
+{
+ return p[1]; // { dg-warning "'p\\\[1]' may be used uninitialized" }
+}
+
+A (write_only, 1, 2)
+int warn_none_ri (int *p, int n, int i)
+{
+ return p[i]; // { dg-warning " may be used uninitialized" }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr100250.c b/gcc/testsuite/gcc.dg/uninit-pr100250.c
new file mode 100644
index 0000000..8e7a787
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr100250.c
@@ -0,0 +1,29 @@
+/* PR middle-end/100250 - ICE related to -Wmaybe-uninitialized
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+extern void f (int D, const int[D], const int[D]);
+
+void g (int D, const int a[D], const int b[D], const int c[D], const int d[D])
+{
+ int c2[D];
+
+ for (int i = 0; i < D; i++) {
+
+ if (a[i] >= D) __builtin_abort ();
+ if (b[i] != d[a[i]]) __builtin_abort ();
+
+ c2[a[i]] = c[i];
+ }
+
+ f (D, d, c2);
+}
+
+void h (int D, const int d[D])
+{
+ int a[D];
+ int b[D];
+ int c[D];
+
+ g (D, a, b, c, d); // { dg-warning "-Wmaybe-uninitialized" }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr100732.c b/gcc/testsuite/gcc.dg/uninit-pr100732.c
new file mode 100644
index 0000000..9c847ce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr100732.c
@@ -0,0 +1,21 @@
+/* PR middle-end/100732 - ICE on sprintf %s with integer argument
+ { dg-do compile }
+ { dg-options "-O2 -Wall -fdump-tree-optimized" } */
+
+void nowarn_s_i (char *d, int i)
+{
+ __builtin_sprintf (d, "%s", i); // { dg-warning "\\\[-Wformat" }
+}
+
+void warn_s_i (char *d)
+{
+ int i;
+ __builtin_sprintf (d, "%s", i); // { dg-warning "\\\[-Wformat" }
+ // { dg-warning "\\\[-Wuninitialized" "" { target *-*-* } .-1 }
+}
+
+void warn_i_i (char *d)
+{
+ int i;
+ __builtin_sprintf (d, "%i", i); // { dg-warning "\\\[-Wuninitialized" }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr101300.c b/gcc/testsuite/gcc.dg/uninit-pr101300.c
new file mode 100644
index 0000000..4392e8ba
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr101300.c
@@ -0,0 +1,53 @@
+/* PR middle-end/101300 - -fsanitize=undefined suppresses -Wuninitialized
+ for a VLA read at -O0
+ { dg-do compile }
+ { dg-options "-O0 -Wall -fsanitize=undefined" } */
+
+int warn_vla_rd0 (int n)
+{
+ char a[n];
+ return a[0]; // { dg-warning "\\\[-Wuninitialized]" }
+}
+
+int warn_vla_rd1 (int n)
+{
+ char a[n];
+ return a[1]; // { dg-warning "\\\[-Wuninitialized]" }
+}
+
+int warn_vla_rdi (int n, int i)
+{
+ char a[n];
+ return a[i]; // { dg-warning "\\\[-Wuninitialized]" }
+}
+
+
+int warn_vla_wr0_rd2_1_0 (int n)
+{
+ char a[n];
+ a[0] = __LINE__;
+ int x = a[2]; // { dg-warning "\\\[-Wuninitialized]" }
+ int y = a[1]; // { dg-warning "\\\[-Wuninitialized]" }
+ int z = a[0];
+ return x + y + z;
+}
+
+int warn_vla_wr1_rd2_1_0 (int n)
+{
+ char a[n];
+ a[1] = __LINE__;
+ int x = a[2]; // { dg-warning "\\\[-Wuninitialized]" }
+ int y = a[1];
+ int z = a[0]; // { dg-warning "\\\[-Wuninitialized]" }
+ return x + y + z;
+}
+
+int warn_vla_wr2_rd2_1_0 (int n)
+{
+ char a[n];
+ a[2] = __LINE__;
+ int x = a[2];
+ int y = a[1]; // { dg-warning "\\\[-Wuninitialized]" }
+ int z = a[0]; // { dg-warning "\\\[-Wuninitialized]" }
+ return x + y + z;
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr101494.c b/gcc/testsuite/gcc.dg/uninit-pr101494.c
new file mode 100644
index 0000000..d3267b6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr101494.c
@@ -0,0 +1,60 @@
+/* PR middle-end/101494 - bogus -Wmaybe-uninitialized on memrchr of size 0
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+void* alloca (size_t);
+
+__attribute__ ((malloc, alloc_size (1))) void* alloc (size_t);
+
+__attribute__ ((access (read_only, 1, 2))) void* sink (void*, size_t);
+
+void test_alloca_zero (size_t i)
+{
+ char *p = alloca (0);
+ sink (p, 0); // { dg-bogus "\\\[-Wuninitialized" }
+}
+
+void test_alloca_zero_pi (size_t i)
+{
+ char *p = alloca (0);
+ sink (p + i, 0);
+}
+
+void test_alloca_cst (void)
+{
+ char *p = alloca (7);
+ sink (p, 0); // { dg-bogus "\\\[-Wuninitialized" }
+}
+
+void test_alloca_cst_p1 (void)
+{
+ char *p = alloca (7);
+ sink (p + 1, 0); // { dg-bogus "\\\[-Wuninitialized" }
+}
+
+void test_alloca_cst_p7 (void)
+{
+ char *p = alloca (7);
+ sink (p + 7, 0); // { dg-bogus "\\\[-Wuninitialized" }
+}
+
+void test_alloca_var (size_t n)
+{
+ char *p = alloca (n);
+ sink (p, 0); // { dg-bogus "\\\[-Wuninitialized" }
+}
+
+void test_alloca_var_p1 (size_t n)
+{
+ char *p = alloca (n);
+ sink (p + 1, 0); // { dg-bogus "\\\[-Wuninitialized" }
+}
+
+void test_alloca_var_pn (size_t n)
+{
+ char *p = alloca (n);
+ sink (p + n, 0); // { dg-bogus "\\\[-Wuninitialized" }
+}
+
diff --git a/gcc/testsuite/gcc.dg/uninit-pr101573.c b/gcc/testsuite/gcc.dg/uninit-pr101573.c
new file mode 100644
index 0000000..a574844
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr101573.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -Wuninitialized" } */
+
+int main(int argc, char **argv)
+{
+ int a;
+ for(; a < 5; ++a) /* { dg-warning "is used uninitialized" } */
+ ;
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr44547.c b/gcc/testsuite/gcc.dg/uninit-pr44547.c
new file mode 100644
index 0000000..ee1035a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr44547.c
@@ -0,0 +1,61 @@
+/* PR tree-optimization/44547 - -Wuninitialized reports false warning
+ in nested switch statements
+ { dg-do compile }
+ { dg-options "-O1 -Wall" } */
+
+__attribute__ ((noipa)) int test_O1 (int argc)
+{
+ switch( argc )
+ {
+ case 1:
+ case 2:
+ case 4:
+ {
+ int n;
+ switch( argc )
+ {
+ case 1:
+ case 2:
+ case 4:
+ n = argc;
+ break;
+ }
+
+ return n;
+
+ break;
+ }
+ }
+
+ return 0;
+}
+
+
+#pragma GCC optimize ("2")
+
+__attribute__ ((noipa)) int test_O2 (int argc)
+{
+ switch( argc )
+ {
+ case 1:
+ case 2:
+ case 4:
+ {
+ int n;
+ switch( argc )
+ {
+ case 1:
+ case 2:
+ case 4:
+ n = argc;
+ break;
+ }
+
+ return n;
+
+ break;
+ }
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr55060.c b/gcc/testsuite/gcc.dg/uninit-pr55060.c
new file mode 100644
index 0000000..b2f2cb1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr55060.c
@@ -0,0 +1,30 @@
+/* PR tree-optimization/55060 - False un-initialized variable warnings
+ { dg-do compile }
+ { dg-options "-O1 -Wuninitialized" } */
+
+static void a(int *i) { }
+static void b(int p) { }
+int foo(void) {
+ int i;
+ a(&i);
+ b(i); // { dg-bogus "\\\[-Wuninitialized" }
+ return 0;
+}
+
+static void c(int *i) { }
+extern void d(int p);
+int bar(void) {
+ int i;
+ c(&i);
+ d(i); // { dg-warning "\\\[-Wuninitialized" }
+ return 0;
+}
+
+extern void e(int *i);
+static void f(int p) {};
+int baz(void) {
+ int i;
+ e(&i);
+ f(i); // { dg-bogus "\\\[-Wuninitialized" }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr59970.c b/gcc/testsuite/gcc.dg/uninit-pr59970.c
new file mode 100644
index 0000000..145af65
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr59970.c
@@ -0,0 +1,79 @@
+/* PR tree-optimization/59970 - Bogus -Wmaybe-uninitialized at low optimization
+ levels
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+#pragma GCC push_options
+#pragma GCC optimize ("1")
+
+__attribute__ ((noipa)) int
+d_demangle_callback_O1 (const char *mangled)
+{
+ enum { DCT_TYPE, DCT_GLOBAL_DTORS } type;
+ int dc;
+
+ /* Fails for -Og and -O1. */
+ if (mangled)
+ type = DCT_GLOBAL_DTORS;
+ else
+ type = DCT_TYPE;
+
+ /* If both cases assign the same value, all is fine. */
+ switch (type)
+ {
+ case DCT_TYPE:
+ dc = 0 /* 1 */;
+ break;
+ case DCT_GLOBAL_DTORS:
+ dc = /* 0 */ 1;
+ break;
+
+ /* If this is added, all is fine. */
+#ifdef ABORT
+ default:
+ __builtin_unreachable ();
+#endif
+ }
+
+ return dc; // { dg-bogus "uninitialized" }
+}
+
+#pragma GCC pop_options
+
+
+#pragma GCC optimize ("Og")
+
+__attribute__ ((noipa)) int
+d_demangle_callback_Og (const char *mangled)
+{
+ enum { DCT_TYPE, DCT_GLOBAL_DTORS } type;
+ int dc;
+
+ /* Fails for -Og. */
+ /* Removing either the function call or the array dereference, it'll be like
+ the TOGGLE1 case. */
+ extern int cmp (void);
+ if (cmp () && mangled[0])
+ type = DCT_GLOBAL_DTORS;
+ else
+ type = DCT_TYPE;
+
+ /* If both cases assign the same value, all is fine. */
+ switch (type)
+ {
+ case DCT_TYPE:
+ dc = 0 /* 1 */;
+ break;
+ case DCT_GLOBAL_DTORS:
+ dc = /* 0 */ 1;
+ break;
+
+ /* If this is added, all is fine. */
+#ifdef ABORT
+ default:
+ __builtin_unreachable ();
+#endif
+ }
+
+ return dc; // { dg-bogus "uninitialized" }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr61112.c b/gcc/testsuite/gcc.dg/uninit-pr61112.c
new file mode 100644
index 0000000..d8f9c80
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr61112.c
@@ -0,0 +1,89 @@
+/* PR tree-optimization/61112 - repeated conditional triggers false-positive
+ -Wmaybe-uninitialized warning
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+int p;
+
+void foo_c0 (int x, int y, int z)
+{
+ int w;
+ if (x)
+ w = z;
+ if (y)
+ w = __LINE__;
+
+ if (x || y)
+ p = w; // { dg-bogus "-Wmaybe-uninitialized" }
+}
+
+
+void foo_c5_1_1 (int x, int y, int z, int a)
+{
+ int w;
+ if (x)
+ w = z;
+ if (y)
+ w = __LINE__;
+ if (a)
+ w = __LINE__;
+
+ if (x || y || a)
+ p = w;
+}
+
+void foo_c5_1_2 (int x, int y, int z, int a)
+{
+ int w;
+ if (x)
+ w = z;
+ if (y)
+ w = __LINE__;
+ if (a)
+ w = __LINE__;
+
+ if (x || a || y)
+ p = w;
+}
+
+void foo_c5_1_3 (int x, int y, int z, int a)
+{
+ int w;
+ if (x)
+ w = z;
+ if (y)
+ w = __LINE__;
+ if (a)
+ w = __LINE__;
+
+ if (a || x || y)
+ p = w;
+}
+
+void foo_c5_2 (int x, int y, int z, int a)
+{
+ int w;
+ if (x)
+ w = __LINE__;
+ if (y)
+ w = z;
+ if (a)
+ w = __LINE__;
+
+ if (x || y || a)
+ p = w; // { dg-bogus "-Wmaybe-uninitialized" }
+}
+
+void foo_c5_3 (int x, int y, int z, int a)
+{
+ int w;
+ if (x)
+ w = __LINE__;
+ if (y)
+ w = __LINE__;
+ if (a)
+ w = z;
+
+ if (x || y || a)
+ p = w; // { dg-bogus "-Wmaybe-uninitialized" }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr61677.c b/gcc/testsuite/gcc.dg/uninit-pr61677.c
new file mode 100644
index 0000000..a982fae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr61677.c
@@ -0,0 +1,26 @@
+/* PR tree-optimization/61677 - False positive with -Wmaybe-uninitialized
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+void *xmalloc (void);
+
+struct menu { struct menu *parent; };
+
+struct jump_key { int offset; };
+
+void f (struct menu *menu)
+{
+ int i;
+ struct menu *submenu[8], *location;
+ struct jump_key *jump;
+ location = menu;
+ for (i = 0; menu && i < 8; menu = menu->parent)
+ submenu[i++] = menu;
+ if (location)
+ jump = xmalloc ();
+ while (--i >= 0) {
+ menu = submenu[i];
+ if (location)
+ jump->offset = 42;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr61869.c b/gcc/testsuite/gcc.dg/uninit-pr61869.c
new file mode 100644
index 0000000..ef4f436
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr61869.c
@@ -0,0 +1,47 @@
+/* PR tree-optimization/61869 - Spurious uninitialized warning (lim1 pass,
+ pretty-printed internal var
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+typedef struct data {
+ struct data *next;
+} data;
+
+typedef struct list {
+ unsigned dummy;
+ struct list *next;
+ data *start;
+ int flags;
+} list;
+
+typedef struct iterator {
+ struct data *ptr;
+ unsigned dummy;
+} iterator;
+
+iterator start (list *a) {
+ iterator i = {
+ *(a->flags ? &a->start : 0),
+ 0
+ };
+ return i;
+}
+
+void g (iterator *i);
+
+void f (list *b)
+{
+ list *a;
+ iterator i; // { dg-bogus "-Wmaybe-uninitialized" }
+
+ for (a = b; a; a = a->next)
+ for (i = start (a); i.ptr; i.ptr = i.ptr->next)
+ {
+ if (i.ptr)
+ return;
+ }
+
+ for (a = b; a; a = a->next)
+ for (i = start (a); i.ptr; i.ptr = i.ptr->next)
+ g(&i);
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr65178.c b/gcc/testsuite/gcc.dg/uninit-pr65178.c
new file mode 100644
index 0000000..21eb354
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr65178.c
@@ -0,0 +1,21 @@
+/* PR tree-optimizatiom/65178 - incorrect -Wmaybe-uninitialized when using
+ nested loops
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+void *bar (int);
+
+char *foo (void)
+{
+ char *c = "bla";
+ char *buf;
+ for (int a = 1;; a = 0)
+ {
+ for (char *s = c; *s; ++s)
+ {
+ }
+ if (!a) break;
+ buf = (char *) bar (1);
+ }
+ return buf; // { dg-bogus "\\\[-Wmaybe-uninitialized" }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr65182.c b/gcc/testsuite/gcc.dg/uninit-pr65182.c
new file mode 100644
index 0000000..45b538d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr65182.c
@@ -0,0 +1,44 @@
+/* PR middle-end/65182 - -Wuninitialized fails when pointer to variable
+ later passed to function
+ { dg-do compile }
+ { dg-options "-O0 -Wall" } */
+
+void bar (int *a);
+
+int baz (void);
+
+__attribute__ ((noipa)) void foo_O0 (int *b)
+{
+ int a;
+
+ if (a) // { dg-warning "\\\[-Wuninitialized" }
+ {
+ *b = 0;
+ return;
+ }
+
+ bar (&a);
+
+ a = baz ();
+
+ *b = a + 2;
+}
+
+#pragma GCC optimize ("2")
+
+__attribute__ ((noipa)) void foo_O2 (int *b)
+{
+ int a;
+
+ if (a) // { dg-warning "\\\[-Wuninitialized" }
+ {
+ *b = 0;
+ return;
+ }
+
+ bar (&a);
+
+ a = baz ();
+
+ *b = a + 3;
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr89230-1.c b/gcc/testsuite/gcc.dg/uninit-pr89230-1.c
new file mode 100644
index 0000000..1c07c4f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr89230-1.c
@@ -0,0 +1,25 @@
+/* PR middle-end/89230 - Bogus uninited usage warning with printf
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+struct S { int i, j; };
+
+/* attribute__ ((malloc)) */ struct S* f (void);
+
+int g (void)
+{
+ struct S *p = f (), *q;
+
+ if (p->i || !(q = f ()) || p->j != q->i)
+ {
+ __builtin_printf ("%i", p->i);
+
+ if (p->i)
+ return 1;
+
+ if (!q) // { dg-bogus "\\\[-Wmaybe-uninitialized" }
+ return 2;
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr89230-2.c b/gcc/testsuite/gcc.dg/uninit-pr89230-2.c
new file mode 100644
index 0000000..473d2da
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr89230-2.c
@@ -0,0 +1,54 @@
+/* PR middle-end/89230 - Bogus uninited usage warning with printf
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+extern void* memset (void*, int, size_t);
+extern int printf (const char*, ...);
+extern int rand (void);
+
+struct S
+{
+ int a;
+ int b;
+};
+
+struct H
+{
+ int c;
+ int d;
+};
+
+void getblk (void* blk)
+{
+ struct S* s = (struct S*) blk;
+ memset (blk, 0, 512);
+ s->a = rand () & 1;
+}
+
+struct H* gethdr (void* blk)
+{
+ memset (blk, 0, 512);
+ return rand () & 1 ? (struct H*) blk : 0;
+}
+
+int main (void)
+{
+ char blk[512], tmp[512];
+ struct S *s = (struct S*) blk;
+ struct H *h;
+
+ getblk (blk);
+
+ if (s->a || !(h = gethdr (tmp)) || s->a != h->d) {
+
+ printf ("%d\n", s->b);
+ if (s->a)
+ printf ("s->a = %d\n", s->a);
+ else if (!h)
+ printf ("!h\n");
+ else
+ printf ("h->d = %d\n", h->d);
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr93100.c b/gcc/testsuite/gcc.dg/uninit-pr93100.c
new file mode 100644
index 0000000..531a5c3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr93100.c
@@ -0,0 +1,75 @@
+/* PR tree-optimization/93100 - gcc -fsanitize=address inhibits -Wuninitialized
+ { dg-do compile }
+ { dg-options "-Wall -fsanitize=address" }
+ { dg-skip-if "sanitize address" { "powerpc-ibm-aix*" } } */
+
+struct A
+{
+ _Bool b;
+ int i;
+};
+
+void warn_A_b_O0 (void)
+{
+ struct A a;
+
+ if (a.b) // { dg-warning "\\\[-Wuninitialized" }
+ {
+ (void)&a;
+ }
+}
+
+void warn_A_i_O0 (void)
+{
+ struct A a;
+
+ if (a.i) // { dg-warning "\\\[-Wuninitialized" }
+ {
+ (void)&a;
+ }
+}
+
+#pragma GCC optimize ("1")
+
+void warn_A_b_O1 (void)
+{
+ struct A a;
+
+ if (a.b) // { dg-warning "\\\[-Wuninitialized" }
+ {
+ (void)&a;
+ }
+}
+
+void warn_A_i_O1 (void)
+{
+ struct A a;
+
+ if (a.i) // { dg-warning "\\\[-Wuninitialized" }
+ {
+ (void)&a;
+ }
+}
+
+
+#pragma GCC optimize ("2")
+
+void warn_A_b_O2 (void)
+{
+ struct A a;
+
+ if (a.b) // { dg-warning "\\\[-Wuninitialized" }
+ {
+ (void)&a;
+ }
+}
+
+void warn_A_i_O2 (void)
+{
+ struct A a;
+
+ if (a.i) // { dg-warning "\\\[-Wuninitialized" }
+ {
+ (void)&a;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr98583.c b/gcc/testsuite/gcc.dg/uninit-pr98583.c
new file mode 100644
index 0000000..638b029
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr98583.c
@@ -0,0 +1,31 @@
+/* PR middle-end/98583 - missing -Wuninitialized reading from a second VLA
+ in its own block
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+void f (int*);
+void g (int);
+
+void h1 (int n)
+{
+ int a[n];
+ f (a);
+
+ int b[n];
+ g (b[1]); // { dg-warning "\\\[-Wuninitialized" }
+}
+
+void h2 (int n, int i, int j)
+{
+ if (i)
+ {
+ int a[n];
+ f (a);
+ }
+
+ if (j)
+ {
+ int b[n];
+ g (b[1]); // { dg-warning "\\\[-Wmaybe-uninitialized" }
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pred-9_b.c b/gcc/testsuite/gcc.dg/uninit-pred-9_b.c
index d9ae75e..8c2d28c 100644
--- a/gcc/testsuite/gcc.dg/uninit-pred-9_b.c
+++ b/gcc/testsuite/gcc.dg/uninit-pred-9_b.c
@@ -1,4 +1,3 @@
-
/* { dg-do compile } */
/* { dg-options "-Wuninitialized -O2" } */
@@ -21,7 +20,7 @@ int foo (int n, int l, int m, int r)
blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */
if ( (n <= 8) && (m < 99) && (r < 19) )
- blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */
+ blah(v); /* { dg-bogus "uninitialized" "pr101674" { xfail powerpc64*-*-* mmix-*-* cris-*-* } } */
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/uninit-suppress_3.c b/gcc/testsuite/gcc.dg/uninit-suppress_3.c
new file mode 100644
index 0000000..7bbe9ed
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-suppress_3.c
@@ -0,0 +1,98 @@
+/* PR middle-end/98871 - Cannot silence -Wmaybe-uninitialized at declaration
+ site
+ { dg-do compile }
+ { dg-options "-O1 -Wall" } */
+
+struct A
+{
+ int x;
+};
+
+// Verify that suppression works at every inlining level.
+
+static int f0 (int *x)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+
+ return ++*x;
+
+#pragma GCC diagnostic pop
+}
+
+static int f1 (int *p, int n)
+{
+ struct A a;
+ for (int i = 0; i < n; ++i) {
+ if (p[i] > 1) {
+ a = (struct A){p[i]};
+ }
+ }
+
+ return f0 (&a.x);
+}
+
+int f2 (void)
+{
+ int a[] = { 1, 2, 3, 4 };
+ return f1 (a, 4);
+}
+
+
+static int g0 (int *x)
+{
+ return ++*x;
+}
+
+static int g1 (int *p, int n)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+
+ struct A a;
+ for (int i = 0; i < n; ++i) {
+ if (p[i] > 1) {
+ a = (struct A){p[i]};
+ }
+ }
+
+ return g0 (&a.x);
+
+#pragma GCC diagnostic pop
+}
+
+int g2 (void)
+{
+ int a[] = { 1, 2, 3, 4, 5 };
+ return g1 (a, 5);
+}
+
+
+static int h0 (int *x)
+{
+ return ++*x;
+}
+
+static int h1 (int *p, int n)
+{
+ struct A a;
+ for (int i = 0; i < n; ++i) {
+ if (p[i] > 1) {
+ a = (struct A){p[i]};
+ }
+ }
+
+ return h0 (&a.x);
+}
+
+int h2 (void)
+{
+ int a[] = { 1, 2, 3, 4, 5, 6 };
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+
+ return h1 (a, 6);
+
+#pragma GCC diagnostic pop
+}
diff --git a/gcc/testsuite/gcc.dg/unroll-10.c b/gcc/testsuite/gcc.dg/unroll-10.c
new file mode 100644
index 0000000..0559915
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/unroll-10.c
@@ -0,0 +1,13 @@
+/* { dg-options "-O3 -fdump-tree-unrolljam" } */
+
+void
+f (int *restrict x, int *restrict y, int z[restrict 100][100])
+{
+ for (int j = 0; j < 100; ++j)
+ for (int i = 0; i < 100; ++i)
+ x[i] += y[i] * z[j][i];
+}
+
+/* The loop should be unrolled 2 times, leaving one load from x,
+ one load from y and 2 loads from z. */
+/* { dg-final { scan-tree-dump-times { = \(*\*} 4 "unrolljam" } } */
diff --git a/gcc/testsuite/gcc.dg/unroll-9.c b/gcc/testsuite/gcc.dg/unroll-9.c
new file mode 100644
index 0000000..2d65ec3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/unroll-9.c
@@ -0,0 +1,12 @@
+/* { dg-options "-O3 -fdump-tree-unrolljam -fno-math-errno" } */
+
+void
+f (float *restrict x, float y[100][100])
+{
+ for (int j = 0; j < 100; ++j)
+ for (int i = 0; i < 100; ++i)
+ x[i] += __builtin_expf (y[j][i]);
+}
+
+/* The loop should be unrolled 2 times, without a tail loop. */
+/* { dg-final { scan-tree-dump-times "__builtin_expf" 2 "unrolljam" } } */
diff --git a/gcc/testsuite/gcc.dg/unroll-and-jam.c b/gcc/testsuite/gcc.dg/unroll-and-jam.c
index 7eb6421..b8f4f16 100644
--- a/gcc/testsuite/gcc.dg/unroll-and-jam.c
+++ b/gcc/testsuite/gcc.dg/unroll-and-jam.c
@@ -1,5 +1,6 @@
/* { dg-do run } */
/* { dg-options "-O3 -floop-unroll-and-jam -fno-tree-loop-im --param unroll-jam-min-percent=0 -fdump-tree-unrolljam-details" } */
+/* { dg-additional-options "--param max-completely-peel-times=16" { target { s390*-*-* } } } */
/* { dg-require-effective-target int32plus } */
#include <stdio.h>
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-16.c b/gcc/testsuite/gcc.dg/vect/bb-slp-16.c
index e68a9b6..664e93e 100644
--- a/gcc/testsuite/gcc.dg/vect/bb-slp-16.c
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-16.c
@@ -1,5 +1,8 @@
/* { dg-require-effective-target vect_int } */
+/* See note below as to why we disable threading. */
+/* { dg-additional-options "-fdisable-tree-thread1" } */
+
#include <stdarg.h>
#include "tree-vect.h"
@@ -27,6 +30,10 @@ main1 (int dummy)
*pout++ = *pin++ + a;
*pout++ = *pin++ + a;
*pout++ = *pin++ + a;
+ /* In some architectures like ppc64, jump threading may thread
+ the iteration where i==0 such that we no longer optimize the
+ BB. Another alternative to disable jump threading would be
+ to wrap the read from `i' into a function returning i. */
if (arr[i] = i)
a = i;
else
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-39.c b/gcc/testsuite/gcc.dg/vect/bb-slp-39.c
index 255bb10..ee596cf 100644
--- a/gcc/testsuite/gcc.dg/vect/bb-slp-39.c
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-39.c
@@ -16,4 +16,5 @@ void foo (double *p)
}
/* See that we vectorize three SLP instances. */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "slp2" } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "slp2" { target { ! s390*-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 5 "slp2" { target { s390*-*-* } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-43.c b/gcc/testsuite/gcc.dg/vect/bb-slp-43.c
index 40bd2e0..a65d951 100644
--- a/gcc/testsuite/gcc.dg/vect/bb-slp-43.c
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-43.c
@@ -14,4 +14,4 @@ f (int *restrict x, short *restrict y)
}
/* { dg-final { scan-tree-dump-not "mixed mask and nonmask" "slp2" } } */
-/* { dg-final { scan-tree-dump-not "vector operands from scalars" "slp2" { target { { vect_int && vect_bool_cmp } && { vect_unpack && vect_hw_misalign } } } } } */
+/* { dg-final { scan-tree-dump-not "vector operands from scalars" "slp2" { target { { vect_int && vect_bool_cmp } && { vect_unpack && vect_hw_misalign } } xfail vect_variable_length } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-71.c b/gcc/testsuite/gcc.dg/vect/bb-slp-71.c
new file mode 100644
index 0000000..6816511
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-71.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+int a[4], b[4];
+
+void __attribute__((noipa))
+foo(int x, int y)
+{
+ int tem0 = x + 1;
+ int tem1 = y + 2;
+ int tem2 = x + 3;
+ int tem3 = y + 4;
+ a[0] = tem0 + b[1];
+ a[1] = tem1 + b[0];
+ a[2] = tem2 + b[2];
+ a[3] = tem3 + b[3];
+}
+
+int main()
+{
+ check_vect ();
+
+ b[0] = 10;
+ b[1] = 14;
+ b[2] = 18;
+ b[3] = 22;
+ foo (-1, -3);
+ if (a[0] != 14 || a[1] != 9 || a[2] != 20 || a[3] != 23)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-72.c b/gcc/testsuite/gcc.dg/vect/bb-slp-72.c
new file mode 100644
index 0000000..5b243fc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-72.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+double x[2], y[2], z[2], w[2];
+
+void __attribute__((noipa)) foo ()
+{
+ double tem0 = x[1] + y[1];
+ double tem1 = x[0] - y[0];
+ double tem2 = z[1] * tem0;
+ double tem3 = z[0] * tem1;
+ z[0] = tem2 - w[0];
+ z[1] = tem3 + w[1];
+}
+
+int main()
+{
+ check_vect ();
+
+ x[0] = 1.; x[1] = 2.;
+ y[0] = 7.; y[1] = -5.;
+ z[0] = 2.; z[1] = 3.;
+ w[0] = 9.; w[1] = -5.;
+ foo ();
+ if (z[0] != -18. || z[1] != -17.)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-73.c b/gcc/testsuite/gcc.dg/vect/bb-slp-73.c
new file mode 100644
index 0000000..d4c8a51
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-73.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+double x[2], y[2], z[2], w[2];
+
+void __attribute__((noipa)) foo ()
+{
+ double tem0 = x[1] + y[1];
+ double tem1 = x[0] - y[0];
+ double tem2 = z[1] * tem0;
+ double tem3 = z[0] * tem1;
+ z[0] = tem2 - w[1];
+ z[1] = tem3 + w[0];
+}
+
+int main()
+{
+ check_vect ();
+
+ x[0] = 1.; x[1] = 2.;
+ y[0] = 7.; y[1] = -5.;
+ z[0] = 2.; z[1] = 3.;
+ w[0] = 9.; w[1] = -5.;
+ foo ();
+ if (z[0] != -4. || z[1] != -3.)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-74.c b/gcc/testsuite/gcc.dg/vect/bb-slp-74.c
new file mode 100644
index 0000000..9c1ebb7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-74.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-require-effective-target vect_double } */
+
+#include "tree-vect.h"
+
+double a[2], b[2], c[2];
+
+void __attribute__((noipa)) foo ()
+{
+ double tem0 = a[1] + b[1];
+ double tem1 = a[0] - b[0];
+ c[0] = 2. * tem0;
+ c[1] = 5. * tem1;
+}
+
+int main()
+{
+ check_vect ();
+
+ a[0] = 1.; a[1] = 3.;
+ b[0] = -5.; b[1] = 13.;
+ foo ();
+ if (c[0] != 32. || c[1] != 30.)
+ __builtin_abort ();
+ return 0;
+}
+
+/* We'd like to see at most one VEC_PERM_EXPR, not one for a blend
+ and one for a permute materialized somewhere else. But addsub
+ pattern recog can likely get in the way here. */
+/* { dg-final { scan-tree-dump-times " \[^ \]\+ = VEC_PERM_EXPR" 1 "slp2" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr100778-1.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr100778-1.c
new file mode 100644
index 0000000..9f8b7ee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr100778-1.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_double } */
+
+double foo (int x, double *p)
+{
+ double res = p[0] + p[1];
+ double tem = p[0] / x;
+ if (x)
+ {
+ p[0] = tem;
+ p[1] /= x;
+ }
+ return res + tem;
+}
+
+/* We may not SLP vectorize the FP division because it can trap and it
+ is distributed between two basic-blocks. */
+/* { dg-final { scan-tree-dump "Build SLP failed: different BB for PHI or possibly trapping operation in _\[0-9\]+ = _\[0-9\]+ / _\[0-9\]+;" "slp2" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr101207.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101207.c
new file mode 100644
index 0000000..1f51d66
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101207.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ffast-math" } */
+
+#include "tree-vect.h"
+
+double a[2];
+double x, y;
+
+void __attribute__((noipa)) foo ()
+{
+ x = a[1] - a[0];
+ y = a[0] + a[1];
+}
+
+int main()
+{
+ check_vect ();
+
+ a[0] = 0.;
+ a[1] = 1.;
+ foo ();
+ if (x != 1. || y != 1.)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c
new file mode 100644
index 0000000..d885446
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Ofast" } */
+
+typedef struct {
+ double real;
+ double imag;
+} complex;
+typedef struct {
+ complex e[3][3];
+} su3_matrix;
+su3_matrix check_su3_c;
+double check_su3_ar, check_su3_ari, check_su3_max;
+int arireturn();
+int check_su3() {
+ check_su3_ar = check_su3_c.e[0][0].real * check_su3_c.e[1][0].real +
+ check_su3_c.e[0][0].imag * check_su3_c.e[1][0].imag +
+ check_su3_c.e[0][1].real * check_su3_c.e[1][1].real +
+ check_su3_c.e[0][1].imag * check_su3_c.e[1][1].imag +
+ check_su3_c.e[0][2].real * check_su3_c.e[1][2].real +
+ check_su3_c.e[0][2].imag * check_su3_c.e[1][2].imag;
+ check_su3_max = check_su3_c.e[0][0].real * check_su3_c.e[2][0].real +
+ check_su3_c.e[0][0].imag * check_su3_c.e[2][0].imag +
+ check_su3_c.e[0][1].real * check_su3_c.e[2][1].real +
+ check_su3_c.e[0][1].imag * check_su3_c.e[2][1].imag +
+ check_su3_c.e[0][2].real * check_su3_c.e[2][2].real +
+ check_su3_c.e[0][2].imag * check_su3_c.e[2][2].imag;
+ check_su3_ari = check_su3_ar;
+ if (check_su3_ari)
+ check_su3_max = check_su3_c.e[1][0].real * check_su3_c.e[2][0].real +
+ check_su3_c.e[1][0].imag * check_su3_c.e[2][0].imag +
+ check_su3_c.e[1][1].real * check_su3_c.e[2][1].real +
+ check_su3_c.e[1][1].imag * check_su3_c.e[2][1].imag +
+ check_su3_c.e[1][2].real * check_su3_c.e[2][2].real +
+ check_su3_c.e[1][2].imag * check_su3_c.e[2][2].imag;
+ if (check_su3_max)
+ arireturn();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr101615-1.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101615-1.c
new file mode 100644
index 0000000..d1c9c02
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101615-1.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-additional-options "-w -Wno-psabi" } */
+
+#include "tree-vect.h"
+
+typedef int v4si __attribute__((vector_size(16)));
+
+int a[4];
+int b[4];
+
+void __attribute__((noipa))
+foo (v4si x)
+{
+ b[0] = a[3] + x[0];
+ b[1] = a[2] + x[1];
+ b[2] = a[1] + x[2];
+ b[3] = a[0] + x[3];
+}
+
+int main()
+{
+ check_vect ();
+ for (int i = 0; i < 4; ++i)
+ a[i] = i;
+ v4si x = (v4si) { 8, 6, 4, 2 };
+ foo (x);
+ if (b[0] != 11 || b[1] != 8 || b[2] != 5 || b[3] != 2)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr101615-2.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101615-2.c
new file mode 100644
index 0000000..ac89883
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101615-2.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-additional-options "-O3 -w -Wno-psabi" } */
+
+#include "tree-vect.h"
+
+int res[6] = { 5, 7, 11, 3, 3, 3 };
+int a[6] = {5, 5, 8};
+int c;
+
+int main()
+{
+ check_vect ();
+ for (int b = 0; b <= 4; b++)
+ for (; c <= 4; c++) {
+ a[0] |= 1;
+ for (int e = 0; e <= 4; e++)
+ a[e + 1] |= 3;
+ }
+ for (int d = 0; d < 6; d++)
+ if (a[d] != res[d])
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c
new file mode 100644
index 0000000..de7f180
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101756.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* SIMD support can emit additional diagnostics. */
+/* { dg-additional-options "-w" } */
+
+__attribute__ ((simd)) int
+tq (long int ea, int of, int kk)
+{
+ int bc;
+
+ for (bc = 0; bc < 2; ++bc)
+ {
+ ++ea;
+ of |= !!kk < !!ea;
+ }
+
+ return of;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr54400.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr54400.c
new file mode 100644
index 0000000..6b427aa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr54400.c
@@ -0,0 +1,43 @@
+/* { dg-do run } */
+/* { dg-require-effective-target vect_float} */
+/* { dg-additional-options "-w -Wno-psabi -ffast-math" } */
+
+#include "tree-vect.h"
+
+typedef float v4sf __attribute__((vector_size(sizeof(float)*4)));
+
+float __attribute__((noipa))
+f(v4sf v)
+{
+ return v[0]+v[1]+v[2]+v[3];
+}
+
+float __attribute__((noipa))
+g(float *v)
+{
+ return v[0]+v[1]+v[2]+v[3];
+}
+
+float __attribute__((noipa))
+h(float *v)
+{
+ return 2*v[0]+3*v[1]+4*v[2]+5*v[3];
+}
+
+int
+main ()
+{
+ check_vect ();
+ v4sf v = (v4sf) { 1.f, 3.f, 4.f, 2.f };
+ if (f (v) != 10.f)
+ abort ();
+ if (g (&v[0]) != 10.f)
+ abort ();
+ if (h (&v[0]) != 37.f)
+ abort ();
+ return 0;
+}
+
+/* We are lacking an effective target for .REDUC_PLUS support. */
+/* { dg-final { scan-tree-dump-times "basic block part vectorized" 3 "slp2" { target x86_64-*-* } } } */
+/* { dg-final { scan-tree-dump-not " = VEC_PERM_EXPR" "slp2" { target x86_64-*-* } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c b/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c
index 246f38f..d9f173b 100644
--- a/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c
+++ b/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c
@@ -25,6 +25,6 @@ main1 (void)
with no word loads (lw, lwu, lwz, lwzu, or their indexed forms)
or word stores (stw, stwu, stwx, stwux, or their indexed forms). */
-/* { dg-final { scan-assembler "\t(lvx|lxv|lvsr|stxv)" } } */
+/* { dg-final { scan-assembler "\t(lvx|lxv|lvsr|stxv|plxv|pstxv)" } } */
/* { dg-final { scan-assembler-not "\tlwz?u?x? " { xfail { powerpc-ibm-aix* } } } } */
/* { dg-final { scan-assembler-not "\tstwu?x? " } } */
diff --git a/gcc/testsuite/gcc.dg/gimplefe-40.c b/gcc/testsuite/gcc.dg/vect/gimplefe-40.c
index 3c5bb4c..3c5bb4c 100644
--- a/gcc/testsuite/gcc.dg/gimplefe-40.c
+++ b/gcc/testsuite/gcc.dg/vect/gimplefe-40.c
diff --git a/gcc/testsuite/gcc.dg/gimplefe-41.c b/gcc/testsuite/gcc.dg/vect/gimplefe-41.c
index e52a3a5..e52a3a5 100644
--- a/gcc/testsuite/gcc.dg/gimplefe-41.c
+++ b/gcc/testsuite/gcc.dg/vect/gimplefe-41.c
diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
index 23a3b39..bcdf7f0 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
@@ -3,7 +3,9 @@
extern void accumulate (int x, int *a);
-int test_missing_function_defn (int *arr, int n) /* { dg-message "vectorized 0 loops in function" } */
+int test_missing_function_defn (int *arr, int n) /* { dg-note "5: vectorized 0 loops in function" } */
+/* { dg-prune-output "note: " } as we're not interested in matching any further
+ notes. */
{
int sum = 0;
for (int i = 0; i < n; ++i) /* { dg-missed "21: couldn't vectorize loop" } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr101145.c b/gcc/testsuite/gcc.dg/vect/pr101145.c
new file mode 100644
index 0000000..cd11c03
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr101145.c
@@ -0,0 +1,187 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-additional-options "-O3" } */
+#include <limits.h>
+
+unsigned __attribute__ ((noinline))
+foo (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
+{
+ while (n < ++l)
+ *a++ = *b++ + 1;
+ return l;
+}
+
+unsigned __attribute__ ((noinline))
+foo_1 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned)
+{
+ while (UINT_MAX - 64 < ++l)
+ *a++ = *b++ + 1;
+ return l;
+}
+
+unsigned __attribute__ ((noinline))
+foo_2 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
+{
+ l = UINT_MAX - 32;
+ while (n < ++l)
+ *a++ = *b++ + 1;
+ return l;
+}
+
+unsigned __attribute__ ((noinline))
+foo_3 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
+{
+ while (n <= ++l)
+ *a++ = *b++ + 1;
+ return l;
+}
+
+unsigned __attribute__ ((noinline))
+foo_4 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
+{ // infininate
+ while (0 <= ++l)
+ *a++ = *b++ + 1;
+ return l;
+}
+
+unsigned __attribute__ ((noinline))
+foo_5 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
+{
+ //no loop
+ l = UINT_MAX;
+ while (n < ++l)
+ *a++ = *b++ + 1;
+ return l;
+}
+
+unsigned __attribute__ ((noinline))
+bar (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
+{
+ while (--l < n)
+ *a++ = *b++ + 1;
+ return l;
+}
+
+unsigned __attribute__ ((noinline))
+bar_1 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned)
+{
+ while (--l < 64)
+ *a++ = *b++ + 1;
+ return l;
+}
+
+unsigned __attribute__ ((noinline))
+bar_2 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
+{
+ l = 32;
+ while (--l < n)
+ *a++ = *b++ + 1;
+ return l;
+}
+
+
+int a[3200], b[3200];
+int fail;
+
+int
+main ()
+{
+ unsigned l, n;
+ unsigned res;
+ /* l > n*/
+ n = UINT_MAX - 64;
+ l = n + 32;
+ res = foo (a, b, l, n);
+ if (res != 0)
+ fail++;
+
+ l = n;
+ res = foo (a, b, l, n);
+ if (res != 0)
+ fail++;
+
+ l = n - 1;
+ res = foo (a, b, l, n);
+ if (res != l + 1)
+ fail++;
+
+ l = n - 32;
+ res = foo (a, b, l, n);
+ if (res != l + 1)
+ fail++;
+
+ l = UINT_MAX;
+ res = foo (a, b, l, n);
+ if (res != 0)
+ fail++;
+
+ l = n + 32;
+ res = foo_1 (a, b, l, n);
+ if (res != 0)
+ fail++;
+
+ l = n + 32;
+ res = foo_2 (a, b, l, n);
+ if (res != 0)
+ fail++;
+
+ l = n;
+ res = foo_3 (a, b, l, n);
+ if (res != 0)
+ fail++;
+
+ l = n - 1;
+ res = foo_3 (a, b, l, n);
+ if (res != 0)
+ fail++;
+
+ l = n - 2;
+ res = foo_3 (a, b, l, n);
+ if (res != l + 1)
+ fail++;
+
+ res = foo_5 (a, b, l, n);
+ if (res != 0)
+ fail++;
+
+ n = 64;
+ l = n - 32;
+ res = bar (a, b, l, n);
+ res++;
+ if (res != 0)
+ fail++;
+
+ l = n;
+ res = bar (a, b, l, n);
+ res++;
+ if (res != 0)
+ fail++;
+
+ l = n + 1;
+ res = bar (a, b, l, n);
+ res++;
+ if (res != l)
+ fail++;
+
+ l = 0;
+ res = bar (a, b, l, n);
+ res++;
+ if (res != l)
+ fail++;
+
+ l = 32;
+ res = bar_1 (a, b, l, n);
+ res++;
+ if (res != 0)
+ fail++;
+
+ res = bar_1 (a, b, l, n);
+ res++;
+ if (res != 0)
+ fail++;
+
+ if (fail)
+ __builtin_abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 7 "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr101145.inc b/gcc/testsuite/gcc.dg/vect/pr101145.inc
new file mode 100644
index 0000000..615d2e5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr101145.inc
@@ -0,0 +1,65 @@
+TYPE __attribute__ ((noinline))
+foo_sign (int *__restrict__ a, int *__restrict__ b, TYPE l, TYPE n)
+{
+ TYPE i;
+ for (i = l; n < i; i += C)
+ *a++ = *b++ + 1;
+ return i;
+}
+
+TYPE __attribute__ ((noinline))
+bar_sign (int *__restrict__ a, int *__restrict__ b, TYPE l, TYPE n)
+{
+ TYPE i;
+ for (i = l; i < n; i -= C)
+ *a++ = *b++ + 1;
+ return i;
+}
+
+int __attribute__ ((noinline)) neq (int a, int b) { return a != b; }
+
+int a[1000], b[1000];
+int fail;
+
+int
+main ()
+{
+ TYPE res;
+ TYPE l;
+ TYPE n;
+ n = N_BASE;
+ l = n - C;
+ res = foo_sign (a, b, l, n);
+ if (res != l)
+ fail++;
+
+ l = n;
+ res = foo_sign (a, b, l, n);
+ if (res != l)
+ fail++;
+
+ l = n + C;
+ res = foo_sign (a, b, l, n);
+ if (neq ((res - MIN) / C, 0))
+ fail++;
+
+ n = N_BASE_DOWN;
+ l = n - C;
+ res = bar_sign (a, b, l, n);
+ if (neq ((MAX - res) / C, 0))
+ fail++;
+
+ l = n;
+ res = bar_sign (a, b, l, n);
+ if (res != l)
+ fail++;
+
+ l = n + C;
+ res = bar_sign (a, b, l, n);
+ if (res != l)
+ fail++;
+
+ if (fail)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr101145_1.c b/gcc/testsuite/gcc.dg/vect/pr101145_1.c
new file mode 100644
index 0000000..9332b2c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr101145_1.c
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-additional-options "-O3" } */
+#define TYPE signed char
+#define MIN -128
+#define MAX 127
+#define N_BASE (MAX - 32)
+#define N_BASE_DOWN (MIN + 32)
+
+#define C 3
+
+#include "pr101145.inc"
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr101145_2.c b/gcc/testsuite/gcc.dg/vect/pr101145_2.c
new file mode 100644
index 0000000..fa2c6be
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr101145_2.c
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-additional-options "-O3" } */
+#define TYPE unsigned char
+#define MIN 0
+#define MAX 255
+#define N_BASE (MAX - 32 + 1)
+#define N_BASE_DOWN (MIN + 32)
+
+#define C 2
+
+#include "pr101145.inc"
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr101145_3.c b/gcc/testsuite/gcc.dg/vect/pr101145_3.c
new file mode 100644
index 0000000..9f43c82
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr101145_3.c
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-additional-options "-O3" } */
+#define TYPE int *
+#define MIN ((TYPE)0)
+#define MAX ((TYPE)((long long)-1))
+#define N_BASE (MIN - 32)
+#define N_BASE_DOWN (MIN + 32)
+
+#define C 1
+
+#include "pr101145.inc"
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr101145inf.c b/gcc/testsuite/gcc.dg/vect/pr101145inf.c
new file mode 100644
index 0000000..ed49f56
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr101145inf.c
@@ -0,0 +1,25 @@
+/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */
+/* { dg-options "-O3" } */
+#include <limits.h>
+#include "pr101145inf.inc"
+
+__attribute__ ((noinline))
+unsigned foo(unsigned val, unsigned start)
+{
+ unsigned cnt = 0;
+ for (unsigned i = start; val <= i; i+=16)
+ cnt++;
+ return cnt;
+}
+
+void test_finite ()
+{
+ unsigned n = foo (16, UINT_MAX - 32);
+ if (n != 3)
+ __builtin_abort ();
+}
+
+void test_infinite ()
+{
+ foo (15, UINT_MAX - 32);
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr101145inf.inc b/gcc/testsuite/gcc.dg/vect/pr101145inf.inc
new file mode 100644
index 0000000..4aa3d04
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr101145inf.inc
@@ -0,0 +1,28 @@
+#include <unistd.h>
+#include <signal.h>
+#include <stdlib.h>
+
+void test_finite ();
+void test_infinite ();
+
+void do_exit (int i)
+{
+ exit (0);
+}
+
+int main(void)
+{
+ test_finite ();
+ struct sigaction s;
+ sigemptyset (&s.sa_mask);
+ s.sa_handler = do_exit;
+ s.sa_flags = 0;
+ sigaction (SIGALRM, &s, NULL);
+ alarm (1);
+
+ test_infinite ();
+
+ __builtin_abort ();
+ return 1;
+}
+
diff --git a/gcc/testsuite/gcc.dg/vect/pr101145inf_1.c b/gcc/testsuite/gcc.dg/vect/pr101145inf_1.c
new file mode 100644
index 0000000..4ee3e31
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr101145inf_1.c
@@ -0,0 +1,23 @@
+/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */
+/* { dg-options "-O3" } */
+#include <limits.h>
+#include "pr101145inf.inc"
+
+__attribute__ ((noinline))
+unsigned foo(unsigned val, unsigned start)
+{
+ unsigned cnt = 0;
+ for (unsigned i = start; i < val; i-=16)
+ cnt++;
+ return cnt;
+}
+
+void test_finite ()
+{
+ foo (UINT_MAX - 15, 32);
+}
+
+void test_infinite ()
+{
+ foo (UINT_MAX - 14, 32);
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr101445.c b/gcc/testsuite/gcc.dg/vect/pr101445.c
new file mode 100644
index 0000000..f8a6e9c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr101445.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+int a[35] = { 1, 1, 3 };
+
+void __attribute__((noipa))
+foo ()
+{
+ for (int b = 4; b >= 0; b--)
+ {
+ int tem = a[b * 5 + 3 + 1];
+ a[b * 5 + 3] = tem;
+ a[b * 5 + 2] = tem;
+ a[b * 5 + 1] = tem;
+ a[b * 5 + 0] = tem;
+ }
+}
+
+int main()
+{
+ check_vect ();
+ foo ();
+ for (int d = 0; d < 25; d++)
+ if (a[d] != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr101505.c b/gcc/testsuite/gcc.dg/vect/pr101505.c
new file mode 100644
index 0000000..e2b8945
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr101505.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O1" } */
+
+int n2;
+
+__attribute__ ((simd)) char
+w7 (void)
+{
+ short int xb = n2;
+ int qp;
+
+ for (qp = 0; qp < 2; ++qp)
+ xb = xb < 1;
+
+ return xb;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr102046.c b/gcc/testsuite/gcc.dg/vect/pr102046.c
new file mode 100644
index 0000000..ae48b49
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr102046.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3 -fvect-cost-model=dynamic" } */
+/* { dg-additional-options "-march=btver2" { target x86_64-*-* i?86-*-* } } */
+
+struct S
+{
+ unsigned a, b;
+};
+
+struct S g;
+
+void
+foo (struct S *o)
+{
+ struct S s = g;
+ s.b *= 3;
+ s.a -= s.a / 2;
+ *o = s;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr34195.c b/gcc/testsuite/gcc.dg/vect/pr34195.c
new file mode 100644
index 0000000..e36950b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr34195.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+
+#define M 11
+
+struct S
+{
+ float x;
+ float y;
+} pS[100];
+
+float a[1000];
+float b[1000];
+
+void
+foo (int n)
+{
+ int i, j;
+
+ for (i = 0; i < n; i++)
+ {
+ pS[i].x = 0;
+ pS[i].y = 0;
+
+ for (j = 0; j < M; j++)
+ {
+ pS[i].x += (a[i]+b[i]);
+ pS[i].y += (a[i]-b[i]);
+ }
+ }
+}
+
+/* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr56541.c b/gcc/testsuite/gcc.dg/vect/pr56541.c
index d5def68..fa86142 100644
--- a/gcc/testsuite/gcc.dg/vect/pr56541.c
+++ b/gcc/testsuite/gcc.dg/vect/pr56541.c
@@ -24,4 +24,4 @@ void foo()
}
}
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { ! vect_cond_mixed } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_floatint_cvt } xfail { ! vect_cond_mixed } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr65947-7.c b/gcc/testsuite/gcc.dg/vect/pr65947-7.c
index 287f57e..16cdcd1 100644
--- a/gcc/testsuite/gcc.dg/vect/pr65947-7.c
+++ b/gcc/testsuite/gcc.dg/vect/pr65947-7.c
@@ -9,7 +9,7 @@ extern void abort (void) __attribute__ ((noreturn));
/* Condition reduction with comparison is a different type to the data. Will
fail to vectorize. */
-int
+int __attribute__ ((noipa))
condition_reduction (short *a, int min_v, int *b)
{
int last = N + 65;
@@ -52,4 +52,5 @@ main (void)
return 0;
}
-/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_fold_extract_last } } } */
+/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" { target { ! vect_fold_extract_last } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr71264.c b/gcc/testsuite/gcc.dg/vect/pr71264.c
index 5f6407a..1381e0e 100644
--- a/gcc/testsuite/gcc.dg/vect/pr71264.c
+++ b/gcc/testsuite/gcc.dg/vect/pr71264.c
@@ -19,5 +19,4 @@ void test(uint8_t *ptr, uint8_t *mask)
}
}
-/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { xfail sparc*-*-* } } } */
-
+/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { xfail { { s390*-*-* sparc*-*-* } || vect32 } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr97769.c b/gcc/testsuite/gcc.dg/vect/pr97769.c
index 127f91a..59e0b46 100644
--- a/gcc/testsuite/gcc.dg/vect/pr97769.c
+++ b/gcc/testsuite/gcc.dg/vect/pr97769.c
@@ -25,7 +25,7 @@ fn2(tmp *p1)
{
char *d = (char *)p1->d1;
int *b = p1->h1;
- for (int a; a; a++, d += 4)
+ for (int a = 0; a; a++, d += 4)
fn1(d, *b++);
}
diff --git a/gcc/testsuite/gcc.dg/vect/pr97832-1.c b/gcc/testsuite/gcc.dg/vect/pr97832-1.c
new file mode 100644
index 0000000..063fc7b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr97832-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Ofast" } */
+/* { dg-require-effective-target vect_double } */
+
+double a[1024], b[1024], c[1024];
+
+void foo()
+{
+ for (int i = 0; i < 256; ++i)
+ {
+ a[2*i] = a[2*i] + b[2*i] - c[2*i];
+ a[2*i+1] = a[2*i+1] - b[2*i+1] - c[2*i+1];
+ }
+}
+
+/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */
+/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr97832-2.c b/gcc/testsuite/gcc.dg/vect/pr97832-2.c
new file mode 100644
index 0000000..4f05781
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr97832-2.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Ofast" } */
+/* { dg-require-effective-target vect_double } */
+
+void foo1x1(double* restrict y, const double* restrict x, int clen)
+{
+ int xi = clen & 2;
+ double f_re = x[0+xi+0];
+ double f_im = x[4+xi+0];
+ int clen2 = (clen+xi) * 2;
+#pragma GCC unroll 0
+ for (int c = 0; c < clen2; c += 8) {
+ // y[c] = y[c] - x[c]*conj(f);
+#pragma GCC unroll 4
+ for (int k = 0; k < 4; ++k) {
+ double x_re = x[c+0+k];
+ double x_im = x[c+4+k];
+ double y_re = y[c+0+k];
+ double y_im = y[c+4+k];
+ y_re = y_re - x_re * f_re - x_im * f_im;;
+ y_im = y_im + x_re * f_im - x_im * f_re;
+ y[c+0+k] = y_re;
+ y[c+4+k] = y_im;
+ }
+ }
+}
+
+/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */
+/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr97832-3.c b/gcc/testsuite/gcc.dg/vect/pr97832-3.c
new file mode 100644
index 0000000..ad1225d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr97832-3.c
@@ -0,0 +1,50 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Ofast" } */
+/* { dg-require-effective-target vect_double } */
+
+void foo(double* restrict y, const double* restrict x0, const double* restrict x1, int clen)
+{
+ int xi = clen & 2;
+ double f00_re = x0[0+xi+0];
+ double f10_re = x1[0+xi+0];
+ double f01_re = x0[0+xi+1];
+ double f11_re = x1[0+xi+1];
+ double f00_im = x0[4+xi+0];
+ double f10_im = x1[4+xi+0];
+ double f01_im = x0[4+xi+1];
+ double f11_im = x1[4+xi+1];
+ int clen2 = (clen+xi) * 2;
+ double* y0 = &y[0];
+ double* y1 = &y[clen2];
+ #pragma GCC unroll 0
+ for (int c = 0; c < clen2; c += 8) {
+ // y0[c] = y0[c] - x0[c]*conj(f00) - x1[c]*conj(f10);
+ // y1[c] = y1[c] - x0[c]*conj(f01) - x1[c]*conj(f11);
+ #pragma GCC unroll 4
+ for (int k = 0; k < 4; ++k) {
+ double x0_re = x0[c+0+k];
+ double x0_im = x0[c+4+k];
+ double y0_re = y0[c+0+k];
+ double y0_im = y0[c+4+k];
+ double y1_re = y1[c+0+k];
+ double y1_im = y1[c+4+k];
+ y0_re = y0_re - x0_re * f00_re - x0_im * f00_im;
+ y0_im = y0_im + x0_re * f00_im - x0_im * f00_re;
+ y1_re = y1_re - x0_re * f01_re - x0_im * f01_im;
+ y1_im = y1_im + x0_re * f01_im - x0_im * f01_re;
+ double x1_re = x1[c+0+k];
+ double x1_im = x1[c+4+k];
+ y0_re = y0_re - x1_re * f10_re - x1_im * f10_im;
+ y0_im = y0_im + x1_re * f10_im - x1_im * f10_re;
+ y1_re = y1_re - x1_re * f11_re - x1_im * f11_im;
+ y1_im = y1_im + x1_re * f11_im - x1_im * f11_re;
+ y0[c+0+k] = y0_re;
+ y0[c+4+k] = y0_im;
+ y1[c+0+k] = y1_re;
+ y1[c+4+k] = y1_im;
+ }
+ }
+}
+
+/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */
+/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr97832-4.c b/gcc/testsuite/gcc.dg/vect/pr97832-4.c
new file mode 100644
index 0000000..74ae27f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr97832-4.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Ofast" } */
+/* { dg-require-effective-target vect_double } */
+
+void foo1x1(double* restrict y, const double* restrict x, int clen)
+{
+ int xi = clen & 2;
+ double f_re = x[0+xi+0];
+ double f_im = x[4+xi+0];
+ int clen2 = (clen+xi) * 2;
+#pragma GCC unroll 0
+ for (int c = 0; c < clen2; c += 8) {
+#pragma GCC unroll 4
+ for (int k = 0; k < 4; ++k) {
+ double x_re = x[k];
+ double x_im = x[c+4+k];
+ double y_re = y[c+0+k];
+ double y_im = y[c+4+k];
+ y_re = y_re - x_re * f_re - x_im * f_im;;
+ y_im = y_im + x_re * f_im - x_im * f_re;
+ y[c+0+k] = y_re;
+ y[c+4+k] = y_im;
+ }
+ }
+}
+
+/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */
+/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr99102.c b/gcc/testsuite/gcc.dg/vect/pr99102.c
index 62d4d33..6c1a13f 100644
--- a/gcc/testsuite/gcc.dg/vect/pr99102.c
+++ b/gcc/testsuite/gcc.dg/vect/pr99102.c
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -ftree-vectorize" } */
+/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details" } */
/* { dg-additional-options "-msve-vector-bits=256" { target aarch64_sve256_hw } } */
long a[44];
short d, e = -7;
diff --git a/gcc/testsuite/gcc.dg/vect/pr99540.c b/gcc/testsuite/gcc.dg/vect/pr99540.c
new file mode 100644
index 0000000..9136b09
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr99540.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftrapv -ffloat-store -march=armv8.2-a+sve" { target aarch64*-*-* } } */
+
+float *MSalign2m2m_rec_initverticalw, *MSalign2m2m_rec_currentw;
+
+void
+match_ribosum (int MSalign2m2m_rec_i, int MSalign2m2m_rec_lgth1,
+ int MSalign2m2m_rec_lgth2)
+{
+ float **WMMTX;
+
+ while (MSalign2m2m_rec_i < 1)
+ WMMTX[MSalign2m2m_rec_i++][0] = MSalign2m2m_rec_initverticalw[0];
+
+ while (MSalign2m2m_rec_i < MSalign2m2m_rec_lgth1)
+ MSalign2m2m_rec_initverticalw[MSalign2m2m_rec_i++] += 0.1;
+
+ while (MSalign2m2m_rec_i < MSalign2m2m_rec_lgth2)
+ MSalign2m2m_rec_currentw[MSalign2m2m_rec_i++] += 0.1;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr99856.c b/gcc/testsuite/gcc.dg/vect/pr99856.c
new file mode 100644
index 0000000..e5d2a45
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr99856.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target vect_unpack } */
+/* { dg-require-effective-target vect_pack_trunc } */
+
+#define SHIFTFORDIV255(a)\
+ ((((a) >> 8) + a) >> 8)
+
+#define DIV255(a)\
+ SHIFTFORDIV255(a + 0x80)
+
+typedef unsigned char uint8_t;
+
+void
+opSourceOver_premul(uint8_t* restrict Rrgba,
+ const uint8_t* restrict Srgba,
+ const uint8_t* restrict Drgba, int len)
+{
+ Rrgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__);
+ Srgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__);
+ Drgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__);
+ int i = 0;
+ for (; i < len*4; i += 4)
+ {
+ uint8_t Sa = Srgba[i + 3];
+ Rrgba[i + 0] = DIV255(Srgba[i + 0] * 255 + Drgba[i + 0] * (255 - Sa));
+ Rrgba[i + 1] = DIV255(Srgba[i + 1] * 255 + Drgba[i + 1] * (255 - Sa));
+ Rrgba[i + 2] = DIV255(Srgba[i + 2] * 255 + Drgba[i + 2] * (255 - Sa));
+ Rrgba[i + 3] = DIV255(Srgba[i + 3] * 255 + Drgba[i + 3] * (255 - Sa));
+ }
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/slp-21.c b/gcc/testsuite/gcc.dg/vect/slp-21.c
index bf8f434..4b83adb 100644
--- a/gcc/testsuite/gcc.dg/vect/slp-21.c
+++ b/gcc/testsuite/gcc.dg/vect/slp-21.c
@@ -210,7 +210,7 @@ int main (void)
Not all vect_perm targets support that, and it's a bit too specific to have
its own effective-target selector, so we just test targets directly. */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target { aarch64*-*-* arm*-*-* powerpc64*-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_strided4 && { ! { aarch64*-*-* arm*-*-* powerpc64*-*-* } } } } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target { powerpc64*-*-* s390*-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_strided4 && { ! { powerpc64*-*-* s390*-*-* } } } } } } */
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { ! { vect_strided4 } } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/slp-28.c b/gcc/testsuite/gcc.dg/vect/slp-28.c
index 7778bad..0bb5f0eb 100644
--- a/gcc/testsuite/gcc.dg/vect/slp-28.c
+++ b/gcc/testsuite/gcc.dg/vect/slp-28.c
@@ -88,6 +88,7 @@ int main (void)
return 0;
}
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { ! vect32 } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target vect32 } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { ! vect32 } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/slp-3.c b/gcc/testsuite/gcc.dg/vect/slp-3.c
index 46ab584..80ded18 100644
--- a/gcc/testsuite/gcc.dg/vect/slp-3.c
+++ b/gcc/testsuite/gcc.dg/vect/slp-3.c
@@ -141,8 +141,8 @@ int main (void)
return 0;
}
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { ! vect_partial_vectors } } } } */
-/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target vect_partial_vectors } } } */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" { target { ! vect_partial_vectors } } } }*/
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target vect_partial_vectors } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { ! { vect_partial_vectors || vect32 } } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target { vect_partial_vectors || vect32 } } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" { target { ! { vect_partial_vectors || vect32 } } } } }*/
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target { vect_partial_vectors || vect32 } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/slp-50.c b/gcc/testsuite/gcc.dg/vect/slp-50.c
new file mode 100644
index 0000000..17509e6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/slp-50.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ffast-math" } */
+
+typedef int Quantum;
+typedef struct {
+ Quantum blue, green;
+} PixelPacket;
+PixelPacket *EnhanceImage_image_q;
+int EnhanceImage_image_x;
+float EnhanceImage_image_distance_squared_total_weight;
+void EnhanceImage_image_distance_squared()
+{
+ float zero_1;
+ for (; EnhanceImage_image_x; EnhanceImage_image_x++) {
+ EnhanceImage_image_distance_squared_total_weight += 5.0;
+ EnhanceImage_image_q->green = EnhanceImage_image_q->blue =
+ zero_1 + EnhanceImage_image_distance_squared_total_weight / 2 - 1;
+ EnhanceImage_image_q++;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/vect/slp-perm-9.c b/gcc/testsuite/gcc.dg/vect/slp-perm-9.c
index ab75f44..873eddf 100644
--- a/gcc/testsuite/gcc.dg/vect/slp-perm-9.c
+++ b/gcc/testsuite/gcc.dg/vect/slp-perm-9.c
@@ -57,13 +57,13 @@ int main (int argc, const char* argv[])
return 0;
}
-/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect" { target { ! { vect_perm_short || vect_load_lanes } } } } } */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_perm_short || vect_load_lanes } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect" { target { ! { { vect_perm_short || vect32 } || vect_load_lanes } } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { { vect_perm_short || vect32 } || vect_load_lanes } } } } */
/* We don't try permutes with a group size of 3 for variable-length
vectors. */
/* { dg-final { scan-tree-dump-times "permutation requires at least three vectors" 1 "vect" { target { vect_perm_short && { { ! vect_perm3_short } && { ! vect_partial_vectors_usage_1 } } } xfail vect_variable_length } } } */
/* Try to vectorize the epilogue using partial vectors. */
/* { dg-final { scan-tree-dump-times "permutation requires at least three vectors" 2 "vect" { target { vect_perm_short && { { ! vect_perm3_short } && vect_partial_vectors_usage_1 } } xfail vect_variable_length } } } */
/* { dg-final { scan-tree-dump-not "permutation requires at least three vectors" "vect" { target vect_perm3_short } } } */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { { ! vect_perm3_short } || vect_load_lanes } } } } */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_short && { ! vect_load_lanes } } } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { { ! { vect_perm3_short || vect32 } } || vect_load_lanes } } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { { vect_perm3_short || vect32 } && { ! vect_load_lanes } } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/slp-reduc-11.c b/gcc/testsuite/gcc.dg/vect/slp-reduc-11.c
index a2f86fb..260d65c 100644
--- a/gcc/testsuite/gcc.dg/vect/slp-reduc-11.c
+++ b/gcc/testsuite/gcc.dg/vect/slp-reduc-11.c
@@ -16,5 +16,5 @@ double dotprod(const double *a, const double *b, unsigned long long n)
/* We should use a SLP reduction even without -ffast-math by using a
VF of one. */
-/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */
+/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { xfail vect_variable_length } } } */
/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-bool-cmp.c b/gcc/testsuite/gcc.dg/vect/vect-bool-cmp.c
index 35d2a3c..c97da52 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-bool-cmp.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-bool-cmp.c
@@ -253,4 +253,4 @@ main (int argc, char **argv)
check (res, ne);
}
-/* { dg-final { scan-tree-dump-times "VECTORIZED" 18 "vect" { target sse4_runtime } } } */
+/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 18 "vect" { target sse4_runtime } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-complex-5.c b/gcc/testsuite/gcc.dg/vect/vect-complex-5.c
index 81fdb67c..addcf60 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-complex-5.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-complex-5.c
@@ -40,4 +40,5 @@ main (void)
return 0;
}
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { xfail { ! vect_hw_misalign } } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { ! vect_load_lanes } xfail { ! vect_hw_misalign } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-3.c b/gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-3.c
index dbf5091..1666526 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-3.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-3.c
@@ -1,4 +1,4 @@
-/* { dg-additional-options "-fdump-tree-cunroll-details" } */
+/* { dg-additional-options "-fdump-tree-cunroll-details --param vect-epilogues-nomask=0" } */
#include "tree-vect.h"
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-10.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-10.c
new file mode 100644
index 0000000..7ce8696
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-10.c
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#define SIGNEDNESS_1 unsigned
+#define SIGNEDNESS_2 unsigned
+#define SIGNEDNESS_3 unsigned
+#define SIGNEDNESS_4 signed
+
+#include "vect-reduc-dot-9.c"
+
+/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_usdot_qi } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-11.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-11.c
new file mode 100644
index 0000000..0f7cbbb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-11.c
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#define SIGNEDNESS_1 unsigned
+#define SIGNEDNESS_2 signed
+#define SIGNEDNESS_3 unsigned
+#define SIGNEDNESS_4 signed
+
+#include "vect-reduc-dot-9.c"
+
+/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_usdot_qi } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-12.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-12.c
new file mode 100644
index 0000000..0841261
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-12.c
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#define SIGNEDNESS_1 unsigned
+#define SIGNEDNESS_2 signed
+#define SIGNEDNESS_3 signed
+#define SIGNEDNESS_4 unsigned
+
+#include "vect-reduc-dot-9.c"
+
+/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_usdot_qi } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-13.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-13.c
new file mode 100644
index 0000000..7ee0f45
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-13.c
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#define SIGNEDNESS_1 signed
+#define SIGNEDNESS_2 unsigned
+#define SIGNEDNESS_3 signed
+#define SIGNEDNESS_4 unsigned
+
+#include "vect-reduc-dot-9.c"
+
+/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_usdot_qi } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-14.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-14.c
new file mode 100644
index 0000000..2de1434
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-14.c
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#define SIGNEDNESS_1 signed
+#define SIGNEDNESS_2 unsigned
+#define SIGNEDNESS_3 unsigned
+#define SIGNEDNESS_4 signed
+
+#include "vect-reduc-dot-9.c"
+
+/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_usdot_qi } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-15.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-15.c
new file mode 100644
index 0000000..dc48f95
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-15.c
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#define SIGNEDNESS_1 signed
+#define SIGNEDNESS_2 signed
+#define SIGNEDNESS_3 unsigned
+#define SIGNEDNESS_4 signed
+
+#include "vect-reduc-dot-9.c"
+
+/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_usdot_qi } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-16.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-16.c
new file mode 100644
index 0000000..aec6287
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-16.c
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#define SIGNEDNESS_1 signed
+#define SIGNEDNESS_2 signed
+#define SIGNEDNESS_3 signed
+#define SIGNEDNESS_4 unsigned
+
+#include "vect-reduc-dot-9.c"
+
+/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_usdot_qi } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-17.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-17.c
new file mode 100644
index 0000000..38f86fe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-17.c
@@ -0,0 +1,53 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#include "tree-vect.h"
+
+#define N 50
+
+#ifndef SIGNEDNESS_1
+#define SIGNEDNESS_1 unsigned
+#define SIGNEDNESS_2 unsigned
+#define SIGNEDNESS_3 signed
+#define SIGNEDNESS_4 unsigned
+#endif
+
+SIGNEDNESS_1 int __attribute__ ((noipa))
+f (SIGNEDNESS_1 int res, SIGNEDNESS_3 char *restrict a,
+ SIGNEDNESS_4 char *restrict b)
+{
+ for (__INTPTR_TYPE__ i = 0; i < N; ++i)
+ {
+ int av = a[i];
+ int bv = b[i];
+ SIGNEDNESS_2 int mult = av * bv;
+ res += mult;
+ }
+ return res;
+}
+
+#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4)
+#define OFFSET 20
+
+int
+main (void)
+{
+ check_vect ();
+
+ SIGNEDNESS_3 char a[N];
+ SIGNEDNESS_4 char b[N];
+ SIGNEDNESS_1 int expected = 0x12345;
+ for (int i = 0; i < N; ++i)
+ {
+ a[i] = BASE + i * 5;
+ b[i] = BASE + OFFSET + i * 4;
+ asm volatile ("" ::: "memory");
+ expected += (SIGNEDNESS_2 int) (a[i] * b[i]);
+ }
+ if (f (0x12345, a, b) != expected)
+ __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_usdot_qi } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-18.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-18.c
new file mode 100644
index 0000000..2e86ebe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-18.c
@@ -0,0 +1,53 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#include "tree-vect.h"
+
+#define N 50
+
+#ifndef SIGNEDNESS_1
+#define SIGNEDNESS_1 unsigned
+#define SIGNEDNESS_2 signed
+#define SIGNEDNESS_3 signed
+#define SIGNEDNESS_4 unsigned
+#endif
+
+SIGNEDNESS_1 int __attribute__ ((noipa))
+f (SIGNEDNESS_1 int res, SIGNEDNESS_3 char *restrict a,
+ SIGNEDNESS_4 char *restrict b)
+{
+ for (__INTPTR_TYPE__ i = 0; i < N; ++i)
+ {
+ int av = a[i];
+ int bv = b[i];
+ SIGNEDNESS_2 int mult = av * bv;
+ res += mult;
+ }
+ return res;
+}
+
+#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4)
+#define OFFSET 20
+
+int
+main (void)
+{
+ check_vect ();
+
+ SIGNEDNESS_3 char a[N];
+ SIGNEDNESS_4 char b[N];
+ SIGNEDNESS_1 int expected = 0x12345;
+ for (int i = 0; i < N; ++i)
+ {
+ a[i] = BASE + i * 5;
+ b[i] = BASE + OFFSET + i * 4;
+ asm volatile ("" ::: "memory");
+ expected += (SIGNEDNESS_2 int) (a[i] * b[i]);
+ }
+ if (f (0x12345, a, b) != expected)
+ __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_usdot_qi } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-19.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-19.c
new file mode 100644
index 0000000..d00f24a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-19.c
@@ -0,0 +1,52 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#include "tree-vect.h"
+
+#define N 50
+
+#ifndef SIGNEDNESS_1
+#define SIGNEDNESS_1 unsigned
+#define SIGNEDNESS_2 signed
+#define SIGNEDNESS_3 signed
+#define SIGNEDNESS_4 unsigned
+#endif
+
+SIGNEDNESS_1 long long __attribute__ ((noipa))
+f (SIGNEDNESS_1 long long res, SIGNEDNESS_3 char *restrict a,
+ SIGNEDNESS_4 short *restrict b)
+{
+ for (__INTPTR_TYPE__ i = 0; i < N; ++i)
+ {
+ int av = a[i];
+ int bv = b[i];
+ SIGNEDNESS_2 long long mult = av * bv;
+ res += mult;
+ }
+ return res;
+}
+
+#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4)
+#define OFFSET 20
+
+int
+main (void)
+{
+ check_vect ();
+
+ SIGNEDNESS_3 char a[N];
+ SIGNEDNESS_4 short b[N];
+ SIGNEDNESS_1 long long expected = 0x12345;
+ for (int i = 0; i < N; ++i)
+ {
+ a[i] = BASE + i * 5;
+ b[i] = BASE + OFFSET + i * 4;
+ asm volatile ("" ::: "memory");
+ expected += (SIGNEDNESS_2 int) (a[i] * b[i]);
+ }
+ if (f (0x12345, a, b) != expected)
+ __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-20.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-20.c
new file mode 100644
index 0000000..17adbca8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-20.c
@@ -0,0 +1,52 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#include "tree-vect.h"
+
+#define N 50
+
+#ifndef SIGNEDNESS_1
+#define SIGNEDNESS_1 unsigned
+#define SIGNEDNESS_2 signed
+#define SIGNEDNESS_3 signed
+#define SIGNEDNESS_4 unsigned
+#endif
+
+SIGNEDNESS_1 long long __attribute__ ((noipa))
+f (SIGNEDNESS_1 long long res, SIGNEDNESS_3 short *restrict a,
+ SIGNEDNESS_4 char *restrict b)
+{
+ for (__INTPTR_TYPE__ i = 0; i < N; ++i)
+ {
+ int av = a[i];
+ int bv = b[i];
+ SIGNEDNESS_2 long long mult = av * bv;
+ res += mult;
+ }
+ return res;
+}
+
+#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4)
+#define OFFSET 20
+
+int
+main (void)
+{
+ check_vect ();
+
+ SIGNEDNESS_3 short a[N];
+ SIGNEDNESS_4 char b[N];
+ SIGNEDNESS_1 long long expected = 0x12345;
+ for (int i = 0; i < N; ++i)
+ {
+ a[i] = BASE + i * 5;
+ b[i] = BASE + OFFSET + i * 4;
+ asm volatile ("" ::: "memory");
+ expected += (SIGNEDNESS_2 int) (a[i] * b[i]);
+ }
+ if (f (0x12345, a, b) != expected)
+ __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-21.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-21.c
new file mode 100644
index 0000000..6cc6a4f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-21.c
@@ -0,0 +1,52 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#include "tree-vect.h"
+
+#define N 50
+
+#ifndef SIGNEDNESS_1
+#define SIGNEDNESS_1 unsigned
+#define SIGNEDNESS_2 signed
+#define SIGNEDNESS_3 signed
+#define SIGNEDNESS_4 unsigned
+#endif
+
+SIGNEDNESS_1 long long __attribute__ ((noipa))
+f (SIGNEDNESS_1 long long res, SIGNEDNESS_3 char *restrict a,
+ SIGNEDNESS_4 short *restrict b)
+{
+ for (__INTPTR_TYPE__ i = 0; i < N; ++i)
+ {
+ int av = a[i];
+ int bv = b[i];
+ SIGNEDNESS_2 int mult = av * bv;
+ res += mult;
+ }
+ return res;
+}
+
+#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4)
+#define OFFSET 20
+
+int
+main (void)
+{
+ check_vect ();
+
+ SIGNEDNESS_3 char a[N];
+ SIGNEDNESS_4 short b[N];
+ SIGNEDNESS_1 long long expected = 0x12345;
+ for (int i = 0; i < N; ++i)
+ {
+ a[i] = BASE + i * 5;
+ b[i] = BASE + OFFSET + i * 4;
+ asm volatile ("" ::: "memory");
+ expected += (SIGNEDNESS_2 int) (a[i] * b[i]);
+ }
+ if (f (0x12345, a, b) != expected)
+ __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-22.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-22.c
new file mode 100644
index 0000000..e13d3d5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-22.c
@@ -0,0 +1,52 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#include "tree-vect.h"
+
+#define N 50
+
+#ifndef SIGNEDNESS_1
+#define SIGNEDNESS_1 unsigned
+#define SIGNEDNESS_2 unsigned
+#define SIGNEDNESS_3 signed
+#define SIGNEDNESS_4 unsigned
+#endif
+
+SIGNEDNESS_1 long long __attribute__ ((noipa))
+f (SIGNEDNESS_1 long long res, SIGNEDNESS_3 char *restrict a,
+ SIGNEDNESS_4 short *restrict b)
+{
+ for (__INTPTR_TYPE__ i = 0; i < N; ++i)
+ {
+ int av = a[i];
+ int bv = b[i];
+ SIGNEDNESS_2 int mult = av * bv;
+ res += mult;
+ }
+ return res;
+}
+
+#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4)
+#define OFFSET 20
+
+int
+main (void)
+{
+ check_vect ();
+
+ SIGNEDNESS_3 char a[N];
+ SIGNEDNESS_4 short b[N];
+ SIGNEDNESS_1 long long expected = 0x12345;
+ for (int i = 0; i < N; ++i)
+ {
+ a[i] = BASE + i * 5;
+ b[i] = BASE + OFFSET + i * 4;
+ asm volatile ("" ::: "memory");
+ expected += (SIGNEDNESS_2 int) (a[i] * b[i]);
+ }
+ if (f (0x12345, a, b) != expected)
+ __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-9.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-9.c
new file mode 100644
index 0000000..d1049c9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-9.c
@@ -0,0 +1,53 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target arm_v8_2a_i8mm_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
+/* { dg-add-options arm_v8_2a_i8mm } */
+
+#include "tree-vect.h"
+
+#define N 50
+
+#ifndef SIGNEDNESS_1
+#define SIGNEDNESS_1 unsigned
+#define SIGNEDNESS_2 unsigned
+#define SIGNEDNESS_3 signed
+#define SIGNEDNESS_4 unsigned
+#endif
+
+SIGNEDNESS_1 int __attribute__ ((noipa))
+f (SIGNEDNESS_1 int res, SIGNEDNESS_3 char *restrict a,
+ SIGNEDNESS_4 char *restrict b)
+{
+ for (__INTPTR_TYPE__ i = 0; i < N; ++i)
+ {
+ int av = a[i];
+ int bv = b[i];
+ SIGNEDNESS_2 short mult = av * bv;
+ res += mult;
+ }
+ return res;
+}
+
+#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4)
+#define OFFSET 20
+
+int
+main (void)
+{
+ check_vect ();
+
+ SIGNEDNESS_3 char a[N];
+ SIGNEDNESS_4 char b[N];
+ SIGNEDNESS_1 int expected = 0x12345;
+ for (int i = 0; i < N; ++i)
+ {
+ a[i] = BASE + i * 5;
+ b[i] = BASE + OFFSET + i * 4;
+ asm volatile ("" ::: "memory");
+ expected += (SIGNEDNESS_2 short) (a[i] * b[i]);
+ }
+ if (f (0x12345, a, b) != expected)
+ __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_usdot_qi } } } */
diff --git a/gcc/testsuite/gcc.dg/vla-stexp-1.c b/gcc/testsuite/gcc.dg/vla-stexp-1.c
new file mode 100644
index 0000000..97d6693
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vla-stexp-1.c
@@ -0,0 +1,18 @@
+/* PR29970*/
+/* { dg-do run } */
+/* { dg-options "-Wall -O0" } */
+
+int foo(void)
+{
+ int n = 0;
+ return sizeof(*({ n = 10; struct foo { int x[n]; } x; &x; }));
+}
+
+
+int main()
+{
+ if (sizeof(struct foo { int x[10]; }) != foo())
+ __builtin_abort();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vla-stexp-2.c b/gcc/testsuite/gcc.dg/vla-stexp-2.c
new file mode 100644
index 0000000..176f400
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vla-stexp-2.c
@@ -0,0 +1,33 @@
+/* PR101838 */
+/* { dg-do run } */
+/* { dg-options "-Wpedantic -O0" } */
+
+
+int bar0(
+ int (*a)[*],
+ int (*b)[sizeof(*a)]
+);
+
+
+int bar(
+ struct f { /* { dg-warning "will not be visible outside of this definition" } */
+ int a[*]; } v, /* { dg-warning "variably modified type" } */
+ int (*b)[sizeof(struct f)] // should not warn about zero size
+);
+
+int foo(void)
+{
+ int n = 0;
+ return sizeof(typeof(*({ n = 10; struct foo { /* { dg-warning "braced-groups" } */
+ int x[n]; /* { dg-warning "variably modified type" } */
+ } x; &x; })));
+}
+
+
+int main()
+{
+ if (sizeof(struct foo { int x[10]; }) != foo())
+ __builtin_abort();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/warn-strnlen-no-nul.c b/gcc/testsuite/gcc.dg/warn-strnlen-no-nul.c
index 2afd2b5..846e930 100644
--- a/gcc/testsuite/gcc.dg/warn-strnlen-no-nul.c
+++ b/gcc/testsuite/gcc.dg/warn-strnlen-no-nul.c
@@ -143,14 +143,17 @@ T (v0 ? b[1] : "", bsz);
T (v0 ? b[2] : "", bsz);
T (v0 ? b[3] : "", bsz);
-T (v0 ? "" : b[0], bsz + 1); /* { dg-warning "bound 6 may exceed source size 5" } */
-T (v0 ? "" : b[1], bsz + 1);
-T (v0 ? "" : b[2], bsz + 1);
-T (v0 ? "" : b[3], bsz + 1); /* { dg-warning "unterminated" "pr86937" { xfail *-*-* } } */
-T (v0 ? b[0] : "", bsz + 1); /* { dg-warning "bound 6 may exceed source size 5" } */
-T (v0 ? b[1] : "", bsz + 1);
-T (v0 ? b[2] : "", bsz + 1);
-T (v0 ? b[3] : "", bsz + 1); /* { dg-warning "unterminated" "pr86937" { xfail *-*-* } } */
+/* The warnings below are strictly correct but the strnlen calls are safe
+ because the reads are bounded by the length of the constant arguments.
+ It might make sense to relax the warning to avoid triggering for them. */
+T (v0 ? "" : b[0], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? "" : b[1], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? "" : b[2], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? "" : b[3], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? b[0] : "", bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? b[1] : "", bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? b[2] : "", bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? b[3] : "", bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
T (v0 ? "" : b[i0], bsz);
T (v0 ? "" : b[i1], bsz);
@@ -164,11 +167,11 @@ T (v0 ? b[i3] : "", bsz);
T (v0 ? "" : b[i0], bsz + 1);
T (v0 ? "" : b[i1], bsz + 1);
T (v0 ? "" : b[i2], bsz + 1);
-T (v0 ? "" : b[i3], bsz + 1); /* { dg-warning "unterminated" "pr86937" { xfail *-*-* } } */
+T (v0 ? "" : b[i3], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" "pr86937" } */
T (v0 ? b[i0] : "", bsz + 1);
T (v0 ? b[i1] : "", bsz + 1);
T (v0 ? b[i2] : "", bsz + 1);
-T (v0 ? b[i3] : "", bsz + 1); /* { dg-warning "unterminated" "pr86937" { xfail *-*-* } } */
+T (v0 ? b[i3] : "", bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" "pr86937" } */
T (v0 ? "1234" : b[3], bsz);
T (v0 ? "1234" : b[i3], bsz);
@@ -180,15 +183,15 @@ T (v0 ? b[0] : b[2], bsz);
T (v0 ? b[2] : b[3], bsz);
T (v0 ? b[3] : b[2], bsz);
-T (v0 ? "1234" : b[3], bsz + 1); /* { dg-warning "unterminated" "pr86937" { xfail *-*-* } } */
-T (v0 ? "1234" : b[i3], bsz + 1); /* { dg-warning "unterminated" "pr86937" { xfail *-*-* } } */
-T (v0 ? b[3] : "1234", bsz + 1); /* { dg-warning "unterminated" "pr86937" { xfail *-*-* } } */
-T (v0 ? b[i3] : "1234", bsz + 1); /* { dg-warning "unterminated" "pr86937" { xfail *-*-* } } */
+T (v0 ? "1234" : b[3], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? "1234" : b[i3], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? b[3] : "1234", bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? b[i3] : "1234", bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
-T (v0 ? a : b[3], bsz + 1); /* { dg-warning "bound 6 may exceed source size 5" "pr86937" { xfail *-*-*} } */
-T (v0 ? b[0] : b[2], bsz + 1); /* { dg-warning "bound 6 may exceed source size 5" "pr86937" } */
-T (v0 ? b[2] : b[3], bsz + 1); /* { dg-warning "unterminated" "pr86937" { xfail *-*-* } } */
-T (v0 ? b[3] : b[2], bsz + 1); /* { dg-warning "unterminated" "pr86937" { xfail *-*-* } } */
+T (v0 ? a : b[3], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? b[0] : b[2], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? b[2] : b[3], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
+T (v0 ? b[3] : b[2], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */
struct A { char a[5], b[5]; };