summaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/c-c++-common')
-rw-r--r--gcc/testsuite/c-c++-common/Waddress-1.c15
-rw-r--r--gcc/testsuite/c-c++-common/Wbool-compare-1.c5
-rw-r--r--gcc/testsuite/c-c++-common/Wbool-compare-2.c100
-rw-r--r--gcc/testsuite/c-c++-common/Wbool-compare-3.c30
-rw-r--r--gcc/testsuite/c-c++-common/Wduplicated-cond-1.c200
-rw-r--r--gcc/testsuite/c-c++-common/Wduplicated-cond-2.c201
-rw-r--r--gcc/testsuite/c-c++-common/Wduplicated-cond-3.c204
-rw-r--r--gcc/testsuite/c-c++-common/Wduplicated-cond-4.c32
-rw-r--r--gcc/testsuite/c-c++-common/Wlogical-op-1.c109
-rw-r--r--gcc/testsuite/c-c++-common/Wlogical-op-3.c22
-rw-r--r--gcc/testsuite/c-c++-common/Wmisleading-indentation-2.c56
-rw-r--r--gcc/testsuite/c-c++-common/Wmisleading-indentation-2.md46
-rw-r--r--gcc/testsuite/c-c++-common/Wmisleading-indentation-3.c82
-rw-r--r--gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c11
-rw-r--r--gcc/testsuite/c-c++-common/Wmisleading-indentation.c1240
-rw-r--r--gcc/testsuite/c-c++-common/Wparentheses-1.c39
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-negative-value-1.c51
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-negative-value-2.c52
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-negative-value-3.c52
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-negative-value-4.c52
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-negative-value-5.c50
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-negative-value-6.c50
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-overflow-1.c63
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-overflow-2.c63
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-overflow-3.c64
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-overflow-4.c64
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-overflow-5.c11
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-overflow-6.c37
-rw-r--r--gcc/testsuite/c-c++-common/Wshift-overflow-7.c37
-rw-r--r--gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess1.c2
-rw-r--r--gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess2.c2
-rw-r--r--gcc/testsuite/c-c++-common/Wtautological-compare-1.c70
-rw-r--r--gcc/testsuite/c-c++-common/Wtautological-compare-2.c13
-rw-r--r--gcc/testsuite/c-c++-common/Wtautological-compare-3.c20
-rw-r--r--gcc/testsuite/c-c++-common/Wtautological-compare-4.c15
-rw-r--r--gcc/testsuite/c-c++-common/Wunused-function-1.c10
-rw-r--r--gcc/testsuite/c-c++-common/Wunused-var-13.c1
-rw-r--r--gcc/testsuite/c-c++-common/Wunused-var-6.c1
-rw-r--r--gcc/testsuite/c-c++-common/Wunused-var-8.c1
-rw-r--r--gcc/testsuite/c-c++-common/Wvarargs.c2
-rw-r--r--gcc/testsuite/c-c++-common/asan/aggressive-opts.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/halt_on_error-1.c23
-rw-r--r--gcc/testsuite/c-c++-common/asan/halt_on_error-2.c24
-rw-r--r--gcc/testsuite/c-c++-common/asan/inc.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/memcmp-1.c6
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-asan-check-glob.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-asan-stack.c4
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-10.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-11.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-12.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-13.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-14.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-15.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-3.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-4.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-5.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-6.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-7.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-8.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/pr70541.c34
-rw-r--r--gcc/testsuite/c-c++-common/asan/red-align-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/red-align-2.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c4
-rw-r--r--gcc/testsuite/c-c++-common/asan/shadow-offset-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/asan/swapcontext-test-1.c4
-rw-r--r--gcc/testsuite/c-c++-common/asan/user-section-1.c10
-rw-r--r--gcc/testsuite/c-c++-common/asan/user-section-2.c10
-rw-r--r--gcc/testsuite/c-c++-common/asan/user-section-3.c10
-rw-r--r--gcc/testsuite/c-c++-common/attr-simd-2.c23
-rw-r--r--gcc/testsuite/c-c++-common/attr-simd-3.c5
-rw-r--r--gcc/testsuite/c-c++-common/attr-simd-4.c42
-rw-r--r--gcc/testsuite/c-c++-common/attr-simd-5.c7
-rw-r--r--gcc/testsuite/c-c++-common/attr-simd.c42
-rw-r--r--gcc/testsuite/c-c++-common/attributes-enum-1.c22
-rw-r--r--gcc/testsuite/c-c++-common/attributes-enum-2.c14
-rw-r--r--gcc/testsuite/c-c++-common/builtin-offsetof-2.c217
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/AN/an-if.c5
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/AN/fn_ptr-2.c14
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c69
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c5
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/pr60586.c28
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-1.c25
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-2.c6
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c15
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c17
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c41
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/PS/body.c2
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/PS/clauses2.c1
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/PS/safelen.c1
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/PS/vectorlength-3.c1
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/SE/ef_error2.c4
-rw-r--r--gcc/testsuite/c-c++-common/conflict-markers-1.c11
-rw-r--r--gcc/testsuite/c-c++-common/conflict-markers-10.c25
-rw-r--r--gcc/testsuite/c-c++-common/conflict-markers-11.c14
-rw-r--r--gcc/testsuite/c-c++-common/conflict-markers-2.c2
-rw-r--r--gcc/testsuite/c-c++-common/conflict-markers-3.c11
-rw-r--r--gcc/testsuite/c-c++-common/conflict-markers-4.c11
-rw-r--r--gcc/testsuite/c-c++-common/conflict-markers-5.c11
-rw-r--r--gcc/testsuite/c-c++-common/conflict-markers-6.c38
-rw-r--r--gcc/testsuite/c-c++-common/conflict-markers-7.c6
-rw-r--r--gcc/testsuite/c-c++-common/conflict-markers-8.c4
-rw-r--r--gcc/testsuite/c-c++-common/conflict-markers-9.c8
-rw-r--r--gcc/testsuite/c-c++-common/cpp/openmp-define-3.c2
-rw-r--r--gcc/testsuite/c-c++-common/cpp/pr57580.c9
-rw-r--r--gcc/testsuite/c-c++-common/cpp/pr63831-2.c1
-rw-r--r--gcc/testsuite/c-c++-common/cpp/warning-zero-location.c2
-rw-r--r--gcc/testsuite/c-c++-common/dfp/convert-dfp-2.c45
-rw-r--r--gcc/testsuite/c-c++-common/dfp/operator-comma.c2
-rw-r--r--gcc/testsuite/c-c++-common/dump-ada-spec-1.c10
-rw-r--r--gcc/testsuite/c-c++-common/dump-ada-spec-2.c49
-rw-r--r--gcc/testsuite/c-c++-common/fold-bitand-4.c3
-rw-r--r--gcc/testsuite/c-c++-common/fold-divmul-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c42
-rw-r--r--gcc/testsuite/c-c++-common/goacc-gomp/nesting-fail-1.c94
-rw-r--r--gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c174
-rw-r--r--gcc/testsuite/c-c++-common/goacc/acc_on_device-2-off.c25
-rw-r--r--gcc/testsuite/c-c++-common/goacc/acc_on_device-2.c37
-rw-r--r--gcc/testsuite/c-c++-common/goacc/clauses-fail.c13
-rw-r--r--gcc/testsuite/c-c++-common/goacc/combined-directives-2.c14
-rw-r--r--gcc/testsuite/c-c++-common/goacc/combined-directives.c116
-rw-r--r--gcc/testsuite/c-c++-common/goacc/data-default-1.c37
-rw-r--r--gcc/testsuite/c-c++-common/goacc/declare-1.c83
-rw-r--r--gcc/testsuite/c-c++-common/goacc/declare-2.c79
-rw-r--r--gcc/testsuite/c-c++-common/goacc/deviceptr-1.c14
-rw-r--r--gcc/testsuite/c-c++-common/goacc/host_data-1.c24
-rw-r--r--gcc/testsuite/c-c++-common/goacc/host_data-2.c78
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-1.c43
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias-2.c27
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias-3.c20
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias-4.c22
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias-5.c19
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias-6.c23
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias-7.c25
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias-8.c22
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-2.c37
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-3.c36
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-4.c21
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta.c23
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-alias.c29
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-counter-vars-function-scope.c53
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-default-2.c17
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-default.c14
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-double-reduction-n.c36
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c36
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-loop-2.c69
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-loop-3.c47
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c15
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-loop-mod-not-zero.c51
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-loop-n.c54
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-loop-nest.c38
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-loop.c54
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-one-counter-var.c52
-rw-r--r--gcc/testsuite/c-c++-common/goacc/kernels-reduction.c34
-rw-r--r--gcc/testsuite/c-c++-common/goacc/loop-1.c16
-rw-r--r--gcc/testsuite/c-c++-common/goacc/loop-2-kernels.c189
-rw-r--r--gcc/testsuite/c-c++-common/goacc/loop-2-parallel.c162
-rw-r--r--gcc/testsuite/c-c++-common/goacc/loop-3.c58
-rw-r--r--gcc/testsuite/c-c++-common/goacc/loop-auto-1.c230
-rw-r--r--gcc/testsuite/c-c++-common/goacc/loop-clauses.c82
-rw-r--r--gcc/testsuite/c-c++-common/goacc/loop-private-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/loop-shape.c323
-rw-r--r--gcc/testsuite/c-c++-common/goacc/nesting-1.c8
-rw-r--r--gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c61
-rw-r--r--gcc/testsuite/c-c++-common/goacc/parallel-1.c36
-rw-r--r--gcc/testsuite/c-c++-common/goacc/pcopy.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/pcopyin.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/pcopyout.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/pcreate.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/pr69916.c20
-rw-r--r--gcc/testsuite/c-c++-common/goacc/present-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/goacc/reduction-1.c56
-rw-r--r--gcc/testsuite/c-c++-common/goacc/reduction-2.c41
-rw-r--r--gcc/testsuite/c-c++-common/goacc/reduction-3.c41
-rw-r--r--gcc/testsuite/c-c++-common/goacc/reduction-4.c39
-rw-r--r--gcc/testsuite/c-c++-common/goacc/reduction-5.c16
-rw-r--r--gcc/testsuite/c-c++-common/goacc/reduction-promotions.c32
-rw-r--r--gcc/testsuite/c-c++-common/goacc/routine-1.c34
-rw-r--r--gcc/testsuite/c-c++-common/goacc/routine-2.c21
-rw-r--r--gcc/testsuite/c-c++-common/goacc/routine-3.c119
-rw-r--r--gcc/testsuite/c-c++-common/goacc/routine-4.c114
-rw-r--r--gcc/testsuite/c-c++-common/goacc/routine-5.c156
-rw-r--r--gcc/testsuite/c-c++-common/goacc/sb-1.c6
-rw-r--r--gcc/testsuite/c-c++-common/goacc/sb-3.c4
-rw-r--r--gcc/testsuite/c-c++-common/goacc/tile.c327
-rw-r--r--gcc/testsuite/c-c++-common/goacc/uninit-copy-clause.c38
-rw-r--r--gcc/testsuite/c-c++-common/goacc/uninit-dim-clause.c19
-rw-r--r--gcc/testsuite/c-c++-common/goacc/uninit-firstprivate-clause.c25
-rw-r--r--gcc/testsuite/c-c++-common/goacc/uninit-if-clause.c38
-rw-r--r--gcc/testsuite/c-c++-common/goacc/uninit-use-device-clause.c14
-rw-r--r--gcc/testsuite/c-c++-common/goacc/update-1.c2
-rw-r--r--gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c338
-rw-r--r--gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c452
-rw-r--r--gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c338
-rw-r--r--gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c452
-rw-r--r--gcc/testsuite/c-c++-common/gomp/atomic-10.c1
-rw-r--r--gcc/testsuite/c-c++-common/gomp/atomic-12.c1
-rw-r--r--gcc/testsuite/c-c++-common/gomp/atomic-13.c1
-rw-r--r--gcc/testsuite/c-c++-common/gomp/atomic-3.c1
-rw-r--r--gcc/testsuite/c-c++-common/gomp/atomic-9.c1
-rw-r--r--gcc/testsuite/c-c++-common/gomp/cancel-1.c91
-rw-r--r--gcc/testsuite/c-c++-common/gomp/clauses-1.c161
-rw-r--r--gcc/testsuite/c-c++-common/gomp/clauses-2.c53
-rw-r--r--gcc/testsuite/c-c++-common/gomp/clauses-3.c23
-rw-r--r--gcc/testsuite/c-c++-common/gomp/clauses-4.c118
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-target-1.c13
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-target-2.c45
-rw-r--r--gcc/testsuite/c-c++-common/gomp/depend-3.c21
-rw-r--r--gcc/testsuite/c-c++-common/gomp/depend-4.c44
-rw-r--r--gcc/testsuite/c-c++-common/gomp/distribute-1.c56
-rw-r--r--gcc/testsuite/c-c++-common/gomp/doacross-1.c48
-rw-r--r--gcc/testsuite/c-c++-common/gomp/element-1.c14
-rw-r--r--gcc/testsuite/c-c++-common/gomp/gridify-1.c54
-rw-r--r--gcc/testsuite/c-c++-common/gomp/if-1.c47
-rw-r--r--gcc/testsuite/c-c++-common/gomp/if-2.c43
-rw-r--r--gcc/testsuite/c-c++-common/gomp/linear-1.c42
-rw-r--r--gcc/testsuite/c-c++-common/gomp/map-2.c44
-rw-r--r--gcc/testsuite/c-c++-common/gomp/map-3.c21
-rw-r--r--gcc/testsuite/c-c++-common/gomp/nesting-1.c14
-rw-r--r--gcc/testsuite/c-c++-common/gomp/nesting-2.c154
-rw-r--r--gcc/testsuite/c-c++-common/gomp/nesting-warn-1.c12
-rw-r--r--gcc/testsuite/c-c++-common/gomp/ordered-1.c91
-rw-r--r--gcc/testsuite/c-c++-common/gomp/ordered-2.c4
-rw-r--r--gcc/testsuite/c-c++-common/gomp/ordered-3.c103
-rw-r--r--gcc/testsuite/c-c++-common/gomp/ordered-4.c54
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr57580.c36
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr61486-1.c6
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr61486-2.c48
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr63326.c479
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr64769.c9
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr67521.c6
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr70550-1.c81
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr70550-2.c55
-rw-r--r--gcc/testsuite/c-c++-common/gomp/priority-1.c26
-rw-r--r--gcc/testsuite/c-c++-common/gomp/reduction-1.c59
-rw-r--r--gcc/testsuite/c-c++-common/gomp/schedule-modifiers-1.c109
-rw-r--r--gcc/testsuite/c-c++-common/gomp/schedule-simd-1.c51
-rw-r--r--gcc/testsuite/c-c++-common/gomp/sink-1.c96
-rw-r--r--gcc/testsuite/c-c++-common/gomp/sink-2.c16
-rw-r--r--gcc/testsuite/c-c++-common/gomp/sink-3.c20
-rw-r--r--gcc/testsuite/c-c++-common/gomp/sink-4.c25
-rw-r--r--gcc/testsuite/c-c++-common/gomp/target-teams-1.c85
-rw-r--r--gcc/testsuite/c-c++-common/gomp/udr-1.c16
-rw-r--r--gcc/testsuite/c-c++-common/nonnull-1.c34
-rw-r--r--gcc/testsuite/c-c++-common/nonnull-2.c26
-rw-r--r--gcc/testsuite/c-c++-common/pr46562-2.c1
-rw-r--r--gcc/testsuite/c-c++-common/pr46562.c1
-rw-r--r--gcc/testsuite/c-c++-common/pr56493.c1
-rw-r--r--gcc/testsuite/c-c++-common/pr58346-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/pr60439.c96
-rw-r--r--gcc/testsuite/c-c++-common/pr61534-1.c13
-rw-r--r--gcc/testsuite/c-c++-common/pr65830.c16
-rw-r--r--gcc/testsuite/c-c++-common/pr66208.c10
-rw-r--r--gcc/testsuite/c-c++-common/pr66322.c144
-rw-r--r--gcc/testsuite/c-c++-common/pr67639.c8
-rw-r--r--gcc/testsuite/c-c++-common/pr67653.c8
-rw-r--r--gcc/testsuite/c-c++-common/pr68107.c37
-rw-r--r--gcc/testsuite/c-c++-common/pr68582.c25
-rw-r--r--gcc/testsuite/c-c++-common/pr68657-1.c26
-rw-r--r--gcc/testsuite/c-c++-common/pr68657-2.c8
-rw-r--r--gcc/testsuite/c-c++-common/pr68657-3.c13
-rw-r--r--gcc/testsuite/c-c++-common/pr68833-1.c22
-rw-r--r--gcc/testsuite/c-c++-common/pr68833-2.c16
-rw-r--r--gcc/testsuite/c-c++-common/pr68833-3.c7
-rw-r--r--gcc/testsuite/c-c++-common/pr69126-2-long.c11
-rw-r--r--gcc/testsuite/c-c++-common/pr69126-2-short.c11
-rw-r--r--gcc/testsuite/c-c++-common/pr69126.c79
-rw-r--r--gcc/testsuite/c-c++-common/pr69543-1.c19
-rw-r--r--gcc/testsuite/c-c++-common/pr69543-2.c14
-rw-r--r--gcc/testsuite/c-c++-common/pr69543-3.c20
-rw-r--r--gcc/testsuite/c-c++-common/pr69543-4.c25
-rw-r--r--gcc/testsuite/c-c++-common/pr69558-1.c21
-rw-r--r--gcc/testsuite/c-c++-common/pr69558-2.c16
-rw-r--r--gcc/testsuite/c-c++-common/pr69558-3.c19
-rw-r--r--gcc/testsuite/c-c++-common/pr69558-4.c23
-rw-r--r--gcc/testsuite/c-c++-common/pr69558.c19
-rw-r--r--gcc/testsuite/c-c++-common/pr69669.c10
-rw-r--r--gcc/testsuite/c-c++-common/pr69764.c38
-rw-r--r--gcc/testsuite/c-c++-common/pr69797.c8
-rw-r--r--gcc/testsuite/c-c++-common/pr70144-1.c9
-rw-r--r--gcc/testsuite/c-c++-common/pr70144-2.c12
-rw-r--r--gcc/testsuite/c-c++-common/pr70264.c13
-rw-r--r--gcc/testsuite/c-c++-common/pr70297.c9
-rw-r--r--gcc/testsuite/c-c++-common/pr70336.c37
-rw-r--r--gcc/testsuite/c-c++-common/pr70651.c9
-rw-r--r--gcc/testsuite/c-c++-common/raw-string-11.c1
-rw-r--r--gcc/testsuite/c-c++-common/raw-string-14.c2
-rw-r--r--gcc/testsuite/c-c++-common/raw-string-18.c1
-rw-r--r--gcc/testsuite/c-c++-common/raw-string-19.c2
-rw-r--r--gcc/testsuite/c-c++-common/restrict-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/restrict-2.c5
-rw-r--r--gcc/testsuite/c-c++-common/restrict-4.c5
-rw-r--r--gcc/testsuite/c-c++-common/rotate-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/rotate-2.c1
-rw-r--r--gcc/testsuite/c-c++-common/rotate-3.c1
-rw-r--r--gcc/testsuite/c-c++-common/rotate-4.c1
-rw-r--r--gcc/testsuite/c-c++-common/taskloop-1.c15
-rw-r--r--gcc/testsuite/c-c++-common/tm/20100127.c1
-rw-r--r--gcc/testsuite/c-c++-common/tm/ipa-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/tm/malloc.c1
-rw-r--r--gcc/testsuite/c-c++-common/tm/pr54893.c1
-rw-r--r--gcc/testsuite/c-c++-common/tm/trxn-expr-3.c1
-rw-r--r--gcc/testsuite/c-c++-common/tm/trxn-expr.c1
-rw-r--r--gcc/testsuite/c-c++-common/tm/volatile-1.c10
-rw-r--r--gcc/testsuite/c-c++-common/tm/wrap-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/torture/vector-shift1.c2
-rw-r--r--gcc/testsuite/c-c++-common/torture/vshuf-2.inc2
-rw-r--r--gcc/testsuite/c-c++-common/transparent-union-1.c1
-rw-r--r--gcc/testsuite/c-c++-common/tsan/pr65400-1.c6
-rw-r--r--gcc/testsuite/c-c++-common/tsan/thread_leak.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/align-6.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/align-7.c3
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/align-8.c1
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/bounds-10.c16
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/bounds-11.c23
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/bounds-12.c23
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/bounds-4.c4
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/bounds-6.c4
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/bounds-8.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-10.c33
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-8.c62
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-9.c26
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/load-bool-enum.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-1.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-10.c6
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-11.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-2.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-3.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-4.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-5.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-6.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-7.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-8.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-9.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/object-size-1.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/object-size-10.c6
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/object-size-4.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/object-size-5.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/object-size-7.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/object-size-8.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/object-size-9.c8
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/overflow-add-2.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/overflow-add-5.c30
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/overflow-int128.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/overflow-mul-2.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/overflow-mul-4.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/overflow-negate-1.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/overflow-negate-3.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/overflow-sub-2.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/overflow-sub-4.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/pr59333.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/pr59667.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/pr60613-2.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/pr60636.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/pr63802.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/pr63866.c1
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/pr67921.c23
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/pr68142.c31
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/recovery-1.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/recovery-3.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/sanitize-all-2.c1
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/sanitize-all-3.c1
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/sanitize-all-4.c1
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/shift-1.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/shift-2.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/shift-4.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/shift-7.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/undefined-2.c2
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/vla-1.c2
-rw-r--r--gcc/testsuite/c-c++-common/vector-compare-4.c44
-rw-r--r--gcc/testsuite/c-c++-common/vector-scalar-2.c1
371 files changed, 13271 insertions, 608 deletions
diff --git a/gcc/testsuite/c-c++-common/Waddress-1.c b/gcc/testsuite/c-c++-common/Waddress-1.c
new file mode 100644
index 0000000000..8df5d2f6fe
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Waddress-1.c
@@ -0,0 +1,15 @@
+/* PR c/69768 */
+/* { dg-do compile } */
+/* { dg-options "-Waddress" } */
+
+static int e;
+
+int
+foo ()
+{
+ return "foo1" != (void *) 0 /* { dg-bogus "comparison with string literal results in unspecified behavior" } */
+ && "foo2" != (const char *) ((void *) 0) /* { dg-bogus "comparison with string literal results in unspecified behavior" } */
+ && "foo3" != (const char *) ((void *) (10 - 10)) /* { dg-bogus "comparison with string literal results in unspecified behavior" } */
+ && "foo4" != (const char *) ((void *) (&e - &e)) /* { dg-warning "comparison with string literal results in unspecified behavior" "" { target c } } */
+ && "foo5" != "foo6"; /* { dg-warning "comparison with string literal results in unspecified behavior" } */
+}
diff --git a/gcc/testsuite/c-c++-common/Wbool-compare-1.c b/gcc/testsuite/c-c++-common/Wbool-compare-1.c
index 5b03e06821..2f435f651e 100644
--- a/gcc/testsuite/c-c++-common/Wbool-compare-1.c
+++ b/gcc/testsuite/c-c++-common/Wbool-compare-1.c
@@ -72,15 +72,10 @@ fn1 (bool b)
r = b == true;
r = b != true;
- /* Some of these don't make much sense, but we don't warn. */
- r = b < false;
- r = b >= false;
r = b <= false;
r = b > false;
r = b < true;
r = b >= true;
- r = b <= true;
- r = b > true;
}
void
diff --git a/gcc/testsuite/c-c++-common/Wbool-compare-2.c b/gcc/testsuite/c-c++-common/Wbool-compare-2.c
new file mode 100644
index 0000000000..633032229f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wbool-compare-2.c
@@ -0,0 +1,100 @@
+/* PR c/64610 */
+/* { dg-do compile } */
+/* { dg-options "-Wbool-compare" } */
+
+#ifndef __cplusplus
+# define bool _Bool
+# define true 1
+# define false 0
+#endif
+
+extern bool foo (void);
+
+enum { A, B };
+
+int
+fn1 (bool b)
+{
+ int r = 0;
+
+ r += b >= 0; /* { dg-warning "with boolean expression is always true" } */
+ r += b > 0;
+ r += b < 0; /* { dg-warning "with boolean expression is always false" } */
+ r += b <= 0;
+
+ r += b >= 1;
+ r += b > 1; /* { dg-warning "with boolean expression is always false" } */
+ r += b < 1;
+ r += b <= 1; /* { dg-warning "with boolean expression is always true" } */
+
+ r += foo () >= 0; /* { dg-warning "with boolean expression is always true" } */
+ r += foo () > 0;
+ r += foo () < 0; /* { dg-warning "with boolean expression is always false" } */
+ r += foo () <= 0;
+
+ r += foo () >= 1;
+ r += foo () > 1; /* { dg-warning "with boolean expression is always false" } */
+ r += foo () < 1;
+ r += foo () <= 1; /* { dg-warning "with boolean expression is always true" } */
+
+ r += b >= A; /* { dg-warning "with boolean expression is always true" } */
+ r += b > A;
+ r += b < A; /* { dg-warning "with boolean expression is always false" } */
+ r += b <= A;
+
+ r += b >= B;
+ r += b > B; /* { dg-warning "with boolean expression is always false" } */
+ r += b < B;
+ r += b <= B; /* { dg-warning "with boolean expression is always true" } */
+
+ /* Swap LHS and RHS. */
+ r += 0 >= b;
+ r += 0 > b; /* { dg-warning "with boolean expression is always false" } */
+ r += 0 < b;
+ r += 0 <= b; /* { dg-warning "with boolean expression is always true" } */
+
+ r += 1 >= b; /* { dg-warning "with boolean expression is always true" } */
+ r += 1 > b;
+ r += 1 < b; /* { dg-warning "with boolean expression is always false" } */
+ r += 1 <= b;
+
+ r += 0 >= foo ();
+ r += 0 > foo (); /* { dg-warning "with boolean expression is always false" } */
+ r += 0 < foo ();
+ r += 0 <= foo (); /* { dg-warning "with boolean expression is always true" } */
+
+ r += 1 >= foo (); /* { dg-warning "with boolean expression is always true" } */
+ r += 1 > foo ();
+ r += 1 < foo (); /* { dg-warning "with boolean expression is always false" } */
+ r += 1 <= foo ();
+
+ r += A >= b;
+ r += A > b; /* { dg-warning "with boolean expression is always false" } */
+ r += A < b;
+ r += A <= b; /* { dg-warning "with boolean expression is always true" } */
+
+ r += B >= b; /* { dg-warning "with boolean expression is always true" } */
+ r += B > b;
+ r += B < b; /* { dg-warning "with boolean expression is always false" } */
+ r += B <= b;
+
+ return r;
+}
+
+int
+fn2 (int i, int j)
+{
+ int r = 0;
+
+ r += (i == j) >= 0; /* { dg-warning "with boolean expression is always true" } */
+ r += (i == j) > 0;
+ r += (i == j) < 0; /* { dg-warning "with boolean expression is always false" } */
+ r += (i == j) <= 0;
+
+ r += (i == j) >= 1;
+ r += (i == j) > 1; /* { dg-warning "with boolean expression is always false" } */
+ r += (i == j) < 1;
+ r += (i == j) <= 1; /* { dg-warning "with boolean expression is always true" } */
+
+ return r;
+}
diff --git a/gcc/testsuite/c-c++-common/Wbool-compare-3.c b/gcc/testsuite/c-c++-common/Wbool-compare-3.c
new file mode 100644
index 0000000000..bac4f47c2a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wbool-compare-3.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-Wbool-compare" } */
+
+#ifndef __cplusplus
+# define bool _Bool
+#endif
+
+#define A 0
+#define B 1
+
+int
+foo (int i, bool b)
+{
+ int r = 0;
+
+ r += i <= (A || B);
+ r += i <= b;
+ r += i <= A;
+ r += i < (A || B);
+ r += i < b;
+ r += i < A;
+ r += i > (A || B);
+ r += i > b;
+ r += i > A;
+ r += i >= (A || B);
+ r += i >= b;
+ r += i >= A;
+
+ return r;
+}
diff --git a/gcc/testsuite/c-c++-common/Wduplicated-cond-1.c b/gcc/testsuite/c-c++-common/Wduplicated-cond-1.c
new file mode 100644
index 0000000000..4763a84e3d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wduplicated-cond-1.c
@@ -0,0 +1,200 @@
+/* PR c/64249 */
+/* { dg-do compile } */
+/* { dg-options "-Wduplicated-cond" } */
+
+#ifndef __cplusplus
+# define bool _Bool
+# define true 1
+# define false 0
+#endif
+
+extern int foo (void);
+
+int
+fn1 (int n)
+{
+ if (n == 1) /* { dg-message "previously used here" } */
+ return -1;
+ else if (n == 2)
+ return 0;
+ else if (n == 1) /* { dg-warning "duplicated .if. condition" } */
+ return 1;
+ return 0;
+}
+
+int
+fn2 (void)
+{
+ if (4)
+ return 1;
+ else if (4)
+ return 2;
+
+#define N 10
+ if (N)
+ return 3;
+ else if (N)
+ return 4;
+}
+
+int
+fn3 (int n)
+{
+ if (n == 42)
+ return 1;
+ if (n == 42)
+ return 2;
+
+ if (n)
+ if (n)
+ if (n)
+ if (n)
+ return 42;
+
+ if (!n)
+ return 10;
+ else
+ return 11;
+}
+
+int
+fn4 (int n)
+{
+ if (n > 0)
+ {
+ if (n == 1) /* { dg-message "previously used here" } */
+ return 1;
+ else if (n == 1) /* { dg-warning "duplicated .if. condition" } */
+ return 2;
+ }
+ else if (n < 0)
+ {
+ if (n < -1)
+ return 6;
+ else if (n < -2)
+ {
+ if (n == -10) /* { dg-message "previously used here" } */
+ return 3;
+ else if (n == -10) /* { dg-warning "duplicated .if. condition" } */
+ return 4;
+ }
+ }
+ else
+ return 7;
+ return 0;
+}
+
+struct S { long p, q; };
+
+int
+fn5 (struct S *s)
+{
+ if (!s->p) /* { dg-message "previously used here" } */
+ return 12345;
+ else if (!s->p) /* { dg-warning "duplicated .if. condition" } */
+ return 1234;
+ return 0;
+}
+
+int
+fn6 (int n)
+{
+ if (n) /* { dg-message "previously used here" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ return 0;
+}
+
+int
+fn7 (int n)
+{
+ if (n == 0) /* { dg-message "previously used here" } */
+ return 10;
+ else if (n == 1) /* { dg-message "previously used here" } */
+ return 11;
+ else if (n == 2) /* { dg-message "previously used here" } */
+ return 12;
+ else if (n == 3) /* { dg-message "previously used here" } */
+ return 13;
+ else if (n == 4) /* { dg-message "previously used here" } */
+ return 14;
+ else if (n == 5) /* { dg-message "previously used here" } */
+ return 15;
+ else if (n == 6) /* { dg-message "previously used here" } */
+ return 16;
+ else if (n == 7) /* { dg-message "previously used here" } */
+ return 17;
+ else if (n == 0) /* { dg-warning "duplicated .if. condition" } */
+ return 100;
+ else if (n == 1) /* { dg-warning "duplicated .if. condition" } */
+ return 101;
+ else if (n == 2) /* { dg-warning "duplicated .if. condition" } */
+ return 102;
+ else if (n == 3) /* { dg-warning "duplicated .if. condition" } */
+ return 103;
+ else if (n == 4) /* { dg-warning "duplicated .if. condition" } */
+ return 104;
+ else if (n == 5) /* { dg-warning "duplicated .if. condition" } */
+ return 105;
+ else if (n == 6) /* { dg-warning "duplicated .if. condition" } */
+ return 106;
+ else if (n == 7) /* { dg-warning "duplicated .if. condition" } */
+ return 107;
+ return 0;
+}
+
+int
+fn8 (bool b)
+{
+ if (!b) /* { dg-message "previously used here" } */
+ return 16;
+ else if (!b) /* { dg-warning "duplicated .if. condition" } */
+ return 27;
+ else
+ return 64;
+}
+
+int
+fn9 (int i, int j, int k)
+{
+ if (i > 0 && j > 0 && k > 0) /* { dg-message "previously used here" } */
+ return -999;
+ else
+ if (i > 0 && j > 0 && k > 0) /* { dg-warning "duplicated .if. condition" } */
+ return 999;
+ else
+ return 0;
+}
+
+int
+fn10 (void)
+{
+ if (foo ())
+ return 1732984;
+ else if (foo ())
+ return 18409;
+ return 0;
+}
+
+int
+fn11 (int n)
+{
+ if (++n == 10)
+ return 666;
+ else if (++n == 10)
+ return 9;
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/Wduplicated-cond-2.c b/gcc/testsuite/c-c++-common/Wduplicated-cond-2.c
new file mode 100644
index 0000000000..c424e76644
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wduplicated-cond-2.c
@@ -0,0 +1,201 @@
+/* PR c/64249 */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+/* { dg-skip-if "PR67819" { *-*-* } } */
+
+#ifndef __cplusplus
+# define bool _Bool
+# define true 1
+# define false 0
+#endif
+
+extern int foo (void);
+
+int
+fn1 (int n)
+{
+ if (n == 1) /* { dg-message "previously used here" } */
+ return -1;
+ else if (n == 2)
+ return 0;
+ else if (n == 1) /* { dg-warning "duplicated .if. condition" } */
+ return 1;
+ return 0;
+}
+
+int
+fn2 (void)
+{
+ if (4)
+ return 1;
+ else if (4)
+ return 2;
+
+#define N 10
+ if (N)
+ return 3;
+ else if (N)
+ return 4;
+}
+
+int
+fn3 (int n)
+{
+ if (n == 42)
+ return 1;
+ if (n == 42)
+ return 2;
+
+ if (n)
+ if (n)
+ if (n)
+ if (n)
+ return 42;
+
+ if (!n)
+ return 10;
+ else
+ return 11;
+}
+
+int
+fn4 (int n)
+{
+ if (n > 0)
+ {
+ if (n == 1) /* { dg-message "previously used here" } */
+ return 1;
+ else if (n == 1) /* { dg-warning "duplicated .if. condition" } */
+ return 2;
+ }
+ else if (n < 0)
+ {
+ if (n < -1)
+ return 6;
+ else if (n < -2)
+ {
+ if (n == -10) /* { dg-message "previously used here" } */
+ return 3;
+ else if (n == -10) /* { dg-warning "duplicated .if. condition" } */
+ return 4;
+ }
+ }
+ else
+ return 7;
+ return 0;
+}
+
+struct S { long p, q; };
+
+int
+fn5 (struct S *s)
+{
+ if (!s->p) /* { dg-message "previously used here" } */
+ return 12345;
+ else if (!s->p) /* { dg-warning "duplicated .if. condition" } */
+ return 1234;
+ return 0;
+}
+
+int
+fn6 (int n)
+{
+ if (n) /* { dg-message "previously used here" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ else if (n) /* { dg-warning "duplicated .if. condition" } */
+ return n;
+ return 0;
+}
+
+int
+fn7 (int n)
+{
+ if (n == 0) /* { dg-message "previously used here" } */
+ return 10;
+ else if (n == 1) /* { dg-message "previously used here" } */
+ return 11;
+ else if (n == 2) /* { dg-message "previously used here" } */
+ return 12;
+ else if (n == 3) /* { dg-message "previously used here" } */
+ return 13;
+ else if (n == 4) /* { dg-message "previously used here" } */
+ return 14;
+ else if (n == 5) /* { dg-message "previously used here" } */
+ return 15;
+ else if (n == 6) /* { dg-message "previously used here" } */
+ return 16;
+ else if (n == 7) /* { dg-message "previously used here" } */
+ return 17;
+ else if (n == 0) /* { dg-warning "duplicated .if. condition" } */
+ return 100;
+ else if (n == 1) /* { dg-warning "duplicated .if. condition" } */
+ return 101;
+ else if (n == 2) /* { dg-warning "duplicated .if. condition" } */
+ return 102;
+ else if (n == 3) /* { dg-warning "duplicated .if. condition" } */
+ return 103;
+ else if (n == 4) /* { dg-warning "duplicated .if. condition" } */
+ return 104;
+ else if (n == 5) /* { dg-warning "duplicated .if. condition" } */
+ return 105;
+ else if (n == 6) /* { dg-warning "duplicated .if. condition" } */
+ return 106;
+ else if (n == 7) /* { dg-warning "duplicated .if. condition" } */
+ return 107;
+ return 0;
+}
+
+int
+fn8 (bool b)
+{
+ if (!b) /* { dg-message "previously used here" } */
+ return 16;
+ else if (!b) /* { dg-warning "duplicated .if. condition" } */
+ return 27;
+ else
+ return 64;
+}
+
+int
+fn9 (int i, int j, int k)
+{
+ if (i > 0 && j > 0 && k > 0) /* { dg-message "previously used here" } */
+ return -999;
+ else
+ if (i > 0 && j > 0 && k > 0) /* { dg-warning "duplicated .if. condition" } */
+ return 999;
+ else
+ return 0;
+}
+
+int
+fn10 (void)
+{
+ if (foo ())
+ return 1732984;
+ else if (foo ())
+ return 18409;
+ return 0;
+}
+
+int
+fn11 (int n)
+{
+ if (++n == 10)
+ return 666;
+ else if (++n == 10)
+ return 9;
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/Wduplicated-cond-3.c b/gcc/testsuite/c-c++-common/Wduplicated-cond-3.c
new file mode 100644
index 0000000000..e3b5ac0cc8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wduplicated-cond-3.c
@@ -0,0 +1,204 @@
+/* PR c/64249 */
+/* { dg-do compile } */
+/* { dg-options "-Wall -Wno-duplicated-cond" } */
+
+#ifndef __cplusplus
+# define bool _Bool
+# define true 1
+# define false 0
+#endif
+
+extern int foo (void);
+
+int
+fn1 (int n)
+{
+ if (n == 1)
+ return -1;
+ else if (n == 2)
+ return 0;
+ else if (n == 1)
+ return 1;
+ return 0;
+}
+
+int
+fn2 (void)
+{
+ if (4)
+ return 1;
+ else if (4)
+ return 2;
+
+#define N 10
+ if (N)
+ return 3;
+ else if (N)
+ return 4;
+}
+
+int
+fn3 (int n)
+{
+ if (n == 42)
+ return 1;
+ if (n == 42)
+ return 2;
+
+ if (n)
+ if (n)
+ if (n)
+ if (n)
+ return 42;
+
+ if (!n)
+ return 10;
+ else
+ return 11;
+}
+
+int
+fn4 (int n)
+{
+ if (n > 0)
+ {
+ if (n == 1)
+ return 1;
+ else if (n == 1)
+ return 2;
+ }
+ else if (n < 0)
+ {
+ if (n < -1)
+ return 6;
+ else if (n < -2)
+ {
+ if (n == -10)
+ return 3;
+ else if (n == -10)
+ return 4;
+ }
+ }
+ else
+ return 7;
+ return 0;
+}
+
+struct S { long p, q; };
+
+int
+fn5 (struct S *s)
+{
+ if (!s->p)
+ return 12345;
+ else if (!s->p)
+ return 1234;
+ return 0;
+}
+
+int
+fn6 (int n)
+{
+ if (n)
+ return n;
+ else if (n)
+ return n;
+ else if (n)
+ return n;
+ else if (n)
+ return n;
+ else if (n)
+ return n;
+ else if (n)
+ return n;
+ else if (n)
+ return n;
+ else if (n)
+ return n;
+ return 0;
+}
+
+int
+fn7 (int n)
+{
+ if (n == 0)
+ return 10;
+ else if (n == 1)
+ return 11;
+ else if (n == 2)
+ return 12;
+ else if (n == 3)
+ return 13;
+ else if (n == 4)
+ return 14;
+ else if (n == 5)
+ return 15;
+ else if (n == 6)
+ return 16;
+ else if (n == 7)
+ return 17;
+ else if (n == 0)
+ return 100;
+ else if (n == 1)
+ return 101;
+ else if (n == 2)
+ return 102;
+ else if (n == 3)
+ return 103;
+ else if (n == 4)
+ return 104;
+ else if (n == 5)
+ return 105;
+ else if (n == 6)
+ return 106;
+ else if (n == 7)
+ return 107;
+ return 0;
+}
+
+int
+fn8 (bool b)
+{
+ if (!b)
+ return 16;
+ else if (!b)
+ return 27;
+ else
+ return 64;
+}
+
+int
+fn9 (int i, int j, int k)
+{
+ if ((i > 0 && j > 0 && k > 0)
+ && ((i > 11 && j == 76 && k < 10)
+ || (i < 0 && j == 99 && k > 103)))
+ return -999;
+ else
+ if ((i > 0 && j > 0 && k > 0)
+ && ((i > 11 && j == 76 && k < 10)
+ || (i < 0 && j == 99 && k > 103)))
+ return 999;
+ else
+ return 0;
+}
+
+int
+fn10 (void)
+{
+ if (foo ())
+ return 1732984;
+ else if (foo ())
+ return 18409;
+ return 0;
+}
+
+int
+fn11 (int n)
+{
+ if (++n == 10)
+ return 666;
+ else if (++n == 10)
+ return 9;
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/Wduplicated-cond-4.c b/gcc/testsuite/c-c++-common/Wduplicated-cond-4.c
new file mode 100644
index 0000000000..4fb7e17484
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wduplicated-cond-4.c
@@ -0,0 +1,32 @@
+/* PR c/64249 */
+/* { dg-do compile } */
+/* { dg-options "-Wduplicated-cond" } */
+/* Test we don't warn if a condition in an if-else-if chain
+ has a side-effect. E.g. __cxxabiv1::__cxa_end_catch ()
+ uses such a construction. */
+
+extern int a, bar (void);
+
+int
+fn1 (void)
+{
+ if (a)
+ return 1;
+ else if (bar ())
+ return 2;
+ else if (a)
+ return 3;
+ return 0;
+}
+
+int
+fn2 (int c)
+{
+ if (c < 0)
+ return 1;
+ else if (--c == 0)
+ return 2;
+ else if (c < 0)
+ return 3;
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/Wlogical-op-1.c b/gcc/testsuite/c-c++-common/Wlogical-op-1.c
new file mode 100644
index 0000000000..33d4f3893d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wlogical-op-1.c
@@ -0,0 +1,109 @@
+/* PR c/63357 */
+/* { dg-do compile } */
+/* { dg-options "-Wlogical-op" } */
+
+#ifndef __cplusplus
+# define bool _Bool
+# define true 1
+# define false 0
+#endif
+
+extern int bar (void);
+extern int *p;
+struct R { int a, b; } S;
+
+void
+andfn (int a, int b)
+{
+ if (a && a) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (!a && !a) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (!!a && !!a) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (a > 0 && a > 0) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (a < 0 && a < 0) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (a == 0 && a == 0) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (a <= 0 && a <= 0) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (a >= 0 && a >= 0) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (a == 0 && !(a != 0)) {} /* { dg-warning "logical .and. of equal expressions" } */
+
+ if (a && a && a) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if ((a + 1) && (a + 1)) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if ((10 * a) && (a * 10)) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (!!a && a) {} /* { dg-warning "logical .and. of equal expressions" } */
+
+ if (*p && *p) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (p[0] && p[0]) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (S.a && S.a) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if ((bool) a && (bool) a) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if ((unsigned) a && a) {} /* { dg-warning "logical .and. of equal expressions" } */
+
+ /* Stay quiet here. */
+ if (a && b) {}
+ if (!a && !b) {}
+ if (!!a && !!b) {}
+ if (a > 0 && b > 0) {}
+ if (a < 0 && b < 0) {}
+ if (a == 0 && b == 0) {}
+ if (a <= 0 && b <= 0) {}
+ if (a >= 0 && b >= 0) {}
+
+ if (a > 0 && a > 1) {}
+ if (a > -2 && a > 1) {}
+ if (a && (short) a) {}
+ if ((char) a && a) {}
+ if (++a && a) {}
+ if (++a && ++a) {}
+ if (a && --a) {}
+ if (a && a / 2) {}
+ if (bar () && bar ()) {}
+ if (p && *p) {}
+ if (p[0] && p[1]) {}
+ if (S.a && S.b) {}
+}
+
+void
+orfn (int a, int b)
+{
+ if (a || a) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (!a || !a) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (!!a || !!a) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (a > 0 || a > 0) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (a < 0 || a < 0) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (a == 0 || a == 0) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (a <= 0 || a <= 0) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (a >= 0 || a >= 0) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (a == 0 || !(a != 0)) {} /* { dg-warning "logical .or. of equal expressions" } */
+
+ if (a || a || a) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if ((a + 1) || (a + 1)) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if ((10 * a) || (a * 10)) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (!!a || a) {} /* { dg-warning "logical .or. of equal expressions" } */
+
+ if (*p || *p) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (p[0] || p[0]) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (S.a || S.a) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if ((bool) a || (bool) a) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if ((unsigned) a || a) {} /* { dg-warning "logical .or. of equal expressions" } */
+
+ /* Stay quiet here. */
+ if (a || b) {}
+ if (!a || !b) {}
+ if (!!a || !!b) {}
+ if (a > 0 || b > 0) {}
+ if (a < 0 || b < 0) {}
+ if (a == 0 || b == 0) {}
+ if (a <= 0 || b <= 0) {}
+ if (a >= 0 || b >= 0) {}
+
+ if (a > 0 || a > 1) {}
+ if (a > -2 || a > 1) {}
+ if (a || (short) a) {}
+ if ((char) a || a) {}
+ if (++a || a) {}
+ if (++a || ++a) {}
+ if (a || --a) {}
+ if (a || a / 2) {}
+ if (bar () || bar ()) {}
+ if (p || *p) {}
+ if (p[0] || p[1]) {}
+ if (S.a || S.b) {}
+}
diff --git a/gcc/testsuite/c-c++-common/Wlogical-op-3.c b/gcc/testsuite/c-c++-common/Wlogical-op-3.c
new file mode 100644
index 0000000000..83b5df43ba
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wlogical-op-3.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-Wlogical-op" } */
+
+void
+fn1 (int a)
+{
+ const int x = a;
+ if (x && x) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (x && (int) x) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if ((int) x && x) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if ((int) x && (int) x) {} /* { dg-warning "logical .and. of equal expressions" } */
+}
+
+void
+fn2 (int a)
+{
+ const int x = a;
+ if (x || x) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (x || (int) x) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if ((int) x || x) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if ((int) x || (int) x) {} /* { dg-warning "logical .or. of equal expressions" } */
+}
diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation-2.c b/gcc/testsuite/c-c++-common/Wmisleading-indentation-2.c
new file mode 100644
index 0000000000..b4ee700ec2
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation-2.c
@@ -0,0 +1,56 @@
+/* { dg-options "-Wmisleading-indentation" } */
+/* { dg-do compile } */
+
+/* Based on get_attr_athlon_decode from the generated insn-attrtab.c
+ for x86_64.
+ A #line directive, followed by a very long line to ensure that
+ we're in a fresh line_map.
+
+ This should not generate a misleading indentation warning.
+
+ This needs to be in its own file since -Wmisleading-indentation stops
+ after seeing a #line directive. */
+void fn ()
+{
+ switch (0)
+ {
+#line 6 "../../../../src/gcc/testsuite/c-c++-common/Wmisleading-indentation-2.md"
+ case 0:
+ if (0)
+ {
+ return;
+ }
+
+ case 1:
+ if (0)
+ {
+ return;
+ }
+ else
+ {
+ return;
+ }
+
+ /**********************************************************************************************************************************/
+ if (0)
+ {
+ return;
+ }
+ else if (0)
+ {
+ return;
+ }
+ else if (0)
+ {
+ return;
+ }
+ else
+ {
+ return;
+ }
+
+ default:
+ return;
+
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation-2.md b/gcc/testsuite/c-c++-common/Wmisleading-indentation-2.md
new file mode 100644
index 0000000000..44bc13adf9
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation-2.md
@@ -0,0 +1,46 @@
+;; Support file for testcase Wmisleading-indentation.c
+;; Adapted from gcc/config/i386/i386.md
+(define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,nehalem,
+ atom,slm,generic,amdfam10,bdver1,bdver2,bdver3,bdver4,
+ btver2,knl"
+ (const (symbol_ref "ix86_schedule")))
+
+;; A basic instruction type. Refinements due to arguments to be
+;; provided in other attributes.
+(define_attr "type"
+ "other,multi,
+ alu,alu1,negnot,imov,imovx,lea,
+ incdec,ishift,ishiftx,ishift1,rotate,rotatex,rotate1,
+ imul,imulx,idiv,icmp,test,ibr,setcc,icmov,
+ push,pop,call,callv,leave,
+ str,bitmanip,
+ fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,
+ fxch,fistp,fisttp,frndint,
+ sse,ssemov,sseadd,sseadd1,sseiadd,sseiadd1,
+ ssemul,sseimul,ssediv,sselog,sselog1,
+ sseishft,sseishft1,ssecmp,ssecomi,
+ ssecvt,ssecvt1,sseicvt,sseins,
+ sseshuf,sseshuf1,ssemuladd,sse4arg,
+ lwp,mskmov,msklog,
+ mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft,
+ mpxmov,mpxmk,mpxchk,mpxld,mpxst"
+ (const_string "other"))
+
+;; Main data type used by the insn
+(define_attr "mode"
+ "unknown,none,QI,HI,SI,DI,TI,OI,XI,SF,DF,XF,TF,V16SF,V8SF,V4DF,V4SF,
+ V2DF,V2SF,V1DF,V8DF"
+ (const_string "unknown"))
+
+;; The CPU unit operations uses.
+(define_attr "unit" "integer,i387,sse,mmx,unknown"
+ (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,
+ fxch,fistp,fisttp,frndint")
+ (const_string "i387")
+ (eq_attr "type" "sse,ssemov,sseadd,sseadd1,sseiadd,sseiadd1,
+ ssemul,sseimul,ssediv,sselog,sselog1,
+ sseishft,sseishft1,ssecmp,ssecomi,
+ ssecvt,ssecvt1,sseicvt,sseins,
+ sseshuf,sseshuf1,ssemuladd,sse4arg,mskmov")
+ (const_string "sse")
+ (const_string "integer")))
diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation-3.c b/gcc/testsuite/c-c++-common/Wmisleading-indentation-3.c
new file mode 100644
index 0000000000..277a3885e2
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation-3.c
@@ -0,0 +1,82 @@
+/* Verify -Wmisleading-indentation with source-printing.
+ This is a subset of Wmisleading-indentation.c. */
+
+/* { dg-options "-Wmisleading-indentation -fdiagnostics-show-caret" } */
+/* { dg-do compile } */
+
+extern int foo (int);
+extern int bar (int, int);
+extern int flagA;
+extern int flagB;
+extern int flagC;
+extern int flagD;
+
+void
+fn_5 (double *a, double *b, double *sum, double *prod)
+{
+ int i = 0;
+ for (i = 0; i < 10; i++) /* { dg-warning "3: this 'for' clause does not guard..." } */
+ sum[i] = a[i] * b[i];
+ prod[i] = a[i] * b[i]; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */
+/* { dg-begin-multiline-output "" }
+ for (i = 0; i < 10; i++)
+ ^~~
+ { dg-end-multiline-output "" } */
+/* { dg-begin-multiline-output "" }
+ prod[i] = a[i] * b[i];
+ ^~~~
+ { dg-end-multiline-output "" } */
+}
+
+/* Based on CVE-2014-1266 aka "goto fail" */
+int fn_6 (int a, int b, int c)
+{
+ int err;
+
+ /* ... */
+ if ((err = foo (a)) != 0)
+ goto fail;
+ if ((err = foo (b)) != 0) /* { dg-message "2: this 'if' clause does not guard..." } */
+ goto fail;
+ goto fail; /* { dg-message "3: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+ if ((err = foo (c)) != 0)
+ goto fail;
+ /* ... */
+
+/* { dg-begin-multiline-output "" }
+ if ((err = foo (b)) != 0)
+ ^~
+ { dg-end-multiline-output "" } */
+/* { dg-begin-multiline-output "" }
+ goto fail;
+ ^~~~
+ { dg-end-multiline-output "" } */
+
+fail:
+ return err;
+}
+
+#define FOR_EACH(VAR, START, STOP) \
+ for ((VAR) = (START); (VAR) < (STOP); (VAR++)) /* { dg-warning "3: this 'for' clause does not guard..." } */
+
+void fn_14 (void)
+{
+ int i;
+ FOR_EACH (i, 0, 10) /* { dg-message "in expansion of macro .FOR_EACH." } */
+ foo (i);
+ bar (i, i); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */
+
+/* { dg-begin-multiline-output "" }
+ for ((VAR) = (START); (VAR) < (STOP); (VAR++))
+ ^
+ { dg-end-multiline-output "" } */
+/* { dg-begin-multiline-output "" }
+ FOR_EACH (i, 0, 10)
+ ^~~~~~~~
+ { dg-end-multiline-output "" } */
+/* { dg-begin-multiline-output "" }
+ bar (i, i);
+ ^~~
+ { dg-end-multiline-output "" } */
+}
+#undef FOR_EACH
diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c b/gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c
new file mode 100644
index 0000000000..d15a4793da
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c
@@ -0,0 +1,11 @@
+/* PR c++/70639 */
+/* { dg-do compile } */
+/* { dg-options "-Wmisleading-indentation" } */
+
+void bar (int);
+void
+foo (int x)
+{
+ switch (x);
+ bar (x);
+}
diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c
new file mode 100644
index 0000000000..dcc66e7f6f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c
@@ -0,0 +1,1240 @@
+/* { dg-options "-Wmisleading-indentation -Wall" } */
+/* { dg-do compile } */
+
+extern int foo (int);
+extern int bar (int, int);
+extern int flagA;
+extern int flagB;
+extern int flagC;
+extern int flagD;
+
+int
+fn_1 (int flag)
+{
+ int x = 4, y = 5;
+ if (flag) /* { dg-warning "3: this 'if' clause does not guard..." } */
+ x = 3;
+ y = 2; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+ return x * y;
+}
+
+int
+fn_2 (int flag, int x, int y)
+{
+ if (flag) /* { dg-warning "3: this 'if' clause does not guard..." } */
+ x++; y++; /* { dg-message "10: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+
+ return x * y;
+}
+
+int
+fn_3 (int flag)
+{
+ int x = 4, y = 5;
+ if (flag)
+ x = 3;
+ else /* { dg-warning "3: this 'else' clause does not guard..." } */
+ x = 2;
+ y = 2; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'else'" } */
+ return x * y;
+}
+
+void
+fn_4 (double *a, double *b, double *c)
+{
+ int i = 0;
+ while (i < 10) /* { dg-warning "3: this 'while' clause does not guard..." } */
+ a[i] = b[i] * c[i];
+ i++; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while'" } */
+}
+
+void
+fn_5 (double *a, double *b, double *sum, double *prod)
+{
+ int i = 0;
+ for (i = 0; i < 10; i++) /* { dg-warning "3: this 'for' clause does not guard..." } */
+ sum[i] = a[i] * b[i];
+ prod[i] = a[i] * b[i]; /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */
+}
+
+/* Based on CVE-2014-1266 aka "goto fail" */
+int fn_6 (int a, int b, int c)
+{
+ int err;
+
+ /* ... */
+ if ((err = foo (a)) != 0)
+ goto fail;
+ if ((err = foo (b)) != 0) /* { dg-message "2: this 'if' clause does not guard..." } */
+ goto fail;
+ goto fail; /* { dg-message "3: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+ if ((err = foo (c)) != 0)
+ goto fail;
+ /* ... */
+
+fail:
+ return err;
+}
+
+int fn_7 (int p, int q, int r, int s, int t)
+{
+ if (bar (p, q))
+ {
+ if (p) /* { dg-message "7: this 'if' clause does not guard..." } */
+ q++; r++; /* { dg-message "14: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+ t++;
+ }
+ return p + q + r + s + t;
+}
+
+int fn_8 (int a, int b, int c)
+{
+ /* This should *not* be flagged as misleading indentation. */
+ if (a) return b; else return c;
+}
+
+void fn_9 (int flag)
+{
+ if (flag) /* { dg-warning "3: this 'if' clause does not guard..." } */
+ foo (0);
+ foo (1); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+}
+
+void fn_10 (int flag)
+{
+ if (flag) /* { dg-warning "3: this 'if' clause does not guard..." } */
+ if (flag / 2)
+ {
+ foo (0);
+ foo (1);
+ }
+ foo (2); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+ foo (3);
+}
+
+void fn_11 (void)
+{
+ if (flagA)
+ if (flagB)
+ if (flagC) /* { dg-message "7: this 'if' clause does not guard..." } */
+ foo (0);
+ bar (1, 2); /* { dg-message "9: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+}
+
+void fn_12 (void)
+{
+ if (flagA)
+ if (flagB) /* { dg-message "5: this 'if' clause does not guard..." } */
+ if (flagC)
+ foo (0);
+ bar (1, 2); /* { dg-message "7: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+}
+
+void fn_13 (void)
+{
+ if (flagA) /* { dg-warning "3: this 'if' clause does not guard..." } */
+ if (flagB)
+ if (flagC)
+ foo (0);
+ bar (1, 2); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+}
+
+#define FOR_EACH(VAR, START, STOP) \
+ for ((VAR) = (START); (VAR) < (STOP); (VAR++)) /* { dg-warning "3: this 'for' clause does not guard..." } */
+
+void fn_14 (void)
+{
+ int i;
+ FOR_EACH (i, 0, 10) /* { dg-message "in expansion of macro .FOR_EACH." } */
+ foo (i);
+ bar (i, i); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */
+}
+#undef FOR_EACH
+
+#define FOR_EACH(VAR, START, STOP) for ((VAR) = (START); (VAR) < (STOP); (VAR++)) /* { dg-message "36: this 'for' clause does not guard..." } */
+void fn_15 (void)
+{
+ int i;
+ FOR_EACH (i, 0, 10) /* { dg-message "in expansion of macro .FOR_EACH." } */
+ foo (i);
+ bar (i, i); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */
+}
+#undef FOR_EACH
+
+void fn_16_spaces (void)
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ while (flagA)
+ if (flagB) /* { dg-message "7: this 'if' clause does not guard..." } */
+ foo (0);
+ foo (1); /* { dg-message "9: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+}
+
+void fn_16_tabs (void)
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ while (flagA)
+ if (flagB) /* { dg-message "7: this 'if' clause does not guard..." } */
+ foo (0);
+ foo (1);/* { dg-message "2: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+}
+
+void fn_17_spaces (void)
+{
+ int i;
+ for (i = 0; i < 10; i++) /* { dg-warning "3: this 'for' clause does not guard..." } */
+ while (flagA)
+ if (flagB)
+ foo (0);
+ foo (1);/* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */
+}
+
+void fn_17_tabs (void)
+{
+ int i;
+ for (i = 0; i < 10; i++) /* { dg-warning "3: this 'for' clause does not guard..." } */
+ while (flagA)
+ if (flagB)
+ foo (0);
+ foo (1);/* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'" } */
+}
+
+void fn_18_spaces (void)
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ while (flagA) /* { dg-message "5: this 'while' clause does not guard..." } */
+ if (flagB)
+ foo (0);
+ foo (1);/* { dg-message "7: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while'" } */
+}
+
+void fn_18_tabs (void)
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ while (flagA) /* { dg-message "5: this 'while' clause does not guard..." } */
+ if (flagB)
+ foo (0);
+ foo (1);/* { dg-message "7: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while'" } */
+}
+
+/* This shouldn't lead to a warning. */
+int fn_19 (void) { if (flagA) return 1; else return 0; }
+
+/* A deeply-nested mixture of spaces and tabs, adapted from
+ c-c++-common/pr60101.c.
+ This should not lead to a warning. */
+void
+fn_20 (unsigned int l)
+{
+ unsigned int i;
+
+ for (i = 0; i < 10; i++)
+ {
+ unsigned int n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11;
+
+ for (n0 = 0; n0 < l; n0++)
+ for (n1 = 0; n1 < l; n1++)
+ for (n2 = 0; n2 < l; n2++)
+ for (n3 = 0; n3 < l; n3++)
+ for (n4 = 0; n4 < l; n4++)
+ for (n5 = 0; n5 < l; n5++)
+ for (n6 = 0; n6 < l; n6++)
+ for (n7 = 0; n7 < l; n7++)
+ for (n8 = 0; n8 < l; n8++)
+ for (n9 = 0; n9 < l; n9++)
+ for (n10 = 0; n10 < l; n10++)
+ for (n11 = 0; n11 < l; n11++)
+ {
+ if (flagA)
+ foo (0);
+ foo (1);
+ }
+ foo (2);
+ }
+}
+
+/* Another nested mix of tabs and spaces that shouldn't lead to a warning,
+ with a preprocessor directive thrown in for good measure
+ (adapted from libgomp/loop.c: gomp_loop_init). */
+void fn_21 (void)
+{
+ foo (0);
+ if (flagA)
+ {
+ foo (1);
+
+#if 1
+ {
+ foo (2);
+ if (flagB)
+ {
+ if (flagC)
+ foo (3);
+ else
+ foo (4);
+ }
+ else if (flagD)
+ foo (5);
+ else
+ foo (6);
+ }
+#endif
+ }
+}
+
+/* The conditionals within the following macros shouldn't be warned about.
+ Adapted from libgomp/driver.c: gomp_load_plugin_for_device. */
+int fn_22 (void)
+{
+ int err = 0;
+
+#define DLSYM() \
+ do \
+ { \
+ err = foo (0); \
+ if (err) \
+ goto out; \
+ } \
+ while (0)
+#define DLSYM_OPT() \
+ do \
+ { \
+ err = foo (1); \
+ if (err) \
+ foo (2); \
+ else \
+ foo (3); \
+ foo (4); \
+ } \
+ while (0)
+ DLSYM ();
+ DLSYM_OPT ();
+#undef DLSYM
+#undef DLSYM_OPT
+
+ out:
+ return err;
+}
+
+/* This shouldn't be warned about. */
+void fn_23 (void) { foo (0); foo (1); if (flagA) foo (2); foo (3); foo (4); }
+
+/* Code that simply doesn't bother indenting anywhere (e.g. autogenerated
+ code) shouldn't be warned about. */
+void fn_24 (void)
+{
+ foo (0);
+ if (flagA)
+ foo (1);
+ foo (2);
+}
+
+/* Adapted from libiberty/regex.c; an example of a conditional in a
+ macro where the successor statement begins with a macro arg:
+
+ if (num < 0)
+ num = 0;
+ num = num * 10 + c - '0';
+ ^ this successor statement
+
+ and hence "num" has a spelling location at the argument of the
+ macro usage site ("lower_bound"), we want the definition of the
+ parameter ("num") for the indentation comparison to be meaninful.
+
+ This should not generate a misleading indentation warning. */
+
+# define GET_UNSIGNED_NUMBER(num) \
+ { \
+ while (flagA) \
+ { \
+ if (flagB) \
+ { \
+ if (num < 0) \
+ num = 0; \
+ num = num * 10 + c - '0'; \
+ } \
+ } \
+ }
+void fn_25 (int c, int lower_bound, int upper_bound)
+{
+ GET_UNSIGNED_NUMBER (lower_bound);
+}
+#undef GET_UNSIGNED_NUMBER
+
+/* Example adapted from libdecnumber/decNumber.c:decExpOp that shouldn't
+ trigger a warning. */
+void fn_26 (void)
+{
+ if (flagA) {
+ if (flagB) foo (0); }
+ foo (1);
+}
+
+/* Ensure that we don't get confused by mixed tabs and spaces; the line
+ "foo (1);" has leading spaces before a tab, but this should not
+ lead to a warning from -Wmisleading-indentation. */
+void fn_27 (void)
+{
+ if (flagA)
+ foo (0);
+ foo (1);
+}
+
+/* Example adapted from gcc/cgraph.h:symtab_node::get_availability of
+ a spurious trailing semicolon that shouldn't generate a warning. */
+void fn_28 (void)
+{
+ if (flagA)
+ foo (0);
+ else
+ foo (1);;
+}
+
+/* However, other kinds of spurious semicolons can be a problem. Sadly
+ we don't yet report for the misleading-indented "foo (1);" in the
+ following, due to the spurious semicolon. */
+void fn_29 (void)
+{
+ if (flagA)
+ if (flagB)
+ foo (0);;
+ foo (1);
+}
+
+/* Adapted from usage site of #ifdef HAVE_cc0. This should not lead
+ to a warning from -Wmisleading-indentation. */
+void fn_30 (void)
+{
+ if (flagA)
+ foo (0);
+#if SOME_CONDITION_THAT_DOES_NOT_HOLD
+ if (flagB)
+#endif
+ foo (1);
+}
+
+/* This shouldn't lead to a warning. */
+void fn_31 (void)
+{
+ if (flagA)
+ foo (0);
+ else if (flagB)
+ foo (1);
+ else if (flagC)
+ foo (2);
+ else
+ foo (3);
+}
+
+/* Ensure that we can disable the warning. */
+int
+fn_32 (int flag)
+{
+ int x = 4, y = 5;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmisleading-indentation"
+ if (flag)
+ x = 3;
+ y = 2;
+#pragma GCC diagnostic pop
+
+ return x * y;
+}
+
+/* Verify that a variety of different indentation styles are supported
+ without leading to warnings. */
+void
+fn_33_k_and_r_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++) {
+ if (flagB) {
+ foo(0);
+ foo(1);
+ } else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_stroustrup_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++) {
+ if (flagA) {
+ foo(0);
+ foo(1);
+ }
+ else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_allman_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (flagA)
+ {
+ foo(0);
+ foo(1);
+ }
+ else
+ {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_whitesmiths_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (flagA)
+ {
+ foo(0);
+ foo(1);
+ }
+ else
+ {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_horstmann_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ { if (flagA)
+ { foo(0);
+ foo(1);
+ }
+ else
+ { foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_ratliff_banner_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++) {
+ if (flagA) {
+ foo(0);
+ foo(1);
+ }
+ else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_lisp_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++) {
+ if (flagA) {
+ foo(0);
+ foo(1); }
+ else {
+ foo(2);
+ foo(3); }
+ foo(4); }
+}
+
+/* A function run through GNU "indent" with various options.
+ None of these should lead to warnings. */
+
+/* "indent -gnu". */
+void
+fn_34_indent_dash_gnu (void)
+{
+ int i;
+ while (flagA)
+ for (i = 0; i < 10; i++)
+ {
+ if (flagB)
+ {
+ foo (0);
+ foo (1);
+ }
+ else
+ {
+ foo (2);
+ foo (3);
+ }
+ foo (4);
+ }
+ foo (5);
+}
+
+/* "indent -kr". */
+void fn_34_indent_dash_kr(void)
+{
+ int i;
+ while (flagA)
+ for (i = 0; i < 10; i++) {
+ if (flagB) {
+ foo(0);
+ foo(1);
+ } else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+ foo(5);
+}
+
+/* "indent -orig". */
+void
+fn_34_indent_dash_orig(void)
+{
+ int i;
+ while (flagA)
+ for (i = 0; i < 10; i++) {
+ if (flagB) {
+ foo(0);
+ foo(1);
+ } else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+ foo(5);
+}
+
+/* Linux style:
+ "indent \
+ -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 \
+ -cli0 -d0 -di1 -nfc1 -i8 -ip0 -l80 -lp -npcs -nprs -npsl -sai \
+ -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -ts8 -il1". */
+
+void fn_34_indent_linux_style(void)
+{
+ int i;
+ while (flagA)
+ for (i = 0; i < 10; i++) {
+ if (flagB) {
+ foo(0);
+ foo(1);
+ } else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+ foo(5);
+}
+
+/* PR 66220. */
+int fn_35 (int v)
+{
+ int res = 28;
+
+ if (v == 2)
+ {
+ res = 27;
+ } else
+ {
+ res = 18;
+ }
+ return res;
+}
+
+/* This variant of K&R-style formatting (in the presence of conditional
+ compilation) shouldn't lead to a warning.
+
+ Based on false positive seen with r223098 when compiling
+ linux-4.0.3:arch/x86/crypto/aesni-intel_glue.c:aesni_init. */
+void
+fn_36 (void)
+{
+#if 1 /* e.g. some configuration variable. */
+ if (flagA) {
+ foo(0);
+ foo(1);
+ foo(2);
+ } else
+#endif
+ {
+ foo(3);
+ foo(4);
+ foo(5);
+ }
+ foo(6); /* We shouldn't warn here. */
+}
+
+/* The following function contain code whose indentation is misleading, thus
+ we warn about it. */
+
+void
+fn_37 (void)
+{
+ int i;
+
+#define EMPTY
+#define FOR_EACH(VAR, START, STOP) for (VAR = START; VAR < STOP; VAR++) /* { dg-warning "this 'for' clause" } */
+
+ while (flagA); /* { dg-warning "3: this 'while' clause" } */
+ foo (0); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while'" } */
+
+ if (flagA)
+ ;
+ else if (flagB); /* { dg-warning "8: this 'if' clause" } */
+ foo (0); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+ while (flagA) /* { dg-warning "3: this 'while' clause" } */
+ /* blah */;
+ foo (0); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while'" } */
+
+ if (flagA)
+ ;
+ else if (flagB) /* { dg-warning "8: this 'if' clause" } */
+ foo (1);
+ foo (2); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+
+ if (flagA)
+ foo (1);
+ else if (flagB) /* { dg-warning "8: this 'if' clause" } */
+ foo (2);
+ foo (3); /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+
+ if (flagB) /* { dg-warning "3: this 'if' clause" } */
+ /* blah */;
+ { /* { dg-message "5: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+ foo (0);
+ }
+
+ if (flagB) /* { dg-warning "3: this 'if' clause" } */
+ /* blah */;
+ { /* { dg-message "4: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'" } */
+ foo (0);
+ }
+
+
+ if (flagB)
+ ;
+ else; foo (0); /* { dg-warning "3: this 'else' clause" } */
+
+ if (flagC); foo (2); /* { dg-warning "3: this 'if' clause" } */
+
+ if (flagA) /* { dg-warning "3: this 'if' clause" } */
+ ; /* blah */ { /* { dg-message "18: ...this statement" } */
+ foo (1);
+ }
+
+ if (flagB) ; /* { dg-warning "3: this 'if' clause" } */
+ return; /* { dg-message "5: ...this statement" } */
+
+ if (flagB) EMPTY; /* { dg-warning "3: this 'if' clause" } */
+ foo (1); /* { dg-message "5: ...this statement" } */
+
+ for (i = 0; i < 10; i++); /* { dg-warning "3: this 'for' clause" } */
+ foo (2); /* { dg-message "5: ...this statement" } */
+
+ FOR_EACH (i, 0, 10); /* { dg-message "3: in expansion of macro .FOR_EACH." } */
+ foo (2); /* { dg-message "5: ...this statement" } */
+
+ FOR_EACH (i, 0, 10); /* { dg-message "3: in expansion of macro .FOR_EACH." } */
+ { /* { dg-message "5: ...this statement" } */
+ foo (3);
+ }
+
+ FOR_EACH (i, 0, 10); /* { dg-message "3: in expansion of macro .FOR_EACH." } */
+ { /* { dg-message "3: ...this statement" } */
+ foo (3);
+ }
+
+ while (i++); { /* { dg-warning "3: this 'while' clause" } */
+ foo (3);
+ }
+
+ if (i++); { /* { dg-warning "3: this 'if' clause" } */
+ foo (3);
+ }
+
+ if (flagA) {
+ foo (1);
+ } else /* { dg-warning "5: this 'else' clause" } */
+ if (flagB)
+ foo (2);
+ foo (3); /* { dg-message "5: ...this statement" } */
+
+ if (flagA)
+ foo (1);
+ else if (flagB); /* { dg-warning "8: this 'if' clause" } */
+ foo (2); /* { dg-message "5: ...this statement" } */
+
+ for (i = 0; /* { dg-warning "3: this 'for' clause" } */
+ i < 10;
+ i++);
+ foo (i); /* { dg-message "5: ...this statement" } */
+
+ if (flagA)
+ {
+ foo (1);
+ }
+ else if (flagB); /* { dg-warning "8: this 'if' clause" } */
+ { /* { dg-message "3: ...this statement" } */
+ foo (2);
+ }
+
+#undef EMPTY
+#undef FOR_EACH
+}
+
+/* The following function contains code whose indentation is not great but not
+ misleading, thus we don't warn. */
+
+void
+fn_38 (void)
+{
+ int i = 0;
+
+ while (flagA)
+ ;
+ foo (0);
+
+ if (flagB)
+ ;
+ {
+ foo (0);
+ }
+
+ while (flagC);
+ foo (2);
+
+ if (flagA)
+ while (flagC++);
+ else
+ foo (2);
+
+ if (i)
+ while (i++ < 10000);
+ foo (5);
+
+ if (i) while (i++ < 10000);
+ foo (5);
+
+ if (flagA) {
+ foo (1);
+ } else
+ if (flagB)
+ foo (2);
+ foo (3);
+
+ if (flagA)
+ {
+ foo (1);
+ } else
+ if (flagB)
+ foo (2);
+ foo (3);
+
+ for (i = 0;
+ i < 10;
+ i++
+ );
+ foo (i);
+}
+
+/* The following function contains good indentation which we definitely should
+ not warn about. */
+
+void
+fn_39 (void)
+{
+ int i;
+
+ if (flagA)
+ ;
+ if (flagB)
+ ;
+
+ if (flagA)
+ if (flagB)
+ foo (0);
+ else
+ foo (1);
+ else
+ foo (2);
+
+ for (i = 0;
+ i < 10;
+ i++);
+ foo (i);
+
+ do foo (0); while (flagA);
+}
+
+/* We shouldn't complain about the following function. */
+#define emit
+void pr69122 (void)
+{
+ if (flagA)
+ foo (0);
+ emit foo (1);
+}
+#undef emit
+
+/* In the following, the 'if' within the 'for' statement is not indented,
+ but arguably should be.
+ The for loop:
+ "for (cnt = 0; cnt < thousands_len; ++cnt)"
+ does not guard this conditional:
+ "cnt < thousands_len;".
+ and the poor indentation is not misleading. Verify that we do
+ not erroneously emit a warning about this.
+ Based on an example seen in glibc (PR c/68187). */
+
+void
+fn_40_a (const char *end, const char *thousands, int thousands_len)
+{
+ int cnt;
+
+ while (flagA)
+ if (flagA
+ && ({ for (cnt = 0; cnt < thousands_len; ++cnt)
+ if (thousands[cnt] != end[cnt])
+ break;
+ cnt < thousands_len; })
+ && flagB)
+ break;
+}
+
+/* As above, but with the indentation within the "for" loop fixed.
+ We should not emit a warning for this, either. */
+
+void
+fn_40_b (const char *end, const char *thousands, int thousands_len)
+{
+ int cnt;
+
+ while (flagA)
+ if (flagA
+ && ({ for (cnt = 0; cnt < thousands_len; ++cnt)
+ if (thousands[cnt] != end[cnt])
+ break;
+ cnt < thousands_len; })
+ && flagB)
+ break;
+}
+
+/* We should not warn for the following
+ (based on libstdc++-v3/src/c++11/random.cc:random_device::_M_init). */
+
+void
+fn_41_a (void)
+{
+ if (flagA)
+ {
+ }
+ else if (flagB)
+ fail:
+ foo (0);
+
+ foo (1);
+ if (!flagC)
+ goto fail;
+}
+
+/* Tweaked version of the above (with the label indented), which we should
+ also not warn for. */
+
+void
+fn_41_b (void)
+{
+ if (flagA)
+ {
+ }
+ else if (flagB)
+ fail:
+ foo (0);
+
+ foo (1);
+ if (!flagC)
+ goto fail;
+}
+
+/* In the following, the
+ "if (i > 0)"
+ is poorly indented, and ought to be on the same column as
+ "engine_ref_debug(e, 0, -1)"
+ However, it is not misleadingly indented, due to the presence
+ of that macro. Verify that we do not emit a warning about it
+ not being guarded by the "else" clause above.
+
+ Based on an example seen in OpenSSL 1.0.1, which was filed as
+ PR c/68187 in comment #1, though it's arguably a separate bug to
+ the one in comment #0. */
+
+int
+fn_42_a (int locked)
+{
+#define engine_ref_debug(X, Y, Z)
+
+ int i;
+
+ if (locked)
+ i = foo (0);
+ else
+ i = foo (1);
+ engine_ref_debug(e, 0, -1)
+ if (i > 0)
+ return 1;
+ return 0;
+#undef engine_ref_debug
+}
+
+/* As above, but the empty macro is at the same indentation level.
+ This *is* misleading; verify that we do emit a warning about it. */
+
+int
+fn_42_b (int locked)
+{
+#define engine_ref_debug(X, Y, Z)
+
+ int i;
+
+ if (locked)
+ i = foo (0);
+ else /* { dg-warning "this .else. clause" } */
+ i = foo (1);
+ engine_ref_debug(e, 0, -1)
+ if (i > 0) /* { dg-message "...this statement" } */
+ return 1;
+ return 0;
+#undef engine_ref_debug
+}
+
+/* As above, but where the body is a semicolon "hidden" by a preceding
+ comment, where the semicolon is not in the same column as the successor
+ "if" statement, but the empty macro expansion is at the same indentation
+ level as the guard.
+ This is poor indentation, but not misleading; verify that we don't emit a
+ warning about it. */
+
+int
+fn_42_c (int locked, int i)
+{
+#define engine_ref_debug(X, Y, Z)
+
+ if (locked)
+ /* blah */;
+ engine_ref_debug(e, 0, -1)
+ if (i > 0)
+ return 1;
+ return 0;
+#undef engine_ref_debug
+}
+
+/* We shouldn't complain about the following function. */
+#define ENABLE_FEATURE
+int pr70085 (int x, int y)
+{
+ if (x > y)
+ return x - y;
+
+ #ifdef ENABLE_FEATURE
+ if (x == y)
+ return 0;
+ #endif
+
+ return -1;
+}
+#undef ENABLE_FEATURE
+
+/* Additional test coverage for PR c/68187, with various locations for a
+ pair of aligned statements ("foo (2);" and "foo (3);") that may or may
+ not be misleadingly indented. */
+
+/* Before the "}".
+
+ The two statements aren't visually "within" the above line, so we
+ shouldn't warn. */
+
+void
+test43_a (void)
+{
+ if (flagA) {
+ foo (1);
+ } else if (flagB)
+ foo (2);
+ foo (3);
+}
+
+/* Aligned with the "}".
+
+ Again, the two statements aren't visually "within" the above line, so we
+ shouldn't warn. */
+
+void
+test43_b (void)
+{
+ if (flagA) {
+ foo (1);
+ } else if (flagB)
+ foo (2);
+ foo (3);
+}
+
+/* Indented between the "}" and the "else".
+
+ The two statements are indented "within" the line above, so appear that
+ they would be guarded together. We should warn about this. */
+
+void
+test43_c (void)
+{
+ if (flagA) {
+ foo (1);
+ } else if (flagB) /* { dg-message "...this .if. clause" } */
+ foo (2);
+ foo (3); /* { dg-message "...this statement" } */
+}
+
+/* Aligned with the "else". Likewise, we should warn. */
+
+void
+test43_d (void)
+{
+ if (flagA) {
+ foo (1);
+ } else if (flagB) /* { dg-message "...this .if. clause" } */
+ foo (2);
+ foo (3); /* { dg-message "...this statement" } */
+}
+
+/* Indented between the "else" and the "if". Likewise, we should warn. */
+
+void
+test43_e (void)
+{
+ if (flagA) {
+ foo (1);
+ } else if (flagB) /* { dg-message "...this .if. clause" } */
+ foo (2);
+ foo (3); /* { dg-message "...this statement" } */
+}
+
+/* Aligned with the "if". Likewise, we should warn. */
+
+void
+test43_f (void)
+{
+ if (flagA) {
+ foo (1);
+ } else if (flagB) /* { dg-warning "this .else. clause" } */
+ foo (2);
+ foo (3); /* { dg-message "...this statement" } */
+}
+
+/* Indented more than the "if". Likewise, we should warn. */
+
+void
+test43_g (void)
+{
+ if (flagA) {
+ foo (1);
+ } else if (flagB) /* { dg-message "...this .if. clause" } */
+ foo (2);
+ foo (3); /* { dg-message "...this statement" } */
+}
+
+/* Again, but without the 2nd "if". */
+
+/* Before the "}".
+
+ As before, the two statements aren't visually "within" the above line,
+ so we shouldn't warn. */
+
+void
+test44_a (void)
+{
+ if (flagA) {
+ foo (1);
+ } else
+ foo (2);
+ foo (3);
+}
+
+/* Aligned with the "}".
+
+ As before, the two statements aren't visually "within" the above line,
+ so we shouldn't warn. */
+
+void
+test44_b (void)
+{
+ if (flagA) {
+ foo (1);
+ } else
+ foo (2);
+ foo (3);
+}
+
+/* Indented between the "}" and the "else".
+
+ The two statements are indented "within" the line above, so appear that
+ they would be guarded together. We should warn about this. */
+
+void
+test44_c (void)
+{
+ if (flagA) {
+ foo (1);
+ } else /* { dg-warning "this .else. clause" } */
+ foo (2);
+ foo (3); /* { dg-message "...this statement" } */
+}
+
+/* Aligned with the "else". Likewise, we should warn. */
+
+void
+test44_d (void)
+{
+ if (flagA) {
+ foo (1);
+ } else /* { dg-warning "this .else. clause" } */
+ foo (2);
+ foo (3); /* { dg-message "...this statement" } */
+}
+
+/* Indented more than the "else". Likewise, we should warn. */
+
+void
+test44_e (void)
+{
+ if (flagA) {
+ foo (1);
+ } else /* { dg-warning "this .else. clause" } */
+ foo (2);
+ foo (3); /* { dg-message "...this statement" } */
+}
diff --git a/gcc/testsuite/c-c++-common/Wparentheses-1.c b/gcc/testsuite/c-c++-common/Wparentheses-1.c
new file mode 100644
index 0000000000..ed50608382
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wparentheses-1.c
@@ -0,0 +1,39 @@
+/* PR c/70436 */
+/* { dg-do compile } */
+/* { dg-options "-Wparentheses" } */
+
+int a, b, c[101], d[101], e[101], f[101];
+
+void
+f1 (void)
+{
+ int i;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma GCC ivdep
+ for (i = 0; i < 100; i++)
+ if (b)
+ c[i] = d[i] + e[i];
+ else
+ f[i] = d[i] * e[i];
+
+ if (a)
+ #pragma GCC ivdep
+ for (i = 0; i < 100; i++)
+ {
+ if (b)
+ c[i] = d[i] + e[i];
+ else
+ f[i] = d[i] * e[i];
+ }
+
+ if (a)
+ #pragma GCC ivdep
+ for (i = 0; i < 100; i++)
+ {
+ if (b)
+ c[i] = d[i] + e[i];
+ }
+ else
+ f[i] = d[i] * e[i];
+}
diff --git a/gcc/testsuite/c-c++-common/Wshift-negative-value-1.c b/gcc/testsuite/c-c++-common/Wshift-negative-value-1.c
new file mode 100644
index 0000000000..8f14034560
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-negative-value-1.c
@@ -0,0 +1,51 @@
+/* PR c/65179 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wextra" } */
+/* { dg-additional-options "-std=c++11" { target c++ } } */
+
+enum E {
+ A = 0 << 1,
+ B = 1 << 1,
+ C = -1 << 1, /* { dg-warning "left shift of negative value|not an integer constant" } */
+ D = 0 >> 1,
+ E = 1 >> 1,
+ F = -1 >> 1
+};
+
+int
+left (int x)
+{
+ /* Warn for LSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z << x;
+ r += o << x;
+ r += m << x; /* { dg-warning "left shift of negative value" } */
+ r += 0 << x;
+ r += 1 << x;
+ r += -1 << x; /* { dg-warning "left shift of negative value" } */
+ r += -1U << x;
+ return r;
+}
+
+int
+right (int x)
+{
+ /* Shouldn't warn for RSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z >> x;
+ r += o >> x;
+ r += m >> x;
+ r += 0 >> x;
+ r += 1 >> x;
+ r += -1 >> x;
+ r += -1U >> x;
+ return r;
+}
+
+/* { dg-error "left operand of shift expression" "shift" { target c++ } 9 } */
diff --git a/gcc/testsuite/c-c++-common/Wshift-negative-value-2.c b/gcc/testsuite/c-c++-common/Wshift-negative-value-2.c
new file mode 100644
index 0000000000..55523a531f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-negative-value-2.c
@@ -0,0 +1,52 @@
+/* PR c/65179 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wshift-negative-value" } */
+/* { dg-additional-options "-std=c++11" { target c++ } } */
+
+enum E {
+ A = 0 << 1,
+ B = 1 << 1,
+ C = -1 << 1, /* { dg-warning "left shift of negative value" } */
+ D = 0 >> 1,
+ E = 1 >> 1,
+ F = -1 >> 1
+};
+
+int
+left (int x)
+{
+ /* Warn for LSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z << x;
+ r += o << x;
+ r += m << x; /* { dg-warning "left shift of negative value" } */
+ r += 0 << x;
+ r += 1 << x;
+ r += -1 << x; /* { dg-warning "left shift of negative value" } */
+ r += -1U << x;
+ return r;
+}
+
+int
+right (int x)
+{
+ /* Shouldn't warn for RSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z >> x;
+ r += o >> x;
+ r += m >> x;
+ r += 0 >> x;
+ r += 1 >> x;
+ r += -1 >> x;
+ r += -1U >> x;
+ return r;
+}
+
+/* { dg-error "not an integer constant" "no constant" { target c++ } 9 } */
+/* { dg-error "left operand of shift expression" "shift" { target c++ } 9 } */
diff --git a/gcc/testsuite/c-c++-common/Wshift-negative-value-3.c b/gcc/testsuite/c-c++-common/Wshift-negative-value-3.c
new file mode 100644
index 0000000000..1295b72556
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-negative-value-3.c
@@ -0,0 +1,52 @@
+/* PR c/65179 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wextra -Wno-shift-negative-value" } */
+/* { dg-additional-options "-std=c++11" { target c++ } } */
+
+enum E {
+ A = 0 << 1,
+ B = 1 << 1,
+ C = -1 << 1,
+ D = 0 >> 1,
+ E = 1 >> 1,
+ F = -1 >> 1
+};
+
+int
+left (int x)
+{
+ /* Warn for LSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z << x;
+ r += o << x;
+ r += m << x; /* { dg-bogus "left shift of negative value" } */
+ r += 0 << x;
+ r += 1 << x;
+ r += -1 << x; /* { dg-bogus "left shift of negative value" } */
+ r += -1U << x;
+ return r;
+}
+
+int
+right (int x)
+{
+ /* Shouldn't warn for RSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z >> x;
+ r += o >> x;
+ r += m >> x;
+ r += 0 >> x;
+ r += 1 >> x;
+ r += -1 >> x;
+ r += -1U >> x;
+ return r;
+}
+
+/* { dg-error "not an integer constant" "no constant" { target c++ } 9 } */
+/* { dg-error "left operand of shift expression" "shift" { target c++ } 9 } */
diff --git a/gcc/testsuite/c-c++-common/Wshift-negative-value-4.c b/gcc/testsuite/c-c++-common/Wshift-negative-value-4.c
new file mode 100644
index 0000000000..3088220ffa
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-negative-value-4.c
@@ -0,0 +1,52 @@
+/* PR c/65179 */
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+/* { dg-additional-options "-std=c++11" { target c++ } } */
+
+enum E {
+ A = 0 << 1,
+ B = 1 << 1,
+ C = -1 << 1,
+ D = 0 >> 1,
+ E = 1 >> 1,
+ F = -1 >> 1
+};
+
+int
+left (int x)
+{
+ /* Warn for LSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z << x;
+ r += o << x;
+ r += m << x; /* { dg-bogus "left shift of negative value" } */
+ r += 0 << x;
+ r += 1 << x;
+ r += -1 << x; /* { dg-bogus "left shift of negative value" } */
+ r += -1U << x;
+ return r;
+}
+
+int
+right (int x)
+{
+ /* Shouldn't warn for RSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z >> x;
+ r += o >> x;
+ r += m >> x;
+ r += 0 >> x;
+ r += 1 >> x;
+ r += -1 >> x;
+ r += -1U >> x;
+ return r;
+}
+
+/* { dg-error "not an integer constant" "no constant" { target c++ } 9 } */
+/* { dg-error "left operand of shift expression" "shift" { target c++ } 9 } */
diff --git a/gcc/testsuite/c-c++-common/Wshift-negative-value-5.c b/gcc/testsuite/c-c++-common/Wshift-negative-value-5.c
new file mode 100644
index 0000000000..74ecd1e286
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-negative-value-5.c
@@ -0,0 +1,50 @@
+/* PR c/65179 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wshift-negative-value" } */
+/* { dg-additional-options "-std=c++03" { target c++ } } */
+/* { dg-additional-options "-std=c90" { target c } } */
+
+enum E {
+ A = 0 << 1,
+ B = 1 << 1,
+ C = -1 << 1, /* { dg-warning "left shift of negative value" } */
+ D = 0 >> 1,
+ E = 1 >> 1,
+ F = -1 >> 1
+};
+
+int
+left (int x)
+{
+ /* Warn for LSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z << x;
+ r += o << x;
+ r += m << x; /* { dg-warning "left shift of negative value" } */
+ r += 0 << x;
+ r += 1 << x;
+ r += -1 << x; /* { dg-warning "left shift of negative value" } */
+ r += -1U << x;
+ return r;
+}
+
+int
+right (int x)
+{
+ /* Shouldn't warn for RSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z >> x;
+ r += o >> x;
+ r += m >> x;
+ r += 0 >> x;
+ r += 1 >> x;
+ r += -1 >> x;
+ r += -1U >> x;
+ return r;
+}
diff --git a/gcc/testsuite/c-c++-common/Wshift-negative-value-6.c b/gcc/testsuite/c-c++-common/Wshift-negative-value-6.c
new file mode 100644
index 0000000000..3603b9ed98
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-negative-value-6.c
@@ -0,0 +1,50 @@
+/* PR c/65179 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wextra" } */
+/* { dg-additional-options "-std=c++11 -std=c++03" { target c++ } } */
+/* { dg-additional-options "-std=c90" { target c } } */
+
+enum E {
+ A = 0 << 1,
+ B = 1 << 1,
+ C = -1 << 1, /* { dg-bogus "left shift of negative value" } */
+ D = 0 >> 1,
+ E = 1 >> 1,
+ F = -1 >> 1
+};
+
+int
+left (int x)
+{
+ /* Warn for LSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z << x;
+ r += o << x;
+ r += m << x; /* { dg-bogus "left shift of negative value" } */
+ r += 0 << x;
+ r += 1 << x;
+ r += -1 << x; /* { dg-bogus "left shift of negative value" } */
+ r += -1U << x;
+ return r;
+}
+
+int
+right (int x)
+{
+ /* Shouldn't warn for RSHIFT_EXPR. */
+ const int z = 0;
+ const int o = 1;
+ const int m = -1;
+ int r = 0;
+ r += z >> x;
+ r += o >> x;
+ r += m >> x;
+ r += 0 >> x;
+ r += 1 >> x;
+ r += -1 >> x;
+ r += -1U >> x;
+ return r;
+}
diff --git a/gcc/testsuite/c-c++-common/Wshift-overflow-1.c b/gcc/testsuite/c-c++-common/Wshift-overflow-1.c
new file mode 100644
index 0000000000..a69f2b8346
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-overflow-1.c
@@ -0,0 +1,63 @@
+/* PR c++/55095 */
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-O" } */
+/* { dg-additional-options "-std=c++11" { target c++ } } */
+
+#define INTM1 (sizeof (int) * __CHAR_BIT__ - 1)
+#define INTM2 (sizeof (int) * __CHAR_BIT__ - 2)
+#define LLONGM1 (sizeof (long long) * __CHAR_BIT__ - 1)
+#define LLONGM2 (sizeof (long long) * __CHAR_BIT__ - 2)
+
+#define INT_MIN (-__INT_MAX__-1)
+#define LONG_LONG_MIN (-__LONG_LONG_MAX__-1)
+
+int i1 = 1 << INTM1;
+int i2 = 9 << INTM1; /* { dg-warning "requires 36 bits to represent" } */
+int i3 = 10 << INTM2; /* { dg-warning "requires 35 bits to represent" } */
+int i4 = __INT_MAX__ << 2; /* { dg-warning "requires 34 bits to represent" } */
+int i5 = __INT_MAX__ << INTM1; /* { dg-warning "requires 63 bits to represent" } */
+int i6 = -1 << INTM1;
+int i7 = -9 << INTM1; /* { dg-warning "requires 36 bits to represent" } */
+int i8 = -10 << INTM2; /* { dg-warning "requires 35 bits to represent" } */
+int i9 = -__INT_MAX__ << 2; /* { dg-warning "requires 34 bits to represent" } */
+int i10 = -__INT_MAX__ << INTM1; /* { dg-warning "requires 63 bits to represent" } */
+int i11 = INT_MIN << 1; /* { dg-warning "requires 33 bits to represent" } */
+
+int r1 = 1 >> INTM1;
+int r2 = 9 >> INTM1;
+int r3 = 10 >> INTM2;
+int r4 = __INT_MAX__ >> 2;
+int r5 = __INT_MAX__ >> INTM1;
+int r6 = -1 >> INTM1;
+int r7 = -9 >> INTM1;
+int r8 = -10 >> INTM2;
+int r9 = -__INT_MAX__ >> 2;
+int r10 = -__INT_MAX__ >> INTM1;
+
+unsigned u1 = 1 << INTM1;
+unsigned u2 = 9 << INTM1; /* { dg-warning "requires 36 bits to represent" } */
+unsigned u3 = 2U << INTM1;
+unsigned u4 = 9U << INTM1;
+unsigned u5 = 10U << INTM2;
+
+long long int l1 = 1LL << LLONGM1;
+long long int l2 = 9LL << LLONGM1; /* { dg-warning "requires 68 bits to represent" } */
+long long int l3 = 10LL << LLONGM2; /* { dg-warning "requires 67 bits to represent" } */
+long long int l4 = __LONG_LONG_MAX__ << 2; /* { dg-warning "requires 66 bits to represent" } */
+long long int l5 = __LONG_LONG_MAX__ << LLONGM1; /* { dg-warning "requires 127 bits to represent" } */
+long long int l6 = -1LL << LLONGM1;
+long long int l7 = -9LL << LLONGM1; /* { dg-warning "requires 68 bits to represent" } */
+long long int l8 = -10LL << LLONGM2; /* { dg-warning "requires 67 bits to represent" } */
+long long int l9 = -__LONG_LONG_MAX__ << 2; /* { dg-warning "requires 66 bits to represent" } */
+long long int l10 = -__LONG_LONG_MAX__ << LLONGM1; /* { dg-warning "requires 127 bits to represent" } */
+long long int l11 = LONG_LONG_MIN << 1; /* { dg-warning "requires 65 bits to represent" } */
+
+void
+fn (void)
+{
+ const int a = 10;
+ const __SIZE_TYPE__ b = INTM1;
+ int k1 = a << b; /* { dg-warning "requires 36 bits to represent" } */
+ int k2 = 10 << b; /* { dg-warning "requires 36 bits to represent" } */
+ int k3 = a << INTM1; /* { dg-warning "requires 36 bits to represent" } */
+}
diff --git a/gcc/testsuite/c-c++-common/Wshift-overflow-2.c b/gcc/testsuite/c-c++-common/Wshift-overflow-2.c
new file mode 100644
index 0000000000..30fd2552df
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-overflow-2.c
@@ -0,0 +1,63 @@
+/* PR c++/55095 */
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-O -Wno-shift-overflow" } */
+/* { dg-additional-options "-std=c++11" { target c++ } } */
+
+#define INTM1 (sizeof (int) * __CHAR_BIT__ - 1)
+#define INTM2 (sizeof (int) * __CHAR_BIT__ - 2)
+#define LLONGM1 (sizeof (long long) * __CHAR_BIT__ - 1)
+#define LLONGM2 (sizeof (long long) * __CHAR_BIT__ - 2)
+
+#define INT_MIN (-__INT_MAX__-1)
+#define LONG_LONG_MIN (-__LONG_LONG_MAX__-1)
+
+int i1 = 1 << INTM1;
+int i2 = 9 << INTM1;
+int i3 = 10 << INTM2;
+int i4 = __INT_MAX__ << 2;
+int i5 = __INT_MAX__ << INTM1;
+int i6 = -1 << INTM1;
+int i7 = -9 << INTM1;
+int i8 = -10 << INTM2;
+int i9 = -__INT_MAX__ << 2;
+int i10 = -__INT_MAX__ << INTM1;
+int i11 = INT_MIN << 1;
+
+int r1 = 1 >> INTM1;
+int r2 = 9 >> INTM1;
+int r3 = 10 >> INTM2;
+int r4 = __INT_MAX__ >> 2;
+int r5 = __INT_MAX__ >> INTM1;
+int r6 = -1 >> INTM1;
+int r7 = -9 >> INTM1;
+int r8 = -10 >> INTM2;
+int r9 = -__INT_MAX__ >> 2;
+int r10 = -__INT_MAX__ >> INTM1;
+
+unsigned u1 = 1 << INTM1;
+unsigned u2 = 9 << INTM1;
+unsigned u3 = 2U << INTM1;
+unsigned u4 = 9U << INTM1;
+unsigned u5 = 10U << INTM2;
+
+long long int l1 = 1LL << LLONGM1;
+long long int l2 = 9LL << LLONGM1;
+long long int l3 = 10LL << LLONGM2;
+long long int l4 = __LONG_LONG_MAX__ << 2;
+long long int l5 = __LONG_LONG_MAX__ << LLONGM1;
+long long int l6 = -1LL << LLONGM1;
+long long int l7 = -9LL << LLONGM1;
+long long int l8 = -10LL << LLONGM2;
+long long int l9 = -__LONG_LONG_MAX__ << 2;
+long long int l10 = -__LONG_LONG_MAX__ << LLONGM1;
+long long int l11 = LONG_LONG_MIN << 1;
+
+void
+fn (void)
+{
+ const int a = 10;
+ const __SIZE_TYPE__ b = INTM1;
+ int k1 = a << b;
+ int k2 = 10 << b;
+ int k3 = a << INTM1;
+}
diff --git a/gcc/testsuite/c-c++-common/Wshift-overflow-3.c b/gcc/testsuite/c-c++-common/Wshift-overflow-3.c
new file mode 100644
index 0000000000..03b07f8092
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-overflow-3.c
@@ -0,0 +1,64 @@
+/* PR c++/55095 */
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-O -Wshift-overflow" } */
+/* { dg-additional-options "-std=gnu90" { target c } } */
+/* { dg-additional-options "-std=c++03" { target c++ } } */
+
+#define INTM1 (sizeof (int) * __CHAR_BIT__ - 1)
+#define INTM2 (sizeof (int) * __CHAR_BIT__ - 2)
+#define LLONGM1 (sizeof (long long) * __CHAR_BIT__ - 1)
+#define LLONGM2 (sizeof (long long) * __CHAR_BIT__ - 2)
+
+#define INT_MIN (-__INT_MAX__-1)
+#define LONG_LONG_MIN (-__LONG_LONG_MAX__-1)
+
+int i1 = 1 << INTM1;
+int i2 = 9 << INTM1; /* { dg-warning "requires 36 bits to represent" } */
+int i3 = 10 << INTM2; /* { dg-warning "requires 35 bits to represent" } */
+int i4 = __INT_MAX__ << 2; /* { dg-warning "requires 34 bits to represent" } */
+int i5 = __INT_MAX__ << INTM1; /* { dg-warning "requires 63 bits to represent" } */
+int i6 = -1 << INTM1;
+int i7 = -9 << INTM1; /* { dg-warning "requires 36 bits to represent" } */
+int i8 = -10 << INTM2; /* { dg-warning "requires 35 bits to represent" } */
+int i9 = -__INT_MAX__ << 2; /* { dg-warning "requires 34 bits to represent" } */
+int i10 = -__INT_MAX__ << INTM1; /* { dg-warning "requires 63 bits to represent" } */
+int i11 = INT_MIN << 1; /* { dg-warning "requires 33 bits to represent" } */
+
+int r1 = 1 >> INTM1;
+int r2 = 9 >> INTM1;
+int r3 = 10 >> INTM2;
+int r4 = __INT_MAX__ >> 2;
+int r5 = __INT_MAX__ >> INTM1;
+int r6 = -1 >> INTM1;
+int r7 = -9 >> INTM1;
+int r8 = -10 >> INTM2;
+int r9 = -__INT_MAX__ >> 2;
+int r10 = -__INT_MAX__ >> INTM1;
+
+unsigned u1 = 1 << INTM1;
+unsigned u2 = 9 << INTM1; /* { dg-warning "requires 36 bits to represent" } */
+unsigned u3 = 2U << INTM1;
+unsigned u4 = 9U << INTM1;
+unsigned u5 = 10U << INTM2;
+
+long long int l1 = 1LL << LLONGM1;
+long long int l2 = 9LL << LLONGM1; /* { dg-warning "requires 68 bits to represent" } */
+long long int l3 = 10LL << LLONGM2; /* { dg-warning "requires 67 bits to represent" } */
+long long int l4 = __LONG_LONG_MAX__ << 2; /* { dg-warning "requires 66 bits to represent" } */
+long long int l5 = __LONG_LONG_MAX__ << LLONGM1; /* { dg-warning "requires 127 bits to represent" } */
+long long int l6 = -1LL << LLONGM1;
+long long int l7 = -9LL << LLONGM1; /* { dg-warning "requires 68 bits to represent" } */
+long long int l8 = -10LL << LLONGM2; /* { dg-warning "requires 67 bits to represent" } */
+long long int l9 = -__LONG_LONG_MAX__ << 2; /* { dg-warning "requires 66 bits to represent" } */
+long long int l10 = -__LONG_LONG_MAX__ << LLONGM1; /* { dg-warning "requires 127 bits to represent" } */
+long long int l11 = LONG_LONG_MIN << 1; /* { dg-warning "requires 65 bits to represent" } */
+
+void
+fn (void)
+{
+ const int a = 10;
+ const __SIZE_TYPE__ b = INTM1;
+ int k1 = a << b; /* { dg-warning "requires 36 bits to represent" } */
+ int k2 = 10 << b; /* { dg-warning "requires 36 bits to represent" } */
+ int k3 = a << INTM1; /* { dg-warning "requires 36 bits to represent" } */
+}
diff --git a/gcc/testsuite/c-c++-common/Wshift-overflow-4.c b/gcc/testsuite/c-c++-common/Wshift-overflow-4.c
new file mode 100644
index 0000000000..d44f9dc980
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-overflow-4.c
@@ -0,0 +1,64 @@
+/* PR c++/55095 */
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-O" } */
+/* { dg-additional-options "-std=gnu90" { target c } } */
+/* { dg-additional-options "-std=c++03" { target c++ } } */
+
+#define INTM1 (sizeof (int) * __CHAR_BIT__ - 1)
+#define INTM2 (sizeof (int) * __CHAR_BIT__ - 2)
+#define LLONGM1 (sizeof (long long) * __CHAR_BIT__ - 1)
+#define LLONGM2 (sizeof (long long) * __CHAR_BIT__ - 2)
+
+#define INT_MIN (-__INT_MAX__-1)
+#define LONG_LONG_MIN (-__LONG_LONG_MAX__-1)
+
+int i1 = 1 << INTM1;
+int i2 = 9 << INTM1;
+int i3 = 10 << INTM2;
+int i4 = __INT_MAX__ << 2;
+int i5 = __INT_MAX__ << INTM1;
+int i6 = -1 << INTM1;
+int i7 = -9 << INTM1;
+int i8 = -10 << INTM2;
+int i9 = -__INT_MAX__ << 2;
+int i10 = -__INT_MAX__ << INTM1;
+int i11 = INT_MIN << 1;
+
+int r1 = 1 >> INTM1;
+int r2 = 9 >> INTM1;
+int r3 = 10 >> INTM2;
+int r4 = __INT_MAX__ >> 2;
+int r5 = __INT_MAX__ >> INTM1;
+int r6 = -1 >> INTM1;
+int r7 = -9 >> INTM1;
+int r8 = -10 >> INTM2;
+int r9 = -__INT_MAX__ >> 2;
+int r10 = -__INT_MAX__ >> INTM1;
+
+unsigned u1 = 1 << INTM1;
+unsigned u2 = 9 << INTM1;
+unsigned u3 = 2U << INTM1;
+unsigned u4 = 9U << INTM1;
+unsigned u5 = 10U << INTM2;
+
+long long int l1 = 1LL << LLONGM1;
+long long int l2 = 9LL << LLONGM1;
+long long int l3 = 10LL << LLONGM2;
+long long int l4 = __LONG_LONG_MAX__ << 2;
+long long int l5 = __LONG_LONG_MAX__ << LLONGM1;
+long long int l6 = -1LL << LLONGM1;
+long long int l7 = -9LL << LLONGM1;
+long long int l8 = -10LL << LLONGM2;
+long long int l9 = -__LONG_LONG_MAX__ << 2;
+long long int l10 = -__LONG_LONG_MAX__ << LLONGM1;
+long long int l11 = LONG_LONG_MIN << 1;
+
+void
+fn (void)
+{
+ const int a = 10;
+ const __SIZE_TYPE__ b = INTM1;
+ int k1 = a << b;
+ int k2 = 10 << b;
+ int k3 = a << INTM1;
+}
diff --git a/gcc/testsuite/c-c++-common/Wshift-overflow-5.c b/gcc/testsuite/c-c++-common/Wshift-overflow-5.c
new file mode 100644
index 0000000000..c9f464355d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-overflow-5.c
@@ -0,0 +1,11 @@
+/* PR c++/55095 */
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-O -Wshift-overflow=2" } */
+/* { dg-additional-options "-std=c++11" { target c++ } } */
+
+#define INTM1 (sizeof (int) * __CHAR_BIT__ - 1)
+#define LLONGM1 (sizeof (long long) * __CHAR_BIT__ - 1)
+
+int i1 = 1 << INTM1; /* { dg-warning "requires 33 bits to represent" } */
+unsigned u1 = 1 << INTM1; /* { dg-warning "requires 33 bits to represent" } */
+long long int l1 = 1LL << LLONGM1; /* { dg-warning "requires 65 bits to represent" } */
diff --git a/gcc/testsuite/c-c++-common/Wshift-overflow-6.c b/gcc/testsuite/c-c++-common/Wshift-overflow-6.c
new file mode 100644
index 0000000000..64797f44a1
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-overflow-6.c
@@ -0,0 +1,37 @@
+/* PR c++/55095 */
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-Wshift-overflow=1" } */
+/* { dg-additional-options "-std=c++11" { target c++ } } */
+
+int i00 = 0b1 << 31;
+int i01 = 0b10 << 30;
+int i02 = 0b100 << 29;
+int i03 = 0b1000 << 28;
+int i04 = 0b10000 << 27;
+int i05 = 0b100000 << 26;
+int i06 = 0b1000000 << 25;
+int i07 = 0b10000000 << 24;
+int i08 = 0b100000000 << 23;
+int i09 = 0b1000000000 << 22;
+int i10 = 0b10000000000 << 21;
+int i11 = 0b100000000000 << 20;
+int i12 = 0b1000000000000 << 19;
+int i13 = 0b10000000000000 << 18;
+int i14 = 0b100000000000000 << 17;
+int i15 = 0b1000000000000000 << 16;
+int i16 = 0b10000000000000000 << 15;
+int i17 = 0b100000000000000000 << 14;
+int i18 = 0b1000000000000000000 << 13;
+int i19 = 0b10000000000000000000 << 12;
+int i20 = 0b100000000000000000000 << 11;
+int i21 = 0b1000000000000000000000 << 10;
+int i22 = 0b10000000000000000000000 << 9;
+int i23 = 0b100000000000000000000000 << 8;
+int i24 = 0b1000000000000000000000000 << 7;
+int i25 = 0b10000000000000000000000000 << 6;
+int i26 = 0b100000000000000000000000000 << 5;
+int i27 = 0b1000000000000000000000000000 << 4;
+int i28 = 0b10000000000000000000000000000 << 3;
+int i29 = 0b100000000000000000000000000000 << 2;
+int i30 = 0b1000000000000000000000000000000 << 1;
+int i31 = (int) 0b10000000000000000000000000000000u << 1; /* { dg-warning "requires 33 bits to represent" } */
diff --git a/gcc/testsuite/c-c++-common/Wshift-overflow-7.c b/gcc/testsuite/c-c++-common/Wshift-overflow-7.c
new file mode 100644
index 0000000000..ca99d2e46f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wshift-overflow-7.c
@@ -0,0 +1,37 @@
+/* PR c++/55095 */
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-Wshift-overflow=2" } */
+/* { dg-additional-options "-std=c++11" { target c++ } } */
+
+int i00 = 0b1 << 31; /* { dg-warning "requires 33 bits to represent" } */
+int i01 = 0b10 << 30; /* { dg-warning "requires 33 bits to represent" } */
+int i02 = 0b100 << 29; /* { dg-warning "requires 33 bits to represent" } */
+int i03 = 0b1000 << 28; /* { dg-warning "requires 33 bits to represent" } */
+int i04 = 0b10000 << 27; /* { dg-warning "requires 33 bits to represent" } */
+int i05 = 0b100000 << 26; /* { dg-warning "requires 33 bits to represent" } */
+int i06 = 0b1000000 << 25; /* { dg-warning "requires 33 bits to represent" } */
+int i07 = 0b10000000 << 24; /* { dg-warning "requires 33 bits to represent" } */
+int i08 = 0b100000000 << 23; /* { dg-warning "requires 33 bits to represent" } */
+int i09 = 0b1000000000 << 22; /* { dg-warning "requires 33 bits to represent" } */
+int i10 = 0b10000000000 << 21; /* { dg-warning "requires 33 bits to represent" } */
+int i11 = 0b100000000000 << 20; /* { dg-warning "requires 33 bits to represent" } */
+int i12 = 0b1000000000000 << 19; /* { dg-warning "requires 33 bits to represent" } */
+int i13 = 0b10000000000000 << 18; /* { dg-warning "requires 33 bits to represent" } */
+int i14 = 0b100000000000000 << 17; /* { dg-warning "requires 33 bits to represent" } */
+int i15 = 0b1000000000000000 << 16; /* { dg-warning "requires 33 bits to represent" } */
+int i16 = 0b10000000000000000 << 15; /* { dg-warning "requires 33 bits to represent" } */
+int i17 = 0b100000000000000000 << 14; /* { dg-warning "requires 33 bits to represent" } */
+int i18 = 0b1000000000000000000 << 13; /* { dg-warning "requires 33 bits to represent" } */
+int i19 = 0b10000000000000000000 << 12; /* { dg-warning "requires 33 bits to represent" } */
+int i20 = 0b100000000000000000000 << 11; /* { dg-warning "requires 33 bits to represent" } */
+int i21 = 0b1000000000000000000000 << 10; /* { dg-warning "requires 33 bits to represent" } */
+int i22 = 0b10000000000000000000000 << 9; /* { dg-warning "requires 33 bits to represent" } */
+int i23 = 0b100000000000000000000000 << 8; /* { dg-warning "requires 33 bits to represent" } */
+int i24 = 0b1000000000000000000000000 << 7; /* { dg-warning "requires 33 bits to represent" } */
+int i25 = 0b10000000000000000000000000 << 6; /* { dg-warning "requires 33 bits to represent" } */
+int i26 = 0b100000000000000000000000000 << 5; /* { dg-warning "requires 33 bits to represent" } */
+int i27 = 0b1000000000000000000000000000 << 4; /* { dg-warning "requires 33 bits to represent" } */
+int i28 = 0b10000000000000000000000000000 << 3; /* { dg-warning "requires 33 bits to represent" } */
+int i29 = 0b100000000000000000000000000000 << 2; /* { dg-warning "requires 33 bits to represent" } */
+int i30 = 0b1000000000000000000000000000000 << 1; /* { dg-warning "requires 33 bits to represent" } */
+int i31 = (int) 0b10000000000000000000000000000000u << 1; /* { dg-warning "requires 33 bits to represent" } */
diff --git a/gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess1.c b/gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess1.c
index 8e829d61ae..7861bb082c 100644
--- a/gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess1.c
+++ b/gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess1.c
@@ -1,6 +1,8 @@
/* Test -Wsizeof-pointer-memaccess warnings. */
/* { dg-do compile } */
/* { dg-options "-Wall -Wno-sizeof-array-argument" } */
+/* { dg-options "-Wall -Wno-sizeof-array-argument -Wno-c++-compat" { target c } } */
+/* { dg-require-effective-target alloca } */
typedef __SIZE_TYPE__ size_t;
#ifdef __cplusplus
diff --git a/gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess2.c b/gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess2.c
index fe17a7056a..d9ec7e2cac 100644
--- a/gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess2.c
+++ b/gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess2.c
@@ -1,6 +1,8 @@
/* Test -Wsizeof-pointer-memaccess warnings. */
/* { dg-do compile } */
/* { dg-options "-Wall -O2 -Wno-sizeof-array-argument" } */
+/* { dg-options "-Wall -O2 -Wno-sizeof-array-argument -Wno-c++-compat" {target c} } */
+/* { dg-require-effective-target alloca } */
#define bos(ptr) __builtin_object_size (ptr, 1)
#define bos0(ptr) __builtin_object_size (ptr, 0)
diff --git a/gcc/testsuite/c-c++-common/Wtautological-compare-1.c b/gcc/testsuite/c-c++-common/Wtautological-compare-1.c
new file mode 100644
index 0000000000..71ba4f8048
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wtautological-compare-1.c
@@ -0,0 +1,70 @@
+/* PR c++/66555 */
+/* { dg-do compile } */
+/* { dg-options "-Wtautological-compare" } */
+
+#define X 5
+#define Y 5
+#define A a
+enum { U };
+
+void
+fn1 (int a, int *p)
+{
+ if (a > a); /* { dg-warning "self-comparison always evaluates to false" } */
+ if (a < a); /* { dg-warning "self-comparison always evaluates to false" } */
+ if (a >= a); /* { dg-warning "self-comparison always evaluates to true" } */
+ if (a <= a); /* { dg-warning "self-comparison always evaluates to true" } */
+ if (a == a); /* { dg-warning "self-comparison always evaluates to true" } */
+ if (a != a); /* { dg-warning "self-comparison always evaluates to false" } */
+ if (A == A); /* { dg-warning "self-comparison always evaluates to true" } */
+ if ((unsigned) a != (unsigned) a);
+ if ((a + 1) <= (a + 1)); /* { dg-warning "self-comparison always evaluates to true" } */
+ if (1 ? a == a : 0); /* { dg-warning "self-comparison always evaluates to true" } */
+ if (fn1 == fn1); /* { dg-warning "self-comparison always evaluates to true" } */
+ if (*p == *p); /* { dg-warning "self-comparison always evaluates to true" } */
+
+ volatile int v = 5;
+ if (v == v);
+ if (v != v);
+}
+
+void
+fn2 (int a)
+{
+ if (sizeof (int) >= 4);
+ if (sizeof (char) != 1);
+ if (sizeof (long) != sizeof (long long));
+ if (0 < sizeof (short));
+ if (5 != 5);
+ if (X > 5);
+ if (X == X);
+ if (3 + 4 == 6 + 1);
+ if ((unsigned) a != (unsigned long) a);
+ if (U == U);
+ if (U > 0);
+}
+
+void
+fn3 (int i, int j)
+{
+ static int a[16];
+ static int b[8][8];
+
+ if (a[5] == a[5]);
+ if (a[X] != a[Y]);
+ if (a[X] != a[X]);
+ if (a[i] == a[i]); /* { dg-warning "self-comparison always evaluates to true" } */
+ if (b[5][5] == b[5][5]);
+ if (b[X][Y] >= b[Y][X]);
+ if (b[X][X] == b[Y][Y]);
+ if (b[i][j] != b[i][j]); /* { dg-warning "self-comparison always evaluates to false" } */
+ if (b[i][Y] < b[i][X]);
+ if (b[X][j] < b[X][j]);
+ if ((a[i] + 4) == (4 + a[i])); /* { dg-warning "self-comparison always evaluates to true" } */
+}
+
+int
+fn4 (int x, int y)
+{
+ return x > x ? 1 : 0; /* { dg-warning "self-comparison always evaluates to false" } */
+}
diff --git a/gcc/testsuite/c-c++-common/Wtautological-compare-2.c b/gcc/testsuite/c-c++-common/Wtautological-compare-2.c
new file mode 100644
index 0000000000..260d9f7d57
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wtautological-compare-2.c
@@ -0,0 +1,13 @@
+/* PR bootstrap/67030 */
+/* { dg-do compile } */
+/* { dg-options "-Wtautological-compare" } */
+
+#define A a
+#define B A
+#define FOO (A > B)
+
+void
+fn1 (int a)
+{
+ if (FOO);
+}
diff --git a/gcc/testsuite/c-c++-common/Wtautological-compare-3.c b/gcc/testsuite/c-c++-common/Wtautological-compare-3.c
new file mode 100644
index 0000000000..64807b01d5
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wtautological-compare-3.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-Wtautological-compare" } */
+/* Test we don't warn for floats. */
+
+struct S { double d; float f; };
+
+void
+fn1 (int i, float f, double d, struct S *s, float *fp)
+{
+ if (f == f);
+ if (f != f);
+ if (d == d);
+ if (d != d);
+ if (fp[i] == fp[i]);
+ if (fp[i] != fp[i]);
+ if (s->f == s->f);
+ if (s->f != s->f);
+ if (s->d == s->d);
+ if (s->d != s->d);
+}
diff --git a/gcc/testsuite/c-c++-common/Wtautological-compare-4.c b/gcc/testsuite/c-c++-common/Wtautological-compare-4.c
new file mode 100644
index 0000000000..207c401a4c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wtautological-compare-4.c
@@ -0,0 +1,15 @@
+/* PR c++/67863 */
+/* { dg-do compile } */
+/* { dg-options "-Wtautological-compare" } */
+
+extern int e;
+#define A (e ? 4 : 8)
+#define B (e ? 4 : 8)
+
+int
+fn (void)
+{
+ if (A <= B)
+ return 1;
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/Wunused-function-1.c b/gcc/testsuite/c-c++-common/Wunused-function-1.c
new file mode 100644
index 0000000000..9f856952b2
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wunused-function-1.c
@@ -0,0 +1,10 @@
+/* PR c++/64079 */
+/* { dg-do compile } */
+/* { dg-options "-Wunused-function" } */
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+
+static void bar() {}
+
+#pragma GCC diagnostic pop
diff --git a/gcc/testsuite/c-c++-common/Wunused-var-13.c b/gcc/testsuite/c-c++-common/Wunused-var-13.c
index 3afd873b64..5b49702d41 100644
--- a/gcc/testsuite/c-c++-common/Wunused-var-13.c
+++ b/gcc/testsuite/c-c++-common/Wunused-var-13.c
@@ -1,6 +1,7 @@
/* PR c/46015 */
/* { dg-options "-Wunused" } */
/* { dg-do compile } */
+/* { dg-require-effective-target label_values } */
int
f1 (int i)
diff --git a/gcc/testsuite/c-c++-common/Wunused-var-6.c b/gcc/testsuite/c-c++-common/Wunused-var-6.c
index 1217719a29..12a7dddc00 100644
--- a/gcc/testsuite/c-c++-common/Wunused-var-6.c
+++ b/gcc/testsuite/c-c++-common/Wunused-var-6.c
@@ -1,6 +1,7 @@
/* PR c/43981 */
/* { dg-do compile } */
/* { dg-options "-Wunused" } */
+/* { dg-require-effective-target alloca } */
void g (char *);
diff --git a/gcc/testsuite/c-c++-common/Wunused-var-8.c b/gcc/testsuite/c-c++-common/Wunused-var-8.c
index 0923b35566..8c49ed2fa5 100644
--- a/gcc/testsuite/c-c++-common/Wunused-var-8.c
+++ b/gcc/testsuite/c-c++-common/Wunused-var-8.c
@@ -1,6 +1,7 @@
/* Origin: PR c++/44108 */
/* { dg-options "-Wunused" } */
/* { dg-do compile } */
+/* { dg-require-effective-target alloca } */
int
foo ()
diff --git a/gcc/testsuite/c-c++-common/Wvarargs.c b/gcc/testsuite/c-c++-common/Wvarargs.c
index 408f427b5c..0f90cb3bfc 100644
--- a/gcc/testsuite/c-c++-common/Wvarargs.c
+++ b/gcc/testsuite/c-c++-common/Wvarargs.c
@@ -49,6 +49,6 @@ foo3 (int a, register int b, ...)
{
va_list vp;
/* 'b' is declared with register storage, so warn. */
- va_start (vp, b); /* { dg-warning "undefined behaviour" } */
+ va_start (vp, b); /* { dg-warning "undefined behavior" } */
va_end (vp);
}
diff --git a/gcc/testsuite/c-c++-common/asan/aggressive-opts.c b/gcc/testsuite/c-c++-common/asan/aggressive-opts.c
index 979b6118d1..294b7fc063 100644
--- a/gcc/testsuite/c-c++-common/asan/aggressive-opts.c
+++ b/gcc/testsuite/c-c++-common/asan/aggressive-opts.c
@@ -25,4 +25,3 @@ Perl_do_sv_dump()
}
/* { dg-final { scan-tree-dump-times "ASAN_CHECK" 2 "asan1" } } */
-/* { dg-final { cleanup-tree-dump "asan1" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/halt_on_error-1.c b/gcc/testsuite/c-c++-common/asan/halt_on_error-1.c
new file mode 100644
index 0000000000..52e705d613
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/halt_on_error-1.c
@@ -0,0 +1,23 @@
+/* Test recovery mode. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize-recover=address" } */
+/* { dg-set-target-env-var ASAN_OPTIONS "halt_on_error=false" } */
+
+#include <string.h>
+
+volatile int ten = 10;
+
+int main() {
+ char x[10];
+ __builtin_memset(x, 0, ten + 1);
+ asm volatile ("" : : : "memory");
+ volatile int res = x[ten];
+ x[ten] = res + 3;
+ res = x[ten];
+ return 0;
+}
+
+/* { dg-output "WRITE of size 11 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
+/* { dg-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
+/* { dg-output "\[^\n\r]*WRITE of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
+/* { dg-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
diff --git a/gcc/testsuite/c-c++-common/asan/halt_on_error-2.c b/gcc/testsuite/c-c++-common/asan/halt_on_error-2.c
new file mode 100644
index 0000000000..35dc0fa2dd
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/halt_on_error-2.c
@@ -0,0 +1,24 @@
+/* Test recovery mode. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize-recover=address" } */
+/* { dg-set-target-env-var ASAN_OPTIONS "halt_on_error=true" } */
+/* { dg-shouldfail "asan" } */
+
+#include <string.h>
+
+volatile int ten = 10;
+
+int main() {
+ char x[10];
+ __builtin_memset(x, 0, ten + 1);
+ asm volatile ("" : : : "memory");
+ volatile int res = x[ten];
+ x[ten] = res + 3;
+ res = x[ten];
+ return 0;
+}
+
+/* { dg-output "WRITE of size 11 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
+/* { dg-prune-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
+/* { dg-prune-output "\[^\n\r]*WRITE of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
+/* { dg-prune-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
diff --git a/gcc/testsuite/c-c++-common/asan/inc.c b/gcc/testsuite/c-c++-common/asan/inc.c
index 36cc3d8d81..5abf373181 100644
--- a/gcc/testsuite/c-c++-common/asan/inc.c
+++ b/gcc/testsuite/c-c++-common/asan/inc.c
@@ -18,4 +18,3 @@ main ()
/* { dg-final { scan-tree-dump-times "ASAN_" 1 "asan0" } } */
/* { dg-final { scan-tree-dump "ASAN_CHECK \\(.*, 4\\);" "asan0" } } */
-/* { dg-final { cleanup-tree-dump "asan0" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/memcmp-1.c b/gcc/testsuite/c-c++-common/asan/memcmp-1.c
index c582e3d0cb..5915988be5 100644
--- a/gcc/testsuite/c-c++-common/asan/memcmp-1.c
+++ b/gcc/testsuite/c-c++-common/asan/memcmp-1.c
@@ -9,12 +9,12 @@ volatile int one = 1;
int
main ()
{
- char a1[] = {one, 2, 3, 4};
- char a2[] = {1, 2*one, 3, 4};
+ char a1[] = {(char)one, 2, 3, 4};
+ char a2[] = {1, (char)(2*one), 3, 4};
int res = memcmp (a1, a2, 5 + one);
return res;
}
/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow.*(\n|\r\n|\r)" } */
-/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)memcmp |\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)memcmp|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-asan-check-glob.c b/gcc/testsuite/c-c++-common/asan/no-asan-check-glob.c
index 02ca646c11..c0505e3b12 100644
--- a/gcc/testsuite/c-c++-common/asan/no-asan-check-glob.c
+++ b/gcc/testsuite/c-c++-common/asan/no-asan-check-glob.c
@@ -10,4 +10,3 @@ int foo ()
}
/* { dg-final { scan-tree-dump-times "ASAN_CHECK" 0 "asan1" } } */
-/* { dg-final { cleanup-tree-dump "asan1" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-asan-stack.c b/gcc/testsuite/c-c++-common/asan/no-asan-stack.c
index 0f65ab3f7a..59ae55b0b0 100644
--- a/gcc/testsuite/c-c++-common/asan/no-asan-stack.c
+++ b/gcc/testsuite/c-c++-common/asan/no-asan-stack.c
@@ -7,8 +7,8 @@ volatile int one = 1;
int
main ()
{
- volatile char a1[] = {one, 2, 3, 4};
- volatile char a2[] = {1, 2*one, 3, 4};
+ volatile char a1[] = {(char)one, 2, 3, 4};
+ volatile char a2[] = {1, (char)(2*one), 3, 4};
volatile int res = memcmp ((void *)a1,(void *)a2, 5 + one);
return 0;
}
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-1.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-1.c
index baacb1e536..a9b51609f0 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-1.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-1.c
@@ -57,4 +57,3 @@ main ()
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_store1" 3 "sanopt" } } */
/* { dg-final { scan-tree-dump-not "__builtin___asan_report_load1" "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-10.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-10.c
index 24dfcfec97..84d469d1de 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-10.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-10.c
@@ -15,4 +15,3 @@ foo ()
}
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_store4" 1 "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-11.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-11.c
index 4082f32694..83034309b2 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-11.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-11.c
@@ -17,4 +17,3 @@ foo ()
/* { dg-final { scan-tree-dump-not "& 7" "sanopt" } } */
/* { dg-final { scan-tree-dump-not "__builtin___asan_report_store" "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-12.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-12.c
index 65e1d96f95..cf216be4e0 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-12.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-12.c
@@ -13,4 +13,3 @@ foo (char *p)
}
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_store1" 1 "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-13.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-13.c
index c04be06418..63a299ef5d 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-13.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-13.c
@@ -12,4 +12,3 @@ foo (char *p)
}
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_store1" 1 "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-14.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-14.c
index fadce906f5..0750f1b6cf 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-14.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-14.c
@@ -12,4 +12,3 @@ foo (char *p)
}
/* { dg-final { scan-tree-dump-not "__builtin___asan_report_store1" "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-15.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-15.c
index 00676dad61..ad6a0bb041 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-15.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-15.c
@@ -13,4 +13,3 @@ foo (char *p)
}
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_store1" 1 "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-3.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-3.c
index 5193ae06f4..6432236c2b 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-3.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-3.c
@@ -15,4 +15,3 @@ foo (__INT32_TYPE__ *p)
/* { dg-final { scan-tree-dump-times "__builtin___asan_report" 2 "sanopt" } } */
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_load1" 1 "sanopt" } } */
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_store" 1 "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-4.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-4.c
index a613b92cbc..d24d1c2c60 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-4.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-4.c
@@ -14,4 +14,3 @@ foo (int *a, char *b, char *c)
/* { dg-final { scan-tree-dump-times "& 7" 2 "sanopt" } } */
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_load1" 1 "sanopt" } } */
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_load4" 1 "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-5.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-5.c
index f4ca603f0c..15418ba4b3 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-5.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-5.c
@@ -13,4 +13,3 @@ foo (int *a, char *b, char *c)
/* { dg-final { scan-tree-dump-times "& 7" 1 "sanopt" } } */
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_load4" 1 "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-6.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-6.c
index 757f0eeb62..0ea1fab8fc 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-6.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-6.c
@@ -16,4 +16,3 @@ foo (int *a, char *b, char *c)
/* { dg-final { scan-tree-dump-times "& 7" 4 "sanopt" } } */
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_load1" 2 "sanopt" } } */
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_load4" 2 "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-7.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-7.c
index 0c50145128..6fb88f8c4f 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-7.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-7.c
@@ -20,4 +20,3 @@ foo (int *a, char *b, char *c)
/* { dg-final { scan-tree-dump-not "& 7" "sanopt" } } */
/* { dg-final { scan-tree-dump-not "__builtin___asan_report_load4" "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-8.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-8.c
index 4eeedcedc9..556aa1e5bb 100644
--- a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-8.c
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-8.c
@@ -17,4 +17,3 @@ foo (int *a, char *b, char *c)
/* { dg-final { scan-tree-dump-times "& 7" 4 "sanopt" } } */
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_load1" 2 "sanopt" } } */
/* { dg-final { scan-tree-dump-times "__builtin___asan_report_load4" 2 "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/pr70541.c b/gcc/testsuite/c-c++-common/asan/pr70541.c
new file mode 100644
index 0000000000..b2a4bd5e07
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/pr70541.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-fno-builtin-malloc -fno-builtin-free" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+/* { dg-shouldfail "asan" } */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+struct Simple {
+ int value;
+};
+
+int f(struct Simple simple) {
+ return simple.value;
+}
+
+int main() {
+ struct Simple *psimple = (struct Simple *) malloc(sizeof(struct Simple));
+ psimple->value = 42;
+ free(psimple);
+ printf("%d\n", f(*psimple));
+ return 0;
+}
+
+/* { dg-output "ERROR: AddressSanitizer:? heap-use-after-free on address\[^\n\r]*" } */
+/* { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*pr70541.c:21|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*freed by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)free|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*pr70541.c:20|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*previously allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output " #0 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*pr70541.c:18|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
diff --git a/gcc/testsuite/c-c++-common/asan/red-align-1.c b/gcc/testsuite/c-c++-common/asan/red-align-1.c
index afd7467720..1b4452477f 100644
--- a/gcc/testsuite/c-c++-common/asan/red-align-1.c
+++ b/gcc/testsuite/c-c++-common/asan/red-align-1.c
@@ -17,4 +17,3 @@ int foo (struct st * s_p)
}
/* { dg-final { scan-tree-dump-times "& 7" 0 "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/red-align-2.c b/gcc/testsuite/c-c++-common/asan/red-align-2.c
index d30b1ad9f0..e0f00c57d5 100644
--- a/gcc/testsuite/c-c++-common/asan/red-align-2.c
+++ b/gcc/testsuite/c-c++-common/asan/red-align-2.c
@@ -17,4 +17,3 @@ int foo (struct st * s_p)
}
/* { dg-final { scan-tree-dump-times "& 7" 1 "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c b/gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c
index 78d15e1aad..219fcf8ac3 100644
--- a/gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c
+++ b/gcc/testsuite/c-c++-common/asan/sanity-check-pure-c-1.c
@@ -10,7 +10,7 @@ int main() {
}
/* { dg-output "heap-use-after-free.*(\n|\r\n|\r)" } */
-/* { dg-output " #0 \[^\n\r]*(in _*(interceptor_|)free|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output " #0 \[^\n\r]*(in _*(interceptor_|wrap_)free|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output " #1 \[^\n\r]*(in _*main (\[^\n\r]*sanity-check-pure-c-1.c:8|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
-/* { dg-output " #0 \[^\n\r]*(in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output " #0 \[^\n\r]*(in _*(interceptor_|wrap_)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output " #1 \[^\n\r]*(in _*main (\[^\n\r]*sanity-check-pure-c-1.c:7|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
diff --git a/gcc/testsuite/c-c++-common/asan/shadow-offset-1.c b/gcc/testsuite/c-c++-common/asan/shadow-offset-1.c
index 2ca0fd641f..d868fd0124 100644
--- a/gcc/testsuite/c-c++-common/asan/shadow-offset-1.c
+++ b/gcc/testsuite/c-c++-common/asan/shadow-offset-1.c
@@ -8,4 +8,3 @@ int f (int *p)
}
/* { dg-final { scan-tree-dump "12345" "sanopt" } } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/asan/swapcontext-test-1.c b/gcc/testsuite/c-c++-common/asan/swapcontext-test-1.c
index 23d3db0655..555f2d9bb4 100644
--- a/gcc/testsuite/c-c++-common/asan/swapcontext-test-1.c
+++ b/gcc/testsuite/c-c++-common/asan/swapcontext-test-1.c
@@ -52,9 +52,9 @@ volatile int zero = 0;
int main(int argc, char **argv) {
int ret = 0;
ret += Run(zero, 0);
- printf("Test1 passed\n");
+ fprintf(stderr, "Test1 passed\n");
ret += Run(zero, 1);
- printf("Test2 passed\n");
+ fprintf(stderr, "Test2 passed\n");
return ret;
}
diff --git a/gcc/testsuite/c-c++-common/asan/user-section-1.c b/gcc/testsuite/c-c++-common/asan/user-section-1.c
new file mode 100644
index 0000000000..7bcc4bc1c3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/user-section-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=address -fsanitize-sections=.xxx,.yyy -fdump-tree-sanopt" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+
+int x __attribute__((section(".xxx"))) = 1;
+int y __attribute__((section(".yyy"))) = 1;
+int z __attribute__((section(".zzz"))) = 1;
+
+/* { dg-final { scan-tree-dump "__builtin___asan_unregister_globals \\(.*, 2\\);" "sanopt" } } */
+
diff --git a/gcc/testsuite/c-c++-common/asan/user-section-2.c b/gcc/testsuite/c-c++-common/asan/user-section-2.c
new file mode 100644
index 0000000000..0c035c3795
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/user-section-2.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=address -fsanitize-sections=.x* -fdump-tree-sanopt" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+
+int x __attribute__((section(".x1"))) = 1;
+int y __attribute__((section(".x2"))) = 1;
+int z __attribute__((section(".x3"))) = 1;
+
+/* { dg-final { scan-tree-dump "__builtin___asan_unregister_globals \\(.*, 3\\);" "sanopt" } } */
+
diff --git a/gcc/testsuite/c-c++-common/asan/user-section-3.c b/gcc/testsuite/c-c++-common/asan/user-section-3.c
new file mode 100644
index 0000000000..3e32591b1d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/user-section-3.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=address -fsanitize-sections=.x* -fsanitize-sections=.y* -fdump-tree-sanopt" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+
+int x __attribute__((section(".x1"))) = 1;
+int y __attribute__((section(".x2"))) = 1;
+int z __attribute__((section(".y1"))) = 1;
+
+/* { dg-final { scan-tree-dump "__builtin___asan_unregister_globals \\(.*, 1\\);" "sanopt" } } */
+
diff --git a/gcc/testsuite/c-c++-common/attr-simd-2.c b/gcc/testsuite/c-c++-common/attr-simd-2.c
new file mode 100644
index 0000000000..d76eba6a47
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-simd-2.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized -fopenmp-simd" } */
+
+#pragma omp declare simd
+extern
+#ifdef __cplusplus
+"C"
+#endif
+__attribute__((__simd__))
+int simd_attr (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "omp declare simd" "optimized" } } */
+/* { dg-final { scan-assembler-times "_ZGVbN4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVbM4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcN4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcM4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdN8_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdM8_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVeN16_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVeM16_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
diff --git a/gcc/testsuite/c-c++-common/attr-simd-3.c b/gcc/testsuite/c-c++-common/attr-simd-3.c
new file mode 100644
index 0000000000..56552bd7e0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-simd-3.c
@@ -0,0 +1,5 @@
+/* { dg-do compile { target cilkplus } } */
+/* { dg-options "-fcilkplus" } */
+/* { dg-prune-output "undeclared here \\(not in a function\\)|\[^\n\r\]* was not declared in this scope" } */
+
+void f () __attribute__((__simd__, __vector__)); /* { dg-error "in the same function marked as a Cilk Plus" "PR68158" } */
diff --git a/gcc/testsuite/c-c++-common/attr-simd-4.c b/gcc/testsuite/c-c++-common/attr-simd-4.c
new file mode 100644
index 0000000000..2a58587ce3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-simd-4.c
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized" } */
+
+extern
+#ifdef __cplusplus
+"C"
+#endif
+__attribute__((__simd__("notinbranch")))
+int simd_attr (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "simd_attr\[ \\t\]simdclone|vector" "optimized" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVbN4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcN4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdN8_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVeN16_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-not "_ZGVbM4_simd_attr:" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-not "_ZGVcM4_simd_attr:" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-not "_ZGVdM8_simd_attr:" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-not "_ZGVeM16_simd_attr:" { target { i?86-*-* x86_64-*-* } } } } */
+
+extern
+#ifdef __cplusplus
+"C"
+#endif
+__attribute__((simd("inbranch")))
+int simd_attr2 (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "simd_attr2\[ \\t\]simdclone|vector" "optimized" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-not "_ZGVbN4_simd_attr2:" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-not "_ZGVcN4_simd_attr2:" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-not "_ZGVdN8_simd_attr2:" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-not "_ZGVeN16_simd_attr2:" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVbM4_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcM4_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdM8_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVeM16_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
diff --git a/gcc/testsuite/c-c++-common/attr-simd-5.c b/gcc/testsuite/c-c++-common/attr-simd-5.c
new file mode 100644
index 0000000000..7bf3f2c045
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-simd-5.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+
+__attribute__((__simd__("bug")))
+int simd_attr (void) { return 0; } /* { dg-error "only 'inbranch' and 'notinbranch'" } */
+
+__attribute__((__simd__("notinbranch", "inbranch")))
+int simd_attr2 (void) { return 0; } /* { dg-error "wrong number of arguments specified" } */
diff --git a/gcc/testsuite/c-c++-common/attr-simd.c b/gcc/testsuite/c-c++-common/attr-simd.c
new file mode 100644
index 0000000000..dde2475f9b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-simd.c
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized" } */
+
+extern
+#ifdef __cplusplus
+"C"
+#endif
+__attribute__((__simd__))
+int simd_attr (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "simd_attr\[ \\t\]simdclone|vector" "optimized" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVbN4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVbM4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcN4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcM4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdN8_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdM8_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVeN16_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVeM16_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+
+extern
+#ifdef __cplusplus
+"C"
+#endif
+__attribute__((simd))
+int simd_attr2 (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "simd_attr2\[ \\t\]simdclone|vector" "optimized" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVbN4_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVbM4_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcN4_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcM4_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdN8_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdM8_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVeN16_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVeM16_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
diff --git a/gcc/testsuite/c-c++-common/attributes-enum-1.c b/gcc/testsuite/c-c++-common/attributes-enum-1.c
new file mode 100644
index 0000000000..cb5af5b9d0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attributes-enum-1.c
@@ -0,0 +1,22 @@
+/* Test enumerators with attributes. */
+/* PR c/47043 */
+/* { dg-do compile } */
+
+enum E {
+ A __attribute__((deprecated)),
+ B __attribute__((deprecated ("foo"))),
+ C __attribute__((deprecated)) = 10,
+ D __attribute__((deprecated ("foo"))) = 15,
+ E
+};
+
+int
+f (int i)
+{
+ i += A; /* { dg-warning ".A. is deprecated" } */
+ i += B; /* { dg-warning ".B. is deprecated" } */
+ i += C; /* { dg-warning ".C. is deprecated" } */
+ i += D; /* { dg-warning ".D. is deprecated" } */
+ i += E;
+ return i;
+}
diff --git a/gcc/testsuite/c-c++-common/attributes-enum-2.c b/gcc/testsuite/c-c++-common/attributes-enum-2.c
new file mode 100644
index 0000000000..f143f15f6e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attributes-enum-2.c
@@ -0,0 +1,14 @@
+/* Test enumerators with attributes. Test invalid uses. */
+/* PR c/47043 */
+/* { dg-do compile } */
+
+enum E {
+ A __attribute__((foo)), /* { dg-warning "ignored" } */
+ B __attribute__((cold)), /* { dg-warning "ignored" } */
+ C __attribute__((const)), /* { dg-warning "ignored" } */
+ D __attribute__((unused)), /* { dg-warning "ignored" } */
+ E __attribute__((flatten)), /* { dg-warning "ignored" } */
+ F __attribute__((tm)), /* { dg-warning "ignored" } */
+ G __attribute__((common)), /* { dg-warning "ignored" } */
+ H __attribute__((volatile)), /* { dg-warning "ignored" } */
+};
diff --git a/gcc/testsuite/c-c++-common/builtin-offsetof-2.c b/gcc/testsuite/c-c++-common/builtin-offsetof-2.c
new file mode 100644
index 0000000000..f943dde05f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/builtin-offsetof-2.c
@@ -0,0 +1,217 @@
+// { dg-options "-Warray-bounds" }
+// { dg-do compile }
+
+// Test case exercising pr c/67882 - surprising offsetof result
+// on an invalid array member without diagnostic.
+
+typedef struct A1 {
+ char a1[1];
+ char c;
+} A1;
+
+typedef struct A1_x_2 {
+ char a1[1];
+ char a[][2];
+} A1_x_2;
+
+typedef struct A1_1_x {
+ char a1_1[1][1];
+ char a[];
+} A1_1_x;
+
+typedef struct Ax_2_3 {
+ int i;
+ char a_x_2_3[][2][3];
+} Ax_2_3;
+
+typedef struct A1_1 {
+ char a1_1[1][1];
+ char c;
+} A1_1;
+
+typedef struct B {
+ A1_1 a2_3[2][3];
+ char a1_1[3][5];
+ char a[];
+} B;
+
+// Structures with members that contain flexible array members are
+// an extension accepted by GCC.
+typedef struct C {
+ A1_1_x a5_7 [5][7];
+ int a;
+} C;
+
+// Structs with a "fake" flexible array member (a GCC extension).
+typedef struct FA0 {
+ int i;
+ char a0 [0];
+} FA0;
+
+typedef struct FA1 {
+ int i;
+ char a1 [1];
+} FA1;
+
+typedef struct FA3 {
+ int i;
+ char a3 [3];
+} FA3;
+
+// A "fake" multidimensional flexible array member.
+typedef struct FA5_7 {
+ int i;
+ char a5_7 [5][7];
+} FA5_7;
+
+static void test (void)
+{
+ // Verify that offsetof references to array elements past the end of
+ // the array member are diagnosed. As an extension, permit references
+ // to the element just past-the-end of the array.
+
+ int a[] = {
+ __builtin_offsetof (A1, a1), // valid
+ __builtin_offsetof (A1, a1 [0]), // valid
+
+ // The following expression is valid because it forms the equivalent
+ // of an address pointing just past the last element of the array.
+ __builtin_offsetof (A1, a1 [1]), // valid
+
+ __builtin_offsetof (A1, a1 [2]), // { dg-warning "index" }
+
+ __builtin_offsetof (A1_x_2, a1), // valid
+ __builtin_offsetof (A1_x_2, a1 [0]), // valid
+ __builtin_offsetof (A1_x_2, a1 [1]), // valid
+ __builtin_offsetof (A1_x_2, a1 [2]), // { dg-warning "index" }
+
+ __builtin_offsetof (A1_x_2, a), // valid
+ __builtin_offsetof (A1_x_2, a [0]), // valid
+ __builtin_offsetof (A1_x_2, a [1]), // valid
+ __builtin_offsetof (A1_x_2, a [99]), // valid
+
+ __builtin_offsetof (A1_x_2, a), // valid
+ __builtin_offsetof (A1_x_2, a [0][0]), // valid
+ __builtin_offsetof (A1_x_2, a [0][1]), // valid
+
+ // The following expression is valid because it forms the equivalent
+ // of an address pointing just past the last element of the first
+ // array.
+ __builtin_offsetof (A1_x_2, a [0][2]), // valid
+
+ // Unlike the case above, this is invalid since it refers to an element
+ // past one one just-past-the-end in A[][2].
+ __builtin_offsetof (A1_x_2, a [0][3]), // { dg-warning "index" }
+
+ __builtin_offsetof (A1_x_2, a [1][0]), // valid
+ __builtin_offsetof (A1_x_2, a [1][1]), // valid
+ __builtin_offsetof (A1_x_2, a [1][2]), // valid
+ __builtin_offsetof (A1_x_2, a [99][0]), // valid
+ __builtin_offsetof (A1_x_2, a [99][1]), // valid
+ __builtin_offsetof (A1_x_2, a [99][2]), // valid
+
+ __builtin_offsetof (A1_1_x, a), // valid
+ __builtin_offsetof (A1_1_x, a [0]), // valid
+ __builtin_offsetof (A1_1_x, a [1]), // valid
+ __builtin_offsetof (A1_1_x, a [99]), // valid
+
+ __builtin_offsetof (A1_1_x, a1_1 [0][0]), // valid
+ __builtin_offsetof (A1_1_x, a1_1 [0][1]), // valid
+ __builtin_offsetof (A1_1_x, a1_1 [0][2]), // { dg-warning "index" }
+ __builtin_offsetof (A1_1_x, a1_1 [1][0]), // { dg-warning "index" }
+ __builtin_offsetof (A1_1_x, a1_1 [1][1]), // { dg-warning "index" }
+
+ __builtin_offsetof (Ax_2_3, a_x_2_3 [0][1][3]), // valid
+ __builtin_offsetof (Ax_2_3, a_x_2_3 [0][1][4]), // { dg-warning "index" }
+ __builtin_offsetof (Ax_2_3, a_x_2_3 [0][2]), // valid
+ __builtin_offsetof (Ax_2_3, a_x_2_3 [0][2][0]), // { dg-warning "index" }
+
+ __builtin_offsetof (B, a2_3 [0][0].c), // valid
+ __builtin_offsetof (B, a2_3 [0][0].a1_1 [0][0]), // valid
+ __builtin_offsetof (B, a2_3 [1][3]), // valid
+ __builtin_offsetof (B, a2_3 [1][4]), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [0][0].a1_1 [0][1]), // valid
+ __builtin_offsetof (B, a2_3 [0][0].a1_1 [0][2]), // { dg-warning "index" }
+
+ __builtin_offsetof (B, a2_3 [0][0].a1_1 [1][0]), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [0][0].a1_1 [1][1]), // { dg-warning "index" }
+
+ __builtin_offsetof (B, a2_3 [1][2].a1_1 [0][0]), // valid
+
+ // Forming an offset to the just-past-end element is valid.
+ __builtin_offsetof (B, a2_3 [1][2].a1_1 [0][1]), // valid
+ __builtin_offsetof (B, a2_3 [1][2].a1_1 [1][0]), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [1][2].a1_1 [1][1]), // { dg-warning "index" }
+
+ // Forming an offset to the just-past-end element is valid.
+ __builtin_offsetof (B, a2_3 [1][3]), // valid
+ // ...but these are diagnosed because they dereference a just-past-the-end
+ // element.
+ __builtin_offsetof (B, a2_3 [1][3].a1_1 [0][0]), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [1][3].a1_1 [0][0]), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [1][3].a1_1 [0][1]), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [1][3].a1_1 [1][0]), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [1][3].a1_1 [1][1]), // { dg-warning "index" }
+
+ // Analogous to the case above, these are both diagnosed because they
+ // dereference just-past-the-end elements of the a2_3 array.
+ __builtin_offsetof (B, a2_3 [1][3].c), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [1][3].c), // { dg-warning "index" }
+
+ // The following are all invalid because of the reference to a2_3[2].
+ __builtin_offsetof (B, a2_3 [2][0].a1_1 [0][0]), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [2][0].a1_1 [0][1]), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [2][0].a1_1 [1][0]), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [2][0].a1_1 [1][1]), // { dg-warning "index" }
+ __builtin_offsetof (B, a2_3 [2][0].c), // { dg-warning "index" }
+
+ __builtin_offsetof (C, a5_7 [4][6]),
+ __builtin_offsetof (C, a5_7 [4][6].a),
+ __builtin_offsetof (C, a5_7 [4][6].a [0]),
+ __builtin_offsetof (C, a5_7 [4][6].a [99]),
+
+ __builtin_offsetof (C, a5_7 [4][7]), // valid
+ // Diagnose the following even though the object whose offset is
+ // computed is a flexible array member.
+ __builtin_offsetof (C, a5_7 [4][7].a), // { dg-warning "index" }
+ __builtin_offsetof (C, a5_7 [4][7].a [0]), // { dg-warning "index" }
+ __builtin_offsetof (C, a5_7 [4][7].a [99]), // { dg-warning "index" }
+
+ // Verify that no diagnostic is issued for offsetof expressions
+ // involving structs where the array has a rank of 1 and is the last
+ // member (e.g., those are treated as flexible array members).
+ __builtin_offsetof (FA0, a0 [0]),
+ __builtin_offsetof (FA0, a0 [1]),
+ __builtin_offsetof (FA0, a0 [99]),
+
+ __builtin_offsetof (FA1, a1 [0]),
+ __builtin_offsetof (FA1, a1 [1]),
+ __builtin_offsetof (FA1, a1 [99]),
+
+ __builtin_offsetof (FA3, a3 [0]),
+ __builtin_offsetof (FA3, a3 [3]),
+ __builtin_offsetof (FA3, a3 [99]),
+
+ __builtin_offsetof (FA5_7, a5_7 [0][0]),
+
+ // Unlike one-dimensional arrays, verify that out-of-bounds references
+ // to "fake" flexible arrays with rank of 2 and greater are diagnosed.
+
+ // The following are valid because they compute the offset of just past
+ // the end of each of the a5_7[0] and a5_7[1] arrays.
+ __builtin_offsetof (FA5_7, a5_7 [0][7]), // valid
+ __builtin_offsetof (FA5_7, a5_7 [1][7]), // valid
+
+ // The following two are accepted as an extesion (because a5_7 is
+ // treated as a flexible array member).
+ __builtin_offsetof (FA5_7, a5_7 [5][0]), // extension
+ __builtin_offsetof (FA5_7, a5_7 [5][7]), // extension
+
+ // The following are invalid since in both cases they denote an element
+ // that's beyond just-past-the-end of the array.
+ __builtin_offsetof (FA5_7, a5_7 [0][8]), // { dg-warning "index" }
+ __builtin_offsetof (FA5_7, a5_7 [6][8]) // { dg-warning "index" }
+ };
+
+ (void)&a;
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/an-if.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/an-if.c
index 4bf85b5ca9..4ac46abc40 100644
--- a/gcc/testsuite/c-c++-common/cilk-plus/AN/an-if.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/an-if.c
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-options "-fcilkplus" } */
+/* { dg-options "-fcilkplus -fdump-tree-original" } */
#if HAVE_IO
#include <stdio.h>
@@ -46,3 +46,6 @@ int main() {
}
return 0;
}
+
+/* The C++ FE once emitted a bogus error_mark_node for this test case. */
+/* { dg-final { scan-tree-dump-not "<<< error >>>" "original" } } */
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/fn_ptr-2.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/fn_ptr-2.c
new file mode 100644
index 0000000000..4e1990fcc3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/fn_ptr-2.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+typedef void (*f) (void *);
+f b[1024];
+void *c[1024][1024];
+
+int
+main (void)
+{
+ (b[:]) (c[:][:]); /* { dg-error "rank mismatch" "" { xfail *-*-* } } */
+ return 0;
+}
+
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c
new file mode 100644
index 0000000000..f07b49a277
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c
@@ -0,0 +1,69 @@
+/* PR c/70436 */
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus -Wparentheses" } */
+/* { dg-additional-options "-std=gnu99" { target c } } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+
+void
+f1 (void)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ _Cilk_for (int i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ _Cilk_for (int i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ _Cilk_for (int i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+}
+
+void
+f2 (void)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma cilk grainsize = 2
+ _Cilk_for (int i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma cilk grainsize = 2
+ _Cilk_for (int i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma cilk grainsize = 2
+ _Cilk_for (int i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c
index ca0cf7f68b..670df17faa 100644
--- a/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c
@@ -1,6 +1,6 @@
/* PR middle-end/60469 */
/* { dg-do compile } */
-/* { dg-options "-fcilkplus" } */
+/* { dg-options "-fcilkplus -fdump-tree-original" } */
void foo() {}
@@ -13,3 +13,6 @@ int main(int argc, char* argv[])
_Cilk_spawn foo();
return 0;
}
+
+/* The C++ FE once emitted a bogus error_mark_node for this test case. */
+/* { dg-final { scan-tree-dump-not "<<< error >>>" "original" } } */
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60586.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60586.c
new file mode 100644
index 0000000000..c4012a0a4b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60586.c
@@ -0,0 +1,28 @@
+/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fcilkplus -O2" } */
+/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+int noop(int x)
+{
+ return x;
+}
+
+int post_increment(int *x)
+{
+ return (*x)++;
+}
+
+int main(int argc, char *argv[])
+{
+ int m = 5;
+ int n = m;
+ int r = _Cilk_spawn noop(post_increment(&n));
+ int n2 = n;
+ _Cilk_sync;
+
+ if (r != m || n2 != m + 1)
+ return 1;
+ else
+ return 0;
+}
+
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-1.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-1.c
new file mode 100644
index 0000000000..bcf7727f0a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-1.c
@@ -0,0 +1,25 @@
+/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fcilkplus" } */
+/* { dg-additional-options "-std=gnu99" { target c } } */
+/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+#define GRAINSIZE 2
+
+int
+main ()
+{
+ int a[64];
+ #pragma cilk grainsize=GRAINSIZE
+ _Cilk_for (int i = 0; i < 64; i++)
+ a[i] = 0;
+ #pragma cilk grainsize =GRAINSIZE
+ _Cilk_for (int i = 0; i < 64; i++)
+ a[i]++;
+ #pragma cilk grainsize = GRAINSIZE
+ _Cilk_for (int i = 0; i < 64; i++)
+ a[i]++;
+ for (int i = 0; i < 64; i++)
+ if (a[i] != 2)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-2.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-2.c
new file mode 100644
index 0000000000..f4056c62e3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-2.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fcilkplus -save-temps" } */
+/* { dg-additional-options "-std=gnu99" { target c } } */
+/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+#include "pr69826-1.c"
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c
index 95e6cab02c..138b82c187 100644
--- a/gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c
@@ -2,6 +2,17 @@
/* { dg-options "-fcilkplus" } */
/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int __cilkrts_set_param (const char *, const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+
void f0(volatile int *steal_flag)
{
int i = 0;
@@ -32,6 +43,10 @@ void f3()
int main()
{
+ /* Ensure more than one worker. */
+ if (__cilkrts_set_param("nworkers", "2") != 0)
+ __builtin_abort();
+
f3();
return 0;
}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c
index 6e2876531c..6b41c7faf0 100644
--- a/gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c
@@ -2,8 +2,16 @@
/* { dg-options "-fcilkplus" } */
/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
-// #include <cilk/cilk_api.h>
-extern void __cilkrts_set_param (char *, char *);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int __cilkrts_set_param (const char *, const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
void foo(volatile int *);
@@ -11,7 +19,10 @@ void main2(void);
int main(void)
{
- // __cilkrts_set_param ((char *)"nworkers", (char *)"2");
+ /* Ensure more than one worker. */
+ if (__cilkrts_set_param("nworkers", "2") != 0)
+ __builtin_abort();
+
main2();
return 0;
}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c b/gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c
new file mode 100644
index 0000000000..d391d7b1ee
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c
@@ -0,0 +1,41 @@
+/* PR c/70436 */
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus -Wparentheses" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+
+void
+f1 (void)
+{
+ int i;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma simd
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/PS/body.c b/gcc/testsuite/c-c++-common/cilk-plus/PS/body.c
index 82c0a0c20b..ed85a7a65e 100644
--- a/gcc/testsuite/c-c++-common/cilk-plus/PS/body.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/PS/body.c
@@ -27,7 +27,7 @@ void foo()
#pragma simd
for (int i=0; i < 1000; ++i)
{
-#pragma omp for /* { dg-error "OpenMP constructs may not" } */
+#pragma omp for /* { dg-error "OpenMP constructs other than" } */
for (j=0; j < 1000; ++j)
a[i] = b[i];
}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/PS/clauses2.c b/gcc/testsuite/c-c++-common/cilk-plus/PS/clauses2.c
index 71589c2b17..0f7b500625 100644
--- a/gcc/testsuite/c-c++-common/cilk-plus/PS/clauses2.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/PS/clauses2.c
@@ -15,4 +15,3 @@ void foo()
/* { dg-final { scan-tree-dump-times "linear\\(j:4\\)" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "linear\\(k:1\\)" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "safelen\\(4\\)" 1 "original" } } */
-/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/PS/safelen.c b/gcc/testsuite/c-c++-common/cilk-plus/PS/safelen.c
index 2c59de9b02..5af2909d2e 100644
--- a/gcc/testsuite/c-c++-common/cilk-plus/PS/safelen.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/PS/safelen.c
@@ -11,4 +11,3 @@ void foo()
}
/* { dg-final { scan-tree-dump-times "safelen\\(8\\)" 1 "gimple" } } */
-/* { dg-final { cleanup-tree-dump "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/PS/vectorlength-3.c b/gcc/testsuite/c-c++-common/cilk-plus/PS/vectorlength-3.c
index 9cef5a5812..d219a85acd 100644
--- a/gcc/testsuite/c-c++-common/cilk-plus/PS/vectorlength-3.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/PS/vectorlength-3.c
@@ -11,4 +11,3 @@ foo (int *a, int *b, int *c)
a[i] = b[i] * c[i];
}
-/* { dg-final { cleanup-saved-temps } } */
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/SE/ef_error2.c b/gcc/testsuite/c-c++-common/cilk-plus/SE/ef_error2.c
index 518d6407ee..89e0c39b02 100644
--- a/gcc/testsuite/c-c++-common/cilk-plus/SE/ef_error2.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/SE/ef_error2.c
@@ -1,8 +1,8 @@
/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
/* { dg-options "-fcilkplus -Wall" } */
-__attribute__((vector (vectorlength(32))))
-//#pragma omp simd simdlen (32)
+__attribute__((vector (vectorlength(128))))
+//#pragma omp simd simdlen (128)
int func2 (int x, int y) /* { dg-warning "unsupported simdlen" } */
{
return (x+y);
diff --git a/gcc/testsuite/c-c++-common/conflict-markers-1.c b/gcc/testsuite/c-c++-common/conflict-markers-1.c
new file mode 100644
index 0000000000..b9b3bab316
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/conflict-markers-1.c
@@ -0,0 +1,11 @@
+int p;
+
+<<<<<<< HEAD /* { dg-error "conflict marker" } */
+extern int some_var;
+======= /* { dg-error "conflict marker" } */
+extern short some_var; /* This line would lead to a warning due to the
+ duplicate name, but it is skipped when handling
+ the conflict marker. */
+>>>>>>> Some commit message /* { dg-error "conflict marker" } */
+
+int q;
diff --git a/gcc/testsuite/c-c++-common/conflict-markers-10.c b/gcc/testsuite/c-c++-common/conflict-markers-10.c
new file mode 100644
index 0000000000..59e5a49f2b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/conflict-markers-10.c
@@ -0,0 +1,25 @@
+/* { dg-options "-fdiagnostics-show-caret" } */
+
+<<<<<<< HEAD /* { dg-error "conflict marker" } */
+/* { dg-begin-multiline-output "" }
+ <<<<<<< HEAD
+ ^~~~~~~
+ { dg-end-multiline-output "" } */
+
+extern int some_var;
+
+======= /* { dg-error "conflict marker" } */
+/* { dg-begin-multiline-output "" }
+ =======
+ ^~~~~~~
+ { dg-end-multiline-output "" } */
+
+extern short some_var; /* This line would lead to a warning due to the
+ duplicate name, but it is skipped when handling
+ the conflict marker. */
+
+>>>>>>> Some commit message /* { dg-error "conflict marker" } */
+/* { dg-begin-multiline-output "" }
+ >>>>>>>
+ ^~~~~~~
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/conflict-markers-11.c b/gcc/testsuite/c-c++-common/conflict-markers-11.c
new file mode 100644
index 0000000000..8771453e9c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/conflict-markers-11.c
@@ -0,0 +1,14 @@
+/* Verify that we only report conflict markers at the start of lines. */
+int p;
+
+ <<<<<<< HEAD /* { dg-error "expected identifier|expected unqualified-id" } */
+
+int q;
+
+ ======= /* { dg-error "expected identifier|expected unqualified-id" } */
+
+int r;
+
+ >>>>>>> Some commit message /* { dg-error "expected identifier|expected unqualified-id" } */
+
+int s;
diff --git a/gcc/testsuite/c-c++-common/conflict-markers-2.c b/gcc/testsuite/c-c++-common/conflict-markers-2.c
new file mode 100644
index 0000000000..f06d04363f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/conflict-markers-2.c
@@ -0,0 +1,2 @@
+/* This should not be flagged as a conflict marker. */
+const char *msg = "<<<<<<< ";
diff --git a/gcc/testsuite/c-c++-common/conflict-markers-3.c b/gcc/testsuite/c-c++-common/conflict-markers-3.c
new file mode 100644
index 0000000000..f149ecccb4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/conflict-markers-3.c
@@ -0,0 +1,11 @@
+/* Ensure we can handle unterminated conflict markers. */
+
+int p;
+
+<<<<<<< HEAD /* { dg-error "conflict marker" } */
+
+int q;
+
+<<<<<<< HEAD /* { dg-error "conflict marker" } */
+
+int r;
diff --git a/gcc/testsuite/c-c++-common/conflict-markers-4.c b/gcc/testsuite/c-c++-common/conflict-markers-4.c
new file mode 100644
index 0000000000..a3c53ea1b1
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/conflict-markers-4.c
@@ -0,0 +1,11 @@
+/* Ensure we can handle mismatched conflict markers. */
+
+int p;
+
+>>>>>>> Some commit message /* { dg-error "conflict marker" } */
+
+int q;
+
+>>>>>>> Some other commit message /* { dg-error "conflict marker" } */
+
+int r;
diff --git a/gcc/testsuite/c-c++-common/conflict-markers-5.c b/gcc/testsuite/c-c++-common/conflict-markers-5.c
new file mode 100644
index 0000000000..b55c9c3d34
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/conflict-markers-5.c
@@ -0,0 +1,11 @@
+/* Ensure we can handle mismatched conflict markers. */
+
+int p;
+
+======= /* { dg-error "conflict marker" } */
+
+int q;
+
+======= /* { dg-error "conflict marker" } */
+
+int r;
diff --git a/gcc/testsuite/c-c++-common/conflict-markers-6.c b/gcc/testsuite/c-c++-common/conflict-markers-6.c
new file mode 100644
index 0000000000..081e289b30
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/conflict-markers-6.c
@@ -0,0 +1,38 @@
+/* Branch coverage of conflict marker detection:
+ none of these should be reported as conflict markers. */
+
+int a0;
+
+<< HEAD /* { dg-error "expected" } */
+
+int a1;
+
+<<<< HEAD /* { dg-error "expected" } */
+
+int a2;
+
+<<<<<< HEAD /* { dg-error "expected" } */
+
+int b0;
+
+== HEAD /* { dg-error "expected" } */
+
+int b1;
+
+==== HEAD /* { dg-error "expected" } */
+
+int b2;
+
+====== HEAD /* { dg-error "expected" } */
+
+int c0;
+
+>> HEAD /* { dg-error "expected" } */
+
+int c1;
+
+>>>> HEAD /* { dg-error "expected" } */
+
+int c2;
+
+>>>>>> HEAD /* { dg-error "expected" } */
diff --git a/gcc/testsuite/c-c++-common/conflict-markers-7.c b/gcc/testsuite/c-c++-common/conflict-markers-7.c
new file mode 100644
index 0000000000..e68f84db3c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/conflict-markers-7.c
@@ -0,0 +1,6 @@
+/* It's valid to stringize the "<<<<<<<"; don't
+ report it as a conflict marker. */
+#define str(s) #s
+const char *s = str(
+<<<<<<<
+);
diff --git a/gcc/testsuite/c-c++-common/conflict-markers-8.c b/gcc/testsuite/c-c++-common/conflict-markers-8.c
new file mode 100644
index 0000000000..be2e121bee
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/conflict-markers-8.c
@@ -0,0 +1,4 @@
+/* A macro that's never expanded shouldn't be reported as a
+ conflict marker. */
+#define foo \
+<<<<<<<
diff --git a/gcc/testsuite/c-c++-common/conflict-markers-9.c b/gcc/testsuite/c-c++-common/conflict-markers-9.c
new file mode 100644
index 0000000000..5c1e66394b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/conflict-markers-9.c
@@ -0,0 +1,8 @@
+/* It's valid to have
+<<<<<<<
+ inside both
+ comments (as above), and within string literals. */
+const char *s = "\
+<<<<<<<";
+
+/* The above shouldn't be reported as errors. */
diff --git a/gcc/testsuite/c-c++-common/cpp/openmp-define-3.c b/gcc/testsuite/c-c++-common/cpp/openmp-define-3.c
index 6986c5507b..ef283d4e7c 100644
--- a/gcc/testsuite/c-c++-common/cpp/openmp-define-3.c
+++ b/gcc/testsuite/c-c++-common/cpp/openmp-define-3.c
@@ -6,6 +6,6 @@
# error _OPENMP not defined
#endif
-#if _OPENMP != 201307
+#if _OPENMP != 201511
# error _OPENMP defined to wrong value
#endif
diff --git a/gcc/testsuite/c-c++-common/cpp/pr57580.c b/gcc/testsuite/c-c++-common/cpp/pr57580.c
new file mode 100644
index 0000000000..1039e213e1
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/pr57580.c
@@ -0,0 +1,9 @@
+/* PR preprocessor/57580 */
+/* { dg-do compile } */
+/* { dg-options "-save-temps" } */
+
+#define MSG \
+ _Pragma("message(\"message0\")") \
+ _Pragma("message(\"message1\")")
+MSG /* { dg-message "message0" } */
+/* { dg-message "message1" "" { target *-*-* } 8 } */
diff --git a/gcc/testsuite/c-c++-common/cpp/pr63831-2.c b/gcc/testsuite/c-c++-common/cpp/pr63831-2.c
index cc87d1d9c1..2479ce8327 100644
--- a/gcc/testsuite/c-c++-common/cpp/pr63831-2.c
+++ b/gcc/testsuite/c-c++-common/cpp/pr63831-2.c
@@ -4,4 +4,3 @@
#include "pr63831-1.c"
-/* { dg-final { cleanup-saved-temps } } */
diff --git a/gcc/testsuite/c-c++-common/cpp/warning-zero-location.c b/gcc/testsuite/c-c++-common/cpp/warning-zero-location.c
index ca2e102bba..2b9c9a9521 100644
--- a/gcc/testsuite/c-c++-common/cpp/warning-zero-location.c
+++ b/gcc/testsuite/c-c++-common/cpp/warning-zero-location.c
@@ -5,4 +5,4 @@
#define _GNU_SOURCE /* { dg-warning "redefined" } */
-/* { dg-message "" "#define _GNU_SOURCE" {target *-*-* } 0 }
+/* { dg-message "" "#define _GNU_SOURCE" {target *-*-* } 0 } */
diff --git a/gcc/testsuite/c-c++-common/dfp/convert-dfp-2.c b/gcc/testsuite/c-c++-common/dfp/convert-dfp-2.c
new file mode 100644
index 0000000000..a50b202885
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/dfp/convert-dfp-2.c
@@ -0,0 +1,45 @@
+/* { dg-options "-O0" } */
+
+/* Test decimal fp conversions of zero. */
+
+#include "dfp-dbg.h"
+
+volatile _Decimal32 d32a, d32c;
+volatile _Decimal64 d64a, d64c;
+volatile _Decimal128 d128a, d128c;
+
+int
+main ()
+{
+ d32a = d32c;
+ if (d32a)
+ FAILURE
+ d32a = d64c;
+ if (d32a)
+ FAILURE
+ d32a = d128c;
+ if (d32a)
+ FAILURE
+
+ d64a = d32c;
+ if (d64a)
+ FAILURE
+ d64a = d64c;
+ if (d64a)
+ FAILURE
+ d64a = d128c;
+ if (d64a)
+ FAILURE
+
+ d128a = d32c;
+ if (d128a)
+ FAILURE
+ d128a = d64c;
+ if (d128a)
+ FAILURE
+ d128a = d128c;
+ if (d128a)
+ FAILURE
+
+ FINISH
+}
diff --git a/gcc/testsuite/c-c++-common/dfp/operator-comma.c b/gcc/testsuite/c-c++-common/dfp/operator-comma.c
index be6bf6f8cd..7055087ba6 100644
--- a/gcc/testsuite/c-c++-common/dfp/operator-comma.c
+++ b/gcc/testsuite/c-c++-common/dfp/operator-comma.c
@@ -24,6 +24,8 @@ init ()
int
main ()
{
+ init ();
+
d32a = (d32b, d32c);
if (d32a != d32c)
FAILURE
diff --git a/gcc/testsuite/c-c++-common/dump-ada-spec-1.c b/gcc/testsuite/c-c++-common/dump-ada-spec-1.c
new file mode 100644
index 0000000000..eb249e7985
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/dump-ada-spec-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-ada-spec" } */
+
+struct S
+{
+ int i;
+};
+
+/* { dg-final { scan-ada-spec "type S is record" } } */
+/* { dg-final { cleanup-ada-spec } } */
diff --git a/gcc/testsuite/c-c++-common/dump-ada-spec-2.c b/gcc/testsuite/c-c++-common/dump-ada-spec-2.c
new file mode 100644
index 0000000000..46eedb582b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/dump-ada-spec-2.c
@@ -0,0 +1,49 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-ada-spec" } */
+
+struct S1 {
+ struct {
+ int i;
+ } F;
+};
+
+struct S2 {
+ union {
+ int i;
+ } F;
+};
+
+struct S3 {
+ struct {
+ int i;
+ } F[2];
+};
+
+struct S4 {
+ struct {
+ struct S4 *next;
+ } F;
+};
+
+struct S5 {
+ struct {
+ struct S5 *next;
+ } F[2];
+};
+
+struct S6 {
+ struct {
+ struct S6 *next[2];
+ } F;
+};
+
+struct S7 {
+ struct {
+ int i;
+ } F1[2];
+ struct {
+ float f;
+ } F2[2];
+};
+
+/* { dg-final { cleanup-ada-spec } } */
diff --git a/gcc/testsuite/c-c++-common/fold-bitand-4.c b/gcc/testsuite/c-c++-common/fold-bitand-4.c
index a5d3168bed..a658ff15e4 100644
--- a/gcc/testsuite/c-c++-common/fold-bitand-4.c
+++ b/gcc/testsuite/c-c++-common/fold-bitand-4.c
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target { c } } } */
/* { dg-options "-fdump-tree-original" } */
/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */
@@ -42,4 +42,3 @@ int f5 (int i)
/* { dg-final { scan-tree-dump-times "\& 15" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "return \[^\n0-9\]*0;" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "\& 7" 1 "original" } } */
-/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/c-c++-common/fold-divmul-1.c b/gcc/testsuite/c-c++-common/fold-divmul-1.c
index 5c867923d2..0196114e43 100644
--- a/gcc/testsuite/c-c++-common/fold-divmul-1.c
+++ b/gcc/testsuite/c-c++-common/fold-divmul-1.c
@@ -8,4 +8,3 @@ fx (int *b, int *e)
}
/* { dg-final { scan-tree-dump-not "/\\\[ex\\\]" "original" } } */
-/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c b/gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c
index df45bcf05f..aaf0e7a4ee 100644
--- a/gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c
+++ b/gcc/testsuite/c-c++-common/goacc-gomp/nesting-1.c
@@ -1,12 +1,46 @@
void
-f_omp_parallel (void)
+f_acc_data (void)
{
-#pragma omp parallel
+#pragma acc data
{
int i;
+#pragma omp atomic write
+ i = 0;
+ }
+}
+
+void
+f_acc_kernels (void)
+{
+#pragma acc kernels
+ {
+ int i;
+#pragma omp atomic write
+ i = 0;
+ }
+}
+
+#pragma acc routine vector
+void
+f_acc_loop (void)
+{
+ int i;
#pragma acc loop
- for (i = 0; i < 2; ++i)
- ;
+ for (i = 0; i < 2; ++i)
+ {
+#pragma omp atomic write
+ i = 0;
+ }
+}
+
+void
+f_acc_parallel (void)
+{
+#pragma acc parallel
+ {
+ int i;
+#pragma omp atomic write
+ i = 0;
}
}
diff --git a/gcc/testsuite/c-c++-common/goacc-gomp/nesting-fail-1.c b/gcc/testsuite/c-c++-common/goacc-gomp/nesting-fail-1.c
index 411fb5f875..1a3324200e 100644
--- a/gcc/testsuite/c-c++-common/goacc-gomp/nesting-fail-1.c
+++ b/gcc/testsuite/c-c++-common/goacc-gomp/nesting-fail-1.c
@@ -1,4 +1,5 @@
extern int i;
+#pragma acc declare create(i)
void
f_omp (void)
@@ -14,6 +15,9 @@ f_omp (void)
#pragma acc update host(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc enter data copyin(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc exit data delete(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
+ for (i = 0; i < 2; ++i)
+ ;
}
#pragma omp for
@@ -28,7 +32,7 @@ f_omp (void)
#pragma acc update host(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc enter data copyin(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc exit data delete(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
-#pragma acc loop /* { dg-error "may not be closely nested" } */
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (i = 0; i < 2; ++i)
;
}
@@ -63,7 +67,7 @@ f_omp (void)
}
#pragma omp section
{
-#pragma acc loop /* { dg-error "may not be closely nested" } */
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (i = 0; i < 2; ++i)
;
}
@@ -80,7 +84,7 @@ f_omp (void)
#pragma acc update host(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc enter data copyin(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc exit data delete(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
-#pragma acc loop /* { dg-error "may not be closely nested" } */
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (i = 0; i < 2; ++i)
;
}
@@ -96,7 +100,7 @@ f_omp (void)
#pragma acc update host(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc enter data copyin(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc exit data delete(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
-#pragma acc loop /* { dg-error "may not be closely nested" } */
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (i = 0; i < 2; ++i)
;
}
@@ -112,7 +116,7 @@ f_omp (void)
#pragma acc update host(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc enter data copyin(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc exit data delete(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
-#pragma acc loop /* { dg-error "may not be closely nested" } */
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (i = 0; i < 2; ++i)
;
}
@@ -128,7 +132,7 @@ f_omp (void)
#pragma acc update host(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc enter data copyin(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc exit data delete(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
-#pragma acc loop /* { dg-error "may not be closely nested" } */
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (i = 0; i < 2; ++i)
;
}
@@ -144,23 +148,23 @@ f_omp (void)
#pragma acc update host(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc enter data copyin(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
#pragma acc exit data delete(i) /* { dg-error "OpenACC construct inside of non-OpenACC region" } */
-#pragma acc loop /* { dg-error "may not be closely nested" } */
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (i = 0; i < 2; ++i)
;
}
#pragma omp target
{
-#pragma acc parallel /* { dg-error "OpenACC parallel construct inside of OpenMP target region" } */
+#pragma acc parallel /* { dg-error "OpenACC .parallel. construct inside of OpenMP .target. region" } */
;
-#pragma acc kernels /* { dg-error "OpenACC kernels construct inside of OpenMP target region" } */
+#pragma acc kernels /* { dg-error "OpenACC .kernels. construct inside of OpenMP .target. region" } */
;
-#pragma acc data /* { dg-error "OpenACC data construct inside of OpenMP target region" } */
+#pragma acc data /* { dg-error "OpenACC .data. construct inside of OpenMP .target. region" } */
;
-#pragma acc update host(i) /* { dg-error "OpenACC update construct inside of OpenMP target region" } */
-#pragma acc enter data copyin(i) /* { dg-error "OpenACC enter/exit data construct inside of OpenMP target region" } */
-#pragma acc exit data delete(i) /* { dg-error "OpenACC enter/exit data construct inside of OpenMP target region" } */
-#pragma acc loop
+#pragma acc update host(i) /* { dg-error "OpenACC .update. construct inside of OpenMP .target. region" } */
+#pragma acc enter data copyin(i) /* { dg-error "OpenACC .enter/exit data. construct inside of OpenMP .target. region" } */
+#pragma acc exit data delete(i) /* { dg-error "OpenACC .enter/exit data. construct inside of OpenMP .target. region" } */
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (i = 0; i < 2; ++i)
;
}
@@ -216,12 +220,6 @@ f_acc_parallel (void)
#pragma acc parallel
{
-#pragma omp atomic write
- i = 0; /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
- }
-
-#pragma acc parallel
- {
#pragma omp ordered /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
;
}
@@ -230,7 +228,7 @@ f_acc_parallel (void)
{
#pragma omp target /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
;
-#pragma omp target data /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp target data map(i) /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
;
#pragma omp target update to(i) /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
}
@@ -286,12 +284,6 @@ f_acc_kernels (void)
#pragma acc kernels
{
-#pragma omp atomic write
- i = 0; /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
- }
-
-#pragma acc kernels
- {
#pragma omp ordered /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
;
}
@@ -300,7 +292,7 @@ f_acc_kernels (void)
{
#pragma omp target /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
;
-#pragma omp target data /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp target data map(i) /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
;
#pragma omp target update to(i) /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
}
@@ -356,12 +348,6 @@ f_acc_data (void)
#pragma acc data
{
-#pragma omp atomic write
- i = 0; /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
- }
-
-#pragma acc data
- {
#pragma omp ordered /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
;
}
@@ -370,26 +356,27 @@ f_acc_data (void)
{
#pragma omp target /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
;
-#pragma omp target data /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp target data map(i) /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
;
#pragma omp target update to(i) /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
}
}
+#pragma acc routine
void
f_acc_loop (void)
{
#pragma acc loop
for (i = 0; i < 2; ++i)
{
-#pragma omp parallel /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp parallel /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
;
}
#pragma acc loop
for (i = 0; i < 2; ++i)
{
-#pragma omp for /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp for /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
for (i = 0; i < 3; i++)
;
}
@@ -397,7 +384,7 @@ f_acc_loop (void)
#pragma acc loop
for (i = 0; i < 2; ++i)
{
-#pragma omp sections /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp sections /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
{
;
}
@@ -406,52 +393,53 @@ f_acc_loop (void)
#pragma acc loop
for (i = 0; i < 2; ++i)
{
-#pragma omp single /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp single /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
;
}
#pragma acc loop
for (i = 0; i < 2; ++i)
{
-#pragma omp task /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp task /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
;
}
#pragma acc loop
for (i = 0; i < 2; ++i)
{
-#pragma omp master /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp master /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
;
}
#pragma acc loop
for (i = 0; i < 2; ++i)
{
-#pragma omp critical /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp critical /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
;
}
#pragma acc loop
for (i = 0; i < 2; ++i)
{
-#pragma omp atomic write
- i = 0; /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
- }
-
-#pragma acc loop
- for (i = 0; i < 2; ++i)
- {
-#pragma omp ordered /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp ordered /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
;
}
#pragma acc loop
for (i = 0; i < 2; ++i)
{
-#pragma omp target /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp target /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
;
-#pragma omp target data /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp target data map(i) /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
;
-#pragma omp target update to(i) /* { dg-error "non-OpenACC construct inside of OpenACC region" } */
+#pragma omp target update to(i) /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
}
}
+
+#pragma acc routine
+void
+f_acc_routine (void)
+{
+#pragma omp target /* { dg-error "non-OpenACC construct inside of OpenACC routine" } */
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c b/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c
new file mode 100644
index 0000000000..08265b65e0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c
@@ -0,0 +1,174 @@
+/* PR c/70436 */
+/* { dg-additional-options "-Wparentheses" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+#pragma acc routine
+void bar2 (void);
+#pragma acc routine
+void baz2 (void);
+
+void
+f1 (void)
+{
+ int i, d[10] = { 0 };
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc data copyin (d[0:10])
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ #pragma acc data copyin (d[0:10])
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc host_data use_device (d)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc kernels
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc kernels
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc parallel
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma acc parallel loop
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+
+ (void) d[0];
+
+ if (a)
+ #pragma acc data copyin (d[0:10])
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma acc data copyin (d[0:10])
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ #pragma acc data copyin (d[0:10])
+ if (a)
+ #pragma acc host_data use_device (d)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ #pragma acc data copyin (d[0:10])
+ if (a)
+ #pragma acc host_data use_device (d)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma acc kernels
+ {
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+ }
+
+ if (a)
+ #pragma acc kernels
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+ }
+
+ if (a)
+ #pragma acc parallel
+ {
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+ }
+
+ if (a)
+ #pragma acc parallel loop
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+ }
+
+ if (a)
+ {
+ #pragma acc parallel loop
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar2 ();
+ else
+ baz2 ();
+ }
+}
+
+#pragma acc routine vector
+void
+f2 (int *a, int b, int c)
+{
+ int i;
+
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma acc loop vector
+ for (i = 0; i < 10; i++)
+ if (c)
+ a[i] = a[i] + 1;
+ else
+ a[i] = a[i] + 2;
+
+ if (b)
+ #pragma acc loop vector
+ for (i = 0; i < 10; i++)
+ {
+ if (c)
+ a[i] = a[i] + 1;
+ else
+ a[i] = a[i] + 2;
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/acc_on_device-2-off.c b/gcc/testsuite/c-c++-common/goacc/acc_on_device-2-off.c
deleted file mode 100644
index ea31047021..0000000000
--- a/gcc/testsuite/c-c++-common/goacc/acc_on_device-2-off.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Have to enable optimizations, as otherwise builtins won't be expanded. */
-/* { dg-additional-options "-O -fdump-rtl-expand -fno-openacc" } */
-
-#if __cplusplus
-extern "C" {
-#endif
-
-typedef enum acc_device_t { acc_device_X = 123 } acc_device_t;
-extern int acc_on_device (acc_device_t);
-
-#if __cplusplus
-}
-#endif
-
-int
-f (void)
-{
- const acc_device_t dev = acc_device_X;
- return acc_on_device (dev);
-}
-
-/* Without -fopenacc, we're expecting one call.
- { dg-final { scan-rtl-dump-times "\\\(call \[^\\n\]* acc_on_device" 1 "expand" } } */
-
-/* { dg-final { cleanup-rtl-dump "expand" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/acc_on_device-2.c b/gcc/testsuite/c-c++-common/goacc/acc_on_device-2.c
deleted file mode 100644
index 7fe4e4e71e..0000000000
--- a/gcc/testsuite/c-c++-common/goacc/acc_on_device-2.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Have to enable optimizations, as otherwise builtins won't be expanded. */
-/* { dg-additional-options "-O -fdump-rtl-expand" } */
-
-#if __cplusplus
-extern "C" {
-#endif
-
-typedef enum acc_device_t { acc_device_X = 123 } acc_device_t;
-extern int acc_on_device (acc_device_t);
-
-#if __cplusplus
-}
-#endif
-
-int
-f (void)
-{
- const acc_device_t dev = acc_device_X;
- return acc_on_device (dev);
-}
-
-/* With -fopenacc, we're expecting the builtin to be expanded, so no calls.
-
- TODO: in C++, even under extern "C", the use of enum for acc_device_t
- perturbs expansion as a builtin, which expects an int parameter. It's fine
- when changing acc_device_t to plain int, but that's not what we're doing in
- <openacc.h>.
-
- TODO: given that we can't expand acc_on_device in
- gcc/builtins.c:expand_builtin_acc_on_device for in the !ACCEL_COMPILER case
- (because at that point we don't know whether we're acc_device_host or
- acc_device_host_nonshm), we'll (erroneously) get a library call in the host
- code.
-
- { dg-final { scan-rtl-dump-times "\\\(call \[^\\n\]* acc_on_device" 0 "expand" { xfail { c || c++ } } } } */
-
-/* { dg-final { cleanup-rtl-dump "expand" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/clauses-fail.c b/gcc/testsuite/c-c++-common/goacc/clauses-fail.c
index 899018026d..853d010d03 100644
--- a/gcc/testsuite/c-c++-common/goacc/clauses-fail.c
+++ b/gcc/testsuite/c-c++-common/goacc/clauses-fail.c
@@ -1,3 +1,5 @@
+/* Miscellaneous tests where clause parsing is expected to fail. */
+
void
f (void)
{
@@ -12,7 +14,18 @@ f (void)
#pragma acc data two /* { dg-error "expected '#pragma acc' clause before 'two'" } */
;
+#pragma acc parallel
#pragma acc loop deux /* { dg-error "expected '#pragma acc' clause before 'deux'" } */
for (i = 0; i < 2; ++i)
;
}
+
+
+void
+f2 (void)
+{
+ int a, b[100];
+
+#pragma acc parallel firstprivate (b[10:20]) /* { dg-error "expected ... before ... token" } */
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/combined-directives-2.c b/gcc/testsuite/c-c++-common/goacc/combined-directives-2.c
new file mode 100644
index 0000000000..c51e2f9c75
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/combined-directives-2.c
@@ -0,0 +1,14 @@
+/* Ensure that bogus clauses aren't propagated in combined loop
+ constructs. */
+
+int
+main ()
+{
+ int a, i;
+
+#pragma acc parallel loop vector copy(a[0:100]) reduction(+:a) /* { dg-error "'a' does not have pointer or array type" } */
+ for (i = 0; i < 100; i++)
+ a++;
+
+ return a;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/combined-directives.c b/gcc/testsuite/c-c++-common/goacc/combined-directives.c
new file mode 100644
index 0000000000..c2a3c57b48
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/combined-directives.c
@@ -0,0 +1,116 @@
+// { dg-additional-options "-fdump-tree-gimple" }
+
+// Remove the comments from the reduction test
+// after the FE learns that reduction variables may appear in data clauses too.
+
+void
+test ()
+{
+ int a[100], i, j, z;
+
+ // acc parallel
+
+ #pragma acc parallel loop collapse (2)
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc parallel loop gang
+ for (i = 0; i < 100; i++)
+ ;
+
+ #pragma acc parallel loop worker
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc parallel loop vector
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc parallel loop seq
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc parallel loop auto
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc parallel loop tile (2, 3)
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc parallel loop independent
+ for (i = 0; i < 100; i++)
+ ;
+
+ #pragma acc parallel loop private (z)
+ for (i = 0; i < 100; i++)
+ z = 0;
+
+// #pragma acc parallel loop reduction (+:z) copy (z)
+// for (i = 0; i < 100; i++)
+// ;
+
+ // acc kernels
+
+ #pragma acc kernels loop collapse (2)
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc kernels loop gang
+ for (i = 0; i < 100; i++)
+ ;
+
+ #pragma acc kernels loop worker
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc kernels loop vector
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc kernels loop seq
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc kernels loop auto
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc kernels loop tile (2, 3)
+ for (i = 0; i < 100; i++)
+ for (j = 0; j < 10; j++)
+ ;
+
+ #pragma acc kernels loop independent
+ for (i = 0; i < 100; i++)
+ ;
+
+ #pragma acc kernels loop private (z)
+ for (i = 0; i < 100; i++)
+ z = 0;
+
+// #pragma acc kernels loop reduction (+:z) copy (z)
+// for (i = 0; i < 100; i++)
+// ;
+}
+
+// { dg-final { scan-tree-dump-times "acc loop collapse.2. private.j. private.i" 2 "gimple" } }
+// { dg-final { scan-tree-dump-times "acc loop gang" 2 "gimple" } }
+// { dg-final { scan-tree-dump-times "acc loop worker" 2 "gimple" } }
+// { dg-final { scan-tree-dump-times "acc loop vector" 2 "gimple" } }
+// { dg-final { scan-tree-dump-times "acc loop seq" 2 "gimple" } }
+// { dg-final { scan-tree-dump-times "acc loop auto" 2 "gimple" } }
+// { dg-final { scan-tree-dump-times "acc loop tile.2, 3" 2 "gimple" } }
+// { dg-final { scan-tree-dump-times "acc loop independent private.i" 2 "gimple" } }
+// { dg-final { scan-tree-dump-times "private.z" 2 "gimple" } }
diff --git a/gcc/testsuite/c-c++-common/goacc/data-default-1.c b/gcc/testsuite/c-c++-common/goacc/data-default-1.c
new file mode 100644
index 0000000000..631032e686
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/data-default-1.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+
+
+int main ()
+{
+ int n = 2;
+ int ary[2];
+
+#pragma acc parallel default (none) /* { dg-message "'parallel' construct" 2 } */
+ {
+ ary[0] /* { dg-error "not specified in enclosing" } */
+ = n; /* { dg-error "not specified in enclosing" } */
+ }
+
+#pragma acc kernels default (none) /* { dg-message "'kernels' construct" 2 } */
+ {
+ ary[0] /* { dg-error "not specified in enclosing" } */
+ = n; /* { dg-error "not specified in enclosing" } */
+ }
+
+#pragma acc data copy (ary, n)
+ {
+#pragma acc parallel default (none)
+ {
+ ary[0]
+ = n;
+ }
+
+#pragma acc kernels default (none)
+ {
+ ary[0]
+ = n;
+ }
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/declare-1.c b/gcc/testsuite/c-c++-common/goacc/declare-1.c
new file mode 100644
index 0000000000..b036c63616
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/declare-1.c
@@ -0,0 +1,83 @@
+/* Test valid uses of declare directive. */
+/* { dg-do compile } */
+
+int v0;
+#pragma acc declare create(v0)
+
+int v1;
+#pragma acc declare copyin(v1)
+
+int *v2;
+#pragma acc declare deviceptr(v2)
+
+int v3;
+#pragma acc declare device_resident(v3)
+
+int v4;
+#pragma acc declare link(v4)
+
+int v5, v6, v7, v8;
+#pragma acc declare create(v5, v6) copyin(v7, v8)
+
+void
+f (void)
+{
+ int va0;
+#pragma acc declare create(va0)
+
+ int va1;
+#pragma acc declare copyin(va1)
+
+ int *va2;
+#pragma acc declare deviceptr(va2)
+
+ int va3;
+#pragma acc declare device_resident(va3)
+
+ extern int ve0;
+#pragma acc declare create(ve0)
+
+ extern int ve1;
+#pragma acc declare copyin(ve1)
+
+ extern int *ve2;
+#pragma acc declare deviceptr(ve2)
+
+ extern int ve3;
+#pragma acc declare device_resident(ve3)
+
+ extern int ve4;
+#pragma acc declare link(ve4)
+
+ int va5;
+#pragma acc declare copy(va5)
+
+ int va6;
+#pragma acc declare copyout(va6)
+
+ int va7;
+#pragma acc declare present(va7)
+
+ int va8;
+#pragma acc declare present_or_copy(va8)
+
+ int va9;
+#pragma acc declare present_or_copyin(va9)
+
+ int va10;
+#pragma acc declare present_or_copyout(va10)
+
+ int va11;
+#pragma acc declare present_or_create(va11)
+
+ a:
+ {
+ int va0;
+#pragma acc declare create(va0)
+ if (v1)
+ goto a;
+ else
+ goto b;
+ }
+ b:;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/declare-2.c b/gcc/testsuite/c-c++-common/goacc/declare-2.c
new file mode 100644
index 0000000000..d24cb2222d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/declare-2.c
@@ -0,0 +1,79 @@
+/* Test invalid uses of declare directive. */
+/* { dg-do compile } */
+
+#pragma acc declare /* { dg-error "no valid clauses" } */
+
+#pragma acc declare create(undeclared) /* { dg-error "undeclared" } */
+/* { dg-error "no valid clauses" "second error" { target *-*-* } 6 } */
+
+int v0[10];
+#pragma acc declare create(v0[1:3]) /* { dg-error "array section" } */
+
+int v1;
+#pragma acc declare create(v1, v1) /* { dg-error "more than once" } */
+
+int v2;
+#pragma acc declare create(v2)
+#pragma acc declare copyin(v2) /* { dg-error "more than once" } */
+
+int v3;
+#pragma acc declare copy(v3) /* { dg-error "at file scope" } */
+
+int v4;
+#pragma acc declare copyout(v4) /* { dg-error "at file scope" } */
+
+int v5;
+#pragma acc declare present(v5) /* { dg-error "at file scope" } */
+
+int v6;
+#pragma acc declare present_or_copy(v6) /* { dg-error "at file scope" } */
+
+int v7;
+#pragma acc declare present_or_copyin(v7) /* { dg-error "at file scope" } */
+
+int v8;
+#pragma acc declare present_or_copyout(v8) /* { dg-error "at file scope" } */
+
+int v9;
+#pragma acc declare present_or_create(v9) /* { dg-error "at file scope" } */
+
+int va10;
+#pragma acc declare create (va10)
+#pragma acc declare link (va10) /* { dg-error "more than once" } */
+
+int va11;
+#pragma acc declare link (va11)
+#pragma acc declare link (va11) /* { dg-error "more than once" } */
+
+int va12;
+#pragma acc declare create (va12) link (va12) /* { dg-error "more than once" } */
+
+void
+f (void)
+{
+ int va0;
+#pragma acc declare link(va0) /* { dg-error "global variable" } */
+
+ extern int ve0;
+#pragma acc declare copy(ve0) /* { dg-error "invalid use of" } */
+
+ extern int ve1;
+#pragma acc declare copyout(ve1) /* { dg-error "invalid use of" } */
+
+ extern int ve2;
+#pragma acc declare present(ve2) /* { dg-error "invalid use of" } */
+
+ extern int ve3;
+#pragma acc declare present_or_copy(ve3) /* { dg-error "invalid use of" } */
+
+ extern int ve4;
+#pragma acc declare present_or_copyin(ve4) /* { dg-error "invalid use of" } */
+
+ extern int ve5;
+#pragma acc declare present_or_copyout(ve5) /* { dg-error "invalid use of" } */
+
+ extern int ve6;
+#pragma acc declare present_or_create(ve6) /* { dg-error "invalid use of" } */
+
+#pragma acc declare present (v9) /* { dg-error "invalid use of" } */
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/deviceptr-1.c b/gcc/testsuite/c-c++-common/goacc/deviceptr-1.c
index 546fa82958..08ddb1072f 100644
--- a/gcc/testsuite/c-c++-common/goacc/deviceptr-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/deviceptr-1.c
@@ -84,3 +84,17 @@ fun4 (void)
#pragma acc parallel deviceptr(s2_p)
s2_p = 0;
}
+
+void
+func5 (float *fp)
+{
+#pragma acc data deviceptr (fp)
+ ;
+}
+
+void
+func6 (float fp)
+{
+#pragma acc data deviceptr (fp) /* { dg-error "is not a pointer variable" } */
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/host_data-1.c b/gcc/testsuite/c-c++-common/goacc/host_data-1.c
new file mode 100644
index 0000000000..0c7a857d0b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/host_data-1.c
@@ -0,0 +1,24 @@
+/* Test valid use of host_data directive. */
+
+int v1[3][3];
+
+void
+f (void)
+{
+#pragma acc host_data use_device(v1)
+ ;
+}
+
+
+void bar (float *, float *);
+
+void
+foo (float *x, float *y)
+{
+ int n = 1 << 10;
+#pragma acc data create(x[0:n]) copyout(y[0:n])
+ {
+#pragma acc host_data use_device(x,y)
+ bar (x, y);
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/host_data-2.c b/gcc/testsuite/c-c++-common/goacc/host_data-2.c
new file mode 100644
index 0000000000..bdce42472b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/host_data-2.c
@@ -0,0 +1,78 @@
+/* Test invalid use of host_data directive. */
+
+int v0;
+#pragma acc host_data use_device(v0) /* { dg-error "expected declaration specifiers before" } */
+
+
+void
+f (void)
+{
+ int v2 = 3;
+#pragma acc host_data copy(v2) /* { dg-error ".copy. is not valid for ..pragma acc host_data." } */
+ ;
+
+#pragma acc host_data use_device(v2)
+ ;
+ /* { dg-error ".use_device_ptr. variable is neither a pointer nor an array" "" { target c } 14 } */
+ /* { dg-error ".use_device_ptr. variable is neither a pointer, nor an arraynor reference to pointer or array" "" { target c++ } 14 } */
+
+#pragma acc host_data use_device(v0)
+ ;
+ /* { dg-error ".use_device_ptr. variable is neither a pointer nor an array" "" { target c } 19 } */
+ /* { dg-error ".use_device_ptr. variable is neither a pointer, nor an arraynor reference to pointer or array" "" { target c++ } 19 } */
+}
+
+
+void
+f2 (void)
+{
+ int x[100];
+
+#pragma acc enter data copyin (x)
+ /* Specifying an array index is not valid for host_data/use_device. */
+#pragma acc host_data use_device (x[4]) /* { dg-error "expected '\\\)' before '\\\[' token" } */
+ ;
+#pragma acc exit data delete (x)
+}
+
+
+void
+f3 (void)
+{
+ int x[100];
+
+#pragma acc data copyin (x[25:50])
+ {
+ int *xp;
+#pragma acc host_data use_device (x)
+ {
+ /* This use of the present clause is undefined behavior for OpenACC. */
+#pragma acc parallel present (x) copyout (xp) /* { dg-error "variable .x. declared in enclosing .host_data. region" } */
+ {
+ xp = x;
+ }
+ }
+ }
+}
+
+
+void
+f4 (void)
+{
+ int x[50];
+
+#pragma acc data copyin (x[10:30])
+ {
+ int *xp;
+#pragma acc host_data use_device (x)
+ {
+ /* Here 'x' being implicitly firstprivate for the parallel region
+ conflicts with it being declared as use_device in the enclosing
+ host_data region. */
+#pragma acc parallel copyout (xp)
+ {
+ xp = x; /* { dg-error "variable .x. declared in enclosing .host_data. region" } */
+ }
+ }
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-1.c b/gcc/testsuite/c-c++-common/goacc/kernels-1.c
index e91b81c8d0..4fcf86eca6 100644
--- a/gcc/testsuite/c-c++-common/goacc/kernels-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-1.c
@@ -1,6 +1,45 @@
-void
-foo (void)
+int
+kernels_empty (void)
{
#pragma acc kernels
;
+
+ return 0;
+}
+
+int
+kernels_eternal (void)
+{
+#pragma acc kernels
+ {
+ while (1)
+ ;
+ }
+
+ return 0;
+}
+
+int
+kernels_noreturn (void)
+{
+#pragma acc kernels
+ __builtin_abort ();
+
+ return 0;
+}
+
+
+float b[10][15][10];
+
+void
+kernels_loop_ptr_it (void)
+{
+ float *i;
+
+#pragma acc kernels
+ {
+#pragma acc loop
+ for (i = &b[0][0][0]; i < &b[0][0][10]; i++)
+ ;
+ }
}
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-2.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-2.c
new file mode 100644
index 0000000000..d437c47779
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-2.c
@@ -0,0 +1,27 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-ealias-all" } */
+
+void
+foo (void)
+{
+ unsigned int a;
+ unsigned int b;
+ unsigned int c;
+ unsigned int d;
+
+#pragma acc kernels copyin (a) create (b) copyout (c) copy (d)
+ {
+ a = 0;
+ b = 0;
+ c = 0;
+ d = 0;
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "clique 1 base 1" 4 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "clique 1 base 2" 1 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "clique 1 base 3" 1 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "clique 1 base 4" 1 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "clique 1 base 5" 1 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 8 "ealias" } } */
+
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-3.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-3.c
new file mode 100644
index 0000000000..0eda7e17c3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-3.c
@@ -0,0 +1,20 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-ealias-all" } */
+
+void
+foo (void)
+{
+ unsigned int a;
+ unsigned int *p = &a;
+
+#pragma acc kernels pcopyin (a, p[0:1])
+ {
+ a = 0;
+ *p = 1;
+ }
+}
+
+/* Only the omp_data_i related loads should be annotated with cliques. */
+/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */
+
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-4.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-4.c
new file mode 100644
index 0000000000..037901fcff
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-4.c
@@ -0,0 +1,22 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-ealias-all" } */
+
+#define N 2
+
+void
+foo (void)
+{
+ unsigned int a[N];
+ unsigned int *p = &a[0];
+
+#pragma acc kernels pcopyin (a, p[0:2])
+ {
+ a[0] = 0;
+ *p = 1;
+ }
+}
+
+/* Only the omp_data_i related loads should be annotated with cliques. */
+/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */
+
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-5.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-5.c
new file mode 100644
index 0000000000..69cd3fb944
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-5.c
@@ -0,0 +1,19 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-ealias-all" } */
+
+void
+foo (int *a)
+{
+ int *p = a;
+
+#pragma acc kernels pcopyin (a[0:1], p[0:1])
+ {
+ *a = 0;
+ *p = 1;
+ }
+}
+
+/* Only the omp_data_i related loads should be annotated with cliques. */
+/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */
+
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-6.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-6.c
new file mode 100644
index 0000000000..6ebce15f5e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-6.c
@@ -0,0 +1,23 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-ealias-all" } */
+
+typedef __SIZE_TYPE__ size_t;
+extern void *acc_copyin (void *, size_t);
+
+void
+foo (void)
+{
+ int a = 0;
+ int *p = (int *)acc_copyin (&a, sizeof (a));
+
+#pragma acc kernels deviceptr (p) pcopy(a)
+ {
+ a = 0;
+ *p = 1;
+ }
+}
+
+/* Only the omp_data_i related loads should be annotated with cliques. */
+/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */
+
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-7.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-7.c
new file mode 100644
index 0000000000..40eb235d60
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-7.c
@@ -0,0 +1,25 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-ealias-all" } */
+
+typedef __SIZE_TYPE__ size_t;
+extern void *acc_copyin (void *, size_t);
+
+#define N 2
+
+void
+foo (void)
+{
+ int a[N];
+ int *p = (int *)acc_copyin (&a[0], sizeof (a));
+
+#pragma acc kernels deviceptr (p) pcopy(a)
+ {
+ a[0] = 0;
+ *p = 1;
+ }
+}
+
+/* Only the omp_data_i related loads should be annotated with cliques. */
+/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */
+
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-8.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-8.c
new file mode 100644
index 0000000000..0b93e35909
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-8.c
@@ -0,0 +1,22 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-ealias-all" } */
+
+typedef __SIZE_TYPE__ size_t;
+extern void *acc_copyin (void *, size_t);
+
+void
+foo (int *a, size_t n)
+{
+ int *p = (int *)acc_copyin (&a, n);
+
+#pragma acc kernels deviceptr (p) pcopy(a[0:n])
+ {
+ a = 0;
+ *p = 1;
+ }
+}
+
+/* Only the omp_data_i related loads should be annotated with cliques. */
+/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */
+
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-2.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-2.c
new file mode 100644
index 0000000000..f16d698af0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-2.c
@@ -0,0 +1,37 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fipa-pta -fdump-tree-optimized" } */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef __SIZE_TYPE__ size_t;
+void *malloc (size_t);
+void free (void *);
+#ifdef __cplusplus
+}
+#endif
+
+#define N 2
+
+void
+foo (void)
+{
+ unsigned int *a = (unsigned int *)malloc (N * sizeof (unsigned int));
+ unsigned int *b = (unsigned int *)malloc (N * sizeof (unsigned int));
+ unsigned int *c = (unsigned int *)malloc (N * sizeof (unsigned int));
+
+#pragma acc kernels pcopyout (a[0:N], b[0:N], c[0:N])
+ {
+ a[0] = 0;
+ b[0] = 1;
+ c[0] = a[0];
+ }
+
+ free (a);
+ free (b);
+ free (c);
+}
+
+/* { dg-final { scan-tree-dump-times "(?n)= 0;$" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n)= 1;$" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n)= \\*a" 0 "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-3.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-3.c
new file mode 100644
index 0000000000..1eb56eb9e6
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-3.c
@@ -0,0 +1,36 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fipa-pta -fdump-tree-optimized" } */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef __SIZE_TYPE__ size_t;
+void *malloc (size_t);
+void free (void *);
+#ifdef __cplusplus
+}
+#endif
+
+#define N 2
+
+void
+foo (void)
+{
+ unsigned int *a = (unsigned int *)malloc (N * sizeof (unsigned int));
+ unsigned int *b = a;
+ unsigned int *c = (unsigned int *)malloc (N * sizeof (unsigned int));
+
+#pragma acc kernels pcopyout (a[0:N], b[0:N], c[0:N])
+ {
+ a[0] = 0;
+ b[0] = 1;
+ c[0] = a[0];
+ }
+
+ free (a);
+ free (c);
+}
+
+/* { dg-final { scan-tree-dump-times "(?n)= 0;$" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n)= 1;$" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n)= \\*a" 1 "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-4.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-4.c
new file mode 100644
index 0000000000..20b21dcb57
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-4.c
@@ -0,0 +1,21 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fipa-pta -fdump-tree-optimized" } */
+
+void
+foo (void)
+{
+ unsigned int a;
+ unsigned int b;
+ unsigned int c;
+
+#pragma acc kernels pcopyout (a, b, c)
+ {
+ a = 0;
+ b = 1;
+ c = a;
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "(?n)= 0;$" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n)= 1;$" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n)= \\*_\[0-9\];$" 0 "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta.c
new file mode 100644
index 0000000000..969b466e8a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta.c
@@ -0,0 +1,23 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fipa-pta -fdump-tree-optimized" } */
+
+#define N 2
+
+void
+foo (void)
+{
+ unsigned int a[N];
+ unsigned int b[N];
+ unsigned int c[N];
+
+#pragma acc kernels pcopyout (a, b, c)
+ {
+ a[0] = 0;
+ b[0] = 1;
+ c[0] = a[0];
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "(?n)= 0;$" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n)= 1;$" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n)= \\*_\[0-9\]\\\[0\\\];$" 0 "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias.c
new file mode 100644
index 0000000000..25821ab2ae
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias.c
@@ -0,0 +1,29 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-ealias-all" } */
+
+#define N 2
+
+void
+foo (void)
+{
+ unsigned int a[N];
+ unsigned int b[N];
+ unsigned int c[N];
+ unsigned int d[N];
+
+#pragma acc kernels copyin (a) create (b) copyout (c) copy (d)
+ {
+ a[0] = 0;
+ b[0] = 0;
+ c[0] = 0;
+ d[0] = 0;
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "clique 1 base 1" 4 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "clique 1 base 2" 1 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "clique 1 base 3" 1 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "clique 1 base 4" 1 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "clique 1 base 5" 1 "ealias" } } */
+/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 8 "ealias" } } */
+
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-counter-vars-function-scope.c b/gcc/testsuite/c-c++-common/goacc/kernels-counter-vars-function-scope.c
new file mode 100644
index 0000000000..17f240e5a8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-counter-vars-function-scope.c
@@ -0,0 +1,53 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N (1024 * 512)
+#define COUNTERTYPE unsigned int
+
+int
+main (void)
+{
+ unsigned int *__restrict a;
+ unsigned int *__restrict b;
+ unsigned int *__restrict c;
+ COUNTERTYPE i;
+ COUNTERTYPE ii;
+
+ a = (unsigned int *)malloc (N * sizeof (unsigned int));
+ b = (unsigned int *)malloc (N * sizeof (unsigned int));
+ c = (unsigned int *)malloc (N * sizeof (unsigned int));
+
+ for (i = 0; i < N; i++)
+ a[i] = i * 2;
+
+ for (i = 0; i < N; i++)
+ b[i] = i * 4;
+
+#pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N])
+ {
+ for (ii = 0; ii < N; ii++)
+ c[ii] = a[ii] + b[ii];
+ }
+
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] + b[i])
+ abort ();
+
+ free (a);
+ free (b);
+ free (c);
+
+ return 0;
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-default-2.c b/gcc/testsuite/c-c++-common/goacc/kernels-default-2.c
new file mode 100644
index 0000000000..232b1236f3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-default-2.c
@@ -0,0 +1,17 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-gimple" } */
+
+#define N 2
+
+void
+foo (void)
+{
+ unsigned int a[N];
+
+#pragma acc kernels
+ {
+ a[0]++;
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "map\\(tofrom" 1 "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-default.c b/gcc/testsuite/c-c++-common/goacc/kernels-default.c
new file mode 100644
index 0000000000..cb031c11a3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-default.c
@@ -0,0 +1,14 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-gimple" } */
+
+void
+foo (void)
+{
+ unsigned int i = 0;
+#pragma acc kernels
+ {
+ i++;
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "map\\(force_tofrom" 1 "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-double-reduction-n.c b/gcc/testsuite/c-c++-common/goacc/kernels-double-reduction-n.c
new file mode 100644
index 0000000000..750f576e4c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-double-reduction-n.c
@@ -0,0 +1,36 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N 500
+
+unsigned int a[N][N];
+
+void __attribute__((noinline,noclone))
+foo (unsigned int n)
+{
+ int i, j;
+ unsigned int sum = 1;
+
+#pragma acc kernels copyin (a[0:n]) copy (sum)
+ {
+ for (i = 0; i < n; ++i)
+ for (j = 0; j < n; ++j)
+ sum += a[i][j];
+ }
+
+ if (sum != 5001)
+ abort ();
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+/* { dg-final { scan-tree-dump-times "parallelizing outer loop" 1 "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*foo.*._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c b/gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c
new file mode 100644
index 0000000000..df60d6a51c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c
@@ -0,0 +1,36 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N 500
+
+unsigned int a[N][N];
+
+void __attribute__((noinline,noclone))
+foo (void)
+{
+ int i, j;
+ unsigned int sum = 1;
+
+#pragma acc kernels copyin (a[0:N]) copy (sum)
+ {
+ for (i = 0; i < N; ++i)
+ for (j = 0; j < N; ++j)
+ sum += a[i][j];
+ }
+
+ if (sum != 5001)
+ abort ();
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+/* { dg-final { scan-tree-dump-times "parallelizing outer loop" 1 "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*foo.*._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-loop-2.c b/gcc/testsuite/c-c++-common/goacc/kernels-loop-2.c
new file mode 100644
index 0000000000..913d91f5fb
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-loop-2.c
@@ -0,0 +1,69 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N (1024 * 512)
+#define COUNTERTYPE unsigned int
+
+int
+main (void)
+{
+ unsigned int *__restrict a;
+ unsigned int *__restrict b;
+ unsigned int *__restrict c;
+
+ a = (unsigned int *)malloc (N * sizeof (unsigned int));
+ b = (unsigned int *)malloc (N * sizeof (unsigned int));
+ c = (unsigned int *)malloc (N * sizeof (unsigned int));
+
+#pragma acc kernels copyout (a[0:N])
+ {
+#ifdef ACC_LOOP
+ #pragma acc loop
+#endif
+ for (COUNTERTYPE i = 0; i < N; i++)
+ a[i] = i * 2;
+ }
+
+#pragma acc kernels copyout (b[0:N])
+ {
+#ifdef ACC_LOOP
+ #pragma acc loop
+#endif
+ for (COUNTERTYPE i = 0; i < N; i++)
+ b[i] = i * 4;
+ }
+
+#pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N])
+ {
+#ifdef ACC_LOOP
+ #pragma acc loop
+#endif
+ for (COUNTERTYPE ii = 0; ii < N; ii++)
+ c[ii] = a[ii] + b[ii];
+ }
+
+ for (COUNTERTYPE i = 0; i < N; i++)
+ if (c[i] != a[i] + b[i])
+ abort ();
+
+ free (a);
+ free (b);
+ free (c);
+
+ return 0;
+}
+
+/* Check that only three loops are analyzed, and that all can be
+ parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.1" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.2" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 3 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-loop-3.c b/gcc/testsuite/c-c++-common/goacc/kernels-loop-3.c
new file mode 100644
index 0000000000..1822d2a687
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-loop-3.c
@@ -0,0 +1,47 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N (1024 * 512)
+#define COUNTERTYPE unsigned int
+
+int
+main (void)
+{
+ unsigned int i;
+
+ unsigned int *__restrict c;
+
+ c = (unsigned int *__restrict)malloc (N * sizeof (unsigned int));
+
+ for (COUNTERTYPE i = 0; i < N; i++)
+ c[i] = i * 2;
+
+#pragma acc kernels copy (c[0:N])
+ {
+#ifdef ACC_LOOP
+ #pragma acc loop
+#endif
+ for (COUNTERTYPE ii = 0; ii < N; ii++)
+ c[ii] = c[ii] + ii + 1;
+ }
+
+ for (COUNTERTYPE i = 0; i < N; i++)
+ if (c[i] != i * 2 + i + 1)
+ abort ();
+
+ free (c);
+
+ return 0;
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c b/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c
new file mode 100644
index 0000000000..e946319e2d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c
@@ -0,0 +1,15 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-g" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include "kernels-loop.c"
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-loop-mod-not-zero.c b/gcc/testsuite/c-c++-common/goacc/kernels-loop-mod-not-zero.c
new file mode 100644
index 0000000000..9b63b45f71
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-loop-mod-not-zero.c
@@ -0,0 +1,51 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N ((1024 * 512) + 1)
+#define COUNTERTYPE unsigned int
+
+int
+main (void)
+{
+ unsigned int *__restrict a;
+ unsigned int *__restrict b;
+ unsigned int *__restrict c;
+
+ a = (unsigned int *__restrict)malloc (N * sizeof (unsigned int));
+ b = (unsigned int *__restrict)malloc (N * sizeof (unsigned int));
+ c = (unsigned int *__restrict)malloc (N * sizeof (unsigned int));
+
+ for (COUNTERTYPE i = 0; i < N; i++)
+ a[i] = i * 2;
+
+ for (COUNTERTYPE i = 0; i < N; i++)
+ b[i] = i * 4;
+
+#pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N])
+ {
+ for (COUNTERTYPE ii = 0; ii < N; ii++)
+ c[ii] = a[ii] + b[ii];
+ }
+
+ for (COUNTERTYPE i = 0; i < N; i++)
+ if (c[i] != a[i] + b[i])
+ abort ();
+
+ free (a);
+ free (b);
+ free (c);
+
+ return 0;
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-loop-n.c b/gcc/testsuite/c-c++-common/goacc/kernels-loop-n.c
new file mode 100644
index 0000000000..279f7976ad
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-loop-n.c
@@ -0,0 +1,54 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N ((1024 * 512) + 1)
+#define COUNTERTYPE unsigned int
+
+int
+foo (COUNTERTYPE n)
+{
+ unsigned int *__restrict a;
+ unsigned int *__restrict b;
+ unsigned int *__restrict c;
+
+ a = (unsigned int *__restrict)malloc (n * sizeof (unsigned int));
+ b = (unsigned int *__restrict)malloc (n * sizeof (unsigned int));
+ c = (unsigned int *__restrict)malloc (n * sizeof (unsigned int));
+
+ for (COUNTERTYPE i = 0; i < n; i++)
+ a[i] = i * 2;
+
+ for (COUNTERTYPE i = 0; i < n; i++)
+ b[i] = i * 4;
+
+#pragma acc kernels copyin (a[0:n], b[0:n]) copyout (c[0:n])
+ {
+#ifdef ACC_LOOP
+ #pragma acc loop
+#endif
+ for (COUNTERTYPE ii = 0; ii < n; ii++)
+ c[ii] = a[ii] + b[ii];
+ }
+
+ for (COUNTERTYPE i = 0; i < n; i++)
+ if (c[i] != a[i] + b[i])
+ abort ();
+
+ free (a);
+ free (b);
+ free (c);
+
+ return 0;
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*foo.*._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-loop-nest.c b/gcc/testsuite/c-c++-common/goacc/kernels-loop-nest.c
new file mode 100644
index 0000000000..db1071f7dd
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-loop-nest.c
@@ -0,0 +1,38 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+/* Based on autopar/outer-1.c. */
+
+#include <stdlib.h>
+
+#define N 1000
+
+int
+main (void)
+{
+ int x[N][N];
+
+#pragma acc kernels copyout (x)
+ {
+ for (int ii = 0; ii < N; ii++)
+ for (int jj = 0; jj < N; jj++)
+ x[ii][jj] = ii + jj + 3;
+ }
+
+ for (int i = 0; i < N; i++)
+ for (int j = 0; j < N; j++)
+ if (x[i][j] != i + j + 3)
+ abort ();
+
+ return 0;
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-loop.c b/gcc/testsuite/c-c++-common/goacc/kernels-loop.c
new file mode 100644
index 0000000000..abf7a3c3c6
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-loop.c
@@ -0,0 +1,54 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N (1024 * 512)
+#define COUNTERTYPE unsigned int
+
+int
+main (void)
+{
+ unsigned int *__restrict a;
+ unsigned int *__restrict b;
+ unsigned int *__restrict c;
+
+ a = (unsigned int *)malloc (N * sizeof (unsigned int));
+ b = (unsigned int *)malloc (N * sizeof (unsigned int));
+ c = (unsigned int *)malloc (N * sizeof (unsigned int));
+
+ for (COUNTERTYPE i = 0; i < N; i++)
+ a[i] = i * 2;
+
+ for (COUNTERTYPE i = 0; i < N; i++)
+ b[i] = i * 4;
+
+#pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N])
+ {
+#ifdef ACC_LOOP
+ #pragma acc loop
+#endif
+ for (COUNTERTYPE ii = 0; ii < N; ii++)
+ c[ii] = a[ii] + b[ii];
+ }
+
+ for (COUNTERTYPE i = 0; i < N; i++)
+ if (c[i] != a[i] + b[i])
+ abort ();
+
+ free (a);
+ free (b);
+ free (c);
+
+ return 0;
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-one-counter-var.c b/gcc/testsuite/c-c++-common/goacc/kernels-one-counter-var.c
new file mode 100644
index 0000000000..95f4817906
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-one-counter-var.c
@@ -0,0 +1,52 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N (1024 * 512)
+#define COUNTERTYPE unsigned int
+
+int
+main (void)
+{
+ unsigned int *__restrict a;
+ unsigned int *__restrict b;
+ unsigned int *__restrict c;
+ COUNTERTYPE i;
+
+ a = (unsigned int *)malloc (N * sizeof (unsigned int));
+ b = (unsigned int *)malloc (N * sizeof (unsigned int));
+ c = (unsigned int *)malloc (N * sizeof (unsigned int));
+
+ for (i = 0; i < N; i++)
+ a[i] = i * 2;
+
+ for (i = 0; i < N; i++)
+ b[i] = i * 4;
+
+#pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N])
+ {
+ for (i = 0; i < N; i++)
+ c[i] = a[i] + b[i];
+ }
+
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] + b[i])
+ abort ();
+
+ free (a);
+ free (b);
+ free (c);
+
+ return 0;
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-reduction.c b/gcc/testsuite/c-c++-common/goacc/kernels-reduction.c
new file mode 100644
index 0000000000..6f5a418a46
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-reduction.c
@@ -0,0 +1,34 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fdump-tree-parloops1-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define n 10000
+
+unsigned int a[n];
+
+void __attribute__((noinline,noclone))
+foo (void)
+{
+ int i;
+ unsigned int sum = 1;
+
+#pragma acc kernels copyin (a[0:n]) copy (sum)
+ {
+ for (i = 0; i < n; ++i)
+ sum += a[i];
+ }
+
+ if (sum != 5001)
+ abort ();
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*foo.*._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/loop-1.c b/gcc/testsuite/c-c++-common/goacc/loop-1.c
index fea40e0ab6..4cf5429c9b 100644
--- a/gcc/testsuite/c-c++-common/goacc/loop-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/loop-1.c
@@ -1,5 +1,3 @@
-/* { dg-skip-if "not yet" { c++ } } */
-
int test1()
{
int i, j, k, b[10];
@@ -38,16 +36,16 @@ int test1()
i = d;
a[i] = 1;
}
- #pragma acc loop
+ #pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (i = 1; i < 30; i++ )
if (i == 16) break; /* { dg-error "break statement used" } */
/* different types of for loop are allowed */
- #pragma acc loop
+ #pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (i = 1; i < 10; i++)
{
}
- #pragma acc loop
+ #pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (i = 1; i < 10; i+=2)
{
a[i] = i;
@@ -69,4 +67,10 @@ int test1()
}
return 0;
}
-/* { dg-prune-output "sorry, unimplemented: directive not yet implemented" } */
+
+// PR64765
+void PR64765(float *f, double *r) {
+ int i;
+ #pragma acc kernels loop create(f) copy(r)
+ for(i = 64; i < 76; i += 5) {}
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/loop-2-kernels.c b/gcc/testsuite/c-c++-common/goacc/loop-2-kernels.c
new file mode 100644
index 0000000000..01ad32d6ea
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/loop-2-kernels.c
@@ -0,0 +1,189 @@
+void K(void)
+{
+ int i, j;
+
+#pragma acc kernels
+ {
+#pragma acc loop auto
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang(5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang(num:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang(static:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang(static:*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang
+ for (i = 0; i < 10; i++)
+ {
+#pragma acc loop vector
+ for (j = 0; j < 10; j++)
+ { }
+#pragma acc loop worker
+ for (j = 0; j < 10; j++)
+ { }
+#pragma acc loop gang // { dg-error "inner loop uses same" }
+ for (j = 0; j < 10; j++)
+ { }
+ }
+#pragma acc loop seq gang // { dg-error "'seq' overrides" }
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc loop worker
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker(5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker(num:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker
+ for (i = 0; i < 10; i++)
+ {
+#pragma acc loop vector
+ for (j = 0; j < 10; j++)
+ { }
+#pragma acc loop worker // { dg-error "inner loop uses same" }
+ for (j = 0; j < 10; j++)
+ { }
+#pragma acc loop gang
+ for (j = 0; j < 10; j++)
+ { }
+ }
+#pragma acc loop seq worker // { dg-error "'seq' overrides" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang worker
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc loop vector
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector(5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector(length:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector
+ for (i = 0; i < 10; i++)
+ {
+#pragma acc loop vector // { dg-error "inner loop uses same" }
+ for (j = 1; j < 10; j++)
+ { }
+#pragma acc loop worker
+ for (j = 1; j < 10; j++)
+ { }
+#pragma acc loop gang
+ for (j = 1; j < 10; j++)
+ { }
+ }
+#pragma acc loop seq vector // { dg-error "'seq' overrides" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang vector
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker vector
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc loop auto
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop seq auto // { dg-error "'seq' overrides" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang auto // { dg-error "'auto' conflicts" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker auto // { dg-error "'auto' conflicts" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector auto // { dg-error "'auto' conflicts" }
+ for (i = 0; i < 10; i++)
+ { }
+ }
+
+#pragma acc kernels loop auto
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop gang
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop gang(5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop gang(num:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop gang(static:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop gang(static:*)
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc kernels loop worker
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop worker(5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop worker(num:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop seq worker // { dg-error "'seq' overrides" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+ { }
+#pragma acc kernels loop gang worker
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc kernels loop vector
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop vector(5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop vector(length:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop seq vector // { dg-error "'seq' overrides" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+ { }
+#pragma acc kernels loop gang vector
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop worker vector
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc kernels loop auto
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop seq auto // { dg-error "'seq' overrides" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+ { }
+#pragma acc kernels loop gang auto // { dg-error "'auto' conflicts" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+ { }
+#pragma acc kernels loop worker auto // { dg-error "'auto' conflicts" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+ { }
+#pragma acc kernels loop vector auto // { dg-error "'auto' conflicts" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+ { }
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/loop-2-parallel.c b/gcc/testsuite/c-c++-common/goacc/loop-2-parallel.c
new file mode 100644
index 0000000000..0ef5741ca4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/loop-2-parallel.c
@@ -0,0 +1,162 @@
+void P(void)
+{
+ int i, j;
+
+#pragma acc parallel
+ {
+#pragma acc loop auto
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang(static:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang(static:*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang // { dg-message "containing loop" }
+ for (i = 0; i < 10; i++)
+ {
+#pragma acc loop vector
+ for (j = 1; j < 10; j++)
+ { }
+#pragma acc loop worker
+ for (j = 1; j < 10; j++)
+ { }
+#pragma acc loop gang // { dg-error "inner loop uses same" }
+ for (j = 1; j < 10; j++)
+ { }
+ }
+#pragma acc loop seq gang // { dg-error "'seq' overrides" }
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc loop worker
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker // { dg-message "containing loop" 2 }
+ for (i = 0; i < 10; i++)
+ {
+#pragma acc loop vector
+ for (j = 1; j < 10; j++)
+ { }
+#pragma acc loop worker // { dg-error "inner loop uses same" }
+ for (j = 1; j < 10; j++)
+ { }
+#pragma acc loop gang // { dg-error "incorrectly nested" }
+ for (j = 1; j < 10; j++)
+ { }
+ }
+#pragma acc loop seq worker // { dg-error "'seq' overrides" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang worker
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc loop vector
+ for (i = 0; i < 10; i++)
+ { }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector // { dg-message "containing loop" 3 }
+ for (i = 0; i < 10; i++)
+ {
+#pragma acc loop vector // { dg-error "inner loop uses same" }
+ for (j = 1; j < 10; j++)
+ { }
+#pragma acc loop worker // { dg-error "incorrectly nested" }
+ for (j = 1; j < 10; j++)
+ { }
+#pragma acc loop gang // { dg-error "incorrectly nested" }
+ for (j = 1; j < 10; j++)
+ { }
+ }
+#pragma acc loop seq vector // { dg-error "'seq' overrides" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang vector
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker vector
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc loop auto
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop seq auto // { dg-error "'seq' overrides" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang auto // { dg-error "'auto' conflicts" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker auto // { dg-error "'auto' conflicts" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector auto // { dg-error "'auto' conflicts" }
+ for (i = 0; i < 10; i++)
+ { }
+
+ }
+
+#pragma acc parallel loop auto
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop gang
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop gang(static:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop gang(static:*)
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc parallel loop seq gang // { dg-error "'seq' overrides" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+ { }
+
+#pragma acc parallel loop worker
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc parallel loop seq worker // { dg-error "'seq' overrides" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+ { }
+#pragma acc parallel loop gang worker
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc parallel loop vector
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc parallel loop seq vector // { dg-error "'seq' overrides" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+ { }
+#pragma acc parallel loop gang vector
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop worker vector
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc parallel loop auto
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop seq auto // { dg-error "'seq' overrides" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+ { }
+#pragma acc parallel loop gang auto // { dg-error "'auto' conflicts" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+ { }
+#pragma acc parallel loop worker auto // { dg-error "'auto' conflicts" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+ { }
+#pragma acc parallel loop vector auto // { dg-error "'auto' conflicts" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+ { }
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/loop-3.c b/gcc/testsuite/c-c++-common/goacc/loop-3.c
new file mode 100644
index 0000000000..44b65a8bf5
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/loop-3.c
@@ -0,0 +1,58 @@
+void par1 (void)
+{
+ int i, j;
+
+#pragma acc parallel
+ {
+#pragma acc loop gang(5) // { dg-error "argument not permitted" }
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc loop gang(num:5) // { dg-error "argument not permitted" }
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc loop worker(5) // { dg-error "argument not permitted" }
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc loop worker(num:5) // { dg-error "argument not permitted" }
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc loop vector(5) // { dg-error "argument not permitted" }
+ for (i = 0; i < 10; i++)
+ { }
+
+#pragma acc loop vector(length:5) // { dg-error "argument not permitted" }
+ for (i = 0; i < 10; i++)
+ { }
+
+ }
+}
+
+void p2 (void)
+{
+ int i, j;
+
+#pragma acc parallel loop gang(5) // { dg-error "argument not permitted" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+ { }
+#pragma acc parallel loop gang(num:5) // { dg-error "argument not permitted" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+ { }
+
+#pragma acc parallel loop worker(5) // { dg-error "argument not permitted" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+ { }
+#pragma acc parallel loop worker(num:5) // { dg-error "argument not permitted" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+ { }
+
+#pragma acc parallel loop vector(5) // { dg-error "argument not permitted" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+ { }
+#pragma acc parallel loop vector(length:5) // { dg-error "argument not permitted" "" { target c } }
+ for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+ { }
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/loop-auto-1.c b/gcc/testsuite/c-c++-common/goacc/loop-auto-1.c
new file mode 100644
index 0000000000..ee6d28c2e8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/loop-auto-1.c
@@ -0,0 +1,230 @@
+
+void Foo ()
+{
+
+#pragma acc parallel num_gangs(10) num_workers(32) vector_length(32)
+ {
+#pragma acc loop vector
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop seq
+ for (int jx = 0; jx < 10; jx++) {}
+
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int jx = 0; jx < 10; jx++) {}
+ }
+
+#pragma acc loop worker
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++) {}
+
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop vector
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+ }
+
+#pragma acc loop gang
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++) {}
+
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop auto
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+
+#pragma acc loop worker
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop auto
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+
+#pragma acc loop vector
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop vector
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+
+ }
+
+#pragma acc loop auto
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop auto
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+ }
+ }
+}
+
+#pragma acc routine gang
+void Gang (void)
+{
+#pragma acc loop vector
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop seq
+ for (int jx = 0; jx < 10; jx++) {}
+
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int jx = 0; jx < 10; jx++) {}
+ }
+
+#pragma acc loop worker
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++) {}
+
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop vector
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+ }
+
+#pragma acc loop gang
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++) {}
+
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop auto
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+
+#pragma acc loop worker
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop auto
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+
+#pragma acc loop vector
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop vector
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+
+ }
+
+#pragma acc loop auto
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop auto
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+ }
+}
+
+#pragma acc routine worker
+void Worker (void)
+{
+#pragma acc loop vector
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop seq
+ for (int jx = 0; jx < 10; jx++) {}
+
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int jx = 0; jx < 10; jx++) {}
+ }
+
+#pragma acc loop worker
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++) {}
+
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop vector
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+ }
+
+#pragma acc loop auto
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++) {}
+ }
+
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++)
+ {
+#pragma acc loop auto
+ for (int kx = 0; kx < 10; kx++) {}
+ }
+ }
+}
+
+#pragma acc routine vector
+void Vector (void)
+{
+#pragma acc loop vector
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop seq
+ for (int jx = 0; jx < 10; jx++) {}
+
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int jx = 0; jx < 10; jx++) {}
+ }
+
+#pragma acc loop auto
+ for (int ix = 0; ix < 10; ix++) {}
+
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int ix = 0; ix < 10; ix++)
+ {
+#pragma acc loop auto
+ for (int jx = 0; jx < 10; jx++) {}
+ }
+}
+
+#pragma acc routine seq
+void Seq (void)
+{
+#pragma acc loop auto /* { dg-warning "insufficient partitioning" } */
+ for (int ix = 0; ix < 10; ix++) {}
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/loop-clauses.c b/gcc/testsuite/c-c++-common/goacc/loop-clauses.c
new file mode 100644
index 0000000000..f3c720730e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/loop-clauses.c
@@ -0,0 +1,82 @@
+int
+main ()
+{
+ int i, j;
+
+#pragma acc parallel firstprivate (j) private (i)
+ {
+#pragma acc loop seq
+ for (i = 0; i < 10; i++)
+ { }
+ }
+
+#pragma acc parallel default (none)
+ {
+#pragma acc loop auto private (j)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang(static:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang(static:*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop auto
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop independent
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop seq
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang worker vector
+ for (i = 0; i < 10; i++)
+ { }
+ }
+
+#pragma acc kernels default (none)
+ {
+#pragma acc loop auto
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang (num:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang(static:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang(static:*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector(length:10)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker(num:5)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop auto
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop independent
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop seq
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang worker vector
+ for (i = 0; i < 10; i++)
+ { }
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/loop-private-1.c b/gcc/testsuite/c-c++-common/goacc/loop-private-1.c
index a54edb2c05..38a4a7d0ac 100644
--- a/gcc/testsuite/c-c++-common/goacc/loop-private-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/loop-private-1.c
@@ -11,4 +11,3 @@ f (int i, int j)
}
/* { dg-final { scan-tree-dump-times "#pragma acc loop collapse\\(2\\) private\\(j\\) private\\(i\\)" 1 "gimple" } } */
-/* { dg-final { cleanup-tree-dump "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/loop-shape.c b/gcc/testsuite/c-c++-common/goacc/loop-shape.c
new file mode 100644
index 0000000000..9708f7bf5e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/loop-shape.c
@@ -0,0 +1,323 @@
+/* Exercise *_parser_oacc_shape_clause by checking various combinations
+ of gang, worker and vector clause arguments. */
+
+/* { dg-compile } */
+
+int main ()
+{
+ int i;
+ int v = 32, w = 19;
+ int length = 1, num = 5;
+ int *abc;
+
+ /* Valid uses. */
+
+ #pragma acc kernels
+ #pragma acc loop gang worker vector
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(26)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(v)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(length: 16)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(length: v)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(16)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(v)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(num: 16)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(num: v)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(16)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(v)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(static: 16, num: 5)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(static: v, num: w)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(length)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(num)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(num, static: 6)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(static: 5, num)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(1, static:*)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(static:*, 1)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(1, static:*)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(num: 5, static: 4)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(num: v, static: w)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(num, static:num)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(length:length)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(num:length)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(num:num)
+ for (i = 0; i < 10; i++)
+ ;
+
+ /* Invalid uses. */
+
+ #pragma acc kernels
+ #pragma acc loop gang(16, 24) /* { dg-error "unexpected argument" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(v, w) /* { dg-error "unexpected argument" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(num: 1, num:2, num:3, 4) /* { dg-error "unexpected argument" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(num: 1 num:2, num:3, 4) /* { dg-error "expected '.' before" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(1, num:2, num:3, 4) /* { dg-error "unexpected argument" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(num, num:5) /* { dg-error "unexpected argument" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(length:num) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(5, length:length) /* { dg-error "expected '.' before" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(num:length) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(length:5) /* { dg-error "expected '.' before" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(1, num:2) /* { dg-error "expected '.' before" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(static: * abc)
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(static:*num:1) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(num: 5 static: *) /* { dg-error "expected '.' before" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(,static: *) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(,length:5) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(,num:10) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(,10) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(,10) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(,10) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(-12) /* { dg-warning "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(-1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(num:-1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(num:1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(static:-1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop gang(static:1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(-1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(num:-1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop worker(num:1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(-1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(length:-1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ #pragma acc kernels
+ #pragma acc loop vector(length:1.0) /* { dg-error "" } */
+ for (i = 0; i < 10; i++)
+ ;
+
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/nesting-1.c b/gcc/testsuite/c-c++-common/goacc/nesting-1.c
index b4b863fb86..cab4f98950 100644
--- a/gcc/testsuite/c-c++-common/goacc/nesting-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/nesting-1.c
@@ -58,10 +58,6 @@ f_acc_data (void)
#pragma acc exit data delete(i)
-#pragma acc loop
- for (i = 0; i < 2; ++i)
- ;
-
#pragma acc data
{
#pragma acc parallel
@@ -92,10 +88,6 @@ f_acc_data (void)
#pragma acc enter data copyin(i)
#pragma acc exit data delete(i)
-
-#pragma acc loop
- for (i = 0; i < 2; ++i)
- ;
}
}
}
diff --git a/gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c b/gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
index 8af1c8244f..93a911120d 100644
--- a/gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
@@ -7,15 +7,15 @@ f_acc_parallel (void)
{
#pragma acc parallel
{
-#pragma acc parallel /* { dg-bogus "parallel construct inside of parallel region" "not implemented" { xfail *-*-* } } */
+#pragma acc parallel /* { dg-bogus ".parallel. construct inside of .parallel. region" "not implemented" { xfail *-*-* } } */
;
-#pragma acc kernels /* { dg-bogus "kernels construct inside of parallel region" "not implemented" { xfail *-*-* } } */
+#pragma acc kernels /* { dg-bogus ".kernels. construct inside of .parallel. region" "not implemented" { xfail *-*-* } } */
;
-#pragma acc data /* { dg-error "data construct inside of parallel region" } */
+#pragma acc data /* { dg-error ".data. construct inside of .parallel. region" } */
;
-#pragma acc update host(i) /* { dg-error "update construct inside of parallel region" } */
-#pragma acc enter data copyin(i) /* { dg-error "enter/exit data construct inside of parallel region" } */
-#pragma acc exit data delete(i) /* { dg-error "enter/exit data construct inside of parallel region" } */
+#pragma acc update host(i) /* { dg-error ".update. construct inside of .parallel. region" } */
+#pragma acc enter data copyin(i) /* { dg-error ".enter/exit data. construct inside of .parallel. region" } */
+#pragma acc exit data delete(i) /* { dg-error ".enter/exit data. construct inside of .parallel. region" } */
}
}
@@ -26,14 +26,51 @@ f_acc_kernels (void)
{
#pragma acc kernels
{
-#pragma acc parallel /* { dg-bogus "parallel construct inside of kernels region" "not implemented" { xfail *-*-* } } */
+#pragma acc parallel /* { dg-bogus ".parallel. construct inside of .kernels. region" "not implemented" { xfail *-*-* } } */
;
-#pragma acc kernels /* { dg-bogus "kernels construct inside of kernels region" "not implemented" { xfail *-*-* } } */
+#pragma acc kernels /* { dg-bogus ".kernels. construct inside of .kernels. region" "not implemented" { xfail *-*-* } } */
;
-#pragma acc data /* { dg-error "data construct inside of kernels region" } */
+#pragma acc data /* { dg-error ".data. construct inside of .kernels. region" } */
;
-#pragma acc update host(i) /* { dg-error "update construct inside of kernels region" } */
-#pragma acc enter data copyin(i) /* { dg-error "enter/exit data construct inside of kernels region" } */
-#pragma acc exit data delete(i) /* { dg-error "enter/exit data construct inside of kernels region" } */
+#pragma acc update host(i) /* { dg-error ".update. construct inside of .kernels. region" } */
+#pragma acc enter data copyin(i) /* { dg-error ".enter/exit data. construct inside of .kernels. region" } */
+#pragma acc exit data delete(i) /* { dg-error ".enter/exit data. construct inside of .kernels. region" } */
}
}
+
+void
+f_acc_data (void)
+{
+ unsigned int i;
+#pragma acc data
+ {
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
+ for (i = 0; i < 2; ++i)
+ ;
+
+#pragma acc data
+ {
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
+ for (i = 0; i < 2; ++i)
+ ;
+ }
+ }
+}
+
+#pragma acc routine
+void
+f_acc_routine (void)
+{
+#pragma acc parallel /* { dg-error "OpenACC region inside of OpenACC routine, nested parallelism not supported yet" } */
+ ;
+}
+
+void
+f (void)
+{
+ int i, v = 0;
+
+#pragma acc loop gang reduction (+:v) /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
+ for (i = 0; i < 10; i++)
+ v++;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/parallel-1.c b/gcc/testsuite/c-c++-common/goacc/parallel-1.c
index a860526674..6c6cc88eca 100644
--- a/gcc/testsuite/c-c++-common/goacc/parallel-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/parallel-1.c
@@ -1,6 +1,38 @@
-void
-foo (void)
+int
+parallel_empty (void)
{
#pragma acc parallel
;
+
+ return 0;
+}
+
+int
+parallel_eternal (void)
+{
+#pragma acc parallel
+ {
+ while (1)
+ ;
+ }
+
+ return 0;
+}
+
+int
+parallel_noreturn (void)
+{
+#pragma acc parallel
+ __builtin_abort ();
+
+ return 0;
+}
+
+int
+parallel_clauses (void)
+{
+ int a, b[100];
+
+#pragma acc parallel firstprivate (a, b)
+ ;
}
diff --git a/gcc/testsuite/c-c++-common/goacc/pcopy.c b/gcc/testsuite/c-c++-common/goacc/pcopy.c
index fd16525517..02c438353e 100644
--- a/gcc/testsuite/c-c++-common/goacc/pcopy.c
+++ b/gcc/testsuite/c-c++-common/goacc/pcopy.c
@@ -8,4 +8,3 @@ f (char *cp)
}
/* { dg-final { scan-tree-dump-times "#pragma acc parallel map\\(tofrom:\\*\\(cp \\+ 3\\) \\\[len: 5]\\) map\\(alloc:cp \\\[pointer assign, bias: 3]\\)" 1 "original" } } */
-/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/pcopyin.c b/gcc/testsuite/c-c++-common/goacc/pcopyin.c
index c009d24101..10911fcbb4 100644
--- a/gcc/testsuite/c-c++-common/goacc/pcopyin.c
+++ b/gcc/testsuite/c-c++-common/goacc/pcopyin.c
@@ -8,4 +8,3 @@ f (char *cp)
}
/* { dg-final { scan-tree-dump-times "#pragma acc parallel map\\(to:\\*\\(cp \\+ 4\\) \\\[len: 6]\\) map\\(alloc:cp \\\[pointer assign, bias: 4]\\)" 1 "original" } } */
-/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/pcopyout.c b/gcc/testsuite/c-c++-common/goacc/pcopyout.c
index 6099effd8f..703ac2f901 100644
--- a/gcc/testsuite/c-c++-common/goacc/pcopyout.c
+++ b/gcc/testsuite/c-c++-common/goacc/pcopyout.c
@@ -8,4 +8,3 @@ f (char *cp)
}
/* { dg-final { scan-tree-dump-times "#pragma acc parallel map\\(from:\\*\\(cp \\+ 5\\) \\\[len: 7]\\) map\\(alloc:cp \\\[pointer assign, bias: 5]\\)" 1 "original" } } */
-/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/pcreate.c b/gcc/testsuite/c-c++-common/goacc/pcreate.c
index 2f6e836e6f..00bf1551a5 100644
--- a/gcc/testsuite/c-c++-common/goacc/pcreate.c
+++ b/gcc/testsuite/c-c++-common/goacc/pcreate.c
@@ -8,4 +8,3 @@ f (char *cp)
}
/* { dg-final { scan-tree-dump-times "#pragma acc parallel map\\(alloc:\\*\\(cp \\+ 6\\) \\\[len: 8]\\) map\\(alloc:cp \\\[pointer assign, bias: 6]\\)" 1 "original" } } */
-/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/pr69916.c b/gcc/testsuite/c-c++-common/goacc/pr69916.c
new file mode 100644
index 0000000000..e037af34a6
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/pr69916.c
@@ -0,0 +1,20 @@
+/* { dg-additional-options "-O2" } */
+
+/* PR 69916, an loop determined to be empty sometime after omp-lower
+ and before oacc-device-lower can evaporate leading to no GOACC_LOOP
+ internal functions existing. */
+
+int
+main (void)
+{
+
+#pragma acc parallel
+ {
+ int j = 0;
+#pragma acc loop private (j)
+ for (int i = 0; i < 10; i++)
+ j++;
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/present-1.c b/gcc/testsuite/c-c++-common/goacc/present-1.c
index 03ee592144..753794852d 100644
--- a/gcc/testsuite/c-c++-common/goacc/present-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/present-1.c
@@ -8,4 +8,3 @@ f (char *cp)
}
/* { dg-final { scan-tree-dump-times "#pragma acc parallel map\\(force_present:\\*\\(cp \\+ 7\\) \\\[len: 9]\\) map\\(alloc:cp \\\[pointer assign, bias: 7]\\)" 1 "original" } } */
-/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/reduction-1.c b/gcc/testsuite/c-c++-common/goacc/reduction-1.c
index 0f50082983..3c1c2dda6c 100644
--- a/gcc/testsuite/c-c++-common/goacc/reduction-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/reduction-1.c
@@ -1,69 +1,65 @@
/* Integer reductions. */
-#define vl 32
+#define n 1000
int
main(void)
{
- const int n = 1000;
int i;
int result, array[n];
int lresult;
/* '+' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (+:result)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (+:result)
for (i = 0; i < n; i++)
result += array[i];
/* '*' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (*:result)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (*:result)
for (i = 0; i < n; i++)
result *= array[i];
-// result = 0;
-// vresult = 0;
-//
-// /* 'max' reductions. */
-// #pragma acc parallel vector_length (vl)
-// #pragma acc loop reduction (+:result)
-// for (i = 0; i < n; i++)
-// result = result > array[i] ? result : array[i];
-//
-// /* 'min' reductions. */
-// #pragma acc parallel vector_length (vl)
-// #pragma acc loop reduction (+:result)
-// for (i = 0; i < n; i++)
-// result = result < array[i] ? result : array[i];
+ /* 'max' reductions. */
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (max:result)
+ for (i = 0; i < n; i++)
+ result = result > array[i] ? result : array[i];
+
+ /* 'min' reductions. */
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (min:result)
+ for (i = 0; i < n; i++)
+ result = result < array[i] ? result : array[i];
/* '&' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (&:result)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (&:result)
for (i = 0; i < n; i++)
result &= array[i];
/* '|' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (|:result)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (|:result)
for (i = 0; i < n; i++)
result |= array[i];
/* '^' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (^:result)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (^:result)
for (i = 0; i < n; i++)
result ^= array[i];
/* '&&' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (&&:lresult)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (&&:lresult)
for (i = 0; i < n; i++)
lresult = lresult && (result > array[i]);
/* '||' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (||:lresult)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (||:lresult)
for (i = 0; i < n; i++)
lresult = lresult || (result > array[i]);
diff --git a/gcc/testsuite/c-c++-common/goacc/reduction-2.c b/gcc/testsuite/c-c++-common/goacc/reduction-2.c
index 1f95138ff0..c3105a2073 100644
--- a/gcc/testsuite/c-c++-common/goacc/reduction-2.c
+++ b/gcc/testsuite/c-c++-common/goacc/reduction-2.c
@@ -1,48 +1,47 @@
/* float reductions. */
-#define vl 32
+#define n 1000
int
main(void)
{
- const int n = 1000;
int i;
float result, array[n];
int lresult;
/* '+' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (+:result)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (+:result)
for (i = 0; i < n; i++)
result += array[i];
/* '*' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (*:result)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (*:result)
for (i = 0; i < n; i++)
result *= array[i];
-// /* 'max' reductions. */
-// #pragma acc parallel vector_length (vl)
-// #pragma acc loop reduction (+:result)
-// for (i = 0; i < n; i++)
-// result = result > array[i] ? result : array[i];
-//
-// /* 'min' reductions. */
-// #pragma acc parallel vector_length (vl)
-// #pragma acc loop reduction (+:result)
-// for (i = 0; i < n; i++)
-// result = result < array[i] ? result : array[i];
+ /* 'max' reductions. */
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (max:result)
+ for (i = 0; i < n; i++)
+ result = result > array[i] ? result : array[i];
+
+ /* 'min' reductions. */
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (min:result)
+ for (i = 0; i < n; i++)
+ result = result < array[i] ? result : array[i];
/* '&&' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (&&:lresult)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (&&:lresult)
for (i = 0; i < n; i++)
lresult = lresult && (result > array[i]);
/* '||' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (||:lresult)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (||:lresult)
for (i = 0; i < n; i++)
lresult = lresult || (result > array[i]);
diff --git a/gcc/testsuite/c-c++-common/goacc/reduction-3.c b/gcc/testsuite/c-c++-common/goacc/reduction-3.c
index 476e375c65..4dbde04bc3 100644
--- a/gcc/testsuite/c-c++-common/goacc/reduction-3.c
+++ b/gcc/testsuite/c-c++-common/goacc/reduction-3.c
@@ -1,48 +1,47 @@
/* double reductions. */
-#define vl 32
+#define n 1000
int
main(void)
{
- const int n = 1000;
int i;
double result, array[n];
int lresult;
/* '+' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (+:result)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (+:result)
for (i = 0; i < n; i++)
result += array[i];
/* '*' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (*:result)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (*:result)
for (i = 0; i < n; i++)
result *= array[i];
-// /* 'max' reductions. */
-// #pragma acc parallel vector_length (vl)
-// #pragma acc loop reduction (+:result)
-// for (i = 0; i < n; i++)
-// result = result > array[i] ? result : array[i];
-//
-// /* 'min' reductions. */
-// #pragma acc parallel vector_length (vl)
-// #pragma acc loop reduction (+:result)
-// for (i = 0; i < n; i++)
-// result = result < array[i] ? result : array[i];
+ /* 'max' reductions. */
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (max:result)
+ for (i = 0; i < n; i++)
+ result = result > array[i] ? result : array[i];
+
+ /* 'min' reductions. */
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (min:result)
+ for (i = 0; i < n; i++)
+ result = result < array[i] ? result : array[i];
/* '&&' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (&&:lresult)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (&&:lresult)
for (i = 0; i < n; i++)
lresult = lresult && (result > array[i]);
/* '||' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (||:lresult)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (||:lresult)
for (i = 0; i < n; i++)
lresult = lresult || (result > array[i]);
diff --git a/gcc/testsuite/c-c++-common/goacc/reduction-4.c b/gcc/testsuite/c-c++-common/goacc/reduction-4.c
index 73dde869a9..c4572b97bb 100644
--- a/gcc/testsuite/c-c++-common/goacc/reduction-4.c
+++ b/gcc/testsuite/c-c++-common/goacc/reduction-4.c
@@ -1,50 +1,35 @@
/* complex reductions. */
-#define vl 32
+#define n 1000
int
main(void)
{
- const int n = 1000;
int i;
__complex__ double result, array[n];
int lresult;
/* '+' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (+:result)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (+:result)
for (i = 0; i < n; i++)
result += array[i];
- /* Needs support for complex multiplication. */
-
-// /* '*' reductions. */
-// #pragma acc parallel vector_length (vl)
-// #pragma acc loop reduction (*:result)
-// for (i = 0; i < n; i++)
-// result *= array[i];
-//
-// /* 'max' reductions. */
-// #pragma acc parallel vector_length (vl)
-// #pragma acc loop reduction (+:result)
-// for (i = 0; i < n; i++)
-// result = result > array[i] ? result : array[i];
-//
-// /* 'min' reductions. */
-// #pragma acc parallel vector_length (vl)
-// #pragma acc loop reduction (+:result)
-// for (i = 0; i < n; i++)
-// result = result < array[i] ? result : array[i];
+ /* '*' reductions. */
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (*:result)
+ for (i = 0; i < n; i++)
+ result *= array[i];
/* '&&' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (&&:lresult)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (&&:lresult)
for (i = 0; i < n; i++)
lresult = lresult && (__real__(result) > __real__(array[i]));
/* '||' reductions. */
-#pragma acc parallel vector_length (vl)
-#pragma acc loop reduction (||:lresult)
+#pragma acc parallel
+#pragma acc loop gang worker vector reduction (||:lresult)
for (i = 0; i < n; i++)
lresult = lresult || (__real__(result) > __real__(array[i]));
diff --git a/gcc/testsuite/c-c++-common/goacc/reduction-5.c b/gcc/testsuite/c-c++-common/goacc/reduction-5.c
new file mode 100644
index 0000000000..74daad35a5
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/reduction-5.c
@@ -0,0 +1,16 @@
+/* Integer reductions. */
+
+#define n 1000
+
+int
+main(void)
+{
+ int v1;
+
+#pragma acc parallel reduction(+:v1) private(v1) /* { dg-error "appears more than once in data clauses" } */
+ ;
+#pragma acc parallel reduction(+:v1) firstprivate(v1) /* { dg-error "appears more than once in data clauses" } */
+ ;
+
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/reduction-promotions.c b/gcc/testsuite/c-c++-common/goacc/reduction-promotions.c
new file mode 100644
index 0000000000..4cc09da998
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/reduction-promotions.c
@@ -0,0 +1,32 @@
+/* Integer reductions. */
+
+#define n 1000
+
+int
+main(void)
+{
+ int v1, v2;
+
+#pragma acc parallel reduction(+:v1,v2)
+ ;
+#pragma acc parallel reduction(+:v1,v2) copy(v1,v2)
+ ;
+#pragma acc parallel reduction(+:v1,v2) pcopy(v1,v2)
+ ;
+#pragma acc parallel reduction(+:v1,v2) present(v1,v2)
+ ;
+#pragma acc parallel reduction(+:v1,v2) copyin(v1,v2) /* { dg-warning "incompatible data clause with reduction" } */
+ ;
+#pragma acc parallel reduction(+:v1,v2) pcopyin(v1,v2) /* { dg-warning "incompatible data clause with reduction" } */
+ ;
+#pragma acc parallel reduction(+:v1,v2) copyout(v1,v2) /* { dg-warning "incompatible data clause with reduction" } */
+ ;
+#pragma acc parallel reduction(+:v1,v2) pcopyout(v1,v2) /* { dg-warning "incompatible data clause with reduction" } */
+ ;
+#pragma acc parallel reduction(+:v1,v2) create(v1,v2) /* { dg-warning "incompatible data clause with reduction" } */
+ ;
+#pragma acc parallel reduction(+:v1,v2) pcreate(v1,v2) /* { dg-warning "incompatible data clause with reduction" } */
+ ;
+
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/routine-1.c b/gcc/testsuite/c-c++-common/goacc/routine-1.c
new file mode 100644
index 0000000000..a5e0d696f7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/routine-1.c
@@ -0,0 +1,34 @@
+
+#pragma acc routine gang
+void gang (void)
+{
+}
+
+#pragma acc routine worker
+void worker (void)
+{
+}
+
+#pragma acc routine vector
+void vector (void)
+{
+}
+
+#pragma acc routine seq
+void seq (void)
+{
+}
+
+int main ()
+{
+
+#pragma acc parallel num_gangs (32) num_workers (32) vector_length (32)
+ {
+ gang ();
+ worker ();
+ vector ();
+ seq ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/routine-2.c b/gcc/testsuite/c-c++-common/goacc/routine-2.c
new file mode 100644
index 0000000000..fc5eb11bb5
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/routine-2.c
@@ -0,0 +1,21 @@
+#pragma acc routine gang worker /* { dg-error "multiple loop axes" } */
+void gang (void)
+{
+}
+
+#pragma acc routine worker vector /* { dg-error "multiple loop axes" } */
+void worker (void)
+{
+}
+
+#pragma acc routine vector seq /* { dg-error "multiple loop axes" } */
+void vector (void)
+{
+}
+
+#pragma acc routine seq gang /* { dg-error "multiple loop axes" } */
+void seq (void)
+{
+}
+
+#pragma acc routine (nothing) gang /* { dg-error "not been declared" } */
diff --git a/gcc/testsuite/c-c++-common/goacc/routine-3.c b/gcc/testsuite/c-c++-common/goacc/routine-3.c
new file mode 100644
index 0000000000..b322d26776
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/routine-3.c
@@ -0,0 +1,119 @@
+/* Test invalid calls to routines. */
+
+#pragma acc routine gang
+int
+gang () /* { dg-message "declared here" 3 } */
+{
+ #pragma acc loop gang worker vector
+ for (int i = 0; i < 10; i++)
+ {
+ }
+
+ return 1;
+}
+
+#pragma acc routine worker
+int
+worker () /* { dg-message "declared here" 2 } */
+{
+ #pragma acc loop worker vector
+ for (int i = 0; i < 10; i++)
+ {
+ }
+
+ return 1;
+}
+
+#pragma acc routine vector
+int
+vector () /* { dg-message "declared here" } */
+{
+ #pragma acc loop vector
+ for (int i = 0; i < 10; i++)
+ {
+ }
+
+ return 1;
+}
+
+#pragma acc routine seq
+int
+seq ()
+{
+ return 1;
+}
+
+int
+main ()
+{
+ int red = 0;
+#pragma acc parallel copy (red)
+ {
+ /* Independent/seq loop tests. */
+#pragma acc loop reduction (+:red) // { dg-warning "insufficient partitioning" }
+ for (int i = 0; i < 10; i++)
+ red += gang ();
+
+#pragma acc loop reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red += worker ();
+
+#pragma acc loop reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red += vector ();
+
+ /* Gang routine tests. */
+#pragma acc loop gang reduction (+:red) /* { dg-message "containing loop" } */
+ for (int i = 0; i < 10; i++)
+ red += gang (); // { dg-error "routine call uses same" }
+
+#pragma acc loop worker reduction (+:red) /* { dg-message "containing loop" } */
+ for (int i = 0; i < 10; i++)
+ red += gang (); // { dg-error "routine call uses same" }
+
+#pragma acc loop vector reduction (+:red) /* { dg-message "containing loop" } */
+ for (int i = 0; i < 10; i++)
+ red += gang (); // { dg-error "routine call uses same" }
+
+ /* Worker routine tests. */
+#pragma acc loop gang reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red += worker ();
+
+#pragma acc loop worker reduction (+:red) /* { dg-message "containing loop" } */
+ for (int i = 0; i < 10; i++)
+ red += worker (); // { dg-error "routine call uses same" }
+
+#pragma acc loop vector reduction (+:red) /* { dg-message "containing loop" } */
+ for (int i = 0; i < 10; i++)
+ red += worker (); // { dg-error "routine call uses same" }
+
+ /* Vector routine tests. */
+#pragma acc loop gang reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red += vector ();
+
+#pragma acc loop worker reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red += vector ();
+
+#pragma acc loop vector reduction (+:red) /* { dg-message "containing loop" } */
+ for (int i = 0; i < 10; i++)
+ red += vector (); // { dg-error "routine call uses same" }
+
+ /* Seq routine tests. */
+#pragma acc loop gang reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red += seq ();
+
+#pragma acc loop worker reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red += seq ();
+
+#pragma acc loop vector reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red += seq ();
+ }
+
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/routine-4.c b/gcc/testsuite/c-c++-common/goacc/routine-4.c
new file mode 100644
index 0000000000..3e5fc4f5d7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/routine-4.c
@@ -0,0 +1,114 @@
+/* Test invalid intra-routine parallelism. */
+
+void gang (void);
+void worker (void);
+void vector (void);
+
+#pragma acc routine (gang) gang
+#pragma acc routine (worker) worker
+#pragma acc routine (vector) vector
+
+#pragma acc routine seq
+void seq (void)
+{
+ gang (); /* { dg-error "routine call uses" } */
+ worker (); /* { dg-error "routine call uses" } */
+ vector (); /* { dg-error "routine call uses" } */
+ seq ();
+
+ int red;
+
+#pragma acc loop reduction (+:red) // { dg-warning "insufficient partitioning" }
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop gang reduction (+:red) // { dg-error "disallowed by containing routine" }
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop worker reduction (+:red) // { dg-error "disallowed by containing routine" }
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop vector reduction (+:red) // { dg-error "disallowed by containing routine" }
+ for (int i = 0; i < 10; i++)
+ red ++;
+}
+
+void vector (void) /* { dg-message "declared here" 1 } */
+{
+ gang (); /* { dg-error "routine call uses" } */
+ worker (); /* { dg-error "routine call uses" } */
+ vector ();
+ seq ();
+
+ int red;
+
+#pragma acc loop reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop gang reduction (+:red) // { dg-error "disallowed by containing routine" }
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop worker reduction (+:red) // { dg-error "disallowed by containing routine" }
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop vector reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red ++;
+}
+
+void worker (void) /* { dg-message "declared here" 2 } */
+{
+ gang (); /* { dg-error "routine call uses" } */
+ worker ();
+ vector ();
+ seq ();
+
+ int red;
+
+#pragma acc loop reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop gang reduction (+:red) // { dg-error "disallowed by containing routine" }
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop worker reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop vector reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red ++;
+}
+
+void gang (void) /* { dg-message "declared here" 3 } */
+{
+ gang ();
+ worker ();
+ vector ();
+ seq ();
+
+ int red;
+
+#pragma acc loop reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop gang reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop worker reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red ++;
+
+#pragma acc loop vector reduction (+:red)
+ for (int i = 0; i < 10; i++)
+ red ++;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/routine-5.c b/gcc/testsuite/c-c++-common/goacc/routine-5.c
new file mode 100644
index 0000000000..2a9db90dcb
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/routine-5.c
@@ -0,0 +1,156 @@
+/* { dg-do compile } */
+
+#pragma acc routine /* { dg-error "not followed by" } */
+int a;
+
+#pragma acc routine /* { dg-error "not followed by" } */
+void fn1 (void), fn1b (void);
+
+#pragma acc routine /* { dg-error "not followed by" } */
+int b, fn2 (void);
+
+#pragma acc routine /* { dg-error "not followed by" } */
+int fn3 (void), b2;
+
+#pragma acc routine /* { dg-error "not followed by" } */
+typedef struct c c;
+
+#pragma acc routine /* { dg-error "not followed by" } */
+struct d {} d;
+
+#pragma acc routine /* { dg-error "not followed by" } */
+#pragma acc routine
+int fn4 (void);
+
+int fn5a (void);
+
+#pragma acc routine /* { dg-error "not followed by" } */
+#pragma acc routine (fn5a)
+int fn5 (void);
+
+#ifdef __cplusplus
+
+#pragma acc routine /* { dg-error "not followed by" "" { target c++ } } */
+namespace f {}
+
+namespace g {}
+
+#pragma acc routine /* { dg-error "not followed by" "" { target c++ } } */
+using namespace g;
+
+#pragma acc routine (g) /* { dg-error "does not refer to" "" { target c++ } } */
+
+#endif
+
+#pragma acc routine (a) /* { dg-error "does not refer to" } */
+
+#pragma acc routine (c) /* { dg-error "does not refer to" } */
+
+
+void Bar ();
+
+void Foo ()
+{
+ Bar ();
+}
+
+#pragma acc routine (Bar) // { dg-error "must be applied before use" }
+
+#pragma acc routine (Foo) gang // { dg-error "must be applied before definition" }
+
+#pragma acc routine (Baz) // { dg-error "not been declared" }
+
+
+int vb1; /* { dg-error "directive for use" } */
+extern int vb2; /* { dg-error "directive for use" } */
+static int vb3; /* { dg-error "directive for use" } */
+
+#pragma acc routine
+int
+func1 (int a)
+{
+ vb1 = a + 1;
+ vb2 = vb1 + 1;
+ vb3 = vb2 + 1;
+
+ return vb3;
+}
+
+#pragma acc routine
+int
+func2 (int a)
+{
+ extern int vb4; /* { dg-error "directive for use" } */
+ static int vb5; /* { dg-error "directive for use" } */
+
+ vb4 = a + 1;
+ vb5 = vb4 + 1;
+
+ return vb5;
+}
+
+extern int vb6; /* { dg-error "clause used in" } */
+#pragma acc declare link (vb6)
+static int vb7; /* { dg-error "clause used in" } */
+#pragma acc declare link (vb7)
+
+#pragma acc routine
+int
+func3 (int a)
+{
+ vb6 = a + 1;
+ vb7 = vb6 + 1;
+
+ return vb7;
+}
+
+int vb8;
+#pragma acc declare create (vb8)
+extern int vb9;
+#pragma acc declare create (vb9)
+static int vb10;
+#pragma acc declare create (vb10)
+
+#pragma acc routine
+int
+func4 (int a)
+{
+ vb8 = a + 1;
+ vb9 = vb8 + 1;
+ vb10 = vb9 + 1;
+
+ return vb10;
+}
+
+int vb11;
+#pragma acc declare device_resident (vb11)
+extern int vb12;
+#pragma acc declare device_resident (vb12)
+extern int vb13;
+#pragma acc declare device_resident (vb13)
+
+#pragma acc routine
+int
+func5 (int a)
+{
+ vb11 = a + 1;
+ vb12 = vb11 + 1;
+ vb13 = vb12 + 1;
+
+ return vb13;
+}
+
+#pragma acc routine
+int
+func6 (int a)
+{
+ extern int vb14;
+#pragma acc declare create (vb14)
+ static int vb15;
+#pragma acc declare create (vb15)
+
+ vb14 = a + 1;
+ vb15 = vb14 + 1;
+
+ return vb15;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/sb-1.c b/gcc/testsuite/c-c++-common/goacc/sb-1.c
index 5e55c9516f..1ce41df0c0 100644
--- a/gcc/testsuite/c-c++-common/goacc/sb-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/sb-1.c
@@ -11,7 +11,7 @@ void foo()
goto bad1; // { dg-error "invalid branch to/from OpenACC structured block" }
#pragma acc data
goto bad1; // { dg-error "invalid branch to/from OpenACC structured block" }
- #pragma acc loop
+ #pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (l = 0; l < 2; ++l)
goto bad1; // { dg-error "invalid branch to/from OpenACC structured block" }
@@ -34,7 +34,7 @@ void foo()
}
goto bad2_loop; // { dg-error "invalid entry to OpenACC structured block" }
- #pragma acc loop
+ #pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (l = 0; l < 2; ++l)
{
bad2_loop: ;
@@ -64,7 +64,7 @@ void foo()
{ ok1_data: break; }
}
- #pragma acc loop
+ #pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for (l = 0; l < 2; ++l)
{
int i;
diff --git a/gcc/testsuite/c-c++-common/goacc/sb-3.c b/gcc/testsuite/c-c++-common/goacc/sb-3.c
index 147b7b0e84..620498ecd6 100644
--- a/gcc/testsuite/c-c++-common/goacc/sb-3.c
+++ b/gcc/testsuite/c-c++-common/goacc/sb-3.c
@@ -3,11 +3,11 @@
void f (void)
{
int i, j;
-#pragma acc loop
+#pragma acc loop /* { dg-error "loop directive must be associated with an OpenACC compute region" } */
for(i = 1; i < 30; i++)
{
if (i == 7) goto out; // { dg-error "invalid branch to/from OpenACC structured block" }
-#pragma acc loop // { dg-error "work-sharing region may not be closely nested inside of work-sharing, critical, ordered, master or explicit task region" }
+#pragma acc loop
for(j = 5; j < 10; j++)
{
if (i == 6 && j == 7) goto out; // { dg-error "invalid branch to/from OpenACC structured block" }
diff --git a/gcc/testsuite/c-c++-common/goacc/tile.c b/gcc/testsuite/c-c++-common/goacc/tile.c
new file mode 100644
index 0000000000..8e70e718e1
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/tile.c
@@ -0,0 +1,327 @@
+int
+main ()
+{
+ int i, *a, b;
+
+#pragma acc parallel loop tile (10)
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (*)
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (10, *)
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (10, *, i)
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile // { dg-error "expected '\\\('" }
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile () // { dg-error "" }
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (,1) // { dg-error "" }
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (,,) // { dg-error "" }
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (1.1) // { dg-error "'tile' value must be integral" }
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (-3) // { dg-warning "'tile' value must be positive" }
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (10,-3) // { dg-warning "'tile' value must be positive" }
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (-100,10,5) // { dg-warning "'tile' value must be positive" }
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (1,2.0,true) // { dg-error "" }
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (*a, 1)
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (1, *a, b)
+ for (i = 0; i < 100; i++)
+ ;
+
+#pragma acc parallel loop tile (b, 1, *a)
+ for (i = 0; i < 100; i++)
+ ;
+
+ return 0;
+}
+
+
+void par (void)
+{
+ int i, j;
+
+#pragma acc parallel
+ {
+#pragma acc loop tile // { dg-error "expected" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile() // { dg-error "expected" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile(1)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 1; j < 10; j++)
+ { }
+ }
+#pragma acc loop tile(-2) // { dg-warning "'tile' value must be positive" }
+ for (i = 1; i < 10; i++)
+ { }
+#pragma acc loop tile(i)
+ for (i = 1; i < 10; i++)
+ { }
+#pragma acc loop tile(2, 2, 1)
+ for (i = 1; i < 3; i++)
+ {
+ for (j = 4; j < 6; j++)
+ { }
+ }
+#pragma acc loop tile(2, 2)
+ for (i = 1; i < 5; i+=2)
+ {
+ for (j = i + 1; j < 7; j+=i)
+ { }
+ }
+#pragma acc loop vector tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector gang tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+ }
+}
+void p3 (void)
+{
+ int i, j;
+
+
+#pragma acc parallel loop tile // { dg-error "expected" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop tile() // { dg-error "expected" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop tile(1)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop tile(*, 1)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 1; j < 10; j++)
+ { }
+ }
+#pragma acc parallel loop tile(-2) // { dg-warning "'tile' value must be positive" }
+ for (i = 1; i < 10; i++)
+ { }
+#pragma acc parallel loop tile(i)
+ for (i = 1; i < 10; i++)
+ { }
+#pragma acc parallel loop tile(2, 2, 1)
+ for (i = 1; i < 3; i++)
+ {
+ for (j = 4; j < 6; j++)
+ { }
+ }
+#pragma acc parallel loop tile(2, 2)
+ for (i = 1; i < 5; i+=2)
+ {
+ for (j = i + 1; j < 7; j++)
+ { }
+ }
+#pragma acc parallel loop vector tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop gang tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop vector gang tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop vector worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc parallel loop gang worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+
+}
+
+
+void
+kern (void)
+{
+ int i, j;
+
+#pragma acc kernels
+ {
+#pragma acc loop tile // { dg-error "expected" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile() // { dg-error "expected" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile(1)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile(2)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile(6-2)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile(6+2)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile(*, 1)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; i++)
+ { }
+ }
+#pragma acc loop tile(-2) // { dg-warning "'tile' value must be positive" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile(i)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop tile(2, 2, 1)
+ for (i = 2; i < 4; i++)
+ for (i = 4; i < 6; i++)
+ { }
+#pragma acc loop tile(2, 2)
+ for (i = 1; i < 5; i+=2)
+ for (j = i+1; j < 7; i++)
+ { }
+#pragma acc loop vector tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector gang tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop vector worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc loop gang worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+ }
+}
+
+
+void k3 (void)
+{
+ int i, j;
+
+#pragma acc kernels loop tile // { dg-error "expected" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop tile() // { dg-error "expected" }
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop tile(1)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop tile(*, 1)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 1; j < 10; j++)
+ { }
+ }
+#pragma acc kernels loop tile(-2) // { dg-warning "'tile' value must be positive" }
+ for (i = 1; i < 10; i++)
+ { }
+#pragma acc kernels loop tile(i)
+ for (i = 1; i < 10; i++)
+ { }
+#pragma acc kernels loop tile(2, 2, 1)
+ for (i = 1; i < 3; i++)
+ {
+ for (j = 4; j < 6; j++)
+ { }
+ }
+#pragma acc kernels loop tile(2, 2)
+ for (i = 1; i < 5; i++)
+ {
+ for (j = i + 1; j < 7; j += i)
+ { }
+ }
+#pragma acc kernels loop vector tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop gang tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop vector gang tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop vector worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+#pragma acc kernels loop gang worker tile(*)
+ for (i = 0; i < 10; i++)
+ { }
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/uninit-copy-clause.c b/gcc/testsuite/c-c++-common/goacc/uninit-copy-clause.c
new file mode 100644
index 0000000000..b3cc445932
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/uninit-copy-clause.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Wuninitialized" } */
+
+void
+foo (void)
+{
+ int i;
+
+#pragma acc kernels
+ {
+ i = 1;
+ }
+
+}
+
+void
+foo2 (void)
+{
+ int i;
+
+#pragma acc kernels copy (i)
+ {
+ i = 1;
+ }
+
+}
+
+void
+foo3 (void)
+{
+ int i;
+
+#pragma acc kernels copyin(i)
+ {
+ i = 1;
+ }
+
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/uninit-dim-clause.c b/gcc/testsuite/c-c++-common/goacc/uninit-dim-clause.c
new file mode 100644
index 0000000000..0a006e370e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/uninit-dim-clause.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Wuninitialized" } */
+
+#include <stdbool.h>
+
+int
+main (void)
+{
+ int i, j, k;
+
+ #pragma acc parallel num_gangs(i) /* { dg-warning "is used uninitialized in this function" } */
+ ;
+
+ #pragma acc parallel num_workers(j) /* { dg-warning "is used uninitialized in this function" } */
+ ;
+
+ #pragma acc parallel vector_length(k) /* { dg-warning "is used uninitialized in this function" } */
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/uninit-firstprivate-clause.c b/gcc/testsuite/c-c++-common/goacc/uninit-firstprivate-clause.c
new file mode 100644
index 0000000000..2584033a8c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/uninit-firstprivate-clause.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Wuninitialized" } */
+
+void
+foo (void)
+{
+ int i;
+
+#pragma acc parallel
+ {
+ i = 1;
+ }
+}
+
+
+void
+foo2 (void)
+{
+ int i;
+
+#pragma acc parallel firstprivate (i) /* { dg-warning "is used uninitialized in this function" } */
+ {
+ i = 1;
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/uninit-if-clause.c b/gcc/testsuite/c-c++-common/goacc/uninit-if-clause.c
new file mode 100644
index 0000000000..55caa4c2c7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/uninit-if-clause.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Wuninitialized" } */
+/* { dg-excess-errors "PR70392" { xfail c++ } } */
+
+#include <stdbool.h>
+
+int
+main (void)
+{
+ int l, l2, l3, l4;
+ bool b, b2, b3, b4;
+ int i, i2;
+
+ #pragma acc parallel if(l) /* { dg-warning "is used uninitialized in this function" } */
+ ;
+
+ #pragma acc parallel if(b) /* { dg-warning "is used uninitialized in this function" "" { xfail c++ } } */
+ ;
+
+ #pragma acc kernels if(l2) /* { dg-warning "is used uninitialized in this function" } */
+ ;
+
+ #pragma acc kernels if(b2) /* { dg-warning "is used uninitialized in this function" "" { xfail c++ } } */
+ ;
+
+ #pragma acc data if(l3) /* { dg-warning "is used uninitialized in this function" } */
+ ;
+
+ #pragma acc data if(b3) /* { dg-warning "is used uninitialized in this function" "" { xfail c++ } } */
+ ;
+
+ #pragma acc update if(l4) self(i) /* { dg-warning "is used uninitialized in this function" } */
+ ;
+
+ #pragma acc update if(b4) self(i2) /* { dg-warning "is used uninitialized in this function" "" { xfail c++ } } */
+ ;
+
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/uninit-use-device-clause.c b/gcc/testsuite/c-c++-common/goacc/uninit-use-device-clause.c
new file mode 100644
index 0000000000..c5d327caf8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/uninit-use-device-clause.c
@@ -0,0 +1,14 @@
+/* Test fails due to PR70388. */
+/* { dg-do compile } */
+/* { dg-excess-errors "PR70388" { xfail *-*-* } } */
+/* { dg-additional-options "-Wuninitialized" } */
+
+void
+foo (void)
+{
+ int i;
+
+#pragma acc host_data use_device(i) /* { dg-warning "is used uninitialized in this function" "" { xfail *-*-* } } */
+ {
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/goacc/update-1.c b/gcc/testsuite/c-c++-common/goacc/update-1.c
index 97e9379493..701ef36364 100644
--- a/gcc/testsuite/c-c++-common/goacc/update-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/update-1.c
@@ -1,7 +1,7 @@
void
f (void)
{
-#pragma acc update /* { dg-error "'#pragma acc update' must contain at least one 'device' or 'host/self' clause" } */
+#pragma acc update /* { dg-error "'#pragma acc update' must contain at least one 'device' or 'host' or 'self' clause" } */
int i = 0;
int a[10];
diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c
new file mode 100644
index 0000000000..4420d670bd
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c
@@ -0,0 +1,338 @@
+/* PR c/70436 */
+/* { dg-additional-options "-Wparentheses" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+
+void
+f1 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ while (1)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp for
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskloop
+ for (i = 0; i < 10; i++)
+ if (b)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+ else
+ bar ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskloop simd
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp critical
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for simd schedule(runtime)
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp master
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp single
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp task
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskgroup
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp taskloop
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp critical
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for simd schedule(dynamic, 5)
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp master
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp single
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp task
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp taskgroup
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp taskloop simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
+
+void
+f2 (int d, int e, int f)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp ordered
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (d) /* { dg-warning "ambiguous" } */
+ #pragma omp ordered threads
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (e)
+ #pragma omp ordered
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (f)
+ #pragma omp ordered threads
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c
new file mode 100644
index 0000000000..4341b22323
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c
@@ -0,0 +1,452 @@
+/* PR c/70436 */
+/* { dg-additional-options "-Wparentheses" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+void f1 (void);
+#pragma omp declare target to (bar, baz, f1, a, b, c)
+
+void
+f1 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+}
+
+void
+f2 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp target teams distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp target teams distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp target teams distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp target teams distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp target
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target parallel
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ { {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ } }
+
+ if (a)
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ { {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ }
+ }
+ else
+ baz ();
+}
+
+void
+f3 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp target
+ #pragma omp teams distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp target
+ #pragma omp teams distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp target
+ #pragma omp teams distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
+
+void
+f4 (void)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target data map (tofrom: b)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target data map (tofrom: b)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c
new file mode 100644
index 0000000000..1688d1062d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c
@@ -0,0 +1,338 @@
+/* PR c/70436 */
+/* { dg-additional-options "-Wparentheses -fno-openmp" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+
+void
+f1 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ while (1)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp for
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskloop
+ for (i = 0; i < 10; i++)
+ if (b)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+ else
+ bar ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskloop simd
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp critical
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp for simd schedule(runtime)
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp master
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp single
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp task
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp taskgroup
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp taskloop
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp critical
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp for simd schedule(dynamic, 5)
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp master
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp single
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp task
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp taskgroup
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp taskloop simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
+
+void
+f2 (int d, int e, int f)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp ordered
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (d) /* { dg-warning "ambiguous" } */
+ #pragma omp ordered threads
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (e)
+ #pragma omp ordered
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (f)
+ #pragma omp ordered threads
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c
new file mode 100644
index 0000000000..d44cdcd575
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c
@@ -0,0 +1,452 @@
+/* PR c/70436 */
+/* { dg-additional-options "-Wparentheses -fno-openmp" } */
+
+int a, b, c;
+void bar (void);
+void baz (void);
+void f1 (void);
+#pragma omp declare target to (bar, baz, f1, a, b, c)
+
+void
+f1 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+}
+
+void
+f2 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp target teams distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target teams
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp target teams distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp target teams distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp target teams distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target teams
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp target
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target parallel
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ #pragma omp target simd
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ { {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ } }
+
+ if (a)
+ #pragma omp target simd collapse(2)
+ for (i = 0; i < 10; i++)
+ { {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ }
+ }
+ else
+ baz ();
+}
+
+void
+f3 (void)
+{
+ int i, j;
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams distribute
+ for (i = 0; i < 10; i++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ for (i = 0; i < 10; i++)
+ #pragma omp target
+ #pragma omp teams distribute simd
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute parallel for
+ for (i = 0; i < 10; i++)
+ if (b) /* { dg-warning "ambiguous" } */
+ #pragma omp parallel for
+ for (j = 0; j < 10; j++)
+ if (c)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams distribute parallel for simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp parallel
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute
+ for (i = 0; i < 10; i++)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ {
+ #pragma omp target
+ #pragma omp teams distribute simd
+ for (i = 0; i < 10; ++i)
+ if (b)
+ bar ();
+ }
+ else baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams distribute parallel for collapse(2)
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 10; j++)
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+
+ if (a)
+ for (i = 0; i < 10; i++)
+ #pragma omp target
+ #pragma omp teams distribute parallel for simd
+ for (j = 0; j < 10; j++)
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams
+ {
+ if (b)
+ bar ();
+ }
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp parallel
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
+
+void
+f4 (void)
+{
+ if (a) /* { dg-warning "ambiguous" } */
+ #pragma omp target data map (tofrom: b)
+ if (b)
+ bar ();
+ else
+ baz ();
+
+ if (a)
+ #pragma omp target data map (tofrom: b)
+ {
+ if (b)
+ bar ();
+ else
+ baz ();
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/atomic-10.c b/gcc/testsuite/c-c++-common/gomp/atomic-10.c
index 21d035e15c..6a2542e426 100644
--- a/gcc/testsuite/c-c++-common/gomp/atomic-10.c
+++ b/gcc/testsuite/c-c++-common/gomp/atomic-10.c
@@ -22,4 +22,3 @@ foo (void)
}
/* { dg-final { scan-tree-dump-times "__atomic_fetch_add" 4 "ompexp" } } */
-/* { dg-final { cleanup-tree-dump "ompexp" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/atomic-12.c b/gcc/testsuite/c-c++-common/gomp/atomic-12.c
index 618c4c8e64..145e420164 100644
--- a/gcc/testsuite/c-c++-common/gomp/atomic-12.c
+++ b/gcc/testsuite/c-c++-common/gomp/atomic-12.c
@@ -4,7 +4,6 @@
/* atomicvar should never be referenced in between the barrier and
following #pragma omp atomic_load. */
/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */
-/* { dg-final { cleanup-tree-dump "gimple" } } */
#ifdef __cplusplus
bool atomicvar, c;
diff --git a/gcc/testsuite/c-c++-common/gomp/atomic-13.c b/gcc/testsuite/c-c++-common/gomp/atomic-13.c
index 0146825f2b..2452035da5 100644
--- a/gcc/testsuite/c-c++-common/gomp/atomic-13.c
+++ b/gcc/testsuite/c-c++-common/gomp/atomic-13.c
@@ -4,6 +4,5 @@
/* atomicvar should never be referenced in between the barrier and
following #pragma omp atomic_load. */
/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */
-/* { dg-final { cleanup-tree-dump "gimple" } } */
#include "atomic-12.c"
diff --git a/gcc/testsuite/c-c++-common/gomp/atomic-3.c b/gcc/testsuite/c-c++-common/gomp/atomic-3.c
index 5b9e60cde8..37fff732ea 100644
--- a/gcc/testsuite/c-c++-common/gomp/atomic-3.c
+++ b/gcc/testsuite/c-c++-common/gomp/atomic-3.c
@@ -11,4 +11,3 @@ void f1(void)
}
/* { dg-final { scan-tree-dump-times "xyzzy, 4" 1 "ompexp" } } */
-/* { dg-final { cleanup-tree-dump "ompexp" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/atomic-9.c b/gcc/testsuite/c-c++-common/gomp/atomic-9.c
index ff5cb4091f..c07da8fc71 100644
--- a/gcc/testsuite/c-c++-common/gomp/atomic-9.c
+++ b/gcc/testsuite/c-c++-common/gomp/atomic-9.c
@@ -11,4 +11,3 @@ void f1(void)
}
/* { dg-final { scan-tree-dump-times "__atomic_fetch_add" 1 "ompexp" } } */
-/* { dg-final { cleanup-tree-dump "ompexp" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/cancel-1.c b/gcc/testsuite/c-c++-common/gomp/cancel-1.c
index d8f7bc1b8f..896a76858b 100644
--- a/gcc/testsuite/c-c++-common/gomp/cancel-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/cancel-1.c
@@ -17,7 +17,7 @@ f1 (void)
void
f2 (void)
{
- int i;
+ int i, j = 0;
#pragma omp parallel
{
#pragma omp cancel parallel
@@ -77,12 +77,73 @@ f2 (void)
#pragma omp cancel parallel /* { dg-error "not closely nested inside" } */
#pragma omp cancel for /* { dg-error "not closely nested inside" } */
#pragma omp cancel sections /* { dg-error "not closely nested inside" } */
+ #pragma omp cancel taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */
+ #pragma omp cancellation point parallel /* { dg-error "not closely nested inside" } */
+ #pragma omp cancellation point for /* { dg-error "not closely nested inside" } */
+ #pragma omp cancellation point sections /* { dg-error "not closely nested inside" } */
+ #pragma omp cancellation point taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */
+ }
+ #pragma omp taskgroup
+ #pragma omp task
+ {
+ #pragma omp cancel parallel /* { dg-error "not closely nested inside" } */
+ #pragma omp cancel for /* { dg-error "not closely nested inside" } */
+ #pragma omp cancel sections /* { dg-error "not closely nested inside" } */
#pragma omp cancel taskgroup
#pragma omp cancellation point parallel /* { dg-error "not closely nested inside" } */
#pragma omp cancellation point for /* { dg-error "not closely nested inside" } */
#pragma omp cancellation point sections /* { dg-error "not closely nested inside" } */
#pragma omp cancellation point taskgroup
}
+ #pragma omp taskgroup
+ {
+ #pragma omp task
+ {
+ #pragma omp task
+ {
+ #pragma omp cancellation point taskgroup
+ #pragma omp cancel taskgroup
+ }
+ }
+ }
+ #pragma omp taskgroup
+ {
+ #pragma omp parallel
+ {
+ #pragma omp task
+ {
+ #pragma omp cancel taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */
+ #pragma omp cancellation point taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */
+ }
+ }
+ #pragma omp target
+ {
+ #pragma omp task
+ {
+ #pragma omp cancel taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */
+ #pragma omp cancellation point taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */
+ }
+ }
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute
+ for (i = 0; i < 10; i++)
+ {
+ #pragma omp task
+ {
+ #pragma omp cancel taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */
+ #pragma omp cancellation point taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */
+ }
+ }
+ #pragma omp target data map(i)
+ {
+ #pragma omp task
+ {
+ #pragma omp cancel taskgroup
+ #pragma omp cancellation point taskgroup
+ }
+ }
+ }
#pragma omp for
for (i = 0; i < 10; i++)
{
@@ -132,7 +193,7 @@ f2 (void)
#pragma omp cancellation point taskgroup/* { dg-error "not closely nested inside" } */
}
}
- #pragma omp target data
+ #pragma omp target data map(j)
{
#pragma omp cancel parallel /* { dg-error "not closely nested inside" } */
#pragma omp cancel for /* { dg-error "not closely nested inside" } */
@@ -155,7 +216,7 @@ f2 (void)
#pragma omp cancellation point taskgroup /* { dg-error "not closely nested inside" } */
}
}
- #pragma omp target data
+ #pragma omp target data map(j)
{
#pragma omp cancel parallel /* { dg-error "not closely nested inside" } */
#pragma omp cancel for /* { dg-error "not closely nested inside" } */
@@ -179,14 +240,14 @@ f2 (void)
}
#pragma omp target teams
{
- #pragma omp cancel parallel /* { dg-error "only distribute or parallel constructs are allowed to be closely nested" } */
- #pragma omp cancel for /* { dg-error "only distribute or parallel constructs are allowed to be closely nested" } */
- #pragma omp cancel sections /* { dg-error "only distribute or parallel constructs are allowed to be closely nested" } */
- #pragma omp cancel taskgroup /* { dg-error "only distribute or parallel constructs are allowed to be closely nested" } */
- #pragma omp cancellation point parallel /* { dg-error "only distribute or parallel constructs are allowed to be closely nested" } */
- #pragma omp cancellation point for /* { dg-error "only distribute or parallel constructs are allowed to be closely nested" } */
- #pragma omp cancellation point sections /* { dg-error "only distribute or parallel constructs are allowed to be closely nested" } */
- #pragma omp cancellation point taskgroup /* { dg-error "only distribute or parallel constructs are allowed to be closely nested" } */
+ #pragma omp cancel parallel /* { dg-error "only .distribute. or .parallel. regions are allowed to be strictly nested" } */
+ #pragma omp cancel for /* { dg-error "only .distribute. or .parallel. regions are allowed to be strictly nested" } */
+ #pragma omp cancel sections /* { dg-error "only .distribute. or .parallel. regions are allowed to be strictly nested" } */
+ #pragma omp cancel taskgroup /* { dg-error "only .distribute. or .parallel. regions are allowed to be strictly nested" } */
+ #pragma omp cancellation point parallel /* { dg-error "only .distribute. or .parallel. regions are allowed to be strictly nested" } */
+ #pragma omp cancellation point for /* { dg-error "only .distribute. or .parallel. regions are allowed to be strictly nested" } */
+ #pragma omp cancellation point sections /* { dg-error "only .distribute. or .parallel. regions are allowed to be strictly nested" } */
+ #pragma omp cancellation point taskgroup /* { dg-error "only .distribute. or .parallel. regions are allowed to be strictly nested" } */
}
#pragma omp target teams distribute
for (i = 0; i < 10; i++)
@@ -214,7 +275,7 @@ f2 (void)
}
#pragma omp for
for (i = 0; i < 10; i++)
- #pragma omp target data
+ #pragma omp target data map(j)
{
#pragma omp cancel parallel /* { dg-error "not closely nested inside" } */
#pragma omp cancel for /* { dg-error "not closely nested inside" } */
@@ -241,7 +302,7 @@ f2 (void)
#pragma omp for ordered
for (i = 0; i < 10; i++)
#pragma omp ordered
- #pragma omp target data
+ #pragma omp target data map(j)
{
#pragma omp cancel parallel /* { dg-error "not closely nested inside" } */
#pragma omp cancel for /* { dg-error "not closely nested inside" } */
@@ -292,7 +353,7 @@ f2 (void)
}
#pragma omp sections
{
- #pragma omp target data
+ #pragma omp target data map(j)
{
#pragma omp cancel parallel /* { dg-error "not closely nested inside" } */
#pragma omp cancel for /* { dg-error "not closely nested inside" } */
@@ -304,7 +365,7 @@ f2 (void)
#pragma omp cancellation point taskgroup /* { dg-error "not closely nested inside" } */
}
#pragma omp section
- #pragma omp target data
+ #pragma omp target data map(j)
{
#pragma omp cancel parallel /* { dg-error "not closely nested inside" } */
#pragma omp cancel for /* { dg-error "not closely nested inside" } */
diff --git a/gcc/testsuite/c-c++-common/gomp/clauses-1.c b/gcc/testsuite/c-c++-common/gomp/clauses-1.c
new file mode 100644
index 0000000000..91aed3960f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/clauses-1.c
@@ -0,0 +1,161 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-std=c99" { target c } } */
+
+int t;
+#pragma omp threadprivate (t)
+
+#pragma omp declare target
+int f, l, ll, r;
+
+void
+foo (int d, int m, int i1, int i2, int p, int *idp, int s,
+ int nte, int tl, int nth, int g, int nta, int fi, int pp, int *q)
+{
+ #pragma omp distribute parallel for \
+ private (p) firstprivate (f) collapse(1) dist_schedule(static, 16) \
+ if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) \
+ lastprivate (l) schedule(static, 4)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp distribute parallel for simd \
+ private (p) firstprivate (f) collapse(1) dist_schedule(static, 16) \
+ if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) \
+ lastprivate (l) schedule(static, 4) \
+ safelen(8) simdlen(4) aligned(q: 32)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp distribute simd \
+ private (p) firstprivate (f) collapse(1) dist_schedule(static, 16) \
+ safelen(8) simdlen(4) aligned(q: 32) reduction(+:r)
+ for (int i = 0; i < 64; i++)
+ ll++;
+}
+#pragma omp end declare target
+
+void
+bar (int d, int m, int i1, int i2, int p, int *idp, int s,
+ int nte, int tl, int nth, int g, int nta, int fi, int pp, int *q)
+{
+ #pragma omp for simd \
+ private (p) firstprivate (f) lastprivate (l) linear (ll:1) reduction(+:r) schedule(static, 4) collapse(1) nowait \
+ safelen(8) simdlen(4) aligned(q: 32)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp parallel for \
+ private (p) firstprivate (f) if (parallel: i2) default(shared) shared(s) copyin(t) reduction(+:r) num_threads (nth) proc_bind(spread) \
+ lastprivate (l) linear (ll:1) ordered schedule(static, 4) collapse(1)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp parallel for simd \
+ private (p) firstprivate (f) if (parallel: i2) default(shared) shared(s) copyin(t) reduction(+:r) num_threads (nth) proc_bind(spread) \
+ lastprivate (l) linear (ll:1) schedule(static, 4) collapse(1) \
+ safelen(8) simdlen(4) aligned(q: 32)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp parallel sections \
+ private (p) firstprivate (f) if (parallel: i2) default(shared) shared(s) copyin(t) reduction(+:r) num_threads (nth) proc_bind(spread) \
+ lastprivate (l)
+ {
+ #pragma omp section
+ {}
+ #pragma omp section
+ {}
+ }
+ #pragma omp target parallel \
+ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \
+ if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread)
+ ;
+ #pragma omp target parallel for \
+ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \
+ if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) \
+ lastprivate (l) linear (ll:1) ordered schedule(static, 4) collapse(1)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp target parallel for simd \
+ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \
+ if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) \
+ lastprivate (l) linear (ll:1) schedule(static, 4) collapse(1) \
+ safelen(8) simdlen(4) aligned(q: 32)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp target teams \
+ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \
+ shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl)
+ ;
+ #pragma omp target teams distribute \
+ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \
+ shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \
+ collapse(1) dist_schedule(static, 16)
+ for (int i = 0; i < 64; i++)
+ ;
+ #pragma omp target teams distribute parallel for \
+ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \
+ shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \
+ collapse(1) dist_schedule(static, 16) \
+ if (parallel: i2) num_threads (nth) proc_bind(spread) \
+ lastprivate (l) schedule(static, 4)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp target teams distribute parallel for simd \
+ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \
+ shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \
+ collapse(1) dist_schedule(static, 16) \
+ if (parallel: i2) num_threads (nth) proc_bind(spread) \
+ lastprivate (l) schedule(static, 4) \
+ safelen(8) simdlen(4) aligned(q: 32)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp target teams distribute simd \
+ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \
+ shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \
+ collapse(1) dist_schedule(static, 16) \
+ safelen(8) simdlen(4) aligned(q: 32)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp target simd \
+ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \
+ safelen(8) simdlen(4) lastprivate (l) linear(ll: 1) aligned(q: 32) reduction(+:r)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp taskloop simd \
+ private (p) firstprivate (f) lastprivate (l) shared (s) default(shared) grainsize (g) collapse(1) untied if(taskloop: i1) final(fi) mergeable nogroup priority (pp) \
+ safelen(8) simdlen(4) linear(ll: 1) aligned(q: 32) reduction(+:r)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp taskwait
+ #pragma omp taskloop simd \
+ private (p) firstprivate (f) lastprivate (l) shared (s) default(shared) num_tasks (nta) collapse(1) if(taskloop: i1) final(fi) priority (pp) \
+ safelen(8) simdlen(4) linear(ll: 1) aligned(q: 32) reduction(+:r)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp target
+ #pragma omp teams distribute \
+ private(p) firstprivate (f) shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \
+ collapse(1) dist_schedule(static, 16)
+ for (int i = 0; i < 64; i++)
+ ;
+ #pragma omp target
+ #pragma omp teams distribute parallel for \
+ private(p) firstprivate (f) shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \
+ collapse(1) dist_schedule(static, 16) \
+ if (parallel: i2) num_threads (nth) proc_bind(spread) \
+ lastprivate (l) schedule(static, 4)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp target
+ #pragma omp teams distribute parallel for simd \
+ private(p) firstprivate (f) shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \
+ collapse(1) dist_schedule(static, 16) \
+ if (parallel: i2) num_threads (nth) proc_bind(spread) \
+ lastprivate (l) schedule(static, 4) \
+ safelen(8) simdlen(4) aligned(q: 32)
+ for (int i = 0; i < 64; i++)
+ ll++;
+ #pragma omp target
+ #pragma omp teams distribute simd \
+ private(p) firstprivate (f) shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \
+ collapse(1) dist_schedule(static, 16) \
+ safelen(8) simdlen(4) aligned(q: 32)
+ for (int i = 0; i < 64; i++)
+ ll++;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/clauses-2.c b/gcc/testsuite/c-c++-common/gomp/clauses-2.c
new file mode 100644
index 0000000000..dff8bfebad
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/clauses-2.c
@@ -0,0 +1,53 @@
+struct S { int r; int *s; int t[10]; };
+void bar (int *);
+
+void
+foo (int *p, int q, struct S t, int i, int j, int k, int l)
+{
+ #pragma omp target map (q), firstprivate (q) /* { dg-error "appears both in data and map clauses" } */
+ bar (&q);
+ #pragma omp target map (p[0]) firstprivate (p) /* { dg-error "appears more than once in data clauses" } */
+ bar (p);
+ #pragma omp target firstprivate (p), map (p[0]) /* { dg-error "appears more than once in data clauses" } */
+ bar (p);
+ #pragma omp target map (p[0]) map (p) /* { dg-error "appears both in data and map clauses" } */
+ bar (p);
+ #pragma omp target map (p) , map (p[0]) /* { dg-error "appears both in data and map clauses" } */
+ bar (p);
+ #pragma omp target map (q) map (q) /* { dg-error "appears more than once in map clauses" } */
+ bar (&q);
+ #pragma omp target map (p[0]) map (p[0]) /* { dg-error "appears more than once in data clauses" } */
+ bar (p);
+ #pragma omp target map (t) map (t.r) /* { dg-error "appears more than once in map clauses" } */
+ bar (&t.r);
+ #pragma omp target map (t.r) map (t) /* { dg-error "appears more than once in map clauses" } */
+ bar (&t.r);
+ #pragma omp target map (t.r) map (t.r) /* { dg-error "appears more than once in map clauses" } */
+ bar (&t.r);
+ #pragma omp target firstprivate (t), map (t.r) /* { dg-error "appears both in data and map clauses" } */
+ bar (&t.r);
+ #pragma omp target map (t.r) firstprivate (t) /* { dg-error "appears both in data and map clauses" } */
+ bar (&t.r);
+ #pragma omp target map (t.s[0]) map (t) /* { dg-error "appears more than once in map clauses" } */
+ bar (t.s);
+ #pragma omp target map (t) map(t.s[0]) /* { dg-error "appears more than once in map clauses" } */
+ bar (t.s);
+ #pragma omp target firstprivate (t) map (t.s[0]) /* { dg-error "appears both in data and map clauses" } */
+ bar (t.s);
+ #pragma omp target map (t.s[0]) firstprivate (t) /* { dg-error "appears both in data and map clauses" } */
+ bar (t.s);
+ #pragma omp target map (t.s[0]) map (t.s[2]) /* { dg-error "appears more than once in map clauses" } */
+ bar (t.s);
+ #pragma omp target map (t.t[0:2]) map (t.t[4:6]) /* { dg-error "appears more than once in map clauses" } */
+ bar (t.t);
+ #pragma omp target map (t.t[i:j]) map (t.t[k:l]) /* { dg-error "appears more than once in map clauses" } */
+ bar (t.t);
+ #pragma omp target map (t.s[0]) map (t.r)
+ bar (t.s);
+ #pragma omp target map (t.r) ,map (t.s[0])
+ bar (t.s);
+ #pragma omp target map (t.r) map (t) map (t.s[0]) firstprivate (t) /* { dg-error "appears both in data and map clauses" } */
+ bar (t.s);
+ #pragma omp target map (t) map (t.r) firstprivate (t) map (t.s[0]) /* { dg-error "appears both in data and map clauses" } */
+ bar (t.s); /* { dg-error "appears more than once in map clauses" "" { target *-*-* } 51 } */
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/clauses-3.c b/gcc/testsuite/c-c++-common/gomp/clauses-3.c
new file mode 100644
index 0000000000..7e07a81c31
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/clauses-3.c
@@ -0,0 +1,23 @@
+struct T { int a; int *b; };
+struct S { int *s; char u; struct T v; long x; };
+
+void bar (int *);
+#pragma omp declare target to (bar)
+
+int
+main ()
+{
+ int a[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ struct S s = { a, 5, { 6, a + 5 }, 99L };
+ #pragma omp target map (s.v.a, s.u, s.x)
+ ;
+ #pragma omp target map (s.v.a, s.u, s.x)
+ bar (&s.v.a);
+ #pragma omp target map (s.v.a) map (always, to: s.u) map (s.x)
+ ;
+ #pragma omp target map (s.s[0]) map (s.v.b[:3])
+ ;
+ #pragma omp target map (s.s[0]) map (s.v.b[:3])
+ bar (s.s);
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/clauses-4.c b/gcc/testsuite/c-c++-common/gomp/clauses-4.c
new file mode 100644
index 0000000000..11e7634e14
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/clauses-4.c
@@ -0,0 +1,118 @@
+int t;
+#pragma omp threadprivate (t)
+
+void
+foo (int y, short z)
+{
+ int x;
+ #pragma omp target teams map (from: x)
+ #pragma omp distribute simd linear (x : 2)
+ for (x = 0; x < 64; x += 2)
+ ;
+ #pragma omp target teams map (from: x)
+ #pragma omp distribute parallel for simd linear (x)
+ for (x = 0; x < 64; x++)
+ ;
+ #pragma omp target teams map (tofrom: y)
+ #pragma omp distribute simd linear (y : 2) /* { dg-error ".linear. clause for variable other than loop iterator specified on construct combined with .distribute." } */
+ for (x = 0; x < 64; x += 2)
+ y += 2;
+ #pragma omp target teams map (tofrom: z)
+ #pragma omp distribute parallel for simd linear (z) /* { dg-error ".linear. clause for variable other than loop iterator specified on construct combined with .distribute." } */
+ for (x = 0; x < 64; x++)
+ z++;
+ #pragma omp target teams map (tofrom: z)
+ #pragma omp distribute parallel for linear (z: 4) /* { dg-error ".linear. is not valid for .#pragma omp distribute parallel for." } */
+ for (x = 0; x < 64; x++)
+ z += 4;
+ #pragma omp target map (from: x)
+ #pragma omp teams distribute simd linear (x : 2)
+ for (x = 0; x < 64; x += 2)
+ ;
+ #pragma omp target map (from: x)
+ #pragma omp teams distribute parallel for simd linear (x)
+ for (x = 0; x < 64; x++)
+ ;
+ #pragma omp target map (tofrom: y)
+ #pragma omp teams distribute simd linear (y : 2) /* { dg-error ".linear. clause for variable other than loop iterator specified on construct combined with .distribute." } */
+ for (x = 0; x < 64; x += 2)
+ y += 2;
+ #pragma omp target map (tofrom: z)
+ #pragma omp teams distribute parallel for simd linear (z) /* { dg-error ".linear. clause for variable other than loop iterator specified on construct combined with .distribute." } */
+ for (x = 0; x < 64; x++)
+ z++;
+ #pragma omp target map (tofrom: z)
+ #pragma omp teams distribute parallel for linear (z: 4) /* { dg-error ".linear. is not valid for .#pragma omp teams distribute parallel for." } */
+ for (x = 0; x < 64; x++)
+ z += 4;
+ #pragma omp target parallel copyin (t) /* { dg-error ".copyin. is not valid for .#pragma omp target parallel." } */
+ ;
+ #pragma omp target parallel for copyin (t) /* { dg-error ".copyin. is not valid for .#pragma omp target parallel for." } */
+ for (x = 0; x < 64; x++)
+ ;
+ #pragma omp target parallel for simd copyin (t) /* { dg-error ".copyin. is not valid for .#pragma omp target parallel for simd." } */
+ for (x = 0; x < 64; x++)
+ ;
+ #pragma omp target teams
+ #pragma omp distribute parallel for ordered /* { dg-error ".ordered. is not valid for .#pragma omp distribute parallel for." } */
+ for (x = 0; x < 64; x++)
+ {
+ #pragma omp ordered /* { dg-error ".ordered. region must be closely nested inside a loop region with an .ordered. clause" } */
+ ;
+ }
+ #pragma omp target teams
+ #pragma omp distribute parallel for simd ordered /* { dg-error ".ordered. is not valid for .#pragma omp distribute parallel for simd." } */
+ for (x = 0; x < 64; x++)
+ {
+ #pragma omp ordered simd, threads
+ ;
+ }
+ #pragma omp target
+ #pragma omp teams distribute parallel for ordered /* { dg-error ".ordered. is not valid for .#pragma omp teams distribute parallel for." } */
+ for (x = 0; x < 64; x++)
+ {
+ #pragma omp ordered /* { dg-error ".ordered. region must be closely nested inside a loop region with an .ordered. clause" } */
+ ;
+ }
+ #pragma omp target
+ #pragma omp teams distribute parallel for simd ordered /* { dg-error ".ordered. is not valid for .#pragma omp teams distribute parallel for simd." } */
+ for (x = 0; x < 64; x++)
+ {
+ #pragma omp ordered simd, threads
+ ;
+ }
+ #pragma omp target teams distribute parallel for ordered /* { dg-error ".ordered. is not valid for .#pragma omp target teams distribute parallel for." } */
+ for (x = 0; x < 64; x++)
+ {
+ #pragma omp ordered /* { dg-error ".ordered. region must be closely nested inside a loop region with an .ordered. clause" } */
+ ;
+ }
+ #pragma omp target teams distribute parallel for simd ordered /* { dg-error ".ordered. is not valid for .#pragma omp target teams distribute parallel for simd." } */
+ for (x = 0; x < 64; x++)
+ {
+ #pragma omp ordered simd, threads
+ ;
+ }
+ #pragma omp simd
+ for (x = 0; x < 64; x++)
+ {
+ #pragma omp ordered threads simd /* { dg-error ".ordered simd threads. must be closely nested inside of .for simd. region" } */
+ ;
+ }
+ #pragma omp for
+ for (x = 0; x < 64; x++)
+ {
+ #pragma omp simd
+ for (y = 0; y < 16; y++)
+ {
+ #pragma omp ordered simd threads /* { dg-error ".ordered simd threads. must be closely nested inside of .for simd. region" } */
+ ;
+ }
+ }
+ #pragma omp for simd
+ for (x = 0; x < 64; x++)
+ {
+ #pragma omp ordered threads simd
+ ;
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-target-1.c b/gcc/testsuite/c-c++-common/gomp/declare-target-1.c
new file mode 100644
index 0000000000..a1f1ea717b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-target-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+int foo (void), bar (void);
+extern int a;
+int b;
+char d;
+#pragma omp declare target
+long c;
+#pragma omp end declare target
+
+#pragma omp declare target (bar, a)
+#pragma omp declare target to (b) link (d) to (foo)
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-target-2.c b/gcc/testsuite/c-c++-common/gomp/declare-target-2.c
new file mode 100644
index 0000000000..1135a1d00b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-target-2.c
@@ -0,0 +1,45 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+extern int a;
+#pragma omp declare target
+#pragma omp declare target to (a) /* { dg-error "with clauses in between" } */
+#pragma omp end declare target
+int b;
+#pragma omp declare target to (b) link (b) /* { dg-error "appears more than once on the same .declare target. directive" } */
+int c;
+#pragma omp declare target (c)
+#pragma omp declare target link (c) /* { dg-error "specified both in declare target" } */
+int foo (void);
+#pragma omp declare target link (foo) /* { dg-error "is not a variable in clause" } */
+struct S;
+extern struct S d[]; /* { dg-error "array type has incomplete element type" "" { target c } } */
+#pragma omp declare target to (d) /* { dg-error "does not have a mappable type in" } */
+extern struct S e;
+#pragma omp declare target link (e) /* { dg-error "does not have a mappable type in" } */
+extern int f[];
+#pragma omp declare target to (f) /* { dg-error "does not have a mappable type in" } */
+int g, h;
+#pragma omp threadprivate (g, h)
+#pragma omp declare target to (g) /* { dg-error "is threadprivate variable in" } */
+#pragma omp declare target link (h) /* { dg-error "is threadprivate variable in" } */
+int j[10];
+#pragma omp declare target to (j[0:4]) /* { dg-error "expected" } */
+int k, l;
+#pragma omp declare target
+int m;
+#pragma omp end declare target
+#pragma omp declare target to (k)
+#pragma omp declare target (k)
+#pragma omp declare target to (k, m) link (l)
+#pragma omp declare target link (l)
+int n, o, s, t;
+#pragma omp declare target to (n) to (n) /* { dg-error "appears more than once on the same .declare target. directive" } */
+#pragma omp declare target link (o, o) /* { dg-error "appears more than once on the same .declare target. directive" } */
+#pragma omp declare target (s, t, s) /* { dg-error "appears more than once on the same .declare target. directive" } */
+int p, q, r;
+#pragma omp declare target (p) to (q) /* { dg-error "expected end of line before .to." } */
+#pragma omp declare target to (p) (q) link (r) /* { dg-error "expected .#pragma omp. clause before" } */
+#pragma omp declare target link (r) (p) /* { dg-error "expected .#pragma omp. clause before" } */
+#pragma omp declare target
+#pragma omp end declare target to (p) /* { dg-error "expected end of line before .to." } */
diff --git a/gcc/testsuite/c-c++-common/gomp/depend-3.c b/gcc/testsuite/c-c++-common/gomp/depend-3.c
new file mode 100644
index 0000000000..22fcd8d9c7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/depend-3.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void bar (int a[10][10][10]);
+void
+foo (int a[10][10][10], int **b, int x)
+{
+ int c[10][10][10];
+ #pragma omp task depend(out: a[2:4][3:0][:7]) /* { dg-error "zero length array section" } */
+ bar (a);
+ #pragma omp task depend(inout: b[:7][0:0][:0]) /* { dg-error "zero length array section" } */
+ bar (a);
+ #pragma omp task depend(in: c[:][:][10:]) /* { dg-error "zero length array section" } */
+ bar (c);
+ #pragma omp task depend(out: a[2:4][3:0][:x]) /* { dg-error "zero length array section" } */
+ bar (a);
+ #pragma omp task depend(inout: b[:x][0:0][:0]) /* { dg-error "zero length array section" } */
+ bar (a);
+ #pragma omp task depend(in: c[:][x-2:x][10:]) /* { dg-error "zero length array section" } */
+ bar (c);
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/depend-4.c b/gcc/testsuite/c-c++-common/gomp/depend-4.c
new file mode 100644
index 0000000000..d40b1fa83c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/depend-4.c
@@ -0,0 +1,44 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (int *p, int (*q)[10], int r[10], int s[10][10])
+{
+ int a[10], b[10][10];
+ #pragma omp task depend (inout: p[-1:2])
+ ;
+ #pragma omp task depend (inout: q[-1:2][2:4])
+ ;
+ #pragma omp task depend (inout: q[-1:2][-2:4]) /* { dg-error "negative low bound in array section in" } */
+ ;
+ #pragma omp task depend (inout: r[-1:2])
+ ;
+ #pragma omp task depend (inout: s[-1:2][2:4])
+ ;
+ #pragma omp task depend (inout: s[-1:2][-2:4]) /* { dg-error "negative low bound in array section in" } */
+ ;
+ #pragma omp task depend (inout: a[-1:2]) /* { dg-error "negative low bound in array section in" } */
+ ;
+ #pragma omp task depend (inout: b[-1:2][2:4]) /* { dg-error "negative low bound in array section in" } */
+ ;
+ #pragma omp task depend (inout: b[1:2][-2:4]) /* { dg-error "negative low bound in array section in" } */
+ ;
+ #pragma omp task depend (inout: p[2:-3]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: q[2:-3][:]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: q[2:3][0:-1]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: r[2:-5]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: s[2:-5][:]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: s[2:5][0:-4]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: a[2:-5]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: b[2:-5][0:10]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: b[2:5][0:-4]) /* { dg-error "negative length in array section in" } */
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/distribute-1.c b/gcc/testsuite/c-c++-common/gomp/distribute-1.c
new file mode 100644
index 0000000000..e5e4bc2669
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/distribute-1.c
@@ -0,0 +1,56 @@
+int s1, s2, s3, s4, s5, s6, s7, s8;
+#pragma omp declare target (s1, s2, s3, s4, s5, s6, s7, s8)
+
+void
+f1 (void)
+{
+ int i;
+ #pragma omp distribute
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp distribute private (i)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp distribute
+ for (int j = 0; j < 64; j++)
+ ;
+ #pragma omp distribute lastprivate (s1)
+ for (s1 = 0; s1 < 64; s1 += 2)
+ ;
+ #pragma omp distribute lastprivate (s2)
+ for (i = 0; i < 64; i++)
+ s2 = 2 * i;
+ #pragma omp distribute simd
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp distribute simd lastprivate (s3, s4) collapse(2)
+ for (s3 = 0; s3 < 64; s3++)
+ for (s4 = 0; s4 < 3; s4++)
+ ;
+ #pragma omp distribute parallel for
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp distribute parallel for private (i)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp distribute parallel for lastprivate (s5)
+ for (s5 = 0; s5 < 64; s5++)
+ ;
+ #pragma omp distribute firstprivate (s7) private (s8)
+ for (i = 0; i < 64; i++)
+ s8 = s7++;
+}
+
+void
+f2 (void)
+{
+ int i;
+ #pragma omp distribute lastprivate (i) /* { dg-error "lastprivate variable .i. is private in outer context" } */
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp distribute firstprivate (s6) lastprivate (s6) /* { dg-error "same variable used in .firstprivate. and .lastprivate. clauses on .distribute. construct" } */
+ for (i = 0; i < 64; i++)
+ s6 += i;
+}
+
+#pragma omp declare target to(f1, f2)
diff --git a/gcc/testsuite/c-c++-common/gomp/doacross-1.c b/gcc/testsuite/c-c++-common/gomp/doacross-1.c
new file mode 100644
index 0000000000..6244ca08d2
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/doacross-1.c
@@ -0,0 +1,48 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (void)
+{
+ int i, j, k;
+ #pragma omp for ordered (1)
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered depend (sink: i - 1)
+ #pragma omp ordered depend (source)
+ }
+ #pragma omp for ordered (1) collapse (1)
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered depend (sink: i - 1)
+ #pragma omp ordered depend (source)
+ }
+ #pragma omp for collapse (2) ordered (1) /* { dg-error "clause parameter is less than" } */
+ for (i = 0; i < 64; i++)
+ for (j = 0; j < 64; j++)
+ {
+ #pragma omp ordered depend (sink: i - 1) /* { dg-error "does not match number" } */
+ #pragma omp ordered depend (source)
+ }
+ #pragma omp for ordered (2) collapse (3) /* { dg-error "clause parameter is less than" } */
+ for (i = 0; i < 64; i++)
+ for (j = 0; j < 64; j++)
+ for (k = 0; k < 64; k++)
+ {
+ #pragma omp ordered depend (sink: i - 1, j - 2) /* { dg-error "does not match number" } */
+ #pragma omp ordered depend (source)
+ }
+ #pragma omp ordered depend (sink: j) /* { dg-error "clause must be closely nested inside an .ordered. loop" } */
+ #pragma omp ordered depend (source) /* { dg-error "clause must be closely nested inside an .ordered. loop" } */
+ #pragma omp for ordered (1)
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered depend (sink: i - 1) depend (sink: i - 2)
+ #pragma omp ordered depend (source) depend (source) /* { dg-error "more than one .depend.source.. clause on an" } */
+ }
+ #pragma omp for ordered (1)
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered depend (sink: i - 1) depend (source) depend (sink: i - 2) /* { dg-error "clause specified together with" } */
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/element-1.c b/gcc/testsuite/c-c++-common/gomp/element-1.c
new file mode 100644
index 0000000000..fbd286c5b8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/element-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+struct S { int a; };
+
+void
+foo (struct S *x)
+{
+ struct S b;
+ #pragma omp parallel private (b.a) /* { dg-error "expected .\\). before .\\.. token" } */
+ ;
+ #pragma omp parallel private (x->a) /* { dg-error "expected .\\). before .->. token" } */
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/gridify-1.c b/gcc/testsuite/c-c++-common/gomp/gridify-1.c
new file mode 100644
index 0000000000..ba7a86665b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/gridify-1.c
@@ -0,0 +1,54 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target offload_hsa } */
+/* { dg-options "-fopenmp -fdump-tree-omplower-details" } */
+
+void
+foo1 (int n, int *a, int workgroup_size)
+{
+ int i;
+#pragma omp target
+#pragma omp teams thread_limit(workgroup_size)
+#pragma omp distribute parallel for shared(a) firstprivate(n) private(i)
+ for (i = 0; i < n; i++)
+ a[i]++;
+}
+
+void
+foo2 (int j, int n, int *a)
+{
+ int i;
+#pragma omp target teams
+#pragma omp distribute parallel for shared(a) firstprivate(n) private(i) firstprivate(j)
+ for (i = j + 1; i < n; i++)
+ a[i] = i;
+}
+
+void
+foo3 (int j, int n, int *a)
+{
+ int i;
+#pragma omp target teams
+#pragma omp distribute parallel for shared(a) firstprivate(n) private(i) firstprivate(j)
+ for (i = j + 1; i < n; i += 3)
+ a[i] = i;
+}
+
+void
+foo4 (int j, int n, int *a)
+{
+#pragma omp parallel
+ {
+ #pragma omp single
+ {
+ int i;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for shared(a) firstprivate(n) private(i) firstprivate(j)
+ for (i = j + 1; i < n; i += 3)
+ a[i] = i;
+ }
+ }
+}
+
+
+/* { dg-final { scan-tree-dump-times "Target construct will be turned into a gridified GPGPU kernel" 4 "omplower" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/if-1.c b/gcc/testsuite/c-c++-common/gomp/if-1.c
new file mode 100644
index 0000000000..3a9b53870c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/if-1.c
@@ -0,0 +1,47 @@
+/* { dg-do compile } */
+
+void
+foo (int a, int b, int *p, int *q)
+{
+ int i;
+ #pragma omp parallel if (a)
+ ;
+ #pragma omp parallel if (parallel:a)
+ ;
+ #pragma omp parallel for simd if (a)
+ for (i = 0; i < 16; i++)
+ ;
+ #pragma omp parallel for simd if (parallel : a)
+ for (i = 0; i < 16; i++)
+ ;
+ #pragma omp task if (a)
+ ;
+ #pragma omp task if (task: a)
+ ;
+ #pragma omp taskloop if (a)
+ for (i = 0; i < 16; i++)
+ ;
+ #pragma omp taskloop if (taskloop : a)
+ for (i = 0; i < 16; i++)
+ ;
+ #pragma omp target if (a)
+ ;
+ #pragma omp target if (target: a)
+ ;
+ #pragma omp target teams distribute parallel for simd if (a)
+ for (i = 0; i < 16; i++)
+ ;
+ #pragma omp target teams distribute parallel for simd if (parallel : a) if (target: b)
+ for (i = 0; i < 16; i++)
+ ;
+ #pragma omp target data if (a) map (p[0:2])
+ ;
+ #pragma omp target data if (target data: a) map (p[0:2])
+ ;
+ #pragma omp target enter data if (a) map (to: p[0:2])
+ #pragma omp target enter data if (target enter data: a) map (to: p[0:2])
+ #pragma omp target exit data if (a) map (from: p[0:2])
+ #pragma omp target exit data if (target exit data: a) map (from: p[0:2])
+ #pragma omp target update if (a) to (q[0:3])
+ #pragma omp target update if (target update:a) to (q[0:3])
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/if-2.c b/gcc/testsuite/c-c++-common/gomp/if-2.c
new file mode 100644
index 0000000000..f1f417ed23
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/if-2.c
@@ -0,0 +1,43 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (int a, int b, int *p, int *q, int task)
+{
+ int i;
+ #pragma omp parallel if (a) if (b) /* { dg-error "too many .if. clauses without modifier" } */
+ ;
+ #pragma omp parallel if (a) if (parallel: b) /* { dg-error "if any .if. clause has modifier, then all .if. clauses have to use modifier" } */
+ ;
+ #pragma omp parallel if (parallel: a) if (b) /* { dg-error "if any .if. clause has modifier, then all .if. clauses have to use modifier" } */
+ ;
+ #pragma omp parallel if (parallel:a) if (parallel:a) /* { dg-error "too many .if. clauses with .parallel. modifier" } */
+ ;
+ #pragma omp parallel if (task:a) /* { dg-error "expected .parallel. .if. clause modifier rather than .task." } */ \
+ if (taskloop: b) /* { dg-error "expected .parallel. .if. clause modifier rather than .taskloop." } */
+ ;
+ #pragma omp parallel if (target update:a) /* { dg-error "expected .parallel. .if. clause modifier rather than .target update." } */
+ ;
+ #pragma omp parallel for simd if (target update: a) /* { dg-error "expected .parallel. .if. clause modifier rather than .target update." } */
+ for (i = 0; i < 16; i++)
+ ;
+ #pragma omp task if (task)
+ ;
+ #pragma omp task if (task: task)
+ ;
+ #pragma omp task if (parallel: a) /* { dg-error "expected .task. .if. clause modifier rather than .parallel." } */
+ ;
+ #pragma omp taskloop if (task : a) /* { dg-error "expected .taskloop. .if. clause modifier rather than .task." } */
+ for (i = 0; i < 16; i++)
+ ;
+ #pragma omp target if (taskloop: a) /* { dg-error "expected .target. .if. clause modifier rather than .taskloop." } */
+ ;
+ #pragma omp target teams distribute parallel for simd if (target exit data : a) /* { dg-error "expected .parallel. or .target. .if. clause modifier" } */
+ for (i = 0; i < 16; i++)
+ ;
+ #pragma omp target data if (target: a) map (p[0:2]) /* { dg-error "expected .target data. .if. clause modifier rather than .target." } */
+ ;
+ #pragma omp target enter data if (target data: a) map (to: p[0:2]) /* { dg-error "expected .target enter data. .if. clause modifier rather than .target data." } */
+ #pragma omp target exit data if (target enter data: a) map (from: p[0:2]) /* { dg-error "expected .target exit data. .if. clause modifier rather than .target enter data." } */
+ #pragma omp target update if (target exit data:a) to (q[0:3]) /* { dg-error "expected .target update. .if. clause modifier rather than .target exit data." } */
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/linear-1.c b/gcc/testsuite/c-c++-common/gomp/linear-1.c
new file mode 100644
index 0000000000..4557e22cb4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/linear-1.c
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+int i;
+
+#pragma omp declare simd linear (val (x) : 1) linear (y : 2)
+int bar (int x, int y, int z);
+
+void
+foo (int x, int y)
+{
+ #pragma omp simd linear (i: 3)
+ for (i = 0; i < 33; i += 3)
+ ;
+ #pragma omp simd linear (val (i): 3) /* { dg-error "modifier should not be specified in" } */
+ for (i = 0; i < 33; i += 3)
+ ;
+ #pragma omp simd linear (x: y + 1)
+ for (i = 0; i < 10; i++)
+ x += y + 1;
+ #pragma omp simd linear (val (x): y + 1) /* { dg-error "modifier should not be specified in" } */
+ for (i = 0; i < 10; i++)
+ x += y + 1;
+ #pragma omp for linear (x: y + 1)
+ for (i = 0; i < 10; i++)
+ x += y + 1;
+ #pragma omp for linear (val (x): y + 1) /* { dg-error "modifier should not be specified in" } */
+ for (i = 0; i < 10; i++)
+ x += y + 1;
+ #pragma omp for simd linear (i: 3)
+ for (i = 0; i < 33; i += 3)
+ ;
+ #pragma omp for simd linear (val (i): 3) /* { dg-error "modifier should not be specified in" } */
+ for (i = 0; i < 33; i += 3)
+ ;
+ #pragma omp for simd linear (x: y + 1)
+ for (i = 0; i < 10; i++)
+ x += y + 1;
+ #pragma omp for simd linear (val (x): y + 1) /* { dg-error "modifier should not be specified in" } */
+ for (i = 0; i < 10; i++)
+ x += y + 1;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/map-2.c b/gcc/testsuite/c-c++-common/gomp/map-2.c
new file mode 100644
index 0000000000..101f4047b8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/map-2.c
@@ -0,0 +1,44 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (int *p, int (*q)[10], int r[10], int s[10][10])
+{
+ int a[10], b[10][10];
+ #pragma omp target map (tofrom: p[-1:2])
+ ;
+ #pragma omp target map (tofrom: q[-1:2][0:10])
+ ;
+ #pragma omp target map (tofrom: q[-1:2][-2:10]) /* { dg-error "negative low bound in array section in" } */
+ ;
+ #pragma omp target map (tofrom: r[-1:2])
+ ;
+ #pragma omp target map (tofrom: s[-1:2][:])
+ ;
+ #pragma omp target map (tofrom: s[-1:2][-2:10]) /* { dg-error "negative low bound in array section in" } */
+ ;
+ #pragma omp target map (tofrom: a[-1:2]) /* { dg-error "negative low bound in array section in" } */
+ ;
+ #pragma omp target map (tofrom: b[-1:2][0:]) /* { dg-error "negative low bound in array section in" } */
+ ;
+ #pragma omp target map (tofrom: b[1:2][-2:10]) /* { dg-error "negative low bound in array section in" } */
+ ;
+ #pragma omp target map (tofrom: p[2:-3]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: q[2:-3][:]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: q[2:3][0:-1]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: r[2:-5]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: s[2:-5][:]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: s[2:5][0:-4]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: a[2:-5]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: b[2:-5][0:10]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: b[2:5][0:-4]) /* { dg-error "negative length in array section in" } */
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/map-3.c b/gcc/testsuite/c-c++-common/gomp/map-3.c
new file mode 100644
index 0000000000..8a14b9c888
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/map-3.c
@@ -0,0 +1,21 @@
+struct S { int i : 1; int j : 4; long long k : 25; };
+void bar (struct S, int);
+#pragma omp declare target to (bar)
+
+void
+foo (struct S a, struct S b, struct S c, struct S d)
+{
+ #pragma omp target map (a)
+ bar (a, 0);
+ #pragma omp target map (a) map (b.i) /* { dg-error "bit-field .b.\(S::\|\)i. in .map. clause" } */
+ bar (a, b.i);
+ #pragma omp target map (a) map (b.j) /* { dg-error "bit-field .b.\(S::\|\)j. in .map. clause" } */
+ bar (a, b.j);
+ #pragma omp target map (a) map (b.k) /* { dg-error "bit-field .b.\(S::\|\)k. in .map. clause" } */
+ bar (a, b.k);
+ #pragma omp target data map (a) map (b.i) /* { dg-error "bit-field .b.\(S::\|\)i. in .map. clause" } */
+ {
+ #pragma omp target enter data map (alloc: a) map (to: c.j) /* { dg-error "bit-field .c.\(S::\|\)j. in .map. clause" } */
+ #pragma omp target exit data map (release: a) map (from: d.k) /* { dg-error "bit-field .d.\(S::\|\)k. in .map. clause" } */
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/nesting-1.c b/gcc/testsuite/c-c++-common/gomp/nesting-1.c
index 711ff8ea86..61b2f818b0 100644
--- a/gcc/testsuite/c-c++-common/gomp/nesting-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/nesting-1.c
@@ -11,12 +11,12 @@ f_omp_parallel (void)
#pragma omp target
;
-#pragma omp target data
+#pragma omp target data map(i)
;
#pragma omp target update to(i)
-#pragma omp target data
+#pragma omp target data map(i)
{
#pragma omp parallel
;
@@ -24,7 +24,7 @@ f_omp_parallel (void)
#pragma omp target
;
-#pragma omp target data
+#pragma omp target data map(i)
;
#pragma omp target update to(i)
@@ -45,7 +45,7 @@ f_omp_target (void)
void
f_omp_target_data (void)
{
-#pragma omp target data
+#pragma omp target data map(i)
{
#pragma omp parallel
;
@@ -53,12 +53,12 @@ f_omp_target_data (void)
#pragma omp target
;
-#pragma omp target data
+#pragma omp target data map(i)
;
#pragma omp target update to(i)
-#pragma omp target data
+#pragma omp target data map(i)
{
#pragma omp parallel
;
@@ -66,7 +66,7 @@ f_omp_target_data (void)
#pragma omp target
;
-#pragma omp target data
+#pragma omp target data map(i)
;
#pragma omp target update to(i)
diff --git a/gcc/testsuite/c-c++-common/gomp/nesting-2.c b/gcc/testsuite/c-c++-common/gomp/nesting-2.c
new file mode 100644
index 0000000000..7a03430311
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/nesting-2.c
@@ -0,0 +1,154 @@
+void
+foo (void)
+{
+ int i;
+ #pragma omp taskloop
+ for (i = 0; i < 64; i++)
+ {
+ int j;
+ #pragma omp for /* { dg-error "region may not be closely nested inside of" } */
+ for (j = 0; j < 10; j++)
+ ;
+ #pragma omp single /* { dg-error "region may not be closely nested inside of" } */
+ ;
+ #pragma omp sections /* { dg-error "region may not be closely nested inside of" } */
+ {
+ #pragma omp section
+ ;
+ }
+ #pragma omp barrier /* { dg-error "region may not be closely nested inside of" } */
+ #pragma omp master /* { dg-error "region may not be closely nested inside of" } */
+ ;
+ #pragma omp ordered /* { dg-error "region may not be closely nested inside of" } */
+ ;
+ #pragma omp ordered threads /* { dg-error "region may not be closely nested inside of" } */
+ ;
+ #pragma omp ordered simd threads /* { dg-error ".ordered. .simd. must be closely nested inside .simd. region" } */
+ ;
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ #pragma omp ordered simd
+ ;
+ #pragma omp critical
+ {
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ #pragma omp ordered simd
+ ;
+ }
+ }
+ #pragma omp taskloop
+ for (i = 0; i < 64; i++)
+ #pragma omp parallel
+ {
+ int j;
+ #pragma omp for
+ for (j = 0; j < 10; j++)
+ ;
+ #pragma omp single
+ ;
+ #pragma omp sections
+ {
+ #pragma omp section
+ ;
+ }
+ #pragma omp barrier
+ #pragma omp master
+ ;
+ #pragma omp ordered /* { dg-error ".ordered. region must be closely nested inside a loop region with an .ordered. clause" } */
+ ;
+ #pragma omp ordered threads /* { dg-error ".ordered. region must be closely nested inside a loop region with an .ordered. clause" } */
+ ;
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ #pragma omp ordered simd
+ ;
+ #pragma omp critical
+ {
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ #pragma omp ordered simd
+ ;
+ }
+ }
+ #pragma omp taskloop
+ for (i = 0; i < 64; i++)
+ #pragma omp target
+ {
+ int j;
+ #pragma omp for
+ for (j = 0; j < 10; j++)
+ ;
+ #pragma omp single
+ ;
+ #pragma omp sections
+ {
+ #pragma omp section
+ ;
+ }
+ #pragma omp barrier
+ #pragma omp master
+ ;
+ #pragma omp ordered /* { dg-error ".ordered. region must be closely nested inside a loop region with an .ordered. clause" } */
+ ;
+ #pragma omp ordered threads /* { dg-error ".ordered. region must be closely nested inside a loop region with an .ordered. clause" } */
+ ;
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ #pragma omp ordered simd
+ ;
+ #pragma omp critical
+ {
+ #pragma omp simd
+ for (j = 0; j < 10; j++)
+ #pragma omp ordered simd
+ ;
+ }
+ }
+ #pragma omp ordered
+ {
+ #pragma omp ordered /* { dg-error "region may not be closely nested inside of" } */
+ ;
+ }
+ #pragma omp ordered threads
+ {
+ #pragma omp ordered /* { dg-error "region may not be closely nested inside of" } */
+ ;
+ }
+ #pragma omp ordered
+ {
+ #pragma omp ordered threads /* { dg-error "region may not be closely nested inside of" } */
+ ;
+ }
+ #pragma omp ordered threads
+ {
+ #pragma omp ordered threads /* { dg-error "region may not be closely nested inside of" } */
+ ;
+ }
+ #pragma omp critical
+ {
+ #pragma omp ordered simd /* { dg-error ".ordered. .simd. must be closely nested inside .simd. region" } */
+ ;
+ }
+ #pragma omp for ordered
+ for (i = 0; i < 64; i++)
+ #pragma omp parallel
+ {
+ #pragma omp ordered threads /* { dg-error ".ordered. region must be closely nested inside a loop region with an .ordered. clause" } */
+ ;
+ }
+ #pragma omp for ordered
+ for (i = 0; i < 64; i++)
+ #pragma omp parallel
+ {
+ #pragma omp ordered /* { dg-error ".ordered. region must be closely nested inside a loop region with an .ordered. clause" } */
+ ;
+ }
+ #pragma omp for ordered(1)
+ for (i = 0; i < 64; i++)
+ #pragma omp parallel
+ {
+ #pragma omp ordered depend(source) /* { dg-error ".ordered. construct with .depend. clause must be closely nested inside a loop with .ordered. clause with a parameter" } */
+ #pragma omp ordered depend(sink: i - 1) /* { dg-error ".ordered. construct with .depend. clause must be closely nested inside a loop with .ordered. clause with a parameter" } */
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/nesting-warn-1.c b/gcc/testsuite/c-c++-common/gomp/nesting-warn-1.c
index c39dd49f12..800ad53210 100644
--- a/gcc/testsuite/c-c++-common/gomp/nesting-warn-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/nesting-warn-1.c
@@ -5,19 +5,19 @@ f_omp_target (void)
{
#pragma omp target
{
-#pragma omp target /* { dg-warning "target construct inside of target region" } */
+#pragma omp target /* { dg-warning ".target. construct inside of .target. region" } */
;
-#pragma omp target data /* { dg-warning "target data construct inside of target region" } */
+#pragma omp target data map(i) /* { dg-warning ".target data. construct inside of .target. region" } */
;
-#pragma omp target update to(i) /* { dg-warning "target update construct inside of target region" } */
+#pragma omp target update to(i) /* { dg-warning ".target update. construct inside of .target. region" } */
#pragma omp parallel
{
-#pragma omp target /* { dg-warning "target construct inside of target region" } */
+#pragma omp target /* { dg-warning ".target. construct inside of .target. region" } */
;
-#pragma omp target data /* { dg-warning "target data construct inside of target region" } */
+#pragma omp target data map(i) /* { dg-warning ".target data. construct inside of .target. region" } */
;
-#pragma omp target update to(i) /* { dg-warning "target update construct inside of target region" } */
+#pragma omp target update to(i) /* { dg-warning ".target update. construct inside of .target. region" } */
}
}
}
diff --git a/gcc/testsuite/c-c++-common/gomp/ordered-1.c b/gcc/testsuite/c-c++-common/gomp/ordered-1.c
new file mode 100644
index 0000000000..11022593e3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/ordered-1.c
@@ -0,0 +1,91 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fopenmp-simd" } */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+/* { dg-additional-options "-mavx" { target avx_runtime } } */
+
+#define N 1024
+extern
+#ifdef __cplusplus
+"C"
+#endif
+void abort (void);
+
+int last;
+
+void
+bar (unsigned char *a, int i, int safelen)
+{
+ int j, k;
+ if (i != last++)
+ abort ();
+ for (j = i - safelen - 32; j < i; j++)
+ if (j >= 0 && a[j] != 2)
+ break;
+ if (j <= i - safelen || a[j] != 1)
+ abort ();
+ for (k = j; k < i + safelen + 32; k++)
+ if (k >= N || a[k] != 1)
+ break;
+ if (k <= i || k > j + safelen)
+ abort ();
+ if (k < N && a[k] != 0)
+ abort ();
+ for (; k < i + safelen + 32; k++)
+ if (k < N && a[k] != 0)
+ abort ();
+}
+
+static inline void
+foo (unsigned char *a, int i)
+{
+ #pragma omp ordered simd
+ bar (a, i, 64);
+}
+
+int
+main ()
+{
+ unsigned char a[N], b[N];
+ int i;
+ #pragma omp simd
+ for (i = 0; i < N; i++)
+ a[i] = 0;
+ #pragma omp simd safelen (64)
+ for (i = 0; i < N; i++)
+ {
+ a[i]++;
+ foo (a, i);
+ a[i]++;
+ }
+ #pragma omp simd
+ for (i = 0; i < N; i++)
+ {
+ a[i] = 0;
+ b[i] = 0;
+ }
+ last = 0;
+ #pragma omp simd safelen (32)
+ for (i = 0; i < N; i++)
+ {
+ a[i]++;
+ #pragma omp ordered simd
+ bar (a, i, 32);
+ a[i]++;
+ }
+ for (i = 0; i < N; i++)
+ if (a[i] != 2)
+ abort ();
+ #pragma omp simd safelen (32)
+ for (i = 1; i < N; i++)
+ {
+ #pragma omp ordered simd
+ b[i] = b[i - 1] + 1;
+ a[i]++;
+ #pragma omp ordered simd
+ a[i] += a[i - 1];
+ }
+ for (i = 0; i < N; i++)
+ if (a[i] != (unsigned char) (2 + 3 * i) || b[i] != (unsigned char) i)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/ordered-2.c b/gcc/testsuite/c-c++-common/gomp/ordered-2.c
new file mode 100644
index 0000000000..96442978a9
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/ordered-2.c
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+/* { dg-options "-O0 -fopenmp-simd" } */
+
+#include "ordered-1.c"
diff --git a/gcc/testsuite/c-c++-common/gomp/ordered-3.c b/gcc/testsuite/c-c++-common/gomp/ordered-3.c
new file mode 100644
index 0000000000..3c107232c0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/ordered-3.c
@@ -0,0 +1,103 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (void)
+{
+ int i;
+ #pragma omp for ordered
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered
+ ;
+ }
+ #pragma omp for ordered
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered threads
+ ;
+ }
+ #pragma omp for ordered
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered threads threads /* { dg-error "too many .threads. clauses" } */
+ ;
+ }
+ #pragma omp simd
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered simd
+ ;
+ }
+ #pragma omp simd
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered simd simd /* { dg-error "too many .simd. clauses" } */
+ ;
+ }
+ #pragma omp for simd ordered
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered threads, simd
+ ;
+ }
+ #pragma omp for simd ordered
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered threads, simd, threads, simd /* { dg-error "too many .threads. clauses" } */
+ ; /* { dg-error "too many .simd. clauses" "" { target *-*-* } 47 } */
+ }
+ #pragma omp for simd ordered(1) /* { dg-error ".ordered. clause with parameter may not be specified on .#pragma omp for simd. construct" } */
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered depend(sink: i - 1) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */
+ #pragma omp ordered depend(source) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */
+ }
+ #pragma omp parallel for simd ordered(1) /* { dg-error ".ordered. clause with parameter may not be specified on .#pragma omp parallel for simd. construct" } */
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered depend(sink: i - 1) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */
+ #pragma omp ordered depend(source) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */
+ }
+ #pragma omp parallel for ordered
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered depend(sink: i - 1) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */
+ #pragma omp ordered depend(source) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */
+ }
+ #pragma omp parallel for
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered depend(sink: i - 1) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */
+ #pragma omp ordered depend(source) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */
+ }
+}
+
+void
+bar (int x)
+{
+ switch (x)
+ {
+ case 0:
+ #pragma omp ordered
+ ;
+ break;
+ case 1:
+ #pragma omp ordered threads
+ ;
+ break;
+ case 2:
+ #pragma omp ordered threads, threads /* { dg-error "too many .threads. clauses" } */
+ ;
+ break;
+ }
+}
+
+void
+baz (void)
+{
+ #pragma omp ordered simd
+ ;
+ #pragma omp ordered simd, simd /* { dg-error "too many .simd. clauses" } */
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/ordered-4.c b/gcc/testsuite/c-c++-common/gomp/ordered-4.c
new file mode 100644
index 0000000000..b56843c0bb
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/ordered-4.c
@@ -0,0 +1,54 @@
+void
+f1 (void)
+{
+ int i, j;
+ #pragma omp critical
+ {
+ #pragma omp simd
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered simd
+ ;
+ }
+ }
+ #pragma omp ordered threads
+ {
+ #pragma omp simd
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered simd
+ ;
+ }
+ }
+ #pragma omp task
+ {
+ #pragma omp simd
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered simd
+ ;
+ }
+ }
+ #pragma omp taskloop
+ for (j = 0; j < 64; j++)
+ #pragma omp simd
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered simd
+ ;
+ }
+}
+
+void
+f2 (void)
+{
+ #pragma omp ordered simd
+ ;
+}
+
+void
+f3 (void)
+{
+ #pragma omp ordered threads , simd
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/pr57580.c b/gcc/testsuite/c-c++-common/gomp/pr57580.c
new file mode 100644
index 0000000000..9bbe707ef3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr57580.c
@@ -0,0 +1,36 @@
+/* PR preprocessor/57580 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -save-temps -fdump-tree-gimple" } */
+
+#define PS \
+ _Pragma("omp parallel num_threads(2)") \
+ { \
+ _Pragma("omp single") \
+ { \
+ ret = 0; \
+ } \
+ }
+
+int
+main ()
+{
+ int ret;
+ _Pragma("omp parallel num_threads(3)")
+ {
+ _Pragma("omp single")
+ {
+ ret = 0;
+ }
+ }
+ _Pragma("omp parallel num_threads(4)") { _Pragma("omp single") { ret = 0; } }
+ { _Pragma("omp parallel num_threads(5)") { _Pragma("omp single") { ret = 0; } } }
+ PS
+ PS
+ return ret;
+}
+
+/* { dg-final { scan-tree-dump-times "#pragma omp parallel\[^\n\r]*num_threads\\(2\\)" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp parallel\[^\n\r]*num_threads\\(3\\)" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp parallel\[^\n\r]*num_threads\\(4\\)" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp parallel\[^\n\r]*num_threads\\(5\\)" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp single" 5 "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/pr61486-1.c b/gcc/testsuite/c-c++-common/gomp/pr61486-1.c
index 9ada58c8cc..dbd621f0db 100644
--- a/gcc/testsuite/c-c++-common/gomp/pr61486-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/pr61486-1.c
@@ -6,8 +6,8 @@ int
foo (int *a)
{
int i, j = 0;
- #pragma omp target teams distribute simd linear(i, j) map(a[:10])
+ #pragma omp target teams distribute simd linear(i) map(a[:10])
for (i = 0; i < 10; i++)
- a[i] = j++;
- return i + j;
+ a[i] = j;
+ return i;
}
diff --git a/gcc/testsuite/c-c++-common/gomp/pr61486-2.c b/gcc/testsuite/c-c++-common/gomp/pr61486-2.c
index 729438101e..4a680235fa 100644
--- a/gcc/testsuite/c-c++-common/gomp/pr61486-2.c
+++ b/gcc/testsuite/c-c++-common/gomp/pr61486-2.c
@@ -1,6 +1,6 @@
/* PR middle-end/61486 */
/* { dg-do compile } */
-/* { dg-options "-fopenmp" } */
+/* { dg-require-effective-target alloca } */
#pragma omp declare target
void dosomething (int *a, int n, int m);
@@ -49,22 +49,21 @@ test (int n, int o, int p, int q, int r, int s, int *pp)
private (p) firstprivate (q) shared (n) reduction (+: r) \
thread_limit (n * 2) dist_schedule (static, 4) collapse (2) \
num_threads (n + 4) proc_bind (spread) lastprivate (s) \
- ordered schedule (static, 8)
+ schedule (static, 8)
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
{
r = r + 1;
p = q;
dosomething (a, n, p + q);
- #pragma omp ordered
- p = q;
+ p = q;
s = i * 10 + j;
}
#pragma omp target teams distribute parallel for device (n + 1) num_teams (n + 4) \
if (n != 6)map (from: n) map (alloc: a[2:o-2]) default(shared) \
private (p) firstprivate (q) shared (n) reduction (+: r) \
thread_limit (n * 2) dist_schedule (static, 4) num_threads (n + 4) \
- proc_bind (master) lastprivate (s) ordered schedule (static, 8)
+ proc_bind (master) lastprivate (s) schedule (static, 8)
for (i = 0; i < 10; i++)
{
for (j = 0; j < 10; j++)
@@ -73,8 +72,7 @@ test (int n, int o, int p, int q, int r, int s, int *pp)
p = q;
dosomething (a, n, p + q);
}
- #pragma omp ordered
- p = q;
+ p = q;
s = i * 10;
}
#pragma omp target teams distribute parallel for simd device (n + 1) \
@@ -164,22 +162,21 @@ test (int n, int o, int p, int q, int r, int s, int *pp)
default(shared) private (p) firstprivate (q) shared (n) reduction (+: r) \
thread_limit (n * 2) dist_schedule (static, 4) collapse (2) \
num_threads (n + 4) proc_bind (spread) lastprivate (s) \
- ordered schedule (static, 8)
+ schedule (static, 8)
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
{
r = r + 1;
p = q;
dosomething (a, n, p + q);
- #pragma omp ordered
- p = q;
+ p = q;
s = i * 10 + j;
}
#pragma omp target device (n + 1) if (n != 6)map(from:n) map(alloc:a[2:o-2])
#pragma omp teams distribute parallel for num_teams (n + 4) if (n != 6) \
default(shared) private (p) firstprivate (q) shared (n) reduction (+: r) \
thread_limit (n * 2) dist_schedule (static, 4) num_threads (n + 4) \
- proc_bind (master) lastprivate (s) ordered schedule (static, 8)
+ proc_bind (master) lastprivate (s) schedule (static, 8)
for (i = 0; i < 10; i++)
{
for (j = 0; j < 10; j++)
@@ -188,8 +185,7 @@ test (int n, int o, int p, int q, int r, int s, int *pp)
p = q;
dosomething (a, n, p + q);
}
- #pragma omp ordered
- p = q;
+ p = q;
s = i * 10;
}
#pragma omp target device (n + 1) if (n != 6)map(from:n) map(alloc:a[2:o-2])
@@ -272,15 +268,14 @@ test (int n, int o, int p, int q, int r, int s, int *pp)
default(shared) private (p) firstprivate (q) shared (n) reduction (+: r) \
collapse (2) dist_schedule (static, 4) \
num_threads (n + 4) proc_bind (spread) lastprivate (s) \
- ordered schedule (static, 8)
+ schedule (static, 8)
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
{
r = r + 1;
p = q;
dosomething (a, n, p + q);
- #pragma omp ordered
- p = q;
+ p = q;
s = i * 10 + j;
}
#pragma omp target teams device (n + 1) if (n != 6)map(from:n) map(alloc:a[2:o-2]) \
@@ -288,7 +283,7 @@ test (int n, int o, int p, int q, int r, int s, int *pp)
#pragma omp distribute parallel for if (n != 6) \
default(shared) private (p) firstprivate (q) shared (n) reduction (+: r) \
num_threads (n + 4) dist_schedule (static, 4) \
- proc_bind (master) lastprivate (s) ordered schedule (static, 8)
+ proc_bind (master) lastprivate (s) schedule (static, 8)
for (i = 0; i < 10; i++)
{
for (j = 0; j < 10; j++)
@@ -297,8 +292,7 @@ test (int n, int o, int p, int q, int r, int s, int *pp)
p = q;
dosomething (a, n, p + q);
}
- #pragma omp ordered
- p = q;
+ p = q;
s = i * 10;
}
#pragma omp target teams device (n + 1) if (n != 6)map(from:n) map(alloc:a[2:o-2]) \
@@ -360,8 +354,11 @@ test (int n, int o, int p, int q, int r, int s, int *pp)
int q, i, j;
+#pragma omp declare target
+int s;
+
void
-test2 (int n, int o, int p, int r, int s, int *pp)
+test2 (int n, int o, int p, int r, int *pp)
{
int a[o];
#pragma omp distribute collapse (2) dist_schedule (static, 4) firstprivate (q)
@@ -384,21 +381,20 @@ test2 (int n, int o, int p, int r, int s, int *pp)
default(shared) private (p) firstprivate (q) shared (n) reduction (+: r) \
collapse (2) dist_schedule (static, 4) \
num_threads (n + 4) proc_bind (spread) lastprivate (s) \
- ordered schedule (static, 8)
+ schedule (static, 8)
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
{
r = r + 1;
p = q;
dosomething (a, n, p + q);
- #pragma omp ordered
- p = q;
+ p = q;
s = i * 10 + j;
}
#pragma omp distribute parallel for if (n != 6) \
default(shared) private (p) firstprivate (q) shared (n) reduction (+: r) \
num_threads (n + 4) dist_schedule (static, 4) \
- proc_bind (master) lastprivate (s) ordered schedule (static, 8)
+ proc_bind (master) lastprivate (s) schedule (static, 8)
for (i = 0; i < 10; i++)
{
for (j = 0; j < 10; j++)
@@ -407,8 +403,7 @@ test2 (int n, int o, int p, int r, int s, int *pp)
p = q;
dosomething (a, n, p + q);
}
- #pragma omp ordered
- p = q;
+ p = q;
s = i * 10;
}
#pragma omp distribute parallel for simd if (n != 6)default(shared) \
@@ -456,3 +451,4 @@ test2 (int n, int o, int p, int r, int s, int *pp)
s = i * 10;
}
}
+#pragma omp end declare target
diff --git a/gcc/testsuite/c-c++-common/gomp/pr63326.c b/gcc/testsuite/c-c++-common/gomp/pr63326.c
new file mode 100644
index 0000000000..e319f49701
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr63326.c
@@ -0,0 +1,479 @@
+/* PR c/63326 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+f1 (int x)
+{
+ int i;
+ if (x)
+ #pragma omp barrier /* { dg-error "may only be used in compound statements" } */
+ ;
+ if (x)
+ #pragma omp flush /* { dg-error "may only be used in compound statements" } */
+ ;
+ if (x)
+ #pragma omp taskwait /* { dg-error "may only be used in compound statements" } */
+ ;
+ if (x)
+ #pragma omp taskyield /* { dg-error "may only be used in compound statements" } */
+ ;
+ #pragma omp parallel
+ {
+ if (x)
+ #pragma omp cancel parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp parallel
+ {
+ if (x)
+ #pragma omp cancellation point parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp for ordered(1)
+ for (i = 0; i < 16; i++)
+ {
+ if (x)
+ #pragma omp ordered depend(source) /* { dg-error "may only be used in compound statements" } */
+ ;
+ if (x)
+ #pragma omp ordered depend(sink: i-1) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ if (x)
+ #pragma omp target enter data map(to:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ if (x)
+ #pragma omp target update to(i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ if (x)
+ #pragma omp target exit data map(from:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+}
+
+void
+f2 (int x)
+{
+ int i;
+ while (x)
+ #pragma omp barrier /* { dg-error "may only be used in compound statements" } */
+ ;
+ while (x)
+ #pragma omp flush /* { dg-error "may only be used in compound statements" } */
+ ;
+ while (x)
+ #pragma omp taskwait /* { dg-error "may only be used in compound statements" } */
+ ;
+ while (x)
+ #pragma omp taskyield /* { dg-error "may only be used in compound statements" } */
+ ;
+ #pragma omp parallel
+ {
+ while (x)
+ #pragma omp cancel parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp parallel
+ {
+ while (x)
+ #pragma omp cancellation point parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp for ordered(1)
+ for (i = 0; i < 16; i++)
+ {
+ while (x)
+ #pragma omp ordered depend(source) /* { dg-error "may only be used in compound statements" } */
+ ;
+ while (x)
+ #pragma omp ordered depend(sink: i-1) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ while (x)
+ #pragma omp target enter data map(to:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ while (x)
+ #pragma omp target update to(i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ while (x)
+ #pragma omp target exit data map(from:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+}
+
+void
+f3 (int x)
+{
+ int i;
+ for (x = 0; x < 10; x++)
+ #pragma omp barrier /* { dg-error "may only be used in compound statements" } */
+ ;
+ for (x = 0; x < 10; x++)
+ #pragma omp flush /* { dg-error "may only be used in compound statements" } */
+ ;
+ for (x = 0; x < 10; x++)
+ #pragma omp taskwait /* { dg-error "may only be used in compound statements" } */
+ ;
+ for (x = 0; x < 10; x++)
+ #pragma omp taskyield /* { dg-error "may only be used in compound statements" } */
+ ;
+ #pragma omp parallel
+ {
+ for (x = 0; x < 10; x++)
+ #pragma omp cancel parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp parallel
+ {
+ for (x = 0; x < 10; x++)
+ #pragma omp cancellation point parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp for ordered(1)
+ for (i = 0; i < 16; i++)
+ {
+ for (x = 0; x < 10; x++)
+ #pragma omp ordered depend(source) /* { dg-error "may only be used in compound statements" } */
+ ;
+ for (x = 0; x < 10; x++)
+ #pragma omp ordered depend(sink: i-1) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ for (x = 0; x < 10; x++)
+ #pragma omp target enter data map(to:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ for (x = 0; x < 10; x++)
+ #pragma omp target update to(i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ for (x = 0; x < 10; x++)
+ #pragma omp target exit data map(from:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+}
+
+void
+f4 (int x)
+{
+ int i;
+ {
+ do
+ #pragma omp barrier /* { dg-error "may only be used in compound statements" } */
+ while (0);
+ } /* { dg-error "before" "" { target c++ } } */
+ {
+ do
+ #pragma omp flush /* { dg-error "may only be used in compound statements" } */
+ while (0);
+ } /* { dg-error "before" "" { target c++ } } */
+ {
+ do
+ #pragma omp taskwait /* { dg-error "may only be used in compound statements" } */
+ while (0);
+ } /* { dg-error "before" "" { target c++ } } */
+ {
+ do
+ #pragma omp taskyield /* { dg-error "may only be used in compound statements" } */
+ while (0);
+ } /* { dg-error "before" "" { target c++ } } */
+ #pragma omp parallel
+ {
+ do
+ #pragma omp cancel parallel /* { dg-error "may only be used in compound statements" } */
+ while (0);
+ } /* { dg-error "before" "" { target c++ } } */
+ #pragma omp parallel
+ {
+ do
+ #pragma omp cancellation point parallel /* { dg-error "may only be used in compound statements" } */
+ while (0);
+ } /* { dg-error "before" "" { target c++ } } */
+ #pragma omp for ordered(1)
+ for (i = 0; i < 16; i++)
+ {
+ {
+ do
+ #pragma omp ordered depend(source) /* { dg-error "may only be used in compound statements" } */
+ while (0);
+ } /* { dg-error "before" "" { target c++ } } */
+ {
+ do
+ #pragma omp ordered depend(sink: i-1) /* { dg-error "may only be used in compound statements" } */
+ while (0);
+ } /* { dg-error "before" "" { target c++ } } */
+ }
+ {
+ do
+ #pragma omp target enter data map(to:i) /* { dg-error "may only be used in compound statements" } */
+ while (0);
+ } /* { dg-error "before" "" { target c++ } } */
+ {
+ do
+ #pragma omp target update to(i) /* { dg-error "may only be used in compound statements" } */
+ while (0);
+ } /* { dg-error "before" "" { target c++ } } */
+ {
+ do
+ #pragma omp target exit data map(from:i) /* { dg-error "may only be used in compound statements" } */
+ while (0);
+ } /* { dg-error "before" "" { target c++ } } */
+}
+
+void
+f5 (int x)
+{
+ int i;
+ switch (x)
+ #pragma omp barrier /* { dg-error "may only be used in compound statements" } */
+ ;
+ switch (x)
+ #pragma omp flush /* { dg-error "may only be used in compound statements" } */
+ ;
+ switch (x)
+ #pragma omp taskwait /* { dg-error "may only be used in compound statements" } */
+ ;
+ switch (x)
+ #pragma omp taskyield /* { dg-error "may only be used in compound statements" } */
+ ;
+ #pragma omp parallel
+ {
+ switch (x)
+ #pragma omp cancel parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp parallel
+ {
+ switch (x)
+ #pragma omp cancellation point parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp for ordered(1)
+ for (i = 0; i < 16; i++)
+ {
+ switch (x)
+ #pragma omp ordered depend(source) /* { dg-error "may only be used in compound statements" } */
+ ;
+ switch (x)
+ #pragma omp ordered depend(sink: i-1) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ #pragma omp target enter data map(to:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ switch (x)
+ #pragma omp target update to(i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ switch (x)
+ #pragma omp target exit data map(from:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+}
+
+void
+f6 (int x)
+{
+ int i;
+ switch (x)
+ {
+ case 1:
+ #pragma omp barrier /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ case 1:
+ #pragma omp flush /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ case 1:
+ #pragma omp taskwait /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ case 1:
+ #pragma omp taskyield /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp parallel
+ {
+ switch (x)
+ {
+ case 1:
+ #pragma omp cancel parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ }
+ #pragma omp parallel
+ {
+ switch (x)
+ {
+ case 1:
+ #pragma omp cancellation point parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ }
+ #pragma omp for ordered(1)
+ for (i = 0; i < 16; i++)
+ {
+ switch (x)
+ {
+ case 1:
+ #pragma omp ordered depend(source) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ case 1:
+ #pragma omp ordered depend(sink: i-1) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ }
+ switch (x)
+ {
+ case 1:
+ #pragma omp target enter data map(to:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ case 1:
+ #pragma omp target update to(i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ case 1:
+ #pragma omp target exit data map(from:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+}
+
+void
+f7 (int x)
+{
+ int i;
+ switch (x)
+ {
+ default:
+ #pragma omp barrier /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ default:
+ #pragma omp flush /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ default:
+ #pragma omp taskwait /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ default:
+ #pragma omp taskyield /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp parallel
+ {
+ switch (x)
+ {
+ default:
+ #pragma omp cancel parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ }
+ #pragma omp parallel
+ {
+ switch (x)
+ {
+ default:
+ #pragma omp cancellation point parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ }
+ #pragma omp for ordered(1)
+ for (i = 0; i < 16; i++)
+ {
+ switch (x)
+ {
+ default:
+ #pragma omp ordered depend(source) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ default:
+ #pragma omp ordered depend(sink: i-1) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ }
+ switch (x)
+ {
+ default:
+ #pragma omp target enter data map(to:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ default:
+ #pragma omp target update to(i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ switch (x)
+ {
+ default:
+ #pragma omp target exit data map(from:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+}
+
+void
+f8 (int x)
+{
+ int i;
+ lab1:
+ #pragma omp barrier /* { dg-error "may only be used in compound statements" } */
+ ;
+ lab2:
+ #pragma omp flush /* { dg-error "may only be used in compound statements" } */
+ ;
+ lab3:
+ #pragma omp taskwait /* { dg-error "may only be used in compound statements" } */
+ ;
+ lab4:
+ #pragma omp taskyield /* { dg-error "may only be used in compound statements" } */
+ ;
+ #pragma omp parallel
+ {
+ lab5:
+ #pragma omp cancel parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp parallel
+ {
+ lab6:
+ #pragma omp cancellation point parallel /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ #pragma omp for ordered(1)
+ for (i = 0; i < 16; i++)
+ {
+ lab7:
+ #pragma omp ordered depend(source) /* { dg-error "may only be used in compound statements" } */
+ ;
+ lab8:
+ #pragma omp ordered depend(sink: i-1) /* { dg-error "may only be used in compound statements" } */
+ ;
+ }
+ lab9:
+ #pragma omp target enter data map(to:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ lab10:
+ #pragma omp target update to(i) /* { dg-error "may only be used in compound statements" } */
+ ;
+ lab11:
+ #pragma omp target exit data map(from:i) /* { dg-error "may only be used in compound statements" } */
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/pr64769.c b/gcc/testsuite/c-c++-common/gomp/pr64769.c
new file mode 100644
index 0000000000..3a301495f0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr64769.c
@@ -0,0 +1,9 @@
+/* PR tree-optimization/64769 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp-simd" } */
+
+#pragma omp declare simd linear(i)
+void
+foo (int i)
+{
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/pr67521.c b/gcc/testsuite/c-c++-common/gomp/pr67521.c
index b34c117ae3..5984fa9c3b 100644
--- a/gcc/testsuite/c-c++-common/gomp/pr67521.c
+++ b/gcc/testsuite/c-c++-common/gomp/pr67521.c
@@ -7,14 +7,14 @@ foo (int x)
{
int i = 0;
#pragma omp parallel for simd
- for (i = (i & x); i < 10; i = i + 2)
+ for (i = (i & x); i < 10; i = i + 2) /* { dg-error "initializer expression refers to iteration variable" } */
;
i = 0;
#pragma omp parallel for simd
- for (i = 0; i < (i & x) + 10; i = i + 2)
+ for (i = 0; i < (i & x) + 10; i = i + 2) /* { dg-error "condition expression refers to iteration variable" } */
;
i = 0;
#pragma omp parallel for simd
- for (i = 0; i < 10; i = i + ((i & x) + 2))
+ for (i = 0; i < 10; i = i + ((i & x) + 2)) /* { dg-error "increment expression refers to iteration variable" } */
;
}
diff --git a/gcc/testsuite/c-c++-common/gomp/pr70550-1.c b/gcc/testsuite/c-c++-common/gomp/pr70550-1.c
new file mode 100644
index 0000000000..493d417599
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr70550-1.c
@@ -0,0 +1,81 @@
+/* PR middle-end/70550 */
+/* { dg-do compile } */
+/* { dg-additional-options "-Wuninitialized" } */
+
+#ifdef __SIZEOF_INT128__
+typedef __int128 T;
+#else
+typedef long long T;
+#endif
+
+void bar (T);
+#pragma omp declare target (bar)
+
+void
+foo (void)
+{
+ {
+ int i;
+ #pragma omp target defaultmap(tofrom:scalar) /* { dg-bogus "is used uninitialized in this function" } */
+ {
+ i = 26;
+ bar (i);
+ }
+ }
+ {
+ T j;
+ #pragma omp target defaultmap(tofrom:scalar) /* { dg-bogus "is used uninitialized in this function" } */
+ {
+ j = 37;
+ bar (j);
+ }
+ }
+ {
+ int i;
+ #pragma omp target /* { dg-bogus "is used uninitialized in this function" } */
+ {
+ i = 26;
+ bar (i);
+ }
+ }
+ {
+ T j;
+ #pragma omp target /* { dg-bogus "is used uninitialized in this function" } */
+ {
+ j = 37;
+ bar (j);
+ }
+ }
+ {
+ int i;
+ #pragma omp target firstprivate (i) /* { dg-warning "is used uninitialized in this function" } */
+ {
+ i = 26;
+ bar (i);
+ }
+ }
+ {
+ T j;
+ #pragma omp target firstprivate (j) /* { dg-warning "is used uninitialized in this function" } */
+ {
+ j = 37;
+ bar (j);
+ }
+ }
+ {
+ int i;
+ #pragma omp target private (i) /* { dg-bogus "is used uninitialized in this function" } */
+ {
+ i = 26;
+ bar (i);
+ }
+ }
+ {
+ T j;
+ #pragma omp target private (j) /* { dg-bogus "is used uninitialized in this function" } */
+ {
+ j = 37;
+ bar (j);
+ }
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/pr70550-2.c b/gcc/testsuite/c-c++-common/gomp/pr70550-2.c
new file mode 100644
index 0000000000..31c34da471
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr70550-2.c
@@ -0,0 +1,55 @@
+/* PR middle-end/70550 */
+/* { dg-do compile } */
+/* { dg-additional-options "-Wuninitialized" } */
+
+void bar (int);
+
+void
+foo (void)
+{
+ int i, j, k, l, m, n, o, p, q;
+ #pragma omp task /* { dg-bogus "is used uninitialized in this function" } */
+ {
+ i = 2;
+ bar (i);
+ }
+ #pragma omp taskloop /* { dg-bogus "is used uninitialized in this function" } */
+ for (j = 0; j < 10; j++)
+ {
+ k = 7;
+ bar (k);
+ }
+ #pragma omp task firstprivate (l) /* { dg-warning "is used uninitialized in this function" } */
+ {
+ l = 2;
+ bar (l);
+ }
+ #pragma omp taskloop firstprivate (m) /* { dg-warning "is used uninitialized in this function" } */
+ for (j = 0; j < 10; j++)
+ {
+ m = 7;
+ bar (m);
+ }
+ #pragma omp task shared (n) /* { dg-bogus "is used uninitialized in this function" } */
+ {
+ n = 2;
+ bar (n);
+ }
+ #pragma omp taskloop shared (o) /* { dg-bogus "is used uninitialized in this function" } */
+ for (j = 0; j < 10; j++)
+ {
+ o = 7;
+ bar (o);
+ }
+ #pragma omp task private (p) /* { dg-bogus "is used uninitialized in this function" } */
+ {
+ p = 2;
+ bar (p);
+ }
+ #pragma omp taskloop shared (q) /* { dg-bogus "is used uninitialized in this function" } */
+ for (j = 0; j < 10; j++)
+ {
+ q = 7;
+ bar (q);
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/priority-1.c b/gcc/testsuite/c-c++-common/gomp/priority-1.c
new file mode 100644
index 0000000000..e2eebf9147
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/priority-1.c
@@ -0,0 +1,26 @@
+void bar (void);
+
+void
+foo (int x, unsigned long long y)
+{
+ #pragma omp task
+ bar ();
+ #pragma omp taskloop
+ for (int i = 0; i < 10; i++)
+ bar ();
+ #pragma omp task
+ bar ();
+ #pragma omp taskloop
+ for (unsigned long long int i = 0; i < y; i++)
+ bar ();
+ #pragma omp task priority (1)
+ bar ();
+ #pragma omp taskloop priority (1)
+ for (int i = 0; i < 10; i++)
+ bar ();
+ #pragma omp task priority (x + 1)
+ bar ();
+ #pragma omp taskloop priority (x + 1)
+ for (unsigned long long int i = 0; i < y; i++)
+ bar ();
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/reduction-1.c b/gcc/testsuite/c-c++-common/gomp/reduction-1.c
new file mode 100644
index 0000000000..e8dd530b1a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/reduction-1.c
@@ -0,0 +1,59 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void bar (int a[10][10][10]);
+extern int f[][2]; /* { dg-error "has incomplete type" "" { target c++ } } */
+extern int g[]; /* { dg-error "has incomplete type" "" { target c++ } } */
+void
+foo (int a[10][10][10], int **b, int x)
+{
+ int c[10][10][0];
+ int d[0];
+ char e[12];
+ #pragma omp parallel reduction(+: a[:4][:0][:7]) /* { dg-error "zero length array section" } */
+ bar (a);
+ #pragma omp parallel reduction(+: b[:7][0:0][:0]) /* { dg-error "zero length array section" } */
+ bar (a);
+ #pragma omp parallel reduction(+: c[:][:][0:]) /* { dg-error "zero length array section|for unknown bound array type length expression must be specified" } */
+ bar (a);
+ #pragma omp parallel reduction(+: a[:4][:0][:x]) /* { dg-error "zero length array section" } */
+ bar (a);
+ #pragma omp parallel reduction(+: b[:x][0:0][:0]) /* { dg-error "zero length array section" } */
+ bar (a);
+ #pragma omp parallel reduction(+: c[:][:x][0:]) /* { dg-error "zero length array section|for unknown bound array type length expression must be specified" } */
+ bar (a);
+ #pragma omp parallel reduction(+: d) /* { dg-error "is a zero size array" } */
+ bar (a);
+ #pragma omp parallel reduction(+: a[0:4])
+ bar (a);
+ #pragma omp parallel reduction(+: a[2:4])
+ bar (a);
+ #pragma omp parallel reduction(+: e[2:4])
+ bar (a);
+ #pragma omp parallel reduction(+: a[x:4])
+ bar (a);
+ #pragma omp parallel reduction(+: e[x:4])
+ bar (a);
+ #pragma omp parallel reduction(+: a[x:x])
+ bar (a);
+ #pragma omp parallel reduction(+: e[x:x])
+ bar (a);
+ #pragma omp parallel reduction(+: a[0.5:2]) /* { dg-error "low bound \[^\n\r]* of array section does not have integral type" } */
+ bar (a);
+ #pragma omp parallel reduction(+: a[0:2.5]) /* { dg-error "length \[^\n\r]* of array section does not have integral type" } */
+ bar (a);
+ #pragma omp parallel reduction(+: f[:][0:2]) /* { dg-error "for unknown bound array type length expression must be specified" } */
+ bar (a);
+ #pragma omp parallel reduction(+: a[:][0:10]) /* { dg-error "for pointer type length expression must be specified" } */
+ bar (a);
+ #pragma omp parallel reduction(+: a[:10][0:12]) /* { dg-error "above array section size" } */
+ bar (a);
+ #pragma omp parallel reduction(+: b[0:10][0:10]) /* { dg-error "array section is not contiguous" } */
+ bar (a);
+ #pragma omp parallel reduction(+: a[0:2][0:9]) /* { dg-error "array section is not contiguous" } */
+ bar (a);
+ #pragma omp parallel reduction(+: f) /* { dg-error "has an incomplete type|invalid use of array with unspecified bounds" } */
+ bar (a);
+ #pragma omp parallel reduction(+: g) /* { dg-error "has an incomplete type|invalid use of array with unspecified bounds" } */
+ bar (a);
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/schedule-modifiers-1.c b/gcc/testsuite/c-c++-common/gomp/schedule-modifiers-1.c
new file mode 100644
index 0000000000..7edea1b147
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/schedule-modifiers-1.c
@@ -0,0 +1,109 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (void)
+{
+ int i;
+ #pragma omp for simd schedule (simd, simd: static, 5)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for simd schedule (monotonic, simd: static)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for simd schedule (simd , monotonic : static, 6)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (monotonic, monotonic : static, 7)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (nonmonotonic, nonmonotonic : dynamic)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for simd schedule (nonmonotonic , simd : dynamic, 3)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for simd schedule (nonmonotonic,simd:guided,4)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (monotonic: static, 2)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (monotonic : static)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (monotonic : dynamic)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (monotonic : dynamic, 3)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (monotonic : guided)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (monotonic : guided, 7)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (monotonic : runtime)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (monotonic : auto)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (nonmonotonic : dynamic)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (nonmonotonic : dynamic, 3)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (nonmonotonic : guided)
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (nonmonotonic : guided, 7)
+ for (i = 0; i < 64; i++)
+ ;
+}
+
+void
+bar (void)
+{
+ int i;
+ #pragma omp for schedule (nonmonotonic: static, 2) /* { dg-error ".nonmonotonic. modifier specified for .static. schedule kind" } */
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (nonmonotonic : static) /* { dg-error ".nonmonotonic. modifier specified for .static. schedule kind" } */
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (nonmonotonic : runtime) /* { dg-error ".nonmonotonic. modifier specified for .runtime. schedule kind" } */
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (nonmonotonic : auto) /* { dg-error ".nonmonotonic. modifier specified for .auto. schedule kind" } */
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (nonmonotonic, dynamic) ordered /* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
+ for (i = 0; i < 64; i++)
+ #pragma omp ordered
+ ;
+ #pragma omp for ordered schedule(nonmonotonic, dynamic, 5) /* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
+ for (i = 0; i < 64; i++)
+ #pragma omp ordered
+ ;
+ #pragma omp for schedule (nonmonotonic, guided) ordered(1) /* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered depend(sink: i - 1)
+ #pragma omp ordered depend(source)
+ }
+ #pragma omp for ordered(1) schedule(nonmonotonic, guided, 2) /* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
+ for (i = 0; i < 64; i++)
+ {
+ #pragma omp ordered depend(source)
+ #pragma omp ordered depend(sink: i - 1)
+ }
+ #pragma omp for schedule (nonmonotonic , monotonic : dynamic) /* { dg-error "both .monotonic. and .nonmonotonic. modifiers specified" } */
+ for (i = 0; i < 64; i++)
+ ;
+ #pragma omp for schedule (monotonic,nonmonotonic:dynamic) /* { dg-error "both .monotonic. and .nonmonotonic. modifiers specified" } */
+ for (i = 0; i < 64; i++)
+ ;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/schedule-simd-1.c b/gcc/testsuite/c-c++-common/gomp/schedule-simd-1.c
new file mode 100644
index 0000000000..e6a7bb92fc
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/schedule-simd-1.c
@@ -0,0 +1,51 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -O2" } */
+/* { dg-additional-options "-mavx512f" { target { x86_64-*-* i?86-*-* } } } */
+
+#define N 1024
+int a[N], b[N], c[N];
+
+void
+f1 (void)
+{
+ int i;
+ #pragma omp parallel for simd schedule (simd:static)
+ for (i = 0; i < N; i++)
+ a[i] = b[i] + c[i];
+}
+
+void
+f2 (void)
+{
+ int i;
+ #pragma omp parallel for simd schedule (simd: static, 7)
+ for (i = 0; i < N; i++)
+ a[i] = b[i] + c[i];
+}
+
+void
+f3 (void)
+{
+ int i;
+ #pragma omp parallel for simd schedule (simd : dynamic, 7)
+ for (i = 0; i < N; i++)
+ a[i] = b[i] + c[i];
+}
+
+void
+f4 (void)
+{
+ int i;
+ #pragma omp parallel for simd schedule ( simd:runtime)
+ for (i = 0; i < N; i++)
+ a[i] = b[i] + c[i];
+}
+
+void
+f5 (void)
+{
+ int i;
+ #pragma omp parallel for simd schedule (simd:auto)
+ for (i = 0; i < N; i++)
+ a[i] = b[i] + c[i];
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/sink-1.c b/gcc/testsuite/c-c++-common/gomp/sink-1.c
new file mode 100644
index 0000000000..4872a07231
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/sink-1.c
@@ -0,0 +1,96 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -Wunknown-pragmas -Werror" } */
+
+extern void bark (void);
+int i,j,k;
+int array[555];
+
+int
+main()
+{
+#pragma omp parallel for ordered(2)
+ for (i=0; i < 100; ++i)
+ for (j=0; j < 100; ++j)
+ {
+/* OUT variant does not apply to ORDERED construct. */
+#pragma omp ordered depend(out:i) /* { dg-error "invalid depend kind" } */
+
+/* depend(sink...) is allowed without an offset. */
+#pragma omp ordered depend(sink:i,j-1)
+
+#pragma omp ordered depend(sink:i-1,j+2)
+ bark ();
+ }
+
+/* depend(sink...) does not apply to `omp task'. */
+#pragma omp task depend(sink:i+3) /* { dg-error "only allowed in 'omp ordered'" } */
+ bark();
+
+#pragma omp ordered depend(source) /* { dg-error "'depend' clause must be closely nested" } */
+
+#pragma omp parallel for ordered(2)
+ for (i=0; i < 100; ++i)
+ for (j=0; j < 100; ++j)
+ {
+/* Multiple depend(source) allowed. */
+#pragma omp ordered depend(source)
+#pragma omp ordered depend(source)
+ }
+
+#pragma omp parallel for ordered(2)
+ for (i=0; i < 100; ++i)
+ for (j=0; j < 100; ++j)
+ {
+#pragma omp ordered depend(sink:i-2,j-2,k+2) /* { dg-error "does not match number of iteration var" } */
+ bark();
+ }
+
+#pragma omp parallel for ordered(2)
+ for (i=0; i < 100; ++i)
+ for (j=0; j < 100; ++j)
+ {
+#pragma omp ordered depend(sink:i-2) /* { dg-error "does not match number of iteration variables" } */
+ bark();
+ }
+
+#pragma omp parallel for ordered(2)
+ for (i=0; i < 100; ++i)
+ for (j=0; j < 100; ++j)
+ {
+#pragma omp ordered depend(sink:k,i) /* { dg-error "is not an iteration" } */
+ bark();
+ }
+}
+
+void bar (int, int, int);
+
+void
+foo (int n, int m, int o)
+{
+ int i, j, k;
+ #pragma omp for collapse(2) ordered(3)
+ for (i = 0; i < m; i++)
+ {
+ for (j = 0; j < n; j++)
+ for (k = 0; k < o; k++)
+ {
+#pragma omp ordered depend(sink: i-1,j,k) depend(sink: i,j-1,k-1) depend(sink: i-1,j-1,k+1)
+ bar (i, j, k);
+#pragma omp ordered depend(source)
+ }
+ }
+}
+
+int
+baz ()
+{
+ int i, j;
+#pragma omp parallel for ordered(2)
+ for (i=0; i < 100; ++i)
+ for (j=0; j < 100; ++j)
+ {
+#pragma omp ordered depend(sink:i-1,j-3)
+ bar (i, j, 0);
+#pragma omp ordered depend(source)
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/sink-2.c b/gcc/testsuite/c-c++-common/gomp/sink-2.c
new file mode 100644
index 0000000000..e781a6fd94
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/sink-2.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+void bar (int *);
+
+void
+foo ()
+{
+ int i,j;
+#pragma omp parallel for ordered(1)
+ for (i=0; i < 100; ++i)
+ {
+#pragma omp ordered depend(sink:i-1)
+ bar(&i);
+#pragma omp ordered depend(source)
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/sink-3.c b/gcc/testsuite/c-c++-common/gomp/sink-3.c
new file mode 100644
index 0000000000..7cb16ed0f7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/sink-3.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+/* Test that we can handle multiple undeclared sink variables
+ gracefully. */
+
+void bar (int *);
+
+void
+foo ()
+{
+ int i,j;
+#pragma omp parallel for ordered(1)
+ for (i=0; i < 100; ++i)
+ {
+#pragma omp ordered depend(sink:poo-1,paa+1) /* { dg-error "poo.*declared.*paa.*declared" } */
+ bar(&i);
+#pragma omp ordered depend(source)
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/sink-4.c b/gcc/testsuite/c-c++-common/gomp/sink-4.c
new file mode 100644
index 0000000000..11b6d9973c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/sink-4.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -fdump-tree-omplower" } */
+
+/* Test that we adjust pointer offsets for sink variables
+ correctly. */
+
+typedef struct {
+ char stuff[400];
+} foo;
+
+void
+funk (foo *begin, foo *end)
+{
+ foo *p;
+#pragma omp parallel for ordered(1)
+ for (p=end; p > begin; p--)
+ {
+#pragma omp ordered depend(sink:p+1)
+ void bar ();
+ bar();
+#pragma omp ordered depend(source)
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "depend\\(sink:p\\+400\\)" 1 "omplower" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/target-teams-1.c b/gcc/testsuite/c-c++-common/gomp/target-teams-1.c
new file mode 100644
index 0000000000..51b8d48856
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/target-teams-1.c
@@ -0,0 +1,85 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fdump-tree-gimple" } */
+
+int v = 6;
+void bar (int);
+void bar2 (int, long *, long *);
+int baz (void);
+#pragma omp declare target to (bar, baz, v)
+
+void
+foo (int a, int b, long c, long d)
+{
+ /* The OpenMP 4.5 spec says that these expressions are evaluated before
+ target region on combined target teams, so those cases are always
+ fine. */
+ #pragma omp target
+ bar (0);
+ #pragma omp target
+ #pragma omp teams
+ bar (1);
+ #pragma omp target teams
+ bar (2);
+ #pragma omp target
+ #pragma omp teams num_teams (4)
+ bar (3);
+ #pragma omp target teams num_teams (4)
+ bar (4);
+ #pragma omp target
+ #pragma omp teams thread_limit (7)
+ bar (5);
+ #pragma omp target teams thread_limit (7)
+ bar (6);
+ #pragma omp target
+ #pragma omp teams num_teams (4) thread_limit (8)
+ {
+ {
+ bar (7);
+ }
+ }
+ #pragma omp target teams num_teams (4) thread_limit (8)
+ bar (8);
+ #pragma omp target
+ #pragma omp teams num_teams (a) thread_limit (b)
+ bar (9);
+ #pragma omp target teams num_teams (a) thread_limit (b)
+ bar (10);
+ #pragma omp target
+ #pragma omp teams num_teams (c + 1) thread_limit (d - 1)
+ bar (11);
+ #pragma omp target teams num_teams (c + 1) thread_limit (d - 1)
+ bar (12);
+ #pragma omp target map (always, to: c, d)
+ #pragma omp teams num_teams (c + 1) thread_limit (d - 1)
+ bar (13);
+ #pragma omp target data map (to: c, d)
+ {
+ #pragma omp target defaultmap (tofrom: scalar)
+ bar2 (14, &c, &d);
+ /* This is one of the cases which can't be generally optimized,
+ the c and d are (or could be) already mapped and whether
+ their device and original values match is unclear. */
+ #pragma omp target map (to: c, d)
+ #pragma omp teams num_teams (c + 1) thread_limit (d - 1)
+ bar (15);
+ }
+ /* This can't be optimized, there are function calls inside of
+ target involved. */
+ #pragma omp target
+ #pragma omp teams num_teams (baz () + 1) thread_limit (baz () - 1)
+ bar (16);
+ #pragma omp target teams num_teams (baz () + 1) thread_limit (baz () - 1)
+ bar (17);
+ /* This one can't be optimized, as v might have different value between
+ host and target. */
+ #pragma omp target
+ #pragma omp teams num_teams (v + 1) thread_limit (v - 1)
+ bar (18);
+}
+
+/* { dg-final { scan-tree-dump-times "num_teams\\(-1\\)" 3 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "thread_limit\\(-1\\)" 3 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "num_teams\\(0\\)" 4 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "thread_limit\\(0\\)" 6 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "num_teams\\(1\\)" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "thread_limit\\(1\\)" 0 "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/udr-1.c b/gcc/testsuite/c-c++-common/gomp/udr-1.c
new file mode 100644
index 0000000000..7c50ff6f9b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/udr-1.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+struct S {};
+void foo (void *, void *);
+void bar (void *, void *);
+void baz (void *);
+#pragma omp declare reduction(+:struct S:foo (&omp_out, &omp_in))initializer(bar(&omp_priv, &omp_orig))
+
+void
+test (void)
+{
+ struct S a, b[10];
+ #pragma omp parallel reduction(+:a)
+ baz (&a);
+}
diff --git a/gcc/testsuite/c-c++-common/nonnull-1.c b/gcc/testsuite/c-c++-common/nonnull-1.c
new file mode 100644
index 0000000000..2446d6fbcf
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/nonnull-1.c
@@ -0,0 +1,34 @@
+/* Test for the bad usage of "nonnull" function attribute parms. */
+/* */
+/* { dg-do compile } */
+/* { dg-options "-Wnonnull-compare" } */
+
+#include <stddef.h>
+#include <stdlib.h>
+
+void foo(void *bar) __attribute__((nonnull(1)));
+
+void foo(void *bar) { if (!bar) abort(); } /* { dg-warning "nonnull argument" "bar compared to NULL" } */
+
+extern int func (char *, char *, char *, char *) __attribute__((nonnull));
+
+int
+func (char *cp1, char *cp2, char *cp3, char *cp4)
+{
+ if (cp1) /* { dg-warning "nonnull argument" "cp1 compared to NULL" } */
+ return 1;
+
+ if (cp2 == NULL) /* { dg-warning "nonnull argument" "cp2 compared to NULL" } */
+ return 2;
+
+ if (NULL != cp3) /* { dg-warning "nonnull argument" "cp3 compared to NULL" } */
+ return 3;
+
+ return cp4 != 0 ? 0 : 1; /* { dg-warning "nonnull argument" "cp4 compared to NULL" } */
+}
+
+__attribute__((nonnull (1))) int
+func2 (char *cp)
+{
+ return (cp != NULL) ? 1 : 0; /* { dg-warning "nonnull argument" "cp compared to NULL" { xfail c++ } } */
+}
diff --git a/gcc/testsuite/c-c++-common/nonnull-2.c b/gcc/testsuite/c-c++-common/nonnull-2.c
new file mode 100644
index 0000000000..ebd17a21f0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/nonnull-2.c
@@ -0,0 +1,26 @@
+/* Test for the bad usage of "nonnull" function attribute parms. */
+/* { dg-do compile } */
+/* { dg-options "-Wnonnull-compare" } */
+
+void bar (char **);
+
+__attribute__((nonnull (1, 3))) int
+foo (char *cp1, char *cp2, char *cp3, char *cp4)
+{
+ if (cp1 == (char *) 0) /* { dg-warning "nonnull argument" "cp1 compared to NULL" } */
+ return 1;
+
+ cp1 = cp2;
+ if (cp1 == (char *) 0) /* { dg-bogus "nonnull argument" } */
+ return 2;
+
+ if (!cp4) /* { dg-bogus "nonnull argument" } */
+ return 3;
+
+ char **p = &cp3;
+ bar (p);
+ if (cp3 == (char *) 0) /* { dg-bogus "nonnull argument" } */
+ return 4;
+
+ return 5;
+}
diff --git a/gcc/testsuite/c-c++-common/pr46562-2.c b/gcc/testsuite/c-c++-common/pr46562-2.c
index e64432c27d..3c64404017 100644
--- a/gcc/testsuite/c-c++-common/pr46562-2.c
+++ b/gcc/testsuite/c-c++-common/pr46562-2.c
@@ -10,4 +10,3 @@ int foo(void)
}
/* { dg-final { scan-tree-dump "return 0;" "fre1" } } */
-/* { dg-final { cleanup-tree-dump "fre1" } } */
diff --git a/gcc/testsuite/c-c++-common/pr46562.c b/gcc/testsuite/c-c++-common/pr46562.c
index 30659070f0..c6b85748d8 100644
--- a/gcc/testsuite/c-c++-common/pr46562.c
+++ b/gcc/testsuite/c-c++-common/pr46562.c
@@ -10,4 +10,3 @@ int foo(void)
}
/* { dg-final { scan-tree-dump "return 0;" "ccp1" } } */
-/* { dg-final { cleanup-tree-dump "ccp1" } } */
diff --git a/gcc/testsuite/c-c++-common/pr56493.c b/gcc/testsuite/c-c++-common/pr56493.c
index 4181260430..aa7f6f4fc2 100644
--- a/gcc/testsuite/c-c++-common/pr56493.c
+++ b/gcc/testsuite/c-c++-common/pr56493.c
@@ -13,4 +13,3 @@ foo (void)
/* Verify we narrow the addition from unsigned long long to unsigned int type. */
/* { dg-final { scan-tree-dump " (\[a-zA-Z._0-9]*) = \\(unsigned int\\) \[^;\n\r]*;.* (\[a-zA-Z._0-9]*) = \\(unsigned int\\) \[^;\n\r]*;.* = \\1 \\+ \\2;" "gimple" { target { ilp32 || lp64 } } } } */
-/* { dg-final { cleanup-tree-dump "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/pr58346-1.c b/gcc/testsuite/c-c++-common/pr58346-1.c
index 371fcf4845..70a16d12d9 100644
--- a/gcc/testsuite/c-c++-common/pr58346-1.c
+++ b/gcc/testsuite/c-c++-common/pr58346-1.c
@@ -1,5 +1,6 @@
/* PR c/58346 */
/* { dg-do compile } */
+/* { dg-options "-Wno-c++-compat" { target c } } */
struct U {
#ifdef __cplusplus
diff --git a/gcc/testsuite/c-c++-common/pr60439.c b/gcc/testsuite/c-c++-common/pr60439.c
index 3368a0b944..68bd33c22c 100644
--- a/gcc/testsuite/c-c++-common/pr60439.c
+++ b/gcc/testsuite/c-c++-common/pr60439.c
@@ -1,5 +1,6 @@
/* PR c/60439 */
/* { dg-do compile } */
+/* { dg-prune-output "case label value exceeds" } */
#ifndef __cplusplus
# define bool _Bool
@@ -11,18 +12,30 @@ void
f1 (bool b)
{
switch (b) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
}
void
f2 (int a, int b)
{
switch (a && b) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch ((bool) (a && b)) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch ((a && b) || a) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
/* No warnings on following. */
switch ((int) (a && b))
break;
@@ -38,35 +51,65 @@ void
f3 (int a)
{
switch (!!a) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch (!a) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
}
void
f4 (void)
{
switch (foo ()) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
}
void
f5 (int a)
{
switch (a == 3) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch (a != 3) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch (a > 3) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch (a < 3) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch (a <= 3) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch (a >= 3) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch (foo (), foo (), a >= 42) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch (a == 3, a & 4, a ^ 5, a)
break;
switch ((int) (a == 3))
@@ -79,11 +122,20 @@ void
f6 (bool b)
{
switch (b) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch (!b) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
switch (b++) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
}
void
@@ -91,7 +143,10 @@ f7 (void)
{
bool b;
switch (b = 1) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 3:
+ break;
+ }
}
void
@@ -104,5 +159,8 @@ f8 (int i)
switch ((unsigned int) i)
break;
switch ((bool) i) /* { dg-warning "switch condition has" } */
- break;
+ {
+ case 11:
+ break;
+ }
}
diff --git a/gcc/testsuite/c-c++-common/pr61534-1.c b/gcc/testsuite/c-c++-common/pr61534-1.c
new file mode 100644
index 0000000000..1e304f0bdf
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr61534-1.c
@@ -0,0 +1,13 @@
+/* PR c/61534 */
+/* { dg-options "-Wlogical-op" } */
+
+extern int xxx;
+#define XXX !xxx
+int
+test (void)
+{
+ if (XXX && xxx) /* { dg-bogus "logical" } */
+ return 4;
+ else
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/pr65830.c b/gcc/testsuite/c-c++-common/pr65830.c
new file mode 100644
index 0000000000..e115f18127
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr65830.c
@@ -0,0 +1,16 @@
+/* PR c/65830 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wno-shift-count-negative -Wno-shift-count-overflow" } */
+
+int
+foo (int x)
+{
+ const int a = sizeof (int) * __CHAR_BIT__;
+ const int b = -7;
+ int c = 0;
+ c += x << a; /* { dg-bogus "left shift count >= width of type" } */
+ c += x << b; /* { dg-bogus "left shift count is negative" } */
+ c += x >> a; /* { dg-bogus "right shift count >= width of type" } */
+ c += x >> b; /* { dg-bogus "right shift count is negative" } */
+ return c;
+}
diff --git a/gcc/testsuite/c-c++-common/pr66208.c b/gcc/testsuite/c-c++-common/pr66208.c
new file mode 100644
index 0000000000..d394c42b76
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr66208.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-Wnonnull" } */
+
+void foox (char*, ...) __attribute__ ((nonnull (1)));
+#define foo(p) foox (p, "p is null") /* { dg-warning "null argument" } */
+
+void baz (void)
+{
+ foo (0); /* { dg-message "note: in expansion" } */
+}
diff --git a/gcc/testsuite/c-c++-common/pr66322.c b/gcc/testsuite/c-c++-common/pr66322.c
new file mode 100644
index 0000000000..eb1e9e4a2e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr66322.c
@@ -0,0 +1,144 @@
+/* PR c/66322 */
+/* { dg-do compile } */
+
+#ifndef __cplusplus
+# define bool _Bool
+# define true 1
+# define false 0
+#endif
+
+void
+nowarn (bool b)
+{
+ switch (b)
+ ;
+
+ switch (b)
+ {
+ case true:
+ case false:
+ break;
+ }
+
+ switch (b)
+ {
+ case true:
+ break;
+ }
+
+ switch (b)
+ {
+ case true:
+ default:
+ break;
+ }
+
+ switch (b)
+ {
+ case false:
+ break;
+ }
+
+ switch (b)
+ {
+ case false:
+ default:
+ break;
+ }
+
+ switch (b)
+ {
+ default:
+ break;
+ }
+
+ switch (b)
+ {
+ case false ... true:
+ break;
+ }
+
+ switch (b)
+ {
+ case 1:
+ switch (b)
+ {
+ case true:
+ default:
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+void
+warn (bool b)
+{
+ switch (b) /* { dg-warning "switch condition has" } */
+ {
+ case true:
+ case false:
+ default:
+ break;
+ }
+
+ switch (b) /* { dg-warning "switch condition has" } */
+ {
+ case false ... true:
+ default:
+ break;
+ }
+}
+
+void
+warn2 (int n)
+{
+ switch (n == 2) /* { dg-warning "switch condition has" } */
+ {
+ case 0 ... 2: /* { dg-warning "upper value" "" { target c++ } } */
+ default:
+ break;
+ }
+
+ switch (n == 2) /* { dg-warning "switch condition has" } */
+ {
+ case 1 ... 10: /* { dg-warning "upper value" "" { target c++ } } */
+ default:
+ break;
+ }
+
+ switch (n == 2) /* { dg-warning "switch condition has" } */
+ {
+ case 2: /* { dg-warning "case label" "" { target c++ } } */
+ break;
+ }
+
+ switch (n == 2) /* { dg-warning "switch condition has" } */
+ {
+ case 0:
+ case 1:
+ case -1: /* { dg-warning "case label" "" { target c++ } } */
+ break;
+ }
+
+ switch (n == 2) /* { dg-warning "switch condition has" } */
+ {
+ case -1 ... 1: /* { dg-warning "lower value" "" { target c++ } } */
+ break;
+ }
+
+ switch (n == 2) /* { dg-warning "switch condition has" } */
+ {
+ case -1 ... 0: /* { dg-warning "lower value" "" { target c++ } } */
+ default:
+ break;
+ }
+
+ switch (n == 2) /* { dg-warning "switch condition has" } */
+ {
+ case -10 ... -1: /* { dg-warning "case label" "" { target c++ } } */
+ default:
+ break;
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/pr67639.c b/gcc/testsuite/c-c++-common/pr67639.c
new file mode 100644
index 0000000000..aa19ba4eda
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr67639.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+void
+foo (int p)
+{
+ int t;
+ register long x asm ("rhubarb") = p; /* { dg-error "register name" } */
+ __asm ("" : "=r" (t), "=r" (t), "=r" (t), "=r" (x) : "0" (x));
+}
diff --git a/gcc/testsuite/c-c++-common/pr67653.c b/gcc/testsuite/c-c++-common/pr67653.c
new file mode 100644
index 0000000000..1b9f63ec62
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr67653.c
@@ -0,0 +1,8 @@
+/* PR middle-end/67653 */
+/* { dg-do compile } */
+
+void
+foo (void)
+{
+ __asm__ ("" : : "m" (({ static int a; a; }))); /* { dg-warning "memory input 0 is not directly addressable" } */
+}
diff --git a/gcc/testsuite/c-c++-common/pr68107.c b/gcc/testsuite/c-c++-common/pr68107.c
new file mode 100644
index 0000000000..f1ed465e07
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr68107.c
@@ -0,0 +1,37 @@
+/* PR c/68107 */
+/* { dg-do compile } */
+
+#define N ((__SIZE_MAX__ / sizeof (int)) / 2 + 1)
+
+typedef int (*T1)[N]; /* { dg-error "too large" } */
+typedef int (*T2)[N - 1];
+typedef int (*T3)[N][N]; /* { dg-error "too large" } */
+typedef int (*T4)[N - 1][N - 1]; /* { dg-error "too large" } */
+typedef int (**T5)[N]; /* { dg-error "too large" } */
+
+struct S {
+ int (*q1)[N]; /* { dg-error "too large" } */
+ int (*q2)[N - 1];
+ int (*q3)[N][N]; /* { dg-error "too large" } */
+ int (*q4)[N - 1][N - 1]; /* { dg-error "too large" } */
+ int (**q5)[N]; /* { dg-error "too large" } */
+};
+
+void fn1 (int (*p1)[N]); /* { dg-error "too large" } */
+void fn2 (int (*p1)[N - 1]);
+void fn3 (int (*p3)[N][N]); /* { dg-error "too large" } */
+void fn4 (int (*p4)[N - 1][N - 1]); /* { dg-error "too large" } */
+void fn5 (int (**p5)[N]); /* { dg-error "too large" } */
+
+void
+fn (void)
+{
+ int (*n1)[N]; /* { dg-error "too large" } */
+ int (*n2)[N - 1];
+ int (*n3)[N][N]; /* { dg-error "too large" } */
+ int (*n4)[N - 1][N - 1]; /* { dg-error "too large" } */
+ int (**n5)[N]; /* { dg-error "too large" } */
+
+ sizeof (int (*)[N]); /* { dg-error "too large" } */
+ sizeof (int [N]); /* { dg-error "too large" } */
+}
diff --git a/gcc/testsuite/c-c++-common/pr68582.c b/gcc/testsuite/c-c++-common/pr68582.c
new file mode 100644
index 0000000000..95ca9a4f3b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr68582.c
@@ -0,0 +1,25 @@
+/* PR middle-end/68582 */
+/* { dg-do compile } */
+/* { dg-options "-Wunused-function" } */
+
+/* We failed to give the warning for functions with TREE_THIS_VOLATILE set. */
+
+static void
+fn1 (void) /* { dg-warning "defined but not used" } */
+{
+ __builtin_abort ();
+}
+
+__attribute__ ((noreturn))
+static void
+fn2 (void) /* { dg-warning "defined but not used" } */
+{
+ __builtin_abort ();
+}
+
+__attribute__ ((volatile))
+static void
+fn3 (void) /* { dg-warning "defined but not used" } */
+{
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/c-c++-common/pr68657-1.c b/gcc/testsuite/c-c++-common/pr68657-1.c
new file mode 100644
index 0000000000..3db6f49d00
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr68657-1.c
@@ -0,0 +1,26 @@
+/* PR c/68657 */
+/* { dg-options "-Werror=sign-conversion -Werror=float-conversion -Werror=frame-larger-than=65536" } */
+
+void
+f1 (void)
+{
+ unsigned int a = -5; /* { dg-error "negative integer implicitly converted to unsigned type" } */
+ (void) a;
+}
+
+int
+f2 (void)
+{
+ return 3.1f; /* { dg-error "conversion to 'int' alters 'float' constant value" } */
+}
+
+int f3 (char *);
+
+int
+f4 (void)
+{
+ char buf[131072];
+ return f3 (buf);
+} /* { dg-error "the frame size of 1\[0-9]* bytes is larger than 65536 bytes" } */
+
+/* { dg-prune-output "treated as errors" } */
diff --git a/gcc/testsuite/c-c++-common/pr68657-2.c b/gcc/testsuite/c-c++-common/pr68657-2.c
new file mode 100644
index 0000000000..9eb68ce38e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr68657-2.c
@@ -0,0 +1,8 @@
+/* PR c/68657 */
+/* { dg-do compile } */
+/* { dg-options "-Werror=larger-than=65536" } */
+
+int a[131072]; /* { dg-error "size of 'a' is \[1-9]\[0-9]* bytes" } */
+int b[1024]; /* { dg-bogus "size of 'b' is \[1-9]\[0-9]* bytes" } */
+
+/* { dg-prune-output "treated as errors" } */
diff --git a/gcc/testsuite/c-c++-common/pr68657-3.c b/gcc/testsuite/c-c++-common/pr68657-3.c
new file mode 100644
index 0000000000..84622fc2e6
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr68657-3.c
@@ -0,0 +1,13 @@
+/* PR c/68657 */
+/* { dg-do compile } */
+
+#pragma GCC diagnostic error "-Wlarger-than=65536"
+int a[131072]; /* { dg-error "size of 'a' is \[1-9]\[0-9]* bytes" } */
+int b[1024]; /* { dg-bogus "size of 'b' is \[1-9]\[0-9]* bytes" } */
+#pragma GCC diagnostic ignored "-Wlarger-than=65536"
+int c[131072]; /* { dg-bogus "size of 'c' is \[1-9]\[0-9]* bytes" } */
+int d[1024]; /* { dg-bogus "size of 'd' is \[1-9]\[0-9]* bytes" } */
+#pragma GCC diagnostic warning "-Wlarger-than=65536"
+int e[131072]; /* { dg-warning "size of 'e' is \[1-9]\[0-9]* bytes" } */
+int f[1024]; /* { dg-bogus "size of 'f' is \[1-9]\[0-9]* bytes" } */
+/* { dg-prune-output "treated as errors" } */
diff --git a/gcc/testsuite/c-c++-common/pr68833-1.c b/gcc/testsuite/c-c++-common/pr68833-1.c
new file mode 100644
index 0000000000..e0601b39ec
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr68833-1.c
@@ -0,0 +1,22 @@
+/* PR c/68833 */
+/* { dg-do compile } */
+/* { dg-options "-Werror=larger-than-65536 -Werror=format -Werror=missing-noreturn" } */
+
+int a[131072]; /* { dg-error "size of 'a' is \[1-9]\[0-9]* bytes" } */
+int b[1024]; /* { dg-bogus "size of 'b' is \[1-9]\[0-9]* bytes" } */
+
+void
+f1 (const char *fmt)
+{
+ __builtin_printf ("%d\n", 1.2); /* { dg-error "expects argument of type" } */
+ __builtin_printf (fmt, 1.2); /* { dg-bogus "format not a string literal, argument types not checked" } */
+}
+
+extern void f2 (void);
+void
+f2 (void) /* { dg-error "candidate for attribute 'noreturn'" "detect noreturn candidate" } */
+{
+ __builtin_exit (0);
+}
+
+/* { dg-prune-output "treated as errors" } */
diff --git a/gcc/testsuite/c-c++-common/pr68833-2.c b/gcc/testsuite/c-c++-common/pr68833-2.c
new file mode 100644
index 0000000000..c991b7a13c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr68833-2.c
@@ -0,0 +1,16 @@
+/* PR c/68833 */
+/* { dg-do compile } */
+/* { dg-options "-Werror=missing-format-attribute" } */
+
+#include <stdarg.h>
+
+void
+foo (const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ __builtin_vprintf (fmt, ap); /* { dg-error "candidate" "printf attribute warning" } */
+ va_end (ap);
+}
+
+/* { dg-prune-output "treated as errors" } */
diff --git a/gcc/testsuite/c-c++-common/pr68833-3.c b/gcc/testsuite/c-c++-common/pr68833-3.c
new file mode 100644
index 0000000000..c99a2c605a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr68833-3.c
@@ -0,0 +1,7 @@
+/* PR c/68833 */
+/* { dg-do preprocess } */
+/* { dg-options "-Werror=normalized" } */
+
+\u0F43 // { dg-error "`.U00000f43' is not in NFC .-Werror=normalized=." }
+
+/* { dg-prune-output "treated as errors" } */
diff --git a/gcc/testsuite/c-c++-common/pr69126-2-long.c b/gcc/testsuite/c-c++-common/pr69126-2-long.c
new file mode 100644
index 0000000000..f4f1964cba
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69126-2-long.c
@@ -0,0 +1,11 @@
+/* { dg-options "-Wdeprecated-declarations" } */
+
+/* The macro's name is >= 32 characters long, and hence its location
+ requires an ad-hoc location. */
+
+#define IGNORE_WHERE_MACRO_IS_LONGER_THAN_31_CHARS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+__attribute__((deprecated)) void f();
+int main() {
+ IGNORE_WHERE_MACRO_IS_LONGER_THAN_31_CHARS
+ f();
+}
diff --git a/gcc/testsuite/c-c++-common/pr69126-2-short.c b/gcc/testsuite/c-c++-common/pr69126-2-short.c
new file mode 100644
index 0000000000..aee43e552d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69126-2-short.c
@@ -0,0 +1,11 @@
+/* { dg-options "-Wdeprecated-declarations" } */
+
+/* IGNORE_SHORT_MACRO is < 32 characters long, and hence its location
+ can be stored without needing an ad-hoc location. */
+
+#define IGNORE_SHORT_MACRO _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+__attribute__((deprecated)) void f();
+int main() {
+ IGNORE_SHORT_MACRO
+ f();
+}
diff --git a/gcc/testsuite/c-c++-common/pr69126.c b/gcc/testsuite/c-c++-common/pr69126.c
new file mode 100644
index 0000000000..52c96ebe18
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69126.c
@@ -0,0 +1,79 @@
+/* { dg-options "-Wunused-variable" } */
+
+/* Verify that ignoring -Wunused-variable works, for various placements
+ of the variable and the _Pragma. */
+
+/* Test 1: the _Pragma is in a macro, but the affected code isn't. */
+
+#pragma GCC diagnostic push
+
+#define MACRO_1 \
+ _Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+
+int test_1()
+{
+ _Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+ int x;
+ return 0;
+}
+#pragma GCC diagnostic pop
+
+
+/* Test 2: neither the _Pragma nor the affected code are in a macro. */
+
+#pragma GCC diagnostic push
+int test_2()
+{
+ _Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+ int x;
+ return 0;
+}
+#pragma GCC diagnostic pop
+
+
+/* Test 3: the _Pragma isn't in a macro, but the affected code is. */
+
+#define MACRO_3 \
+ int x;
+
+#pragma GCC diagnostic push
+int test_3()
+{
+ _Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+ MACRO_3
+ return 0;
+}
+#pragma GCC diagnostic pop
+
+
+/* Test 4: the _Pragma and the affected code are in different macros. */
+
+#pragma GCC diagnostic push
+#define MACRO_4A \
+ _Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+
+#define MACRO_4B \
+ int x;
+
+int test_4()
+{
+ MACRO_4A;
+ MACRO_4B
+ return 0;
+}
+#pragma GCC diagnostic pop
+
+
+/* Test 5: both the _Pragma and the affected code are in the same macro. */
+
+#pragma GCC diagnostic push
+#define MACRO_5 \
+ _Pragma("GCC diagnostic ignored \"-Wunused-variable\"") \
+ int x;
+
+int test_5()
+{
+ MACRO_5;
+ return 0;
+}
+#pragma GCC diagnostic pop
diff --git a/gcc/testsuite/c-c++-common/pr69543-1.c b/gcc/testsuite/c-c++-common/pr69543-1.c
new file mode 100644
index 0000000000..bbf4759368
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69543-1.c
@@ -0,0 +1,19 @@
+/* { dg-options "-Wuninitialized" } */
+
+/* Verify disabling a warning, where the _Pragma is within
+ a macro, but the affected code is *not* in a macro. */
+
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
+ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
+ _Pragma ("GCC diagnostic pop")
+
+void test (char yylval)
+{
+ char *yyvsp;
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+ *++yyvsp = yylval;
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
+}
diff --git a/gcc/testsuite/c-c++-common/pr69543-2.c b/gcc/testsuite/c-c++-common/pr69543-2.c
new file mode 100644
index 0000000000..4099fb2555
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69543-2.c
@@ -0,0 +1,14 @@
+/* { dg-options "-Wuninitialized" } */
+
+/* Verify disabling a warning, where both the _Pragma and the
+ affected code are *not* in a macro. */
+
+void test (char yylval)
+{
+ char *yyvsp;
+ _Pragma ("GCC diagnostic push")
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
+ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+ *++yyvsp = yylval;
+ _Pragma ("GCC diagnostic pop")
+}
diff --git a/gcc/testsuite/c-c++-common/pr69543-3.c b/gcc/testsuite/c-c++-common/pr69543-3.c
new file mode 100644
index 0000000000..fcf750cc05
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69543-3.c
@@ -0,0 +1,20 @@
+/* { dg-options "-Wuninitialized" } */
+
+/* Verify disabling a warning, where the _Pragma is in regular code,
+ but the affected code is within a macro. */
+
+/* TODO: XFAIL: both C and C++ erroneously fail to suppress the warning
+ The warning is reported at the macro definition location, rather than
+ the macro expansion location. */
+
+#define WARNABLE_CODE *++yyvsp = yylval; /* { dg-bogus "used uninitialized" "" { xfail *-*-* } } */
+
+void test (char yylval)
+{
+ char *yyvsp; /* { dg-bogus "declared here" "" { xfail *-*-* } } */
+ _Pragma ("GCC diagnostic push")
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
+ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+ WARNABLE_CODE
+ _Pragma ("GCC diagnostic pop")
+}
diff --git a/gcc/testsuite/c-c++-common/pr69543-4.c b/gcc/testsuite/c-c++-common/pr69543-4.c
new file mode 100644
index 0000000000..cd71e7e118
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69543-4.c
@@ -0,0 +1,25 @@
+/* { dg-options "-Wuninitialized" } */
+
+/* Verify disabling a warning, where both the _Pragma and the
+ affected code are within (different) macros. */
+
+/* TODO: XFAIL: both C and C++ erroneously fail to suppress the warning
+ The warning is reported at the macro definition location, rather than
+ the macro expansion location. */
+
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
+ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
+ _Pragma ("GCC diagnostic pop")
+
+#define WARNABLE_CODE *++yyvsp = yylval; /* { dg-bogus "used uninitialized" "" { xfail *-*-* } } */
+
+void test (char yylval)
+{
+ char *yyvsp; /* { dg-bogus "declared here" "" { xfail *-*-* } } */
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+ WARNABLE_CODE
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
+}
diff --git a/gcc/testsuite/c-c++-common/pr69558-1.c b/gcc/testsuite/c-c++-common/pr69558-1.c
new file mode 100644
index 0000000000..57ac4904d3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69558-1.c
@@ -0,0 +1,21 @@
+/* PR c/69558 */
+/* { dg-do compile } */
+/* { dg-options "-Wdeprecated-declarations" } */
+
+/* Verify disabling -Wdeprecated-declarations, where the _Pragma is in a
+ macro, but the affected code is *not* in a macro. */
+
+#define A \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#define B \
+ _Pragma ("GCC diagnostic pop")
+
+__attribute__((deprecated)) void foo (void);
+
+void bar (void)
+{
+ A
+ foo ();
+ B
+}
diff --git a/gcc/testsuite/c-c++-common/pr69558-2.c b/gcc/testsuite/c-c++-common/pr69558-2.c
new file mode 100644
index 0000000000..83ae6470a3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69558-2.c
@@ -0,0 +1,16 @@
+/* PR c/69558 */
+/* { dg-do compile } */
+/* { dg-options "-Wdeprecated-declarations" } */
+
+/* Verify disabling -Wdeprecated-declarations, where neither the _Pragma nor
+ the affected code are in macros. */
+
+__attribute__((deprecated)) void foo (void);
+
+void bar (void)
+{
+ _Pragma ("GCC diagnostic push")
+ _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+ foo ();
+ _Pragma ("GCC diagnostic pop")
+}
diff --git a/gcc/testsuite/c-c++-common/pr69558-3.c b/gcc/testsuite/c-c++-common/pr69558-3.c
new file mode 100644
index 0000000000..45c38a9d9c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69558-3.c
@@ -0,0 +1,19 @@
+/* PR c/69558 */
+/* { dg-do compile } */
+/* { dg-options "-Wdeprecated-declarations" } */
+
+/* Verify disabling -Wdeprecated-declarations, where the _Pragma is not
+ in a macro, but the affected code *is*. */
+
+#define C \
+ foo ();
+
+__attribute__((deprecated)) void foo (void);
+
+void bar (void)
+{
+ _Pragma ("GCC diagnostic push")
+ _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+ C
+ _Pragma ("GCC diagnostic pop")
+}
diff --git a/gcc/testsuite/c-c++-common/pr69558-4.c b/gcc/testsuite/c-c++-common/pr69558-4.c
new file mode 100644
index 0000000000..02d526e09b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69558-4.c
@@ -0,0 +1,23 @@
+/* PR c/69558 */
+/* { dg-do compile } */
+/* { dg-options "-Wdeprecated-declarations" } */
+
+/* Verify disabling -Wdeprecated-declarations, where the _Pragma and the
+ affected code are in different macros. */
+
+#define A \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#define B \
+ _Pragma ("GCC diagnostic pop")
+#define C \
+ foo ();
+
+__attribute__((deprecated)) void foo (void);
+
+void bar (void)
+{
+ A
+ C
+ B
+}
diff --git a/gcc/testsuite/c-c++-common/pr69558.c b/gcc/testsuite/c-c++-common/pr69558.c
new file mode 100644
index 0000000000..102d72c276
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69558.c
@@ -0,0 +1,19 @@
+/* PR c/69558 */
+/* { dg-do compile } */
+/* { dg-options "-Wdeprecated-declarations" } */
+
+/* TODO: XFAIL for g++ (works for C). */
+
+#define A \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#define B \
+ _Pragma ("GCC diagnostic pop")
+#define C(x) \
+ A \
+ static inline void bar (void) { x (); } /* { dg-bogus "in definition of|deprecated" "" { xfail { c++ } } } */ \
+ B
+
+__attribute__((deprecated)) void foo (void); /* { dg-bogus "declared here" "" { xfail { c++ } } } */
+
+C (foo) /* { dg-bogus "is deprecated" "" { xfail { c++ } } } */
diff --git a/gcc/testsuite/c-c++-common/pr69669.c b/gcc/testsuite/c-c++-common/pr69669.c
new file mode 100644
index 0000000000..9940afe8ff
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69669.c
@@ -0,0 +1,10 @@
+/* PR c/69669 */
+/* { dg-do compile } */
+
+enum __attribute__((mode(QI))) E { F = 1 };
+
+void
+foo (enum E *x, int y)
+{
+ *x = (enum E) y;
+}
diff --git a/gcc/testsuite/c-c++-common/pr69764.c b/gcc/testsuite/c-c++-common/pr69764.c
new file mode 100644
index 0000000000..79623ec737
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69764.c
@@ -0,0 +1,38 @@
+/* PR rtl-optimization/69764 */
+/* { dg-do compile { target int32plus } } */
+
+unsigned char
+fn1 (unsigned char a)
+{
+ return a >> ~6; /* { dg-warning "right shift count is negative" } */
+}
+
+unsigned short
+fn2 (unsigned short a)
+{
+ return a >> ~6; /* { dg-warning "right shift count is negative" } */
+}
+
+unsigned int
+fn3 (unsigned int a)
+{
+ return a >> ~6; /* { dg-warning "right shift count is negative" } */
+}
+
+unsigned char
+fn4 (unsigned char a)
+{
+ return a >> 0xff03; /* { dg-warning "right shift count >= width of type" } */
+}
+
+unsigned short
+fn5 (unsigned short a)
+{
+ return a >> 0xff03; /* { dg-warning "right shift count >= width of type" } */
+}
+
+unsigned int
+fn6 (unsigned int a)
+{
+ return a >> 0xff03; /* { dg-warning "right shift count >= width of type" } */
+}
diff --git a/gcc/testsuite/c-c++-common/pr69797.c b/gcc/testsuite/c-c++-common/pr69797.c
new file mode 100644
index 0000000000..fe2d4304c3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69797.c
@@ -0,0 +1,8 @@
+/* PR c++/69797 */
+/* { dg-do compile } */
+
+void
+foo ()
+{
+ __atomic_fetch_add (); /* { dg-error "too few arguments to function" } */
+}
diff --git a/gcc/testsuite/c-c++-common/pr70144-1.c b/gcc/testsuite/c-c++-common/pr70144-1.c
new file mode 100644
index 0000000000..01c7b78b17
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr70144-1.c
@@ -0,0 +1,9 @@
+/* PR c++/70144 */
+/* { dg-do compile } */
+
+void
+foo ()
+{
+ __builtin_constant_p (__builtin_constant_p) ?: ({ unsigned t = 0; t; }); /* { dg-error "must be directly called" } */
+ __builtin_classify_type (__builtin_expect); /* { dg-error "must be directly called" } */
+}
diff --git a/gcc/testsuite/c-c++-common/pr70144-2.c b/gcc/testsuite/c-c++-common/pr70144-2.c
new file mode 100644
index 0000000000..0973b792e9
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr70144-2.c
@@ -0,0 +1,12 @@
+/* PR c++/70144 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+int
+main ()
+{
+ if (__builtin_constant_p (__builtin_memset) != 0
+ || __builtin_classify_type (__builtin_memset) != 5)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/pr70264.c b/gcc/testsuite/c-c++-common/pr70264.c
new file mode 100644
index 0000000000..815aad175e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr70264.c
@@ -0,0 +1,13 @@
+/* { dg-options "-fdiagnostics-show-caret" } */
+
+#define X __LINE__ /* { dg-error "expected" } */
+X
+
+/* { dg-begin-multiline-output "" }
+ #define X __LINE__
+ ^
+ { dg-end-multiline-output "" } */
+/* { dg-begin-multiline-output "" }
+ X
+ ^
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/pr70297.c b/gcc/testsuite/c-c++-common/pr70297.c
new file mode 100644
index 0000000000..70a4f15cd2
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr70297.c
@@ -0,0 +1,9 @@
+/* PR c/70297 */
+/* { dg-do compile } */
+/* { dg-options "-g" } */
+
+typedef int T;
+typedef int T __attribute__((aligned (4)));
+struct S {
+ T *t;
+};
diff --git a/gcc/testsuite/c-c++-common/pr70336.c b/gcc/testsuite/c-c++-common/pr70336.c
new file mode 100644
index 0000000000..095bd569b1
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr70336.c
@@ -0,0 +1,37 @@
+/* PR c++/70336 */
+/* { dg-do compile } */
+/* { dg-options "-Wconversion" } */
+
+void
+f1 (unsigned char * x, int y, int z)
+{
+ x[z / 8] |= (unsigned char) (0x80 >> y); /* { dg-bogus "may alter its value" } */
+}
+
+unsigned char
+f2 (unsigned char x, int y)
+{
+ x = x | (unsigned char) (0x80 >> y); /* { dg-bogus "may alter its value" } */
+ return x;
+}
+
+unsigned char
+f3 (unsigned char x, int y)
+{
+ x = x | (unsigned char) (y & 255); /* { dg-bogus "may alter its value" } */
+ return x;
+}
+
+unsigned char
+f4 (unsigned char x, unsigned char y)
+{
+ x = x | (unsigned char) (y & 255); /* { dg-bogus "may alter its value" } */
+ return x;
+}
+
+unsigned char
+f5 (unsigned char x, int y)
+{
+ x = (unsigned char) (y & 255); /* { dg-bogus "may alter its value" } */
+ return x;
+}
diff --git a/gcc/testsuite/c-c++-common/pr70651.c b/gcc/testsuite/c-c++-common/pr70651.c
new file mode 100644
index 0000000000..a91a2d8fc8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr70651.c
@@ -0,0 +1,9 @@
+/* PR c/70651 */
+/* { dg-do compile } */
+/* { dg-prune-output "\[^\n\r\]*first argument to .va_arg. not of type .va_list.\[^\n\r\]*" } */
+
+void fn1 ()
+{
+ char **a = 0;
+ __builtin_va_arg (a, char **);
+}
diff --git a/gcc/testsuite/c-c++-common/raw-string-11.c b/gcc/testsuite/c-c++-common/raw-string-11.c
index 49ceba225b..19210c5745 100644
--- a/gcc/testsuite/c-c++-common/raw-string-11.c
+++ b/gcc/testsuite/c-c++-common/raw-string-11.c
@@ -10,4 +10,3 @@ int main ()
sizeof ("foo%sbar%sfred%sbob?""?""?""?""?"));
}
-// { dg-final { cleanup-saved-temps } }
diff --git a/gcc/testsuite/c-c++-common/raw-string-14.c b/gcc/testsuite/c-c++-common/raw-string-14.c
index 2eeb7258f4..2253ffea3c 100644
--- a/gcc/testsuite/c-c++-common/raw-string-14.c
+++ b/gcc/testsuite/c-c++-common/raw-string-14.c
@@ -12,7 +12,7 @@ const void *s1 = R"??/
// { dg-error "invalid new-line" "invalid" { target *-*-* } 10 }
// { dg-error "stray" "stray" { target *-*-* } 10 }
// { dg-warning "missing terminating" "missing" { target *-*-* } 10 }
- // { dg-error "missing terminating" "missing" { target *-*-* } 10 }
+ // { dg-error "19:missing terminating" "missing" { target *-*-* } 10 }
const void *s2 = R"abcdefghijklmn??/(a)abcdefghijklmn???";
// { dg-error "raw string delimiter longer" "longer" { target *-*-* } 16 }
// { dg-error "stray" "stray" { target *-*-* } 16 }
diff --git a/gcc/testsuite/c-c++-common/raw-string-18.c b/gcc/testsuite/c-c++-common/raw-string-18.c
index 01dd339b18..6709946e0c 100644
--- a/gcc/testsuite/c-c++-common/raw-string-18.c
+++ b/gcc/testsuite/c-c++-common/raw-string-18.c
@@ -18,4 +18,3 @@ main ()
/* Verify call to foo is on line 15. */
/* { dg-final { scan-tree-dump "c:15:\[^\n\r\]*foo" "optimized" } } */
-/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/raw-string-19.c b/gcc/testsuite/c-c++-common/raw-string-19.c
index abbecfb950..7ab9e6cbea 100644
--- a/gcc/testsuite/c-c++-common/raw-string-19.c
+++ b/gcc/testsuite/c-c++-common/raw-string-19.c
@@ -18,5 +18,3 @@ main ()
/* Verify call to foo is on line 15. */
/* { dg-final { scan-tree-dump "c:15:\[^\n\r\]*foo" "optimized" } } */
-/* { dg-final { cleanup-tree-dump "optimized" } } */
-/* { dg-final { cleanup-saved-temps } } */
diff --git a/gcc/testsuite/c-c++-common/restrict-1.c b/gcc/testsuite/c-c++-common/restrict-1.c
index 08fc10f560..15b9dafea4 100644
--- a/gcc/testsuite/c-c++-common/restrict-1.c
+++ b/gcc/testsuite/c-c++-common/restrict-1.c
@@ -17,4 +17,3 @@ int main()
}
/* { dg-final { scan-tree-dump-not "link_error" "optimized" } } */
-/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/restrict-2.c b/gcc/testsuite/c-c++-common/restrict-2.c
index 3f71b77b9c..ad19fb3f2d 100644
--- a/gcc/testsuite/c-c++-common/restrict-2.c
+++ b/gcc/testsuite/c-c++-common/restrict-2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O -fno-strict-aliasing -fdump-tree-lim1-details" } */
+/* { dg-options "-O -fno-strict-aliasing -fdump-tree-lim2-details" } */
void foo (float * __restrict__ a, float * __restrict__ b, int n, int j)
{
@@ -10,5 +10,4 @@ void foo (float * __restrict__ a, float * __restrict__ b, int n, int j)
/* We should move the RHS of the store out of the loop. */
-/* { dg-final { scan-tree-dump-times "Moving statement" 11 "lim1" } } */
-/* { dg-final { cleanup-tree-dump "lim1" } } */
+/* { dg-final { scan-tree-dump-times "Moving statement" 11 "lim2" } } */
diff --git a/gcc/testsuite/c-c++-common/restrict-4.c b/gcc/testsuite/c-c++-common/restrict-4.c
index 3a36def25c..5806a2a901 100644
--- a/gcc/testsuite/c-c++-common/restrict-4.c
+++ b/gcc/testsuite/c-c++-common/restrict-4.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-lim1-details" } */
+/* { dg-options "-O2 -fdump-tree-lim2-details" } */
struct Foo
{
@@ -15,5 +15,4 @@ void bar(struct Foo f, int * __restrict__ q)
}
}
-/* { dg-final { scan-tree-dump "Executing store motion" "lim1" } } */
-/* { dg-final { cleanup-tree-dump "lim1" } } */
+/* { dg-final { scan-tree-dump "Executing store motion" "lim2" } } */
diff --git a/gcc/testsuite/c-c++-common/rotate-1.c b/gcc/testsuite/c-c++-common/rotate-1.c
index bca9dd8d1c..0777c6b191 100644
--- a/gcc/testsuite/c-c++-common/rotate-1.c
+++ b/gcc/testsuite/c-c++-common/rotate-1.c
@@ -2,7 +2,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fno-ipa-icf -fdump-tree-optimized" } */
/* { dg-final { scan-tree-dump-times "r\[<>]\[<>]" 96 "optimized" } } */
-/* { dg-final { cleanup-tree-dump "optimized" } } */
unsigned int
f1 (unsigned int x, unsigned int y)
diff --git a/gcc/testsuite/c-c++-common/rotate-2.c b/gcc/testsuite/c-c++-common/rotate-2.c
index 4ffa218e4a..c8359cd2ae 100644
--- a/gcc/testsuite/c-c++-common/rotate-2.c
+++ b/gcc/testsuite/c-c++-common/rotate-2.c
@@ -4,7 +4,6 @@
/* Rotates should be recognized only in functions with | instead of + or ^,
or in functions that have constant shift counts (unused attribute on y). */
/* { dg-final { scan-tree-dump-times "r\[<>]\[<>]" 48 "optimized" } } */
-/* { dg-final { cleanup-tree-dump "optimized" } } */
unsigned int
f1 (unsigned int x, unsigned int y)
diff --git a/gcc/testsuite/c-c++-common/rotate-3.c b/gcc/testsuite/c-c++-common/rotate-3.c
index aaa9f507f8..def2e8faf5 100644
--- a/gcc/testsuite/c-c++-common/rotate-3.c
+++ b/gcc/testsuite/c-c++-common/rotate-3.c
@@ -2,7 +2,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fno-ipa-icf -fdump-tree-optimized" } */
/* { dg-final { scan-tree-dump-times "r\[<>]\[<>]" 96 "optimized" } } */
-/* { dg-final { cleanup-tree-dump "optimized" } } */
unsigned int
f1 (unsigned int x, int y)
diff --git a/gcc/testsuite/c-c++-common/rotate-4.c b/gcc/testsuite/c-c++-common/rotate-4.c
index 0a21177ad9..44fd1d0bb8 100644
--- a/gcc/testsuite/c-c++-common/rotate-4.c
+++ b/gcc/testsuite/c-c++-common/rotate-4.c
@@ -4,7 +4,6 @@
/* Rotates should be recognized only in functions with | instead of + or ^,
or in functions that have constant shift counts (unused attribute on y). */
/* { dg-final { scan-tree-dump-times "r\[<>]\[<>]" 48 "optimized" } } */
-/* { dg-final { cleanup-tree-dump "optimized" } } */
unsigned int
f1 (unsigned int x, int y)
diff --git a/gcc/testsuite/c-c++-common/taskloop-1.c b/gcc/testsuite/c-c++-common/taskloop-1.c
new file mode 100644
index 0000000000..f5c3a5d153
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/taskloop-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+int e;
+int bar (int, int);
+void baz (int, int, int, int *, int *, int *);
+
+void
+foo (int a, int b, int c, int d, int f, int g, int h, int j, int k, int l)
+{
+ int i;
+ #pragma omp taskloop if (a) final (b) untied default(none) mergeable \
+ private(c) firstprivate (e) shared (d) num_tasks(f) collapse(1)
+ for (i = bar (g, h) + j; i < k; i += l)
+ baz (i, d, e++, &c, &d, &e);
+}
diff --git a/gcc/testsuite/c-c++-common/tm/20100127.c b/gcc/testsuite/c-c++-common/tm/20100127.c
index c25336d682..59f949eb88 100644
--- a/gcc/testsuite/c-c++-common/tm/20100127.c
+++ b/gcc/testsuite/c-c++-common/tm/20100127.c
@@ -33,4 +33,3 @@ void test(void *data)
}
/* { dg-final { scan-tree-dump-times "_ITM_W.*nontrxn" 0 "tmmark" } } */
-/* { dg-final { cleanup-tree-dump "tmmark" } } */
diff --git a/gcc/testsuite/c-c++-common/tm/ipa-1.c b/gcc/testsuite/c-c++-common/tm/ipa-1.c
index 961f7fe79c..2f9972b299 100644
--- a/gcc/testsuite/c-c++-common/tm/ipa-1.c
+++ b/gcc/testsuite/c-c++-common/tm/ipa-1.c
@@ -20,4 +20,3 @@ int set_remove(void)
/* { dg-final { scan-ipa-dump-not "getTMCloneOrIrrevocable" "tmipa" } } */
-/* { dg-final { cleanup-ipa-dump "tmipa" } } */
diff --git a/gcc/testsuite/c-c++-common/tm/malloc.c b/gcc/testsuite/c-c++-common/tm/malloc.c
index 81bcc56fc4..4312765f75 100644
--- a/gcc/testsuite/c-c++-common/tm/malloc.c
+++ b/gcc/testsuite/c-c++-common/tm/malloc.c
@@ -23,4 +23,3 @@ void foobar(void)
/* { dg-final { scan-tree-dump-times "__builtin__ITM_malloc" 1 "tmmark" } } */
/* { dg-final { scan-tree-dump-times "__builtin__ITM_calloc" 1 "tmmark" } } */
/* { dg-final { scan-tree-dump-times "__builtin__ITM_free" 2 "tmmark" } } */
-/* { dg-final { cleanup-tree-dump "tmmark" } } */
diff --git a/gcc/testsuite/c-c++-common/tm/pr54893.c b/gcc/testsuite/c-c++-common/tm/pr54893.c
index 8967f384af..3766078d31 100644
--- a/gcc/testsuite/c-c++-common/tm/pr54893.c
+++ b/gcc/testsuite/c-c++-common/tm/pr54893.c
@@ -13,4 +13,3 @@ int main()
}
/* { dg-final { scan-ipa-dump "GTMA_DOES_GO_IRREVOCABLE" "tmipa" } } */
-/* { dg-final { cleanup-ipa-dump "tmipa" } } */
diff --git a/gcc/testsuite/c-c++-common/tm/trxn-expr-3.c b/gcc/testsuite/c-c++-common/tm/trxn-expr-3.c
index db66873dc8..27ff633fac 100644
--- a/gcc/testsuite/c-c++-common/tm/trxn-expr-3.c
+++ b/gcc/testsuite/c-c++-common/tm/trxn-expr-3.c
@@ -11,4 +11,3 @@ int f2()
/* { dg-final { scan-tree-dump-times "ITM_RU" 2 "tmmark" } } */
/* { dg-final { scan-tree-dump-times "ITM_commitTransaction" 4 "tmmark" } } */
-/* { dg-final { cleanup-tree-dump "tmmark" } } */
diff --git a/gcc/testsuite/c-c++-common/tm/trxn-expr.c b/gcc/testsuite/c-c++-common/tm/trxn-expr.c
index 53d4677e3e..eb27c888fd 100644
--- a/gcc/testsuite/c-c++-common/tm/trxn-expr.c
+++ b/gcc/testsuite/c-c++-common/tm/trxn-expr.c
@@ -10,4 +10,3 @@ void foobar(void)
/* { dg-final { scan-tree-dump-times "_ITM_RU.*york" 1 "tmmark" } } */
/* { dg-final { scan-tree-dump-times "_ITM_RU" 1 "tmmark" } } */
-/* { dg-final { cleanup-tree-dump "tmmark" } } */
diff --git a/gcc/testsuite/c-c++-common/tm/volatile-1.c b/gcc/testsuite/c-c++-common/tm/volatile-1.c
new file mode 100644
index 0000000000..eb3799dd97
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/tm/volatile-1.c
@@ -0,0 +1,10 @@
+// Transaction-unsafe testcase from TM TS.
+// { dg-options -fgnu-tm }
+
+volatile int * p = 0;
+__attribute ((transaction_safe))
+int f() {
+ int x = 0; // ok: not volatile
+ p = &x; // ok: the pointer is not volatile
+ int i = *p; // { dg-error "volatile" "read through volatile glvalue" }
+}
diff --git a/gcc/testsuite/c-c++-common/tm/wrap-1.c b/gcc/testsuite/c-c++-common/tm/wrap-1.c
index 04b5b6f0dc..eec43a1caa 100644
--- a/gcc/testsuite/c-c++-common/tm/wrap-1.c
+++ b/gcc/testsuite/c-c++-common/tm/wrap-1.c
@@ -7,4 +7,3 @@ void xyzzy(void) __attribute__((transaction_wrap (orig)));
void foo() { __transaction_relaxed { orig (); } }
/* { dg-final { scan-tree-dump-times "xyzzy" 1 "optimized" } } */
-/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/torture/vector-shift1.c b/gcc/testsuite/c-c++-common/torture/vector-shift1.c
index e6e31daf57..c80d7cccdf 100644
--- a/gcc/testsuite/c-c++-common/torture/vector-shift1.c
+++ b/gcc/testsuite/c-c++-common/torture/vector-shift1.c
@@ -2,7 +2,7 @@
#define vector __attribute__((vector_size(8*sizeof(short))))
int main (int argc, char *argv[]) {
- vector short v0 = {argc,2,3,4,5,6,7};
+ vector short v0 = {(short)argc,2,3,4,5,6,7};
vector short v1 = {2,2,2,2,2,2,2};
vector short r1,r2,r3,r4;
int i = 8;
diff --git a/gcc/testsuite/c-c++-common/torture/vshuf-2.inc b/gcc/testsuite/c-c++-common/torture/vshuf-2.inc
index ef778e5941..bc2179414a 100644
--- a/gcc/testsuite/c-c++-common/torture/vshuf-2.inc
+++ b/gcc/testsuite/c-c++-common/torture/vshuf-2.inc
@@ -11,7 +11,7 @@ struct S
struct S tests[] = {
{ { A, B }, { 0, 1 }, { A, B } },
- { { A, B }, { -16, -1 }, { A, B } },
+ { { A, B }, { -16U, -1U }, { A, B } },
{ { A, B }, { 1, 0 }, { B, A } },
{ { A, B }, { 0, 0 }, { A, A } },
{ { X, Y }, { 1, 1 }, { Y, Y } },
diff --git a/gcc/testsuite/c-c++-common/transparent-union-1.c b/gcc/testsuite/c-c++-common/transparent-union-1.c
index 3fb6e782a1..91f2642fdb 100644
--- a/gcc/testsuite/c-c++-common/transparent-union-1.c
+++ b/gcc/testsuite/c-c++-common/transparent-union-1.c
@@ -1,4 +1,5 @@
/* PR c++/51228 */
+/* { dg-options "-Wno-c++-compat" { target c } } */
typedef union {} U __attribute__((transparent_union)); /* { dg-warning "ignored" } */
diff --git a/gcc/testsuite/c-c++-common/tsan/pr65400-1.c b/gcc/testsuite/c-c++-common/tsan/pr65400-1.c
index 96fbbfd36b..d441ff8371 100644
--- a/gcc/testsuite/c-c++-common/tsan/pr65400-1.c
+++ b/gcc/testsuite/c-c++-common/tsan/pr65400-1.c
@@ -7,9 +7,9 @@
#include "tsan_barrier.h"
static pthread_barrier_t barrier;
-int v;
-int q;
-int o;
+int v __attribute__((aligned(8)));
+int q __attribute__((aligned(8)));
+int o __attribute__((aligned(8)));
extern void baz4 (int *);
__attribute__((noinline, noclone)) int
diff --git a/gcc/testsuite/c-c++-common/tsan/thread_leak.c b/gcc/testsuite/c-c++-common/tsan/thread_leak.c
index 02deaba584..4ddda4aecb 100644
--- a/gcc/testsuite/c-c++-common/tsan/thread_leak.c
+++ b/gcc/testsuite/c-c++-common/tsan/thread_leak.c
@@ -9,7 +9,7 @@ int main() {
pthread_t t;
pthread_create(&t, 0, Thread, 0);
pthread_join(t, 0);
- printf("PASS\n");
+ fprintf(stderr, "PASS\n");
return 0;
}
diff --git a/gcc/testsuite/c-c++-common/ubsan/align-6.c b/gcc/testsuite/c-c++-common/ubsan/align-6.c
index 5521292586..3364746fb2 100644
--- a/gcc/testsuite/c-c++-common/ubsan/align-6.c
+++ b/gcc/testsuite/c-c++-common/ubsan/align-6.c
@@ -30,4 +30,4 @@ main ()
/* { dg-output "\.c:15:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
/* { dg-output "\.c:16:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
/* { dg-output "\.c:17:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
-/* { dg-output "\.c:18:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
+/* { dg-output "\.c:18:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/align-7.c b/gcc/testsuite/c-c++-common/ubsan/align-7.c
index 68c9135fa4..ec4e87f56d 100644
--- a/gcc/testsuite/c-c++-common/ubsan/align-7.c
+++ b/gcc/testsuite/c-c++-common/ubsan/align-7.c
@@ -28,6 +28,5 @@ main ()
return 0;
}
-/* { dg-output "\.c:16:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
+/* { dg-output "\.c:16:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment" } */
/* { dg-final { scan-tree-dump-times "Optimizing" 4 "sanopt"} } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/align-8.c b/gcc/testsuite/c-c++-common/ubsan/align-8.c
index 4e43a09ff3..61c1ceb668 100644
--- a/gcc/testsuite/c-c++-common/ubsan/align-8.c
+++ b/gcc/testsuite/c-c++-common/ubsan/align-8.c
@@ -29,4 +29,3 @@ main ()
}
/* { dg-final { scan-tree-dump-times "Optimizing" 4 "sanopt"} } */
-/* { dg-final { cleanup-tree-dump "sanopt" } } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/bounds-10.c b/gcc/testsuite/c-c++-common/ubsan/bounds-10.c
new file mode 100644
index 0000000000..a6187b543e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/bounds-10.c
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds-strict" } */
+
+struct V { int l; int a[1]; };
+
+int
+main (void)
+{
+ /* For strict, do instrument last array in a struct. */
+ struct V *v = (struct V *) __builtin_malloc (sizeof (struct V) + 10);
+ v->a[1] = 1;
+
+ return 0;
+}
+
+/* { dg-output "index 1 out of bounds for type 'int \\\[1\\\]'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/bounds-11.c b/gcc/testsuite/c-c++-common/ubsan/bounds-11.c
new file mode 100644
index 0000000000..c3e0f220dc
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/bounds-11.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+
+struct S
+{
+ unsigned long a[1];
+ int l;
+};
+
+static inline unsigned long
+fn (const struct S *s, int i)
+{
+ return s->a[i] / i;
+}
+
+int
+main ()
+{
+ struct S s;
+ fn (&s, 1);
+}
+
+/* { dg-output "index 1 out of bounds for type 'long unsigned int \\\[1\\\]'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/bounds-12.c b/gcc/testsuite/c-c++-common/ubsan/bounds-12.c
new file mode 100644
index 0000000000..3cd3a4abb4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/bounds-12.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+
+struct S
+{
+ unsigned long a[1];
+ int l;
+};
+
+static inline unsigned long
+fn (const struct S *s, int i)
+{
+ return s->a[i] << i;
+}
+
+int
+main ()
+{
+ struct S s;
+ fn (&s, 1);
+}
+
+/* { dg-output "index 1 out of bounds for type 'long unsigned int \\\[1\\\]'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/bounds-4.c b/gcc/testsuite/c-c++-common/ubsan/bounds-4.c
index 7748780884..88e7e14050 100644
--- a/gcc/testsuite/c-c++-common/ubsan/bounds-4.c
+++ b/gcc/testsuite/c-c++-common/ubsan/bounds-4.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fsanitize=bounds -Wall -Wextra -Wno-unused" } */
+/* { dg-options "-fsanitize=bounds -Wall -Wextra -Wno-array-bounds -Wno-unused" } */
/* Initializers of TREE_STATICs aren't instrumented.
But don't ICE on 'em. */
@@ -11,7 +11,7 @@ int *gpi;
int
main (void)
{
- gpi = &A[4];
+ gpi = &A[4]; /* This will warn with -Warray-bounds, but only if VRP runs. */
static int *pi = &A[4];
return 0;
}
diff --git a/gcc/testsuite/c-c++-common/ubsan/bounds-6.c b/gcc/testsuite/c-c++-common/ubsan/bounds-6.c
index aef2055fb3..952354985d 100644
--- a/gcc/testsuite/c-c++-common/ubsan/bounds-6.c
+++ b/gcc/testsuite/c-c++-common/ubsan/bounds-6.c
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-options "-fsanitize=bounds -Wall -Wextra" } */
+/* { dg-options "-fsanitize=bounds -Wall -Wextra -Wno-array-bounds" } */
/* Test off-by-one. */
@@ -24,7 +24,7 @@ main (void)
a = &u[4].a[10]; // Error
a = &u[3].a[9]; // OK
a = &u[3].a[10]; // OK
- a = &u[3].a[11]; // Error
+ a = &u[3].a[11]; // Error, warns with -Warray-bounds, but only if VRP runs
return 0;
}
diff --git a/gcc/testsuite/c-c++-common/ubsan/bounds-8.c b/gcc/testsuite/c-c++-common/ubsan/bounds-8.c
index 9a1b1d25c6..20f938269f 100644
--- a/gcc/testsuite/c-c++-common/ubsan/bounds-8.c
+++ b/gcc/testsuite/c-c++-common/ubsan/bounds-8.c
@@ -10,4 +10,4 @@ main (void)
(*a)[2] = 1;
}
-/* { dg-output "index 2 out of bounds for type 'int \\\[1\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "index 2 out of bounds for type 'int \\\[1\\\]'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-10.c b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-10.c
index 269a0ed702..a54a838870 100644
--- a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-10.c
+++ b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-10.c
@@ -10,70 +10,37 @@
/* _Decimal32 */
/* { dg-output "value <unknown> is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* _Decimal64 */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* _Decimal128 */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long unsigned int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-8.c b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-8.c
index 5b1837d5a1..4adb22ae3b 100644
--- a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-8.c
+++ b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-8.c
@@ -100,106 +100,44 @@ main ()
/* float */
/* { dg-output "value -129 is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "value \[0-9.e+-]* is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value 128 is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value (-129|-1) is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value (128|256) is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value 256 is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value -32769 is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value 32768 is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value 65536 is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type '__int128'\[^\n\r]*(\n|\r\n|\r)" { target { int128 } } } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type '__int128'\[^\n\r]*(\n|\r\n|\r)" { target { int128 } } } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type '__int128 unsigned'\[^\n\r]*(\n|\r\n|\r)" { target { int128 } } } */
/* No error for float and __int128 unsigned max value, as ui128_MAX is +Inf in float. */
/* double */
/* { dg-output "\[^\n\r]*value -129 is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value 128 is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value (-129|-1) is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value (128|256) is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value 256 is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value -32769 is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value 32768 is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value 65536 is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type '__int128'\[^\n\r]*(\n|\r\n|\r)" { target { int128 } } } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type '__int128'\[^\n\r]*(\n|\r\n|\r)" { target { int128 } } } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type '__int128 unsigned'\[^\n\r]*(\n|\r\n|\r)" { target { int128 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type '__int128 unsigned'\[^\n\r]*(\n|\r\n|\r)" { target { int128 } } } */
/* long double */
/* { dg-output "\[^\n\r]*value -129 is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value 128 is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value (-129|-1) is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value (128|256) is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value 256 is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value -32769 is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value 32768 is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value 65536 is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" { target { ilp32 || lp64 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" { target { ! { ilp32 || lp64 } } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long unsigned int'" } */
-/* { dg-output "(\n|\r\n|\r)\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type '__int128'\[^\n\r]*(\n|\r\n|\r)" { target { int128 } } } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type '__int128'\[^\n\r]*(\n|\r\n|\r)" { target { int128 } } } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type '__int128 unsigned'\[^\n\r]*(\n|\r\n|\r)" { target { int128 } } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type '__int128 unsigned'" { target { int128 } } } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-9.c b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-9.c
index 05399e7402..f2d71f6a53 100644
--- a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-9.c
+++ b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-9.c
@@ -7,55 +7,29 @@
/* __float80 */
/* { dg-output "value -129 is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value 128 is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value (-129|-1) is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value (128|256) is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value 256 is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -32769 is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value 32768 is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value 65536 is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type '__int128'\[^\n\r]*(\n|\r\n|\r)" { target int128 } } */
/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type '__int128'\[^\n\r]*(\n|\r\n|\r)" { target int128 } } */
/* { dg-output "\[^\n\r]*value -1 is outside the range of representable values of type '__int128 unsigned'\[^\n\r]*(\n|\r\n|\r)" { target int128 } } */
-/* { dg-output "\[^\n\r]*value \[0-9.e+-]* is outside the range of representable values of type '__int128 unsigned'\[^\n\r]*(\n|\r\n|\r)" { target int128 } } */
/* __float128 */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'signed char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'short unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type '__int128'\[^\n\r]*(\n|\r\n|\r)" { target int128 } } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type '__int128'\[^\n\r]*(\n|\r\n|\r)" { target int128 } } */
-/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type '__int128 unsigned'\[^\n\r]*(\n|\r\n|\r)" { target int128 } } */
/* { dg-output "\[^\n\r]*value <unknown> is outside the range of representable values of type '__int128 unsigned'\[^\n\r]*(\n|\r\n|\r)" { target int128 } } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/load-bool-enum.c b/gcc/testsuite/c-c++-common/ubsan/load-bool-enum.c
index 4ffd6325bc..c7f0683c50 100644
--- a/gcc/testsuite/c-c++-common/ubsan/load-bool-enum.c
+++ b/gcc/testsuite/c-c++-common/ubsan/load-bool-enum.c
@@ -11,7 +11,7 @@ __attribute__((noinline, noclone)) enum A
foo (bool *p)
{
*p = b; /* { dg-output "load-bool-enum.c:13:\[^\n\r]*runtime error: \[^\n\r]*load of value 4, which is not a valid value for type '(_B|b)ool'\[^\n\r]*(\n|\r\n|\r)*" } */
- return a; /* { dg-output "\[^\n\r]*load-bool-enum.c:14:\[^\n\r]*runtime error: \[^\n\r]*load of value 9, which is not a valid value for type 'A'\[^\n\r]*(\n|\r\n|\r)*" { target c++ } } */
+ return a; /* { dg-output "\[^\n\r]*load-bool-enum.c:14:\[^\n\r]*runtime error: \[^\n\r]*load of value 9, which is not a valid value for type 'A'" { target c++ } } */
}
int
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-1.c b/gcc/testsuite/c-c++-common/ubsan/null-1.c
index 17f6d19c88..26dc22c6dd 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-1.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-1.c
@@ -9,4 +9,4 @@ main (void)
return *p;
}
-/* { dg-output "load of null pointer of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "load of null pointer of type 'int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-10.c b/gcc/testsuite/c-c++-common/ubsan/null-10.c
index 8dacf6c06c..705e00d327 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-10.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-10.c
@@ -2,12 +2,14 @@
/* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */
+short x;
+
int
main (void)
{
- short *p = 0, *u;
+ short *p = 0, *u = &x;
*(u + *p) = 23;
return 0;
}
-/* { dg-output "load of null pointer of type 'short int'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "load of null pointer of type 'short int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-11.c b/gcc/testsuite/c-c++-common/ubsan/null-11.c
index 6aefaab003..659a5f2a07 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-11.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-11.c
@@ -13,4 +13,4 @@ main (void)
return (*s)->i;
}
-/* { dg-output "load of null pointer of type 'struct S \\*'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "load of null pointer of type 'struct S \\*'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-2.c b/gcc/testsuite/c-c++-common/ubsan/null-2.c
index df4901faed..de9d519086 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-2.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-2.c
@@ -9,4 +9,4 @@ main (void)
return ***ppp;
}
-/* { dg-output "load of null pointer of type 'int \\*\\*'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "load of null pointer of type 'int \\*\\*'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-3.c b/gcc/testsuite/c-c++-common/ubsan/null-3.c
index b1eb3dbc73..e9e8b7bd21 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-3.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-3.c
@@ -15,4 +15,4 @@ main (void)
return foo (*p);
}
-/* { dg-output "load of null pointer of type 'int \\*'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "load of null pointer of type 'int \\*'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-4.c b/gcc/testsuite/c-c++-common/ubsan/null-4.c
index 7c0aa2c70a..09018164fc 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-4.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-4.c
@@ -11,4 +11,4 @@ main (void)
return 0;
}
-/* { dg-output "load of null pointer of type 'complex double'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "load of null pointer of type 'complex double'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-5.c b/gcc/testsuite/c-c++-common/ubsan/null-5.c
index f7f6b86d31..fb2d49381c 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-5.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-5.c
@@ -13,4 +13,4 @@ main (void)
return 0;
}
-/* { dg-output "load of null pointer of type 'volatile const complex float'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "load of null pointer of type 'volatile const complex float'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-6.c b/gcc/testsuite/c-c++-common/ubsan/null-6.c
index 6f8ba6bf45..1239793635 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-6.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-6.c
@@ -10,4 +10,4 @@ main (void)
return 0;
}
-/* { dg-output "store to null pointer of type 'long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "store to null pointer of type 'long unsigned int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-7.c b/gcc/testsuite/c-c++-common/ubsan/null-7.c
index 92881d7318..19c21da456 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-7.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-7.c
@@ -14,4 +14,4 @@ main (void)
return *gao ();
}
-/* { dg-output "load of null pointer of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "load of null pointer of type 'int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-8.c b/gcc/testsuite/c-c++-common/ubsan/null-8.c
index 246824197b..73bef75c37 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-8.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-8.c
@@ -13,4 +13,4 @@ main (void)
return s->i;
}
-/* { dg-output "member access within null pointer of type 'struct S'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "member access within null pointer of type 'struct S'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-9.c b/gcc/testsuite/c-c++-common/ubsan/null-9.c
index 88d441c381..0b993cfaa7 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-9.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-9.c
@@ -13,4 +13,4 @@ main (void)
return u->i;
}
-/* { dg-output "member access within null pointer of type 'union U'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "member access within null pointer of type 'union U'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/object-size-1.c b/gcc/testsuite/c-c++-common/ubsan/object-size-1.c
index 7a3c87a9ed..f4ea8bb46e 100644
--- a/gcc/testsuite/c-c++-common/ubsan/object-size-1.c
+++ b/gcc/testsuite/c-c++-common/ubsan/object-size-1.c
@@ -102,7 +102,7 @@ f4 (void)
/* { dg-output "\[^\n\r]*store to address \[^\n\r]* with insufficient space for an object of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\\^" } */
__attribute__((noinline, noclone)) void
f5 (int *p)
diff --git a/gcc/testsuite/c-c++-common/ubsan/object-size-10.c b/gcc/testsuite/c-c++-common/ubsan/object-size-10.c
index ebc8582ec3..53e719de0c 100644
--- a/gcc/testsuite/c-c++-common/ubsan/object-size-10.c
+++ b/gcc/testsuite/c-c++-common/ubsan/object-size-10.c
@@ -2,8 +2,8 @@
/* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */
/* { dg-options "-fsanitize=undefined" } */
-static char a[128];
-static int b[128];
+static char a[128] __attribute__ ((aligned(4096)));
+static int b[128] __attribute__ ((aligned(4096)));
__attribute__ ((noinline, noclone)) int
fn1 (int i)
@@ -56,7 +56,7 @@ fn5 (int i, int j)
/* { dg-output "\[^\n\r]*load of address \[^\n\r]* with insufficient space for an object of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\\^" } */
__attribute__ ((noinline, noclone)) int
fn6 (int i)
diff --git a/gcc/testsuite/c-c++-common/ubsan/object-size-4.c b/gcc/testsuite/c-c++-common/ubsan/object-size-4.c
index 8b95ec9c80..7e55a0fe35 100644
--- a/gcc/testsuite/c-c++-common/ubsan/object-size-4.c
+++ b/gcc/testsuite/c-c++-common/ubsan/object-size-4.c
@@ -28,4 +28,4 @@ main (void)
/* { dg-output "\[^\n\r]*load of address \[^\n\r]* with insufficient space for an object of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\\^" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/object-size-5.c b/gcc/testsuite/c-c++-common/ubsan/object-size-5.c
index 3dada101be..6d10fdf73b 100644
--- a/gcc/testsuite/c-c++-common/ubsan/object-size-5.c
+++ b/gcc/testsuite/c-c++-common/ubsan/object-size-5.c
@@ -27,7 +27,7 @@ f1 (int i)
/* { dg-output "\[^\n\r]*load of address \[^\n\r]* with insufficient space for an object of type 'char'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\\^" } */
int
main ()
diff --git a/gcc/testsuite/c-c++-common/ubsan/object-size-7.c b/gcc/testsuite/c-c++-common/ubsan/object-size-7.c
index f5b26e50c8..268de64df6 100644
--- a/gcc/testsuite/c-c++-common/ubsan/object-size-7.c
+++ b/gcc/testsuite/c-c++-common/ubsan/object-size-7.c
@@ -26,4 +26,4 @@ main ()
/* { dg-output "load of address \[^\n\r]* with insufficient space for an object of type\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\\^" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/object-size-8.c b/gcc/testsuite/c-c++-common/ubsan/object-size-8.c
index ee0945b902..f09a445f37 100644
--- a/gcc/testsuite/c-c++-common/ubsan/object-size-8.c
+++ b/gcc/testsuite/c-c++-common/ubsan/object-size-8.c
@@ -29,4 +29,4 @@ main (void)
/* { dg-output "load of address \[^\n\r]* with insufficient space for an object of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\\^" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/object-size-9.c b/gcc/testsuite/c-c++-common/ubsan/object-size-9.c
index 829c822959..46f1fb9f9b 100644
--- a/gcc/testsuite/c-c++-common/ubsan/object-size-9.c
+++ b/gcc/testsuite/c-c++-common/ubsan/object-size-9.c
@@ -11,7 +11,7 @@ struct C { C () : d("abcdefg"), e(1) {} C (const C &x) { __builtin_memcpy (d, x.
#endif
struct U { int a : 5; int b : 19; int c : 8; };
struct S { struct U d[10]; };
-struct S s;
+struct S s __attribute__ ((aligned(4096)));
int
f1 (struct T x, int i)
@@ -27,7 +27,7 @@ f1 (struct T x, int i)
/* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
#ifdef __cplusplus
-struct C
+static struct C
f2 (int i)
{
struct C x;
@@ -41,7 +41,7 @@ f2 (int i)
/* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" { target { c++ } } } */
/* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" { target { c++ } } } */
-struct C
+static struct C
f3 (int i)
{
struct C x;
@@ -81,7 +81,7 @@ f5 (int i)
/* { dg-output "\[^\n\r]*load of address \[^\n\r]* with insufficient space for an object of type 'unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*\\^" } */
int
main (void)
diff --git a/gcc/testsuite/c-c++-common/ubsan/overflow-add-2.c b/gcc/testsuite/c-c++-common/ubsan/overflow-add-2.c
index 61097fa0e0..b104d6158f 100644
--- a/gcc/testsuite/c-c++-common/ubsan/overflow-add-2.c
+++ b/gcc/testsuite/c-c++-common/ubsan/overflow-add-2.c
@@ -57,4 +57,4 @@ main (void)
/* { dg-output "\[^\n\r]*signed integer overflow: \[^\n\r]* \\+ 1024 cannot be represented in type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*signed integer overflow: -\[^\n\r]* \\+ -1 cannot be represented in type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*signed integer overflow: -1 \\+ -\[^\n\r]* cannot be represented in type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*signed integer overflow: -\[^\n\r]* \\+ -1024 cannot be represented in type 'long int'\[^\n\r]*" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: -\[^\n\r]* \\+ -1024 cannot be represented in type 'long int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/overflow-add-5.c b/gcc/testsuite/c-c++-common/ubsan/overflow-add-5.c
new file mode 100644
index 0000000000..905a60a73b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/overflow-add-5.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=signed-integer-overflow" } */
+
+int __attribute__ ((noinline))
+foo (int i, int j)
+{
+ return (i + j) - (i | j);
+}
+
+/* { dg-output "signed integer overflow: 2147483647 \\+ 1 cannot be represented in type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: -2147483648 - 2147483647 cannot be represented in type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
+
+int __attribute__ ((noinline))
+bar (int i, int j)
+{
+ return (i + j) - (i & j);
+}
+
+/* { dg-output "\[^\n\r]*signed integer overflow: 2147483647 \\+ 1 cannot be represented in type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'" } */
+
+int
+main ()
+{
+ int r = foo (__INT_MAX__, 1);
+ asm volatile ("" : "+g" (r));
+ r = bar (__INT_MAX__, 1);
+ asm volatile ("" : "+g" (r));
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/ubsan/overflow-int128.c b/gcc/testsuite/c-c++-common/ubsan/overflow-int128.c
index 4384d7c7ab..400f25b01e 100644
--- a/gcc/testsuite/c-c++-common/ubsan/overflow-int128.c
+++ b/gcc/testsuite/c-c++-common/ubsan/overflow-int128.c
@@ -44,4 +44,4 @@ main (void)
/* { dg-output "\[^\n\r]*signed integer overflow: 0x80000000000000000000000000000000 - 1 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*signed integer overflow: 0x80000000000000000000000000000064 \\+ -1024 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*signed integer overflow: 0x7fffffffffffffffffffffffffffffff \\* 2 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*negation of 0x80000000000000000000000000000000 cannot be represented in type '__int128'; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*negation of 0x80000000000000000000000000000000 cannot be represented in type '__int128'; cast to an unsigned type to negate this value to itself" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/overflow-mul-2.c b/gcc/testsuite/c-c++-common/ubsan/overflow-mul-2.c
index 54b382a418..1ccc3f736b 100644
--- a/gcc/testsuite/c-c++-common/ubsan/overflow-mul-2.c
+++ b/gcc/testsuite/c-c++-common/ubsan/overflow-mul-2.c
@@ -23,4 +23,4 @@ main (void)
/* { dg-output "signed integer overflow: 2147483647 \\* 2 cannot be represented in type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*signed integer overflow: 2 \\* 2147483647 cannot be represented in type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*signed integer overflow: \[^\n\r]* \\* 2 cannot be represented in type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*signed integer overflow: 2 \\* \[^\n\r]* cannot be represented in type 'long int'\[^\n\r]*" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 2 \\* \[^\n\r]* cannot be represented in type 'long int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/overflow-mul-4.c b/gcc/testsuite/c-c++-common/ubsan/overflow-mul-4.c
index 834eda6730..1878451192 100644
--- a/gcc/testsuite/c-c++-common/ubsan/overflow-mul-4.c
+++ b/gcc/testsuite/c-c++-common/ubsan/overflow-mul-4.c
@@ -83,4 +83,4 @@ main ()
/* { dg-output "\[^\n\r]*overflow-mul-4.c:48:\[^\n\r]*signed integer overflow: 4257126176 \\* 2166572391 cannot be represented in type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*overflow-mul-4.c:49:\[^\n\r]*signed integer overflow: -4257126176 \\* -2166572391 cannot be represented in type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*overflow-mul-4.c:50:\[^\n\r]*signed integer overflow: -4257126176 \\* 2166572391 cannot be represented in type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*overflow-mul-4.c:51:\[^\n\r]*signed integer overflow: 4257126176 \\* -2166572391 cannot be represented in type 'long long int'\[^\n\r]*" } */
+/* { dg-output "\[^\n\r]*overflow-mul-4.c:51:\[^\n\r]*signed integer overflow: 4257126176 \\* -2166572391 cannot be represented in type 'long long int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/overflow-negate-1.c b/gcc/testsuite/c-c++-common/ubsan/overflow-negate-1.c
index 35fa482c61..87b47974de 100644
--- a/gcc/testsuite/c-c++-common/ubsan/overflow-negate-1.c
+++ b/gcc/testsuite/c-c++-common/ubsan/overflow-negate-1.c
@@ -35,4 +35,4 @@ main (void)
/* { dg-output "\[^\n\r]*negation of -\[^\n\r]* cannot be represented in type 'long int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*negation of -9223372036854775808 cannot be represented in type 'long long int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*negation of -9223372036854775808 cannot be represented in type 'long long int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*negation of -9223372036854775808 cannot be represented in type 'long long int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*" } */
+/* { dg-output "\[^\n\r]*negation of -9223372036854775808 cannot be represented in type 'long long int'\[^\n\r]*; cast to an unsigned type to negate this value to itself" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/overflow-negate-3.c b/gcc/testsuite/c-c++-common/ubsan/overflow-negate-3.c
index e6db394a4f..85acce8e72 100644
--- a/gcc/testsuite/c-c++-common/ubsan/overflow-negate-3.c
+++ b/gcc/testsuite/c-c++-common/ubsan/overflow-negate-3.c
@@ -18,4 +18,4 @@ main ()
/* { dg-output "negation of -2147483648 cannot be represented in type 'int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*negation of -2147483648 cannot be represented in type 'int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*negation of -2147483648 cannot be represented in type 'int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*negation of -2147483648 cannot be represented in type 'int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*negation of -2147483648 cannot be represented in type 'int'\[^\n\r]*; cast to an unsigned type to negate this value to itself" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/overflow-sub-2.c b/gcc/testsuite/c-c++-common/ubsan/overflow-sub-2.c
index 88c4762dc2..cc94061634 100644
--- a/gcc/testsuite/c-c++-common/ubsan/overflow-sub-2.c
+++ b/gcc/testsuite/c-c++-common/ubsan/overflow-sub-2.c
@@ -51,4 +51,4 @@ main (void)
/* { dg-output "\[^\n\r]*signed integer overflow: -\[^\n\r]* - 1 cannot be represented in type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*signed integer overflow: -\[^\n\r]* - 1024 cannot be represented in type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*signed integer overflow: -\[^\n\r]* - 1 cannot be represented in type 'long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*signed integer overflow: -\[^\n\r]* - 1048576 cannot be represented in type 'long int'\[^\n\r]*" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: -\[^\n\r]* - 1048576 cannot be represented in type 'long int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/overflow-sub-4.c b/gcc/testsuite/c-c++-common/ubsan/overflow-sub-4.c
index 519b7babd0..d3fb9baeec 100644
--- a/gcc/testsuite/c-c++-common/ubsan/overflow-sub-4.c
+++ b/gcc/testsuite/c-c++-common/ubsan/overflow-sub-4.c
@@ -16,4 +16,4 @@ main ()
}
/* { dg-output "negation of -2147483648 cannot be represented in type 'int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*signed integer overflow: 0 - -2147483648 cannot be represented in type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 0 - -2147483648 cannot be represented in type 'int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr59333.c b/gcc/testsuite/c-c++-common/ubsan/pr59333.c
index 3550475097..b68775702b 100644
--- a/gcc/testsuite/c-c++-common/ubsan/pr59333.c
+++ b/gcc/testsuite/c-c++-common/ubsan/pr59333.c
@@ -15,4 +15,4 @@ main (void)
return 0;
}
-/* { dg-output "signed integer overflow: 2 \\+ 9223372036854775807 cannot be represented in type 'long long int'\[^\n\r]*" } */
+/* { dg-output "signed integer overflow: 2 \\+ 9223372036854775807 cannot be represented in type 'long long int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr59667.c b/gcc/testsuite/c-c++-common/ubsan/pr59667.c
index c76c9de980..d534661102 100644
--- a/gcc/testsuite/c-c++-common/ubsan/pr59667.c
+++ b/gcc/testsuite/c-c++-common/ubsan/pr59667.c
@@ -11,4 +11,4 @@ main (void)
return 0;
}
-/* { dg-output "store to null pointer of type 'float'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "store to null pointer of type 'float'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr60613-2.c b/gcc/testsuite/c-c++-common/ubsan/pr60613-2.c
index af6917e6b7..ed33e9341f 100644
--- a/gcc/testsuite/c-c++-common/ubsan/pr60613-2.c
+++ b/gcc/testsuite/c-c++-common/ubsan/pr60613-2.c
@@ -33,4 +33,4 @@ main ()
}
/* { dg-output "signed integer overflow: 8 \\- -9223372036854775801 cannot be represented in type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*signed integer overflow: 8 \\- -9223372036854775802 cannot be represented in type 'long long int'\[^\n\r]*" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 8 \\- -9223372036854775802 cannot be represented in type 'long long int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr60636.c b/gcc/testsuite/c-c++-common/ubsan/pr60636.c
index d6749ab678..4164341375 100644
--- a/gcc/testsuite/c-c++-common/ubsan/pr60636.c
+++ b/gcc/testsuite/c-c++-common/ubsan/pr60636.c
@@ -12,4 +12,4 @@ main ()
return 0;
}
-/* { dg-output "negation of -9223372036854775808 cannot be represented in type 'long long int'\[^\n\r]*" } */
+/* { dg-output "negation of -9223372036854775808 cannot be represented in type 'long long int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr63802.c b/gcc/testsuite/c-c++-common/ubsan/pr63802.c
index 454c0980f5..0ca7461ce9 100644
--- a/gcc/testsuite/c-c++-common/ubsan/pr63802.c
+++ b/gcc/testsuite/c-c++-common/ubsan/pr63802.c
@@ -20,4 +20,4 @@ int main ()
return 0;
}
-/* { dg-output "\.c:18:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct test_struct', which requires 64 byte alignment.*" } */
+/* { dg-output "\.c:18:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct test_struct', which requires 64 byte alignment" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr63866.c b/gcc/testsuite/c-c++-common/ubsan/pr63866.c
index e70daa72e1..2b53dd1548 100644
--- a/gcc/testsuite/c-c++-common/ubsan/pr63866.c
+++ b/gcc/testsuite/c-c++-common/ubsan/pr63866.c
@@ -8,4 +8,3 @@ foo (int x, int y)
return x + y;
}
-/* { dg-final { cleanup-ipa-dump "cgraph" } } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr67921.c b/gcc/testsuite/c-c++-common/ubsan/pr67921.c
new file mode 100644
index 0000000000..728ff93a60
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/pr67921.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=undefined" } */
+
+struct s
+{
+ int n;
+ int arr[][6];
+};
+void bar (int);
+void foo (struct s *ptr)
+{
+ int i;
+ for (; i < 2; i++)
+ for (; ptr->n;)
+ {
+ int *a = ptr->arr[i];
+ int b[66];
+ int j = 0;
+
+ for (; j < 56; j++)
+ bar (a[j] - b[j]);
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr68142.c b/gcc/testsuite/c-c++-common/ubsan/pr68142.c
new file mode 100644
index 0000000000..9498f08ae4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/pr68142.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
+
+int __attribute__((noinline,noclone))
+h(int a)
+{
+ return 2 * (a * (__INT_MAX__/2 + 1));
+}
+int __attribute__((noinline,noclone))
+i(int a)
+{
+ return (2 * a) * (__INT_MAX__/2 + 1);
+}
+int __attribute__((noinline,noclone))
+j(int a, int b)
+{
+ return (b * a) * (__INT_MAX__/2 + 1);
+}
+int __attribute__((noinline,noclone))
+k(int a, int b)
+{
+ return (2 * a) * b;
+}
+int main()
+{
+ volatile int tem = h(-1);
+ tem = i(-1);
+ tem = j(-1, 2);
+ tem = k(-1, __INT_MAX__/2 + 1);
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/ubsan/recovery-1.c b/gcc/testsuite/c-c++-common/ubsan/recovery-1.c
index 8043a5cbb6..62dd6f769f 100644
--- a/gcc/testsuite/c-c++-common/ubsan/recovery-1.c
+++ b/gcc/testsuite/c-c++-common/ubsan/recovery-1.c
@@ -6,4 +6,4 @@
/* { dg-output "shift exponent 152 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*shift exponent 153 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*signed integer overflow: 2147483647 \\+ 1 cannot be represented in type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*signed integer overflow: 2147483647 \\+ 2 cannot be represented in type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 2147483647 \\+ 2 cannot be represented in type 'int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/recovery-3.c b/gcc/testsuite/c-c++-common/ubsan/recovery-3.c
index 02f2272499..d1dcd3e829 100644
--- a/gcc/testsuite/c-c++-common/ubsan/recovery-3.c
+++ b/gcc/testsuite/c-c++-common/ubsan/recovery-3.c
@@ -6,4 +6,4 @@
/* { dg-output "shift exponent 152 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*shift exponent 153 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*signed integer overflow: 2147483647 \\+ 1 cannot be represented in type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*signed integer overflow: 2147483647 \\+ 2 cannot be represented in type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 2147483647 \\+ 2 cannot be represented in type 'int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/sanitize-all-2.c b/gcc/testsuite/c-c++-common/ubsan/sanitize-all-2.c
index 6ae6f3c233..4c631af325 100644
--- a/gcc/testsuite/c-c++-common/ubsan/sanitize-all-2.c
+++ b/gcc/testsuite/c-c++-common/ubsan/sanitize-all-2.c
@@ -38,4 +38,3 @@ main ()
/* { dg-final { scan-tree-dump-not "__ubsan_" "optimized" } } */
/* { dg-final { scan-tree-dump-not "UBSAN_CHECK_" "optimized" } } */
-/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/sanitize-all-3.c b/gcc/testsuite/c-c++-common/ubsan/sanitize-all-3.c
index 9be62acdbe..dc6ed1b6e4 100644
--- a/gcc/testsuite/c-c++-common/ubsan/sanitize-all-3.c
+++ b/gcc/testsuite/c-c++-common/ubsan/sanitize-all-3.c
@@ -39,4 +39,3 @@ main ()
/* { dg-final { scan-tree-dump "__ubsan_" "optimized" } } */
/* { dg-final { scan-tree-dump-not "__ubsan_\[a-z_\]*_abort" "optimized" } } */
/* { dg-final { scan-tree-dump "UBSAN_CHECK_" "optimized" } } */
-/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/sanitize-all-4.c b/gcc/testsuite/c-c++-common/ubsan/sanitize-all-4.c
index 1f7ec2b53f..adc7069138 100644
--- a/gcc/testsuite/c-c++-common/ubsan/sanitize-all-4.c
+++ b/gcc/testsuite/c-c++-common/ubsan/sanitize-all-4.c
@@ -39,4 +39,3 @@ main ()
/* { dg-final { scan-tree-dump "__ubsan_\[a-z_\]*_abort" "optimized" } } */
/* { dg-final { scan-tree-dump-not "__ubsan_\[a-z_\]*\[^et\] " "optimized" } } */
/* { dg-final { scan-tree-dump "UBSAN_CHECK_" "optimized" } } */
-/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/shift-1.c b/gcc/testsuite/c-c++-common/ubsan/shift-1.c
index d5c70baa81..d770e833df 100644
--- a/gcc/testsuite/c-c++-common/ubsan/shift-1.c
+++ b/gcc/testsuite/c-c++-common/ubsan/shift-1.c
@@ -28,4 +28,4 @@ main (void)
/* { dg-output "\[^\n\r]*shift exponent 154 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*shift exponent 524 is too large for \[^\n\r]*-bit type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*shift exponent 370 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*shift exponent 402 is too large for \[^\n\r]*-bit type 'long int'\[^\n\r]*" } */
+/* { dg-output "\[^\n\r]*shift exponent 402 is too large for \[^\n\r]*-bit type 'long int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/shift-2.c b/gcc/testsuite/c-c++-common/ubsan/shift-2.c
index 426ec09370..23067d8f3d 100644
--- a/gcc/testsuite/c-c++-common/ubsan/shift-2.c
+++ b/gcc/testsuite/c-c++-common/ubsan/shift-2.c
@@ -20,4 +20,4 @@ main (void)
/* { dg-output "\[^\n\r]*shift exponent -4 is negative\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*shift exponent -5 is negative\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*shift exponent -6 is negative\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*shift exponent -11 is negative\[^\n\r]*" } */
+/* { dg-output "\[^\n\r]*shift exponent -11 is negative" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/shift-4.c b/gcc/testsuite/c-c++-common/ubsan/shift-4.c
index 5f095b61ac..5b539ac223 100644
--- a/gcc/testsuite/c-c++-common/ubsan/shift-4.c
+++ b/gcc/testsuite/c-c++-common/ubsan/shift-4.c
@@ -11,4 +11,4 @@ main ()
return 0;
}
-/* { dg-output "shift exponent 120 is too large\[^\n\r]*" } */
+/* { dg-output "shift exponent 120 is too large" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/shift-7.c b/gcc/testsuite/c-c++-common/ubsan/shift-7.c
index 1e33273e57..5ecd368f98 100644
--- a/gcc/testsuite/c-c++-common/ubsan/shift-7.c
+++ b/gcc/testsuite/c-c++-common/ubsan/shift-7.c
@@ -24,4 +24,4 @@ main ()
}
/* { dg-output "shift exponent 4294967296 is too large for \[^\n\r]*-bit type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*shift exponent 4294967296 is too large for \[^\n\r]*-bit type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*shift exponent 4294967296 is too large for \[^\n\r]*-bit type 'long long unsigned int'" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/undefined-2.c b/gcc/testsuite/c-c++-common/ubsan/undefined-2.c
index 05dea44674..9f764f8009 100644
--- a/gcc/testsuite/c-c++-common/ubsan/undefined-2.c
+++ b/gcc/testsuite/c-c++-common/ubsan/undefined-2.c
@@ -19,4 +19,4 @@ main ()
return 0;
}
-/* { dg-output "shift exponent -\[^\n\r]* is negative\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "shift exponent -\[^\n\r]* is negative" } */
diff --git a/gcc/testsuite/c-c++-common/ubsan/vla-1.c b/gcc/testsuite/c-c++-common/ubsan/vla-1.c
index 1412203241..52ade3aab7 100644
--- a/gcc/testsuite/c-c++-common/ubsan/vla-1.c
+++ b/gcc/testsuite/c-c++-common/ubsan/vla-1.c
@@ -116,4 +116,4 @@ main (void)
/* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -6\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -4\[^\n\r]*" } */
+/* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -4" } */
diff --git a/gcc/testsuite/c-c++-common/vector-compare-4.c b/gcc/testsuite/c-c++-common/vector-compare-4.c
new file mode 100644
index 0000000000..e7d37eb845
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/vector-compare-4.c
@@ -0,0 +1,44 @@
+/* PR c/68062 */
+/* { dg-do compile } */
+/* { dg-options "-Wsign-compare -Wno-psabi" } */
+/* Ignore warning on some powerpc configurations. */
+/* { dg-prune-output "non-standard ABI extension" } */
+
+typedef signed char __attribute__ ((vector_size (4))) v4qi;
+typedef unsigned char __attribute__ ((vector_size (4))) uv4qi;
+typedef signed int __attribute__ ((vector_size (4 * __SIZEOF_INT__))) v4si;
+typedef unsigned int __attribute__ ((vector_size (4 * __SIZEOF_INT__))) uv4si;
+
+v4qi
+fn1 (void)
+{
+ v4qi a = { 1, 2, 3, 4 };
+ uv4qi b = { 4, 3, 2, 1 };
+ v4qi v = { 0, 0, 0, 0 };
+
+ v += (a == b); /* { dg-warning "comparison between types" } */
+ v += (a != b); /* { dg-warning "comparison between types" } */
+ v += (a >= b); /* { dg-warning "comparison between types" } */
+ v += (a <= b); /* { dg-warning "comparison between types" } */
+ v += (a > b); /* { dg-warning "comparison between types" } */
+ v += (a < b); /* { dg-warning "comparison between types" } */
+
+ return v;
+}
+
+v4si
+fn2 (void)
+{
+ v4si a = { 1, 2, 3, 4 };
+ uv4si b = { 4, 3, 2, 1 };
+ v4si v = { 0, 0, 0, 0 };
+
+ v += (a == b); /* { dg-warning "comparison between types" } */
+ v += (a != b); /* { dg-warning "comparison between types" } */
+ v += (a >= b); /* { dg-warning "comparison between types" } */
+ v += (a <= b); /* { dg-warning "comparison between types" } */
+ v += (a > b); /* { dg-warning "comparison between types" } */
+ v += (a < b); /* { dg-warning "comparison between types" } */
+
+ return v;
+}
diff --git a/gcc/testsuite/c-c++-common/vector-scalar-2.c b/gcc/testsuite/c-c++-common/vector-scalar-2.c
index f624c4c751..1957ffc30e 100644
--- a/gcc/testsuite/c-c++-common/vector-scalar-2.c
+++ b/gcc/testsuite/c-c++-common/vector-scalar-2.c
@@ -11,4 +11,3 @@ void f (veci *a)
}
/* { dg-final { scan-tree-dump-times " \\\+ 1" 1 "gimple" } } */
-/* { dg-final { cleanup-tree-dump "gimple" } } */