aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2023-02-12 16:27:19 +0100
committerThomas Schwinge <thomas@codesourcery.com>2023-02-12 16:27:19 +0100
commite9b5dc738b08b6e4af74b3ab1bea08db21ba7893 (patch)
tree308f90708fe3135f4b11836c05467f797f59d52c /gcc
parent6d4f8ef1a199460b7e7cc99b3e721eabbd97951f (diff)
parent982629bea416df976686467f235e09cb1a5531cc (diff)
downloadgcc-e9b5dc738b08b6e4af74b3ab1bea08db21ba7893.zip
gcc-e9b5dc738b08b6e4af74b3ab1bea08db21ba7893.tar.gz
gcc-e9b5dc738b08b6e4af74b3ab1bea08db21ba7893.tar.bz2
Merge commit 'f80f540e394e87ac70349bad109bfc4b465c7c98^' into HEAD
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog120
-rw-r--r--gcc/DATESTAMP2
-rw-r--r--gcc/analyzer/ChangeLog21
-rw-r--r--gcc/analyzer/kf.cc2
-rw-r--r--gcc/analyzer/region-model-asm.cc2
-rw-r--r--gcc/analyzer/region-model.cc11
-rw-r--r--gcc/analyzer/region-model.h1
-rw-r--r--gcc/analyzer/sm-fd.cc1
-rw-r--r--gcc/analyzer/varargs.cc3
-rw-r--r--gcc/c-family/ChangeLog4
-rw-r--r--gcc/c-family/c.opt5
-rw-r--r--gcc/config/i386/cmpccxaddintrin.h8
-rw-r--r--gcc/config/pa/pa.cc3
-rw-r--r--gcc/config/riscv/riscv.cc2
-rw-r--r--gcc/cp/ChangeLog85
-rw-r--r--gcc/cp/coroutines.cc6
-rw-r--r--gcc/cp/error.cc9
-rw-r--r--gcc/cp/init.cc9
-rw-r--r--gcc/cp/mangle.cc14
-rw-r--r--gcc/cp/parser.cc43
-rw-r--r--gcc/cp/pt.cc224
-rw-r--r--gcc/cp/rtti.cc4
-rw-r--r--gcc/cp/typeck.cc8
-rw-r--r--gcc/doc/extend.texi14
-rw-r--r--gcc/doc/invoke.texi31
-rw-r--r--gcc/doc/passes.texi15
-rw-r--r--gcc/gimple-array-bounds.cc105
-rw-r--r--gcc/loop-invariant.cc2
-rw-r--r--gcc/m2/ChangeLog11
-rwxr-xr-xgcc/m2/configure47
-rw-r--r--gcc/m2/configure.ac5
-rwxr-xr-xgcc/m2/tools-src/calcpath34
-rw-r--r--gcc/opts.cc8
-rw-r--r--gcc/testsuite/ChangeLog122
-rw-r--r--gcc/testsuite/c-c++-common/Wstrict-flex-arrays.c9
-rw-r--r--gcc/testsuite/g++.dg/contracts/contracts-externC.C19
-rw-r--r--gcc/testsuite/g++.dg/coroutines/pr107768.C26
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-alias1.C23
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr107065.C14
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/lambda-generic-107437.C21
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/constexpr-if-lambda5.C15
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/constexpr-lambda26.C1
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/using-variadic1.C29
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/using-variadic1a.C34
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/using-variadic1b.C37
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/using-variadic1c.C33
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/using-variadic2.C24
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/using-variadic3.C8
-rw-r--r--gcc/testsuite/g++.dg/cpp23/ext-floating13.C35
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/concepts-placeholder11.C10
-rw-r--r--gcc/testsuite/g++.dg/template/ptrmem33.C30
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr106751.c17
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-1.c5
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-2.c6
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-3.c7
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-4.c5
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-5.c6
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-6.c7
-rw-r--r--gcc/testsuite/gcc.dg/Wstrict-flex-arrays-2.c39
-rw-r--r--gcc/testsuite/gcc.dg/Wstrict-flex-arrays-3.c39
-rw-r--r--gcc/testsuite/gcc.dg/Wstrict-flex-arrays.c39
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr104308.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/cmpccxadd-1.c64
-rw-r--r--gcc/testsuite/gcc.target/i386/cmpccxadd-2.c64
-rw-r--r--gcc/testsuite/lib/target-supports.exp3
-rw-r--r--gcc/tree-inline.cc67
-rw-r--r--gcc/tree-vrp.cc2
67 files changed, 1398 insertions, 323 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5299b0d..a4c26b4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,123 @@
+2022-12-16 John David Anglin <danglin@gcc.gnu.org>
+
+ * config/pa/pa.cc (pa_option_override): Disable -fstack-protector.
+
+2022-12-16 Vladimir N. Makarov <vmakarov@redhat.com>
+
+ Revert:
+ 2022-12-15 Vladimir N. Makarov <vmakarov@redhat.com>
+
+ * ira-costs.cc: Include print-rtl.h.
+ (record_reg_classes, scan_one_insn): Add code to print debug info.
+ * ira.cc (ira_init_register_move_cost): Check that at least one hard
+ reg of the mode are in the class contents to calculate the
+ register move costs.
+
+2022-12-16 Qing Zhao <qing.zhao@oracle.com>
+
+ * doc/invoke.texi: Document -Wstrict-flex-arrays option.
+ * gimple-array-bounds.cc (check_out_of_bounds_and_warn): Add two more
+ arguments.
+ (array_bounds_checker::check_array_ref): Issue warnings for
+ -Wstrict-flex-arrays.
+ * opts.cc (finish_options): Issue warning for unsupported combination
+ of -Wstrict_flex_arrays and -fstrict-flex-array.
+ * tree-vrp.cc (execute_ranger_vrp): Enable the pass when
+ warn_strict_flex_array is true.
+
+2022-12-16 Palmer Dabbelt <palmer@rivosinc.com>
+
+ * config/riscv/riscv.cc (riscv_option_override): Fix comment
+ wording.
+
+2022-12-16 Palmer Dabbelt <palmer@rivosinc.com>
+
+ * doc/extend.texi (__builtin_riscv_pause): Imply
+ Xgnuzihintpausestate.
+
+2022-12-16 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/108086
+ * tree-inline.cc (remap_ssa_name): Do not unshare the
+ result from the decl_map.
+
+2022-12-16 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/108086
+ * tree-inline.cc (copy_bb): Remove handling of (foo *)&this->m
+ substitution which is done in remap_gimple_op_r via
+ re-gimplifying.
+
+2022-12-16 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/106751
+ * loop-invariant.cc (move_invariant_reg): If preheader bb ends
+ with a JUMP_INSN, split the preheader edge and emit invariants
+ into the new preheader basic block.
+
+2022-12-16 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/108086
+ * tree-inline.cc (remap_gimple_stmt): Add stmts to the
+ sequence without updating them. Simplify x == x detection.
+
+2022-12-16 Haochen Jiang <haochen.jiang@intel.com>
+
+ * config/i386/cmpccxaddintrin.h
+ (__cmpccxadd_epi32): Rename to _cmpccxadd_epi32.
+ (__cmpccxadd_epi64): Rename to _cmpccxadd_epi64.
+
+2022-12-15 Vladimir N. Makarov <vmakarov@redhat.com>
+
+ * ira-costs.cc: Include print-rtl.h.
+ (record_reg_classes, scan_one_insn): Add code to print debug info.
+ * ira.cc (ira_init_register_move_cost): Check that at least one hard
+ reg of the mode are in the class contents to calculate the
+ register move costs.
+
+2022-12-15 Siddhesh Poyarekar <siddhesh@gotplt.org>
+
+ * doc/extend.texi (__builtin_dynamic_object_size): Document
+ builtin.
+ * doc/passes.texi
+ (Optimize calls to @code{__builtin_object_size}): Also mention
+ __builtin_dynamic_object_size.
+
+2022-12-15 Siddhesh Poyarekar <siddhesh@gotplt.org>
+
+ PR middle-end/70090
+ * doc/invoke.texi (-fsanitize=object-size): Use
+ __builtin_dynamic_object_size instead of
+ __builtin_object_size.
+
+2022-12-15 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/108086
+ * tree-inline.cc (copy_edges_for_bb): Walk stmts backwards for
+ splitting the block to avoid quadratic behavior with setting
+ stmts BB on multliple splits.
+
+2022-12-15 Spacetown <michael.foerderer@gmx.de>
+
+ PR gcov-profile/107537
+ * gcov.cc (output_branch_count): Add annotation '(fallthrough)'
+ or '(throw)' also to uncovered branches.
+
+2022-12-15 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/108086
+ * tree-inline.cc (copy_edges_for_bb): Do not update all
+ stmts again.
+
+2022-12-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/108095
+ * tree-into-ssa.cc (maybe_register_def): Insert debug stmt
+ on all non-EH edges from asm goto if they have a single
+ predecessor rather than asserting there is at most one such edge.
+ Test whether there are no PHI nodes next to the single predecessor
+ test.
+
2022-12-14 David Faust <david.faust@oracle.com>
PR target/106773
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 414c306..ee0b666 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221215
+20221217
diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog
index 3363fc8..9ca2e46 100644
--- a/gcc/analyzer/ChangeLog
+++ b/gcc/analyzer/ChangeLog
@@ -1,3 +1,24 @@
+2022-12-16 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/106479
+ * kf.cc (kf_memcpy_memmove::impl_call_pre): Pass in source region
+ to region_model::check_for_poison.
+ * region-model-asm.cc (region_model::on_asm_stmt): Pass NULL
+ region to region_model::check_for_poison.
+ * region-model.cc (region_model::check_for_poison): Add
+ "src_region" param, and pass it to poisoned_value_diagnostic.
+ (region_model::on_assignment): Pass NULL region to
+ region_model::check_for_poison.
+ (region_model::get_rvalue): Likewise.
+ * region-model.h (region_model::check_for_poison): Add
+ "src_region" param.
+ * sm-fd.cc (fd_state_machine::on_accept): Pass in source region
+ to region_model::check_for_poison.
+ * varargs.cc (kf_va_copy::impl_call_pre): Pass NULL region to
+ region_model::check_for_poison.
+ (kf_va_arg::impl_call_pre): Pass in source region to
+ region_model::check_for_poison.
+
2022-12-14 David Malcolm <dmalcolm@redhat.com>
PR analyzer/108065
diff --git a/gcc/analyzer/kf.cc b/gcc/analyzer/kf.cc
index ff2f1b1..6088bfc 100644
--- a/gcc/analyzer/kf.cc
+++ b/gcc/analyzer/kf.cc
@@ -288,7 +288,7 @@ kf_memcpy_memmove::impl_call_pre (const call_details &cd) const
const svalue *src_contents_sval
= model->get_store_value (sized_src_reg, cd.get_ctxt ());
model->check_for_poison (src_contents_sval, cd.get_arg_tree (1),
- cd.get_ctxt ());
+ sized_src_reg, cd.get_ctxt ());
model->set_value (sized_dest_reg, src_contents_sval, cd.get_ctxt ());
}
diff --git a/gcc/analyzer/region-model-asm.cc b/gcc/analyzer/region-model-asm.cc
index 171b249..ac32c6f 100644
--- a/gcc/analyzer/region-model-asm.cc
+++ b/gcc/analyzer/region-model-asm.cc
@@ -226,7 +226,7 @@ region_model::on_asm_stmt (const gasm *stmt, region_model_context *ctxt)
tree src_expr = input_tvec[i];
const svalue *src_sval = get_rvalue (src_expr, ctxt);
- check_for_poison (src_sval, src_expr, ctxt);
+ check_for_poison (src_sval, src_expr, NULL, ctxt);
input_svals.quick_push (src_sval);
reachable_regs.handle_sval (src_sval);
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index f6cd34f..5506440 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -1004,11 +1004,13 @@ due_to_ifn_deferred_init_p (const gassign *assign_stmt)
/* Check for SVAL being poisoned, adding a warning to CTXT.
Return SVAL, or, if a warning is added, another value, to avoid
- repeatedly complaining about the same poisoned value in followup code. */
+ repeatedly complaining about the same poisoned value in followup code.
+ SRC_REGION is a hint about where SVAL came from, and can be NULL. */
const svalue *
region_model::check_for_poison (const svalue *sval,
tree expr,
+ const region *src_region,
region_model_context *ctxt) const
{
if (!ctxt)
@@ -1046,8 +1048,7 @@ region_model::check_for_poison (const svalue *sval,
the tree other than via the def stmts, using
fixup_tree_for_diagnostic. */
tree diag_arg = fixup_tree_for_diagnostic (expr);
- const region *src_region = NULL;
- if (pkind == POISON_KIND_UNINIT)
+ if (src_region == NULL && pkind == POISON_KIND_UNINIT)
src_region = get_region_for_poisoned_expr (expr);
if (ctxt->warn (make_unique<poisoned_value_diagnostic> (diag_arg,
pkind,
@@ -1100,7 +1101,7 @@ region_model::on_assignment (const gassign *assign, region_model_context *ctxt)
if (const svalue *sval = get_gassign_result (assign, ctxt))
{
tree expr = get_diagnostic_tree_for_gassign (assign);
- check_for_poison (sval, expr, ctxt);
+ check_for_poison (sval, expr, NULL, ctxt);
set_value (lhs_reg, sval, ctxt);
return;
}
@@ -2227,7 +2228,7 @@ region_model::get_rvalue (path_var pv, region_model_context *ctxt) const
assert_compat_types (result_sval->get_type (), TREE_TYPE (pv.m_tree));
- result_sval = check_for_poison (result_sval, pv.m_tree, ctxt);
+ result_sval = check_for_poison (result_sval, pv.m_tree, NULL, ctxt);
return result_sval;
}
diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h
index 626b10d..e8767e5 100644
--- a/gcc/analyzer/region-model.h
+++ b/gcc/analyzer/region-model.h
@@ -485,6 +485,7 @@ class region_model
const svalue *check_for_poison (const svalue *sval,
tree expr,
+ const region *src_region,
region_model_context *ctxt) const;
void check_region_for_write (const region *dest_reg,
diff --git a/gcc/analyzer/sm-fd.cc b/gcc/analyzer/sm-fd.cc
index 50e1313..03bcdfa 100644
--- a/gcc/analyzer/sm-fd.cc
+++ b/gcc/analyzer/sm-fd.cc
@@ -1992,6 +1992,7 @@ fd_state_machine::on_accept (const call_details &cd,
build_int_cst (TREE_TYPE (len_ptr), 0));
old_len_sval = model->check_for_poison (old_len_sval,
star_len_ptr,
+ len_reg,
cd.get_ctxt ());
if (successful)
{
diff --git a/gcc/analyzer/varargs.cc b/gcc/analyzer/varargs.cc
index 1a3bdde..5414f23 100644
--- a/gcc/analyzer/varargs.cc
+++ b/gcc/analyzer/varargs.cc
@@ -723,6 +723,7 @@ kf_va_copy::impl_call_pre (const call_details &cd) const
in_va_list
= model->check_for_poison (in_va_list,
get_va_list_diag_arg (cd.get_arg_tree (1)),
+ NULL,
cd.get_ctxt ());
const region *out_dst_reg
@@ -1004,7 +1005,7 @@ kf_va_arg::impl_call_pre (const call_details &cd) const
ap_sval = cast;
tree va_list_tree = get_va_list_diag_arg (cd.get_arg_tree (0));
- ap_sval = model->check_for_poison (ap_sval, va_list_tree, ctxt);
+ ap_sval = model->check_for_poison (ap_sval, va_list_tree, ap_reg, ctxt);
if (const region *impl_reg = ap_sval->maybe_get_region ())
{
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 3fb66a7..3670dcc 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,7 @@
+2022-12-16 Qing Zhao <qing.zhao@oracle.com>
+
+ * c.opt (Wstrict-flex-arrays): New option.
+
2022-12-02 Andrew MacLeod <amacleod@redhat.com>
* c-attribs.cc (handle_deprecated_attribute): Use type when
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 0d0ad0a..33edeef 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -976,6 +976,11 @@ Wstringop-truncation
C ObjC C++ LTO ObjC++ Var(warn_stringop_truncation) Warning Init (1) LangEnabledBy(C ObjC C++ LTO ObjC++, Wall)
Warn about truncation in string manipulation functions like strncat and strncpy.
+Wstrict-flex-arrays
+C C++ Var(warn_strict_flex_arrays) Warning
+Warn about inproper usages of flexible array members
+according to the level of -fstrict-flex-arrays.
+
Wsuggest-attribute=format
C ObjC C++ ObjC++ Var(warn_suggest_attribute_format) Warning
Warn about functions which might be candidates for format attributes.
diff --git a/gcc/config/i386/cmpccxaddintrin.h b/gcc/config/i386/cmpccxaddintrin.h
index 1afa03b..11fce1f 100644
--- a/gcc/config/i386/cmpccxaddintrin.h
+++ b/gcc/config/i386/cmpccxaddintrin.h
@@ -58,23 +58,23 @@ typedef enum {
#ifdef __OPTIMIZE__
extern __inline int
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-__cmpccxadd_epi32 (int *__A, int __B, int __C, const _CMPCCX_ENUM __D)
+_cmpccxadd_epi32 (int *__A, int __B, int __C, const _CMPCCX_ENUM __D)
{
return __builtin_ia32_cmpccxadd (__A, __B, __C, __D);
}
extern __inline long long
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-__cmpccxadd_epi64 (long long *__A, long long __B, long long __C,
+_cmpccxadd_epi64 (long long *__A, long long __B, long long __C,
const _CMPCCX_ENUM __D)
{
return __builtin_ia32_cmpccxadd64 (__A, __B, __C, __D);
}
#else
-#define __cmpccxadd_epi32(A,B,C,D) \
+#define _cmpccxadd_epi32(A,B,C,D) \
__builtin_ia32_cmpccxadd ((int *) (A), (int) (B), (int) (C), \
(_CMPCCX_ENUM) (D))
-#define __cmpccxadd_epi64(A,B,C,D) \
+#define _cmpccxadd_epi64(A,B,C,D) \
__builtin_ia32_cmpccxadd64 ((long long *) (A), (long long) (B), \
(long long) (C), (_CMPCCX_ENUM) (D))
#endif
diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc
index 54ab486..9f43802 100644
--- a/gcc/config/pa/pa.cc
+++ b/gcc/config/pa/pa.cc
@@ -567,6 +567,9 @@ pa_option_override (void)
flag_reorder_blocks = 1;
}
+ /* Disable -fstack-protector to suppress warning. */
+ flag_stack_protect = 0;
+
/* We can't guarantee that .dword is available for 32-bit targets. */
if (UNITS_PER_WORD == 4)
targetm.asm_out.aligned_op.di = NULL;
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 1f85391..6dd2ab2 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -5991,7 +5991,7 @@ riscv_option_override (void)
target_flags |= MASK_FDIV;
/* Handle -mtune, use -mcpu if -mtune is not given, and use default -mtune
- if -mtune and -mcpu both not given. */
+ if both -mtune and -mcpu are not given. */
cpu = riscv_parse_tune (riscv_tune_string ? riscv_tune_string :
(riscv_cpu_string ? riscv_cpu_string :
RISCV_TUNE_STRING_DEFAULT));
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a4733be..d52b03f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,88 @@
+2022-12-16 Andrew Pinski <pinskia@gmail.com>
+ Iain Sandoe <iain@sandoe.co.uk>
+
+ PR c++/107768
+ * coroutines.cc (coro_rewrite_function_body): Initialize pointers
+ from nullptr_node. (morph_fn_to_coro): Likewise.
+
+2022-12-15 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/102104
+ PR c++/108090
+ * error.cc (dump_decl) <case USING_DECL>: Look through a
+ pack expansion in the name as well.
+ * parser.cc (cp_parser_using_declaration): Handle a parameter
+ pack appearing in the terminal name of a variadic using-decl.
+ * pt.cc (tsubst_decl) <case USING_DECL>: Likewise. Combine the
+ handling of variadic and non-variadic using-decls.
+
+2022-12-15 Jason Merrill <jason@redhat.com>
+
+ * init.cc (build_vec_init): Rename "flags" to "cleanup_flags"
+ to distinguish from LOOKUP_*.
+
+2022-12-15 Arsen Arsenović <arsen@aarsen.me>
+
+ * mangle.cc (write_encoding): Move contract pre/post function
+ mangling from here...
+ (write_mangled_name): ... to here, and make it happen always.
+
+2022-12-15 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/107188
+ * parser.cc (cp_parser_using_declaration): Give up early if the
+ scope of an access-declaration isn't possibly a class type.
+
+2022-12-15 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/100295
+ PR c++/107579
+ * pt.cc (el_data::skip_unevaluated_operands): New data member.
+ (extract_locals_r): If skip_unevaluated_operands is true,
+ don't walk into unevaluated contexts.
+ (extract_local_specs): Walk the pattern twice, first with
+ skip_unevaluated_operands true followed by it set to false.
+
+2022-12-15 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/105518
+ * pt.cc (tsubst_aggr_type): Handle typedefs by delegating to
+ tsubst and adjusting the result if entering_scope. Split out
+ the main part of the function into ...
+ (tsubst_aggr_type_1) ... here.
+ (tsubst): Use tsubst_aggr_type_1 instead of tsubst_aggr_type.
+ Handle TYPE_PTRMEMFUNC_P RECORD_TYPEs here instead of in
+ tsubst_aggr_type_1.
+
+2022-12-15 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/108104
+ * pt.cc (unify) <default>: Relax assert to accept any
+ CONSTRUCTOR parm, not just COMPOUND_LITERAL_P one.
+
+2022-12-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/107065
+ * typeck.cc (cp_build_unary_op) <case TRUTH_NOT_EXPR>: If
+ invert_truthvalue_loc returns obvalue_p, wrap it into NON_LVALUE_EXPR.
+ * parser.cc (cp_parser_binary_expression): Don't call
+ warn_logical_not_parentheses if current.lhs is a NON_LVALUE_EXPR
+ of a decl with boolean type.
+
+2022-12-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR libstdc++/108075
+ * rtti.cc (emit_support_tinfos): Add pointers to
+ {bfloat16,float{16,32,64,128,32x,64x,128x}}_type_node to fundamentals
+ array.
+
+2022-12-15 Jason Merrill <jason@redhat.com>
+
+ PR c++/108071
+ PR c++/105838
+ * call.cc (struct conversion_obstack_sentinel): New.
+ (maybe_init_list_as_array): Compare conversion of dummy argument.
+
2022-12-12 Jason Merrill <jason@redhat.com>
Revert:
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 3f23317..88d6c30 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -4132,7 +4132,7 @@ coro_rewrite_function_body (location_t fn_start, tree fnbody, tree orig,
/* We will need to be able to set the resume function pointer to nullptr
to signal that the coroutine is 'done'. */
tree zero_resume
- = build1 (CONVERT_EXPR, resume_fn_ptr_type, integer_zero_node);
+ = build1 (CONVERT_EXPR, resume_fn_ptr_type, nullptr_node);
/* The pointer to the destroy function. */
tree var = coro_build_artificial_var (fn_start, coro_destroy_fn_id,
@@ -4519,7 +4519,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
tree ramp_body = push_stmt_list ();
tree zeroinit = build1_loc (fn_start, CONVERT_EXPR,
- coro_frame_ptr, integer_zero_node);
+ coro_frame_ptr, nullptr_node);
tree coro_fp = coro_build_artificial_var (fn_start, "_Coro_frameptr",
coro_frame_ptr, orig, zeroinit);
tree varlist = coro_fp;
@@ -4754,7 +4754,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
gcc_checking_assert (same_type_p (fn_return_type, TREE_TYPE (grooaf)));
tree if_stmt = begin_if_stmt ();
- tree cond = build1 (CONVERT_EXPR, coro_frame_ptr, integer_zero_node);
+ tree cond = build1 (CONVERT_EXPR, coro_frame_ptr, nullptr_node);
cond = build2 (EQ_EXPR, boolean_type_node, coro_fp, cond);
finish_if_stmt_cond (cond, if_stmt);
if (VOID_TYPE_P (fn_return_type))
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index 12b28e8..e7f6033 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -1477,11 +1477,20 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags)
if (!(flags & TFF_UNQUALIFIED_NAME))
{
tree scope = USING_DECL_SCOPE (t);
+ tree name = DECL_NAME (t);
if (PACK_EXPANSION_P (scope))
{
scope = PACK_EXPANSION_PATTERN (scope);
variadic = true;
}
+ if (identifier_p (name)
+ && IDENTIFIER_CONV_OP_P (name)
+ && PACK_EXPANSION_P (TREE_TYPE (name)))
+ {
+ name = make_conv_op_name (PACK_EXPANSION_PATTERN
+ (TREE_TYPE (name)));
+ variadic = true;
+ }
dump_type (pp, scope, flags);
pp_cxx_colon_colon (pp);
}
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index 428fac5..73e6547 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -4379,7 +4379,7 @@ build_vec_init (tree base, tree maxindex, tree init,
bool explicit_value_init_p,
int from_array,
tsubst_flags_t complain,
- vec<tree, va_gc>** flags /* = nullptr */)
+ vec<tree, va_gc>** cleanup_flags /* = nullptr */)
{
tree rval;
tree base2 = NULL_TREE;
@@ -4590,8 +4590,8 @@ build_vec_init (tree base, tree maxindex, tree init,
anything for arrays. But if the array is a subobject, we need to
tell split_nonconstant_init how to turn off this cleanup in favor of
the cleanup for the complete object. */
- if (flags)
- vec_safe_push (*flags, build_tree_list (iterator, maxindex));
+ if (cleanup_flags)
+ vec_safe_push (*cleanup_flags, build_tree_list (iterator, maxindex));
}
/* Should we try to create a constant initializer? */
@@ -4650,7 +4650,8 @@ build_vec_init (tree base, tree maxindex, tree init,
if (digested)
one_init = cp_build_init_expr (baseref, elt);
else if (tree vi = get_vec_init_expr (elt))
- one_init = expand_vec_init_expr (baseref, vi, complain, flags);
+ one_init = expand_vec_init_expr (baseref, vi, complain,
+ cleanup_flags);
else if (MAYBE_CLASS_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
one_init = build_aggr_init (baseref, elt, 0, complain);
else
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index e363ef3..074cf27 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -798,6 +798,13 @@ write_mangled_name (const tree decl, bool top_level)
write_string ("_Z");
write_encoding (decl);
}
+
+ /* If this is the pre/post function for a guarded function, append
+ .pre/post, like something from create_virtual_clone. */
+ if (DECL_IS_PRE_FN_P (decl))
+ write_string (".pre");
+ else if (DECL_IS_POST_FN_P (decl))
+ write_string (".post");
}
/* Returns true if the return type of DECL is part of its signature, and
@@ -856,13 +863,6 @@ write_encoding (const tree decl)
mangle_return_type_p (decl),
d);
- /* If this is the pre/post function for a guarded function, append
- .pre/post, like something from create_virtual_clone. */
- if (DECL_IS_PRE_FN_P (decl))
- write_string (".pre");
- else if (DECL_IS_POST_FN_P (decl))
- write_string (".post");
-
/* If this is a coroutine helper, then append an appropriate string to
identify which. */
if (tree ramp = DECL_RAMP_FN (decl))
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 4798aae..bfd8aea 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -10224,7 +10224,10 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p,
|| (TREE_CODE (TREE_TYPE (TREE_OPERAND (current.lhs, 0)))
!= BOOLEAN_TYPE))))
/* Avoid warning for !!b == y where b is boolean. */
- && (!DECL_P (tree_strip_any_location_wrapper (current.lhs))
+ && (!(DECL_P (tree_strip_any_location_wrapper (current.lhs))
+ || (TREE_CODE (current.lhs) == NON_LVALUE_EXPR
+ && DECL_P (tree_strip_any_location_wrapper
+ (TREE_OPERAND (current.lhs, 0)))))
|| TREE_TYPE (current.lhs) == NULL_TREE
|| TREE_CODE (TREE_TYPE (current.lhs)) != BOOLEAN_TYPE))
warn_logical_not_parentheses (current.loc, current.tree_type,
@@ -21670,6 +21673,13 @@ cp_parser_using_declaration (cp_parser* parser,
cp_warn_deprecated_use_scopes (qscope);
+ if (access_declaration_p
+ && !MAYBE_CLASS_TYPE_P (qscope)
+ && TREE_CODE (qscope) != ENUMERAL_TYPE)
+ /* If the qualifying scope of an access-declaration isn't a class
+ or enumeration type then it can't be valid. */
+ cp_parser_simulate_error (parser);
+
if (access_declaration_p && cp_parser_error_occurred (parser))
/* Something has already gone wrong; there's no need to parse
further. Since an error has occurred, the return value of
@@ -21698,7 +21708,36 @@ cp_parser_using_declaration (cp_parser* parser,
pedwarn (ell->location, OPT_Wc__17_extensions,
"pack expansion in using-declaration only available "
"with %<-std=c++17%> or %<-std=gnu++17%>");
- qscope = make_pack_expansion (qscope);
+
+ /* A parameter pack can appear in the qualifying scope, and/or in the
+ terminal name (if naming a conversion function). Logically they're
+ part of a single pack expansion of the overall USING_DECL, but we
+ express them as separate pack expansions within the USING_DECL since
+ we can't create a pack expansion over a USING_DECL. */
+ bool saw_parm_pack = false;
+ if (uses_parameter_packs (qscope))
+ {
+ qscope = make_pack_expansion (qscope);
+ saw_parm_pack = true;
+ }
+ if (identifier_p (identifier)
+ && IDENTIFIER_CONV_OP_P (identifier)
+ && uses_parameter_packs (TREE_TYPE (identifier)))
+ {
+ identifier = make_conv_op_name (make_pack_expansion
+ (TREE_TYPE (identifier)));
+ saw_parm_pack = true;
+ }
+ if (!saw_parm_pack)
+ {
+ /* Issue an error in terms using a SCOPE_REF that includes both
+ components. */
+ tree name
+ = build_qualified_name (NULL_TREE, qscope, identifier, false);
+ make_pack_expansion (name);
+ gcc_assert (seen_error ());
+ qscope = identifier = error_mark_node;
+ }
}
/* The function we call to handle a using-declaration is different
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 80110da..2516cca 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -185,6 +185,7 @@ static tree tsubst_template_parms (tree, tree, tsubst_flags_t);
static void tsubst_each_template_parm_constraints (tree, tree, tsubst_flags_t);
tree most_specialized_partial_spec (tree, tsubst_flags_t);
static tree tsubst_aggr_type (tree, tree, tsubst_flags_t, tree, int);
+static tree tsubst_aggr_type_1 (tree, tree, tsubst_flags_t, tree, int);
static tree tsubst_arg_types (tree, tree, tree, tsubst_flags_t, tree);
static tree tsubst_function_type (tree, tree, tsubst_flags_t, tree);
static bool check_specialization_scope (void);
@@ -7317,7 +7318,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
&& has_value_dependent_address (expr))
/* If we want the address and it's value-dependent, don't fold. */;
else if (processing_template_decl
- && is_nondependent_constant_expression (expr))
+ && !instantiation_dependent_expression_p (expr))
non_dep = true;
if (error_operand_p (expr))
return error_mark_node;
@@ -13015,17 +13016,26 @@ public:
/* List of local_specializations used within the pattern. */
tree extra;
tsubst_flags_t complain;
+ /* True iff we don't want to walk into unevaluated contexts. */
+ bool skip_unevaluated_operands = false;
el_data (tsubst_flags_t c)
: extra (NULL_TREE), complain (c) {}
};
static tree
-extract_locals_r (tree *tp, int */*walk_subtrees*/, void *data_)
+extract_locals_r (tree *tp, int *walk_subtrees, void *data_)
{
el_data &data = *reinterpret_cast<el_data*>(data_);
tree *extra = &data.extra;
tsubst_flags_t complain = data.complain;
+ if (data.skip_unevaluated_operands
+ && unevaluated_p (TREE_CODE (*tp)))
+ {
+ *walk_subtrees = 0;
+ return NULL_TREE;
+ }
+
if (TYPE_P (*tp) && typedef_variant_p (*tp))
/* Remember local typedefs (85214). */
tp = &TYPE_NAME (*tp);
@@ -13117,6 +13127,14 @@ static tree
extract_local_specs (tree pattern, tsubst_flags_t complain)
{
el_data data (complain);
+ /* Walk the pattern twice, ignoring unevaluated operands the first time
+ around, so that if a local specialization appears in both an evaluated
+ and unevaluated context we prefer to process it in the evaluated context
+ (since e.g. process_outer_var_ref is a no-op inside an unevaluated
+ context). */
+ data.skip_unevaluated_operands = true;
+ cp_walk_tree (&pattern, extract_locals_r, &data, &data.visited);
+ data.skip_unevaluated_operands = false;
cp_walk_tree (&pattern, extract_locals_r, &data, &data.visited);
return data.extra;
}
@@ -13828,57 +13846,80 @@ tsubst_aggr_type (tree t,
if (t == NULL_TREE)
return NULL_TREE;
- /* If T is an alias template specialization, we want to substitute that
- rather than strip it, especially if it's dependent_alias_template_spec_p.
- It should be OK not to handle entering_scope in this case, since
- DECL_CONTEXT will never be an alias template specialization. We only get
- here with an alias when tsubst calls us for TYPENAME_TYPE. */
- if (alias_template_specialization_p (t, nt_transparent))
- return tsubst (t, args, complain, in_decl);
+ /* Handle typedefs via tsubst so that they get consistently reused. */
+ if (typedef_variant_p (t))
+ {
+ t = tsubst (t, args, complain, in_decl);
+ if (t == error_mark_node)
+ return error_mark_node;
+
+ /* The effect of entering_scope is that for a dependent specialization
+ A<T>, lookup_template_class prefers to return A's primary template
+ type instead of the implicit instantiation. So when entering_scope,
+ we mirror this behavior by inspecting TYPE_CANONICAL appropriately,
+ taking advantage of the fact that lookup_template_class links the two
+ types by setting TYPE_CANONICAL of the latter to the former. */
+ if (entering_scope
+ && CLASS_TYPE_P (t)
+ && dependent_type_p (t)
+ && TYPE_CANONICAL (t) == TREE_TYPE (TYPE_TI_TEMPLATE (t)))
+ t = TYPE_CANONICAL (t);
+
+ return t;
+ }
switch (TREE_CODE (t))
{
- case RECORD_TYPE:
- if (TYPE_PTRMEMFUNC_P (t))
- return tsubst (TYPE_PTRMEMFUNC_FN_TYPE (t), args, complain, in_decl);
+ case RECORD_TYPE:
+ case ENUMERAL_TYPE:
+ case UNION_TYPE:
+ return tsubst_aggr_type_1 (t, args, complain, in_decl, entering_scope);
- /* Fall through. */
- case ENUMERAL_TYPE:
- case UNION_TYPE:
- if (TYPE_TEMPLATE_INFO (t) && uses_template_parms (t))
- {
- tree argvec;
- tree r;
+ default:
+ return tsubst (t, args, complain, in_decl);
+ }
+}
+
+/* The part of tsubst_aggr_type that's shared with the RECORD_, UNION_
+ and ENUMERAL_TYPE cases of tsubst. */
- /* Figure out what arguments are appropriate for the
- type we are trying to find. For example, given:
+static tree
+tsubst_aggr_type_1 (tree t,
+ tree args,
+ tsubst_flags_t complain,
+ tree in_decl,
+ int entering_scope)
+{
+ if (TYPE_TEMPLATE_INFO (t) && uses_template_parms (t))
+ {
+ tree argvec;
+ tree r;
- template <class T> struct S;
- template <class T, class U> void f(T, U) { S<U> su; }
+ /* Figure out what arguments are appropriate for the
+ type we are trying to find. For example, given:
- and supposing that we are instantiating f<int, double>,
- then our ARGS will be {int, double}, but, when looking up
- S we only want {double}. */
- argvec = tsubst_template_args (TYPE_TI_ARGS (t), args,
- complain, in_decl);
- if (argvec == error_mark_node)
- r = error_mark_node;
- else
- {
- r = lookup_template_class (t, argvec, in_decl, NULL_TREE,
- entering_scope, complain);
- r = cp_build_qualified_type (r, cp_type_quals (t), complain);
- }
+ template <class T> struct S;
+ template <class T, class U> void f(T, U) { S<U> su; }
- return r;
- }
+ and supposing that we are instantiating f<int, double>,
+ then our ARGS will be {int, double}, but, when looking up
+ S we only want {double}. */
+ argvec = tsubst_template_args (TYPE_TI_ARGS (t), args,
+ complain, in_decl);
+ if (argvec == error_mark_node)
+ r = error_mark_node;
else
- /* This is not a template type, so there's nothing to do. */
- return t;
+ {
+ r = lookup_template_class (t, argvec, in_decl, NULL_TREE,
+ entering_scope, complain);
+ r = cp_build_qualified_type (r, cp_type_quals (t), complain);
+ }
- default:
- return tsubst (t, args, complain, in_decl);
+ return r;
}
+ else
+ /* This is not a template type, so there's nothing to do. */
+ return t;
}
/* Map from a FUNCTION_DECL to a vec of default argument instantiations,
@@ -14921,43 +14962,81 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
if (DECL_DEPENDENT_P (t)
|| uses_template_parms (USING_DECL_SCOPE (t)))
{
+ /* True iff this using-decl was written as a pack expansion
+ (and a pack appeared in its scope or name). If a pack
+ appeared in both, we expand the packs separately and
+ manually merge them. */
+ bool variadic_p = false;
+
tree scope = USING_DECL_SCOPE (t);
- tree name = tsubst_copy (DECL_NAME (t), args, complain, in_decl);
if (PACK_EXPANSION_P (scope))
{
- tree vec = tsubst_pack_expansion (scope, args, complain, in_decl);
- int len = TREE_VEC_LENGTH (vec);
- r = make_tree_vec (len);
- for (int i = 0; i < len; ++i)
+ scope = tsubst_pack_expansion (scope, args, complain, in_decl);
+ variadic_p = true;
+ }
+ else
+ scope = tsubst_copy (scope, args, complain, in_decl);
+
+ tree name = DECL_NAME (t);
+ if (IDENTIFIER_CONV_OP_P (name)
+ && PACK_EXPANSION_P (TREE_TYPE (name)))
+ {
+ name = tsubst_pack_expansion (TREE_TYPE (name), args,
+ complain, in_decl);
+ if (name == error_mark_node)
{
- tree escope = TREE_VEC_ELT (vec, i);
- tree elt = do_class_using_decl (escope, name);
- if (!elt)
- {
- r = error_mark_node;
- break;
- }
- else
- {
- TREE_PROTECTED (elt) = TREE_PROTECTED (t);
- TREE_PRIVATE (elt) = TREE_PRIVATE (t);
- }
- TREE_VEC_ELT (r, i) = elt;
+ r = error_mark_node;
+ break;
}
+ for (tree& elt : tree_vec_range (name))
+ elt = make_conv_op_name (elt);
+ variadic_p = true;
}
else
+ name = tsubst_copy (name, args, complain, in_decl);
+
+ int len;
+ if (!variadic_p)
+ len = 1;
+ else if (TREE_CODE (scope) == TREE_VEC
+ && TREE_CODE (name) == TREE_VEC)
{
- tree inst_scope = tsubst_copy (USING_DECL_SCOPE (t), args,
- complain, in_decl);
- r = do_class_using_decl (inst_scope, name);
- if (!r)
- r = error_mark_node;
- else
+ if (TREE_VEC_LENGTH (scope) != TREE_VEC_LENGTH (name))
{
- TREE_PROTECTED (r) = TREE_PROTECTED (t);
- TREE_PRIVATE (r) = TREE_PRIVATE (t);
+ error ("mismatched argument pack lengths (%d vs %d)",
+ TREE_VEC_LENGTH (scope), TREE_VEC_LENGTH (name));
+ r = error_mark_node;
+ break;
}
+ len = TREE_VEC_LENGTH (scope);
}
+ else if (TREE_CODE (scope) == TREE_VEC)
+ len = TREE_VEC_LENGTH (scope);
+ else /* TREE_CODE (name) == TREE_VEC */
+ len = TREE_VEC_LENGTH (name);
+
+ r = make_tree_vec (len);
+ for (int i = 0; i < len; ++i)
+ {
+ tree escope = (TREE_CODE (scope) == TREE_VEC
+ ? TREE_VEC_ELT (scope, i)
+ : scope);
+ tree ename = (TREE_CODE (name) == TREE_VEC
+ ? TREE_VEC_ELT (name, i)
+ : name);
+ tree elt = do_class_using_decl (escope, ename);
+ if (!elt)
+ {
+ r = error_mark_node;
+ break;
+ }
+ TREE_PROTECTED (elt) = TREE_PROTECTED (t);
+ TREE_PRIVATE (elt) = TREE_PRIVATE (t);
+ TREE_VEC_ELT (r, i) = elt;
+ }
+
+ if (!variadic_p && r != error_mark_node)
+ r = TREE_VEC_ELT (r, 0);
}
else
{
@@ -15795,10 +15874,13 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
switch (code)
{
case RECORD_TYPE:
+ if (TYPE_PTRMEMFUNC_P (t))
+ return tsubst (TYPE_PTRMEMFUNC_FN_TYPE (t), args, complain, in_decl);
+ /* Fall through. */
case UNION_TYPE:
case ENUMERAL_TYPE:
- return tsubst_aggr_type (t, args, complain, in_decl,
- /*entering_scope=*/0);
+ return tsubst_aggr_type_1 (t, args, complain, in_decl,
+ /*entering_scope=*/0);
case ERROR_MARK:
case IDENTIFIER_NODE:
@@ -24873,7 +24955,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
if (is_overloaded_fn (parm) || type_unknown_p (parm))
return unify_success (explain_p);
gcc_assert (EXPR_P (parm)
- || COMPOUND_LITERAL_P (parm)
+ || TREE_CODE (parm) == CONSTRUCTOR
|| TREE_CODE (parm) == TRAIT_EXPR);
expr:
/* We must be looking at an expression. This can happen with
diff --git a/gcc/cp/rtti.cc b/gcc/cp/rtti.cc
index a85c7b5..c2cf78d 100644
--- a/gcc/cp/rtti.cc
+++ b/gcc/cp/rtti.cc
@@ -1603,7 +1603,9 @@ emit_support_tinfos (void)
&long_long_integer_type_node, &long_long_unsigned_type_node,
&float_type_node, &double_type_node, &long_double_type_node,
&dfloat32_type_node, &dfloat64_type_node, &dfloat128_type_node,
- &nullptr_type_node,
+ &bfloat16_type_node, &float16_type_node, &float32_type_node,
+ &float64_type_node, &float128_type_node, &float32x_type_node,
+ &float64x_type_node, &float128x_type_node, &nullptr_type_node,
0
};
int ix;
diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 7dfe5ac..69b1268 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -7396,9 +7396,13 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
build_zero_cst (TREE_TYPE (arg)), complain);
arg = perform_implicit_conversion (boolean_type_node, arg,
complain);
- val = invert_truthvalue_loc (location, arg);
if (arg != error_mark_node)
- return val;
+ {
+ val = invert_truthvalue_loc (location, arg);
+ if (obvalue_p (val))
+ val = non_lvalue_loc (location, val);
+ return val;
+ }
errstring = _("in argument to unary !");
break;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index d3812fa..adba057 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -14291,8 +14291,14 @@ and GCC does not issue a warning.
@end deftypefn
@deftypefn {Built-in Function}{size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
-Returns the size of an object pointed to by @var{ptr}. @xref{Object Size
-Checking}, for a detailed description of the function.
+Returns a constant size estimate of an object pointed to by @var{ptr}.
+@xref{Object Size Checking}, for a detailed description of the function.
+@end deftypefn
+
+@deftypefn {Built-in Function}{size_t} __builtin_dynamic_object_size (const void * @var{ptr}, int @var{type})
+Similar to @code{__builtin_object_size} except that the return value
+need not be a constant. @xref{Object Size Checking}, for a detailed
+description of the function.
@end deftypefn
@deftypefn {Built-in Function} double __builtin_huge_val (void)
@@ -21103,7 +21109,9 @@ Returns the value that is currently set in the @samp{tp} register.
@end deftypefn
@deftypefn {Built-in Function} void __builtin_riscv_pause (void)
-Generates the @code{pause} (hint) machine instruction.
+Generates the @code{pause} (hint) machine instruction. This implies the
+Xgnuzihintpausestate extension, which redefines the @code{pause} instruction to
+change architectural state.
@end deftypefn
@node RX Built-in Functions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index f48df64..c7e88e4 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -398,7 +398,7 @@ Objective-C and Objective-C++ Dialects}.
-Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} @gol
-Wstring-compare @gol
-Wno-stringop-overflow -Wno-stringop-overread @gol
--Wno-stringop-truncation @gol
+-Wno-stringop-truncation -Wstrict-flex-arrays @gol
-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]} @gol
-Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum @gol
-Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand @gol
@@ -7835,6 +7835,31 @@ however, are not suitable arguments to functions that expect
such arrays GCC issues warnings unless it can prove that the use is
safe. @xref{Common Variable Attributes}.
+@item -Wstrict-flex-arrays
+@opindex Wstrict-flex-arrays
+@opindex Wno-strict-flex-arrays
+Warn about inproper usages of flexible array members
+according to the @var{level} of the @code{strict_flex_array (@var{level})}
+attribute attached to the trailing array field of a structure if it's
+available, otherwise according to the @var{level} of the option
+@option{-fstrict-flex-arrays=@var{level}}.
+
+This option is effective only when @var{level} is bigger than 0. Otherwise,
+it will be ignored with a warning.
+
+when @var{level}=1, warnings will be issued for a trailing array reference
+of a structure that have 2 or more elements if the trailing array is referenced
+as a flexible array member.
+
+when @var{level}=2, in addition to @var{level}=1, additional warnings will be
+issued for a trailing one-element array reference of a structure
+if the array is referenced as a flexible array member.
+
+when @var{level}=3, in addition to @var{level}=2, additional warnings will be
+issued for a trailing zero-length array reference of a structure
+if the array is referenced as a flexible array member.
+
+
@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
@opindex Wsuggest-attribute=
@opindex Wno-suggest-attribute=
@@ -16744,8 +16769,8 @@ or when a method or constructor is invoked on insufficiently aligned object.
@item -fsanitize=object-size
@opindex fsanitize=object-size
This option enables instrumentation of memory references using the
-@code{__builtin_object_size} function. Various out of bounds pointer
-accesses are detected.
+@code{__builtin_dynamic_object_size} function. Various out of bounds
+pointer accesses are detected.
@item -fsanitize=float-divide-by-zero
@opindex fsanitize=float-divide-by-zero
diff --git a/gcc/doc/passes.texi b/gcc/doc/passes.texi
index 9e8b4f5..a248c5d 100644
--- a/gcc/doc/passes.texi
+++ b/gcc/doc/passes.texi
@@ -843,12 +843,15 @@ foo()}, this pass tries to change the call so that the address of
pass is located in @code{tree-nrv.cc} and is described by
@code{pass_return_slot}.
-@item Optimize calls to @code{__builtin_object_size}
-
-This is a propagation pass similar to CCP that tries to remove calls
-to @code{__builtin_object_size} when the size of the object can be
-computed at compile-time. This pass is located in
-@file{tree-object-size.cc} and is described by
+@item Optimize calls to @code{__builtin_object_size} or
+@code{__builtin_dynamic_object_size}
+
+This is a propagation pass similar to CCP that tries to remove calls to
+@code{__builtin_object_size} when the upper or lower bound for the size
+of the object can be computed at compile-time. It also tries to replace
+calls to @code{__builtin_dynamic_object_size} with an expression that
+evaluates the upper or lower bound for the size of the object. This
+pass is located in @file{tree-object-size.cc} and is described by
@code{pass_object_sizes}.
@item Loop invariant motion
diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc
index 59bd9eb..9fd42fe 100644
--- a/gcc/gimple-array-bounds.cc
+++ b/gcc/gimple-array-bounds.cc
@@ -252,25 +252,33 @@ get_up_bounds_for_array_ref (tree ref, tree *decl,
/* Given the LOW_SUB_ORG, LOW_SUB and UP_SUB, and the computed UP_BOUND
and UP_BOUND_P1, check whether the array reference REF is out of bound.
- Issue warnings if out of bound, return TRUE if warnings are issued. */
+ When out of bounds, set OUT_OF_BOUND to true.
+ Issue warnings if FOR_ARRAY_BOUND is true.
+ return TRUE if warnings are issued. */
static bool
check_out_of_bounds_and_warn (location_t location, tree ref,
tree low_sub_org, tree low_sub, tree up_sub,
tree up_bound, tree up_bound_p1,
const value_range *vr,
- bool ignore_off_by_one)
+ bool ignore_off_by_one, bool for_array_bound,
+ bool *out_of_bound)
{
tree low_bound = array_ref_low_bound (ref);
tree artype = TREE_TYPE (TREE_OPERAND (ref, 0));
bool warned = false;
+ *out_of_bound = false;
/* Empty array. */
if (up_bound && tree_int_cst_equal (low_bound, up_bound_p1))
- warned = warning_at (location, OPT_Warray_bounds_,
- "array subscript %E is outside array bounds of %qT",
- low_sub_org, artype);
+ {
+ *out_of_bound = true;
+ if (for_array_bound)
+ warned = warning_at (location, OPT_Warray_bounds_,
+ "array subscript %E is outside array"
+ " bounds of %qT", low_sub_org, artype);
+ }
if (warned)
; /* Do nothing. */
@@ -283,24 +291,36 @@ check_out_of_bounds_and_warn (location_t location, tree ref,
: tree_int_cst_le (up_bound, up_sub))
&& TREE_CODE (low_sub) == INTEGER_CST
&& tree_int_cst_le (low_sub, low_bound))
- warned = warning_at (location, OPT_Warray_bounds_,
- "array subscript [%E, %E] is outside "
- "array bounds of %qT",
- low_sub, up_sub, artype);
+ {
+ *out_of_bound = true;
+ if (for_array_bound)
+ warned = warning_at (location, OPT_Warray_bounds_,
+ "array subscript [%E, %E] is outside "
+ "array bounds of %qT",
+ low_sub, up_sub, artype);
+ }
}
else if (up_bound
&& TREE_CODE (up_sub) == INTEGER_CST
&& (ignore_off_by_one
? !tree_int_cst_le (up_sub, up_bound_p1)
: !tree_int_cst_le (up_sub, up_bound)))
- warned = warning_at (location, OPT_Warray_bounds_,
- "array subscript %E is above array bounds of %qT",
- up_sub, artype);
+ {
+ *out_of_bound = true;
+ if (for_array_bound)
+ warned = warning_at (location, OPT_Warray_bounds_,
+ "array subscript %E is above array bounds of %qT",
+ up_sub, artype);
+ }
else if (TREE_CODE (low_sub) == INTEGER_CST
&& tree_int_cst_lt (low_sub, low_bound))
- warned = warning_at (location, OPT_Warray_bounds_,
- "array subscript %E is below array bounds of %qT",
- low_sub, artype);
+ {
+ *out_of_bound = true;
+ if (for_array_bound)
+ warned = warning_at (location, OPT_Warray_bounds_,
+ "array subscript %E is below array bounds of %qT",
+ low_sub, artype);
+ }
return warned;
}
@@ -333,14 +353,21 @@ array_bounds_checker::check_array_ref (location_t location, tree ref,
tree arg = TREE_OPERAND (ref, 0);
const bool compref = TREE_CODE (arg) == COMPONENT_REF;
+ unsigned int strict_flex_array_level = flag_strict_flex_arrays;
if (compref)
- /* Try to determine special array member type for this COMPONENT_REF. */
- sam = component_ref_sam_type (arg);
+ {
+ /* Try to determine special array member type for this COMPONENT_REF. */
+ sam = component_ref_sam_type (arg);
+ /* Get the level of strict_flex_array for this array field. */
+ tree afield_decl = TREE_OPERAND (arg, 1);
+ strict_flex_array_level = strict_flex_array_level_of (afield_decl);
+ }
get_up_bounds_for_array_ref (ref, &decl, &up_bound, &up_bound_p1);
bool warned = false;
+ bool out_of_bound = false;
tree artype = TREE_TYPE (TREE_OPERAND (ref, 0));
tree low_sub_org = TREE_OPERAND (ref, 1);
@@ -361,7 +388,8 @@ array_bounds_checker::check_array_ref (location_t location, tree ref,
warned = check_out_of_bounds_and_warn (location, ref,
low_sub_org, low_sub, up_sub,
up_bound, up_bound_p1, vr,
- ignore_off_by_one);
+ ignore_off_by_one, warn_array_bounds,
+ &out_of_bound);
if (!warned && sam == special_array_member::int_0)
@@ -373,19 +401,56 @@ array_bounds_checker::check_array_ref (location_t location, tree ref,
"of an interior zero-length array %qT")),
low_sub, artype);
- if (warned)
+ if (warned || out_of_bound)
{
- if (dump_file && (dump_flags & TDF_DETAILS))
+ if (warned && dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Array bound warning for ");
dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
fprintf (dump_file, "\n");
}
+ /* issue warnings for -Wstrict-flex-arrays according to the level of
+ flag_strict_flex_arrays. */
+ if (out_of_bound && warn_strict_flex_arrays)
+ switch (strict_flex_array_level)
+ {
+ case 3:
+ /* Issue additional warnings for trailing arrays [0]. */
+ if (sam == special_array_member::trail_0)
+ warned = warning_at (location, OPT_Wstrict_flex_arrays,
+ "trailing array %qT should not be used as "
+ "a flexible array member for level 3",
+ artype);
+ /* FALLTHROUGH. */
+ case 2:
+ /* Issue additional warnings for trailing arrays [1]. */
+ if (sam == special_array_member::trail_1)
+ warned = warning_at (location, OPT_Wstrict_flex_arrays,
+ "trailing array %qT should not be used as "
+ "a flexible array member for level 2 and "
+ "above", artype);
+ /* FALLTHROUGH. */
+ case 1:
+ /* Issue warnings for trailing arrays [n]. */
+ if (sam == special_array_member::trail_n)
+ warned = warning_at (location, OPT_Wstrict_flex_arrays,
+ "trailing array %qT should not be used as "
+ "a flexible array member for level 1 and "
+ "above", artype);
+ break;
+ case 0:
+ /* Do nothing. */
+ break;
+ default:
+ gcc_unreachable ();
+ }
+
/* Avoid more warnings when checking more significant subscripts
of the same expression. */
ref = TREE_OPERAND (ref, 0);
suppress_warning (ref, OPT_Warray_bounds_);
+ suppress_warning (ref, OPT_Wstrict_flex_arrays);
if (decl)
ref = decl;
diff --git a/gcc/loop-invariant.cc b/gcc/loop-invariant.cc
index f324854..9b5f6cd 100644
--- a/gcc/loop-invariant.cc
+++ b/gcc/loop-invariant.cc
@@ -1837,6 +1837,8 @@ move_invariant_reg (class loop *loop, unsigned invno)
else if (dump_file)
fprintf (dump_file, "Invariant %d moved without introducing a new "
"temporary register\n", invno);
+ if (JUMP_P (BB_END (preheader)))
+ preheader = split_edge (loop_preheader_edge (loop));
reorder_insns (inv->insn, inv->insn, BB_END (preheader));
df_recompute_luids (preheader);
diff --git a/gcc/m2/ChangeLog b/gcc/m2/ChangeLog
index 34da98a..c23beec 100644
--- a/gcc/m2/ChangeLog
+++ b/gcc/m2/ChangeLog
@@ -1,3 +1,14 @@
+2022-12-15 Gaius Mulley <gaiusmod2@gmail.com>
+
+ * configure.ac: Stop probing for realpath.
+ * tools-src/calcpath: Break dependency on realpath, cut
+ and echo.
+ * configure: Rebuilt.
+
+2022-12-15 Gaius Mulley <gaiusmod2@gmail.com>
+
+ * gm2config.h.in: Rebuilt.
+
2022-12-14 Gaius Mulley <gaiusmod2@gmail.com>
* COPYING.FDL: New file.
diff --git a/gcc/m2/configure b/gcc/m2/configure
index db1ca3d..91768ab 100755
--- a/gcc/m2/configure
+++ b/gcc/m2/configure
@@ -630,7 +630,6 @@ CPPFLAGS
LDFLAGS
CFLAGS
CC
-regex_realpath
target_os
target_vendor
target_cpu
@@ -2235,52 +2234,6 @@ test -n "$target_alias" &&
NONENONEs,x,x, &&
program_prefix=${target_alias}-
-for ac_prog in realpath
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_regex_realpath+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$regex_realpath"; then
- ac_cv_prog_regex_realpath="$regex_realpath" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_regex_realpath="$ac_prog"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-regex_realpath=$ac_cv_prog_regex_realpath
-if test -n "$regex_realpath"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $regex_realpath" >&5
-$as_echo "$regex_realpath" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$regex_realpath" && break
-done
-
-if test x$regex_realpath = "x" ; then
- as_fn_error $? "realpath is required to build GNU Modula-2 (hint install coreutils)." "$LINENO" 5
-fi
-
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
diff --git a/gcc/m2/configure.ac b/gcc/m2/configure.ac
index 756e01c..5583af7 100644
--- a/gcc/m2/configure.ac
+++ b/gcc/m2/configure.ac
@@ -24,11 +24,6 @@ AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
-AC_CHECK_PROGS(regex_realpath, realpath)
-if test x$regex_realpath = "x" ; then
- AC_MSG_ERROR([realpath is required to build GNU Modula-2 (hint install coreutils).])
-fi
-
AC_CHECK_FUNCS([stpcpy])
AC_CHECK_HEADERS(sys/types.h)
diff --git a/gcc/m2/tools-src/calcpath b/gcc/m2/tools-src/calcpath
index e081770..0532451 100755
--- a/gcc/m2/tools-src/calcpath
+++ b/gcc/m2/tools-src/calcpath
@@ -23,27 +23,29 @@
Usage () {
- echo "Usage: calcpath pathcomponent1 pathcomponent2 subdir"
- echo -n " if pathcomponent1 is relative then pathcomponent1/pathcomponet2/subdir is"
- echo " returned"
- echo " otherwise pathcomponet2/subdir is returned"
- echo " the path is checked for legality in subdir."
+ cat<<EOF
+Usage: $0 pathcomponent1 pathcomponent2 subdir
+ if pathcomponent2 is relative then pathcomponent1/pathcompinent2/subdir is returned
+ otherwise pathcomponent2/subdir is returned
+ the path is checked for legality in subdir.
+EOF
}
+die () {
+ printf "calcpath: error: %s\n" "$1" >&2
+ exit 1
+}
if [ $# -eq 3 ]; then
- if [ "$(echo $2 | cut -b 1)" = "." ] ; then
- # relative path
- the_path=$1/$2/$3
- else
- the_path=$2/$3
- fi
- cd $3
- if realpath ${the_path} > /dev/null ; then
- echo ${the_path}
+ case "$2" in
+ /*) the_path="$2/$3" ;;
+ *) the_path="$1/$2/$3" ;;
+ esac
+ cd "$3" || die "could not access $3"
+ if ( cd "$the_path" ); then
+ printf '%s\n' "${the_path}"
else
- echo "calcpath: error ${the_path} is not a valid path in subdirectory $3" 1>&2
- exit 1
+ die "${the_path} is not a valid path in subdirectory $3"
fi
else
Usage
diff --git a/gcc/opts.cc b/gcc/opts.cc
index 73fc977..7981e2c 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -1411,6 +1411,14 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
opts->x_profile_flag = 0;
}
+ if (opts->x_warn_strict_flex_arrays)
+ if (opts->x_flag_strict_flex_arrays == 0)
+ {
+ opts->x_warn_strict_flex_arrays = 0;
+ warning_at (UNKNOWN_LOCATION, 0,
+ "%<-Wstrict-flex-arrays%> is ignored when"
+ " %<-fstrict-flex-arrays%> is not present");
+ }
diagnose_options (opts, opts_set, loc);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a3a6de8..24c4756 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,125 @@
+2022-12-16 John David Anglin <danglin@gcc.gnu.org>
+
+ * lib/target-supports.exp (check_effective_target_static): Return 0
+ on hppa*-*-*.
+
+2022-12-16 Andrew Pinski <pinskia@gmail.com>
+ Iain Sandoe <iain@sandoe.co.uk>
+
+ PR c++/107768
+ * g++.dg/coroutines/pr107768.C: New test.
+
+2022-12-16 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/106479
+ * gcc.dg/analyzer/pr104308.c (test_memmove_within_uninit): Remove
+ xfail on region creation event.
+
+2022-12-16 Vladimir N. Makarov <vmakarov@redhat.com>
+
+ Revert:
+ 2022-12-16 Vladimir N. Makarov <vmakarov@redhat.com>
+
+ * gcc.target/avr/pr90706.c: New.
+
+2022-12-16 Qing Zhao <qing.zhao@oracle.com>
+
+ * gcc.dg/Warray-bounds-flex-arrays-1.c: Update testing case with
+ -Wstrict-flex-arrays.
+ * gcc.dg/Warray-bounds-flex-arrays-2.c: Likewise.
+ * gcc.dg/Warray-bounds-flex-arrays-3.c: Likewise.
+ * gcc.dg/Warray-bounds-flex-arrays-4.c: Likewise.
+ * gcc.dg/Warray-bounds-flex-arrays-5.c: Likewise.
+ * gcc.dg/Warray-bounds-flex-arrays-6.c: Likewise.
+ * c-c++-common/Wstrict-flex-arrays.c: New test.
+ * gcc.dg/Wstrict-flex-arrays-2.c: New test.
+ * gcc.dg/Wstrict-flex-arrays-3.c: New test.
+ * gcc.dg/Wstrict-flex-arrays.c: New test.
+
+2022-12-16 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/106751
+ * gcc.c-torture/compile/pr106751.c: New test.
+
+2022-12-16 Haochen Jiang <haochen.jiang@intel.com>
+
+ * gcc.target/i386/cmpccxadd-1.c: Fix intrin name.
+ * gcc.target/i386/cmpccxadd-2.c: Ditto.
+
+2022-12-15 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/102104
+ PR c++/108090
+ * g++.dg/cpp1z/using-variadic1.C: New test.
+ * g++.dg/cpp1z/using-variadic1a.C: New test.
+ * g++.dg/cpp1z/using-variadic1b.C: New test.
+ * g++.dg/cpp1z/using-variadic1c.C: New test.
+ * g++.dg/cpp1z/using-variadic2.C: New test.
+ * g++.dg/cpp1z/using-variadic3.C: New test.
+
+2022-12-15 Arsen Arsenović <arsen@aarsen.me>
+
+ * g++.dg/contracts/contracts-externC.C: New test.
+
+2022-12-15 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/107188
+ * g++.dg/cpp2a/concepts-placeholder11.C: New test.
+
+2022-12-15 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/100295
+ PR c++/107579
+ * g++.dg/cpp1z/constexpr-if-lambda5.C: New test.
+
+2022-12-15 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/105518
+ * g++.dg/cpp0x/lambda/lambda-alias1.C: New test.
+
+2022-12-15 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/108104
+ * g++.dg/template/ptrmem33.C: New test.
+
+2022-12-15 Vladimir N. Makarov <vmakarov@redhat.com>
+
+ * gcc.target/avr/pr90706.c: New.
+
+2022-12-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/107065
+ * g++.dg/cpp0x/pr107065.C: New test.
+
+2022-12-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR libstdc++/108075
+ * g++.dg/cpp23/ext-floating13.C: New test.
+
+2022-12-15 Jakub Jelinek <jakub@redhat.com>
+
+ * lib/target-supports.exp (check_compile): Further quoting
+ fixes for /* Assembly, /* ObjC and (* Modula-2 *) checks.
+
+2022-12-15 Jakub Jelinek <jakub@redhat.com>
+
+ * lib/target-supports.exp (check_compile): Add support for
+ Rust and Modula-2. Use \* rather than * for /* comment for
+ Assembly.
+
+2022-12-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/108095
+ * gcc.dg/pr108095.c: New test.
+
+2022-12-15 Jason Merrill <jason@redhat.com>
+
+ PR c++/108071
+ PR c++/105838
+ * g++.dg/cpp0x/initlist131.C: New test.
+ * g++.dg/cpp0x/initlist132.C: New test.
+ * g++.dg/cpp0x/initlist133.C: New test.
+
2022-12-14 David Malcolm <dmalcolm@redhat.com>
PR analyzer/108065
diff --git a/gcc/testsuite/c-c++-common/Wstrict-flex-arrays.c b/gcc/testsuite/c-c++-common/Wstrict-flex-arrays.c
new file mode 100644
index 0000000..5151423
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wstrict-flex-arrays.c
@@ -0,0 +1,9 @@
+/* Test the usage of option -Wstrict-flex-arrays. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wstrict-flex-arrays" } */
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
+/* { dg-warning "is ignored when \'-fstrict-flex-arrays\' is not present" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/g++.dg/contracts/contracts-externC.C b/gcc/testsuite/g++.dg/contracts/contracts-externC.C
new file mode 100644
index 0000000..873056b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/contracts/contracts-externC.C
@@ -0,0 +1,19 @@
+// simple check to ensure we don't emit a function with the same name twice,
+// when wrapping functions in pre- and postconditions.
+// { dg-do link }
+// { dg-options "-std=c++2a -fcontracts -fcontract-continuation-mode=on" }
+
+volatile int x = 10;
+
+extern "C" void
+f ()
+ [[ pre: x < 10 ]]
+{
+}
+
+int
+main ()
+ [[ post: x > 10 ]]
+{
+ f();
+}
diff --git a/gcc/testsuite/g++.dg/coroutines/pr107768.C b/gcc/testsuite/g++.dg/coroutines/pr107768.C
new file mode 100644
index 0000000..22d7074
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/pr107768.C
@@ -0,0 +1,26 @@
+// { dg-additional-options "-Wzero-as-null-pointer-constant -fsyntax-only" }
+
+#include <coroutine>
+
+struct task
+{
+ struct promise_type
+ {
+ task get_return_object() { return {}; }
+ std::suspend_never initial_suspend() { return {}; }
+ std::suspend_never final_suspend() noexcept { return {}; }
+ void return_void() {}
+ void unhandled_exception() {}
+ };
+};
+
+task resuming_on_new_thread(void)
+{
+ struct awaitable
+ {
+ bool await_ready() { return false; }
+ void await_suspend(std::coroutine_handle<> h) { }
+ void await_resume() {}
+ };
+ co_await awaitable{};
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-alias1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-alias1.C
new file mode 100644
index 0000000..08c38e6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-alias1.C
@@ -0,0 +1,23 @@
+// PR c++/105518
+// { dg-do compile { target c++11 } }
+
+struct integral_constant {
+ constexpr operator int() const { return 42; }
+};
+
+template<int N>
+struct A {
+ using type = A;
+ static constexpr int value = N;
+};
+
+template<class T>
+void f(T t) {
+ using alias = A<t>;
+ [](int) {
+ typename alias::type a; // { dg-bogus "'t' is not captured" }
+ return a.value;
+ }(0);
+}
+
+template void f(integral_constant);
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr107065.C b/gcc/testsuite/g++.dg/cpp0x/pr107065.C
new file mode 100644
index 0000000..5e18bb9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr107065.C
@@ -0,0 +1,14 @@
+// PR c++/107065
+// { dg-do compile { target c++11 } }
+
+template<class, class> struct is_same { static constexpr bool value = false; };
+template<class T> struct is_same<T, T> { static constexpr bool value = true; };
+
+int
+main ()
+{
+ bool b = true;
+ static_assert (is_same<decltype (!(!b)), bool>::value, "");
+ auto bb = (!(!b));
+ static_assert (is_same<decltype (bb), bool>::value, "");
+}
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-107437.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-107437.C
new file mode 100644
index 0000000..f9b4e01
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-107437.C
@@ -0,0 +1,21 @@
+// PR c++/107437
+// { dg-do compile { target c++14 } }
+
+struct integral_constant {
+ constexpr operator int() const { return 42; }
+};
+
+template<int N>
+struct A {
+ static constexpr int value = N;
+};
+
+template<class T>
+void f(T t) {
+ [=](auto) {
+ A<t> a; // { dg-bogus "constant" }
+ return a.value;
+ }(0);
+}
+
+template void f(integral_constant);
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if-lambda5.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if-lambda5.C
new file mode 100644
index 0000000..d2bf022
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if-lambda5.C
@@ -0,0 +1,15 @@
+// PR c++/100295
+// { dg-do compile { target c++17 } }
+
+template<typename... Ts>
+void f(Ts... ts) {
+ auto lambda = [=](auto x) {
+ if constexpr (sizeof((ts+x) + ...) != 0)
+ (..., ts);
+ };
+ lambda(0);
+}
+
+int main() {
+ f(0, 'a');
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda26.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda26.C
index 0cdb400..e66cd1d 100644
--- a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda26.C
+++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda26.C
@@ -1,7 +1,6 @@
// PR c++/87765
// { dg-do compile { target c++17 } }
// { dg-additional-options "-fchecking" }
-// { dg-ice "cxx_eval_constant_expression" }
template <int N>
using foo = int;
diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic1.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic1.C
new file mode 100644
index 0000000..7a8bcbb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic1.C
@@ -0,0 +1,29 @@
+// PR c++/102104
+// { dg-do compile { target c++17 } }
+
+struct A {
+ using target_type = bool*;
+ operator bool*();
+};
+
+struct B {
+ using target_type = long*;
+ operator long*();
+};
+
+template<typename... Bases>
+struct cls : private Bases... {
+ using Bases::operator typename Bases::target_type...;
+};
+
+cls<A, B> v1;
+bool* a1 = v1;
+long* b1 = v1;
+
+cls<B> v2;
+bool* a2 = v2; // { dg-error "cannot convert" }
+long* b2 = v2;
+
+cls<A> v3;
+bool* a3 = v3;
+long* b3 = v3; // { dg-error "cannot convert" }
diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic1a.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic1a.C
new file mode 100644
index 0000000..0393cab
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic1a.C
@@ -0,0 +1,34 @@
+// PR c++/102104
+// A version of using-variadic1.C where the qualifying scope and the
+// terminal name of the using-declaration use different parameter packs.
+// { dg-do compile { target c++17 } }
+
+struct A {
+ using target_type = bool*;
+ operator bool*();
+};
+
+struct B {
+ using target_type = long*;
+ operator long*();
+};
+
+template<typename... Bases>
+struct cls {
+ template<class... Ts>
+ struct nested : private Bases... {
+ using Bases::operator typename Ts::target_type...;
+ };
+};
+
+cls<A, B>::nested<A, B> v1;
+bool* a1 = v1;
+long* b1 = v1;
+
+cls<B>::nested<B> v2;
+bool* a2 = v2; // { dg-error "cannot convert" }
+long* b2 = v2;
+
+cls<A>::nested<A> v3;
+bool* a3 = v3;
+long* b3 = v3; // { dg-error "cannot convert" }
diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic1b.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic1b.C
new file mode 100644
index 0000000..fd3a417
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic1b.C
@@ -0,0 +1,37 @@
+// PR c++/102104
+// A version of using-variadic1.C where only the qualifying scope
+// uses a parameter pack.
+// { dg-do compile { target c++17 } }
+
+struct A {
+ using target_type = bool*;
+};
+
+struct B {
+ using target_type = long*;
+};
+
+struct C {
+ operator bool*();
+ operator long*();
+};
+
+template<typename Base>
+struct cls {
+ template<class... Ts>
+ struct nested : private Base {
+ using Base::operator typename Ts::target_type...;
+ };
+};
+
+cls<C>::nested<A, B> v1;
+bool* a1 = v1;
+long* b1 = v1;
+
+cls<C>::nested<B> v2;
+bool* a2 = v2; // { dg-error "inaccessible|not an accessible" }
+long* b2 = v2;
+
+cls<C>::nested<A> v3;
+bool* a3 = v3;
+long* b3 = v3; // { dg-error "inaccessible|not an accessible" }
diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic1c.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic1c.C
new file mode 100644
index 0000000..aa86b28
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic1c.C
@@ -0,0 +1,33 @@
+// PR c++/102104
+// A version of of using-variadic1.C where only the terminal name
+// uses a parameter pack.
+// { dg-do compile { target c++17 } }
+
+struct A {
+ operator bool*();
+};
+
+struct B {
+ operator bool*();
+};
+
+struct C {
+ using target_type = bool*;
+};
+
+template<typename... Bases>
+struct cls {
+ template<class T>
+ struct nested : private Bases... {
+ using Bases::operator typename T::target_type...;
+ };
+};
+
+cls<A, B>::nested<C> v1;
+bool* a1 = v1; // { dg-error "ambiguous" }
+
+cls<A>::nested<C> v2;
+bool* a2 = v2;
+
+cls<B>::nested<C> v3;
+bool* a3 = v3;
diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic2.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic2.C
new file mode 100644
index 0000000..1d68cee
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic2.C
@@ -0,0 +1,24 @@
+// PR c++/102104
+// A version of using-variadic1a.C where the argument packs have
+// different lengths.
+// { dg-do compile { target c++17 } }
+
+struct A {
+ using target_type = bool*;
+ operator bool*();
+};
+
+struct B {
+ using target_type = long*;
+ operator long*();
+};
+
+template<typename... Bases>
+struct cls {
+ template<class... Ts>
+ struct nested : private Bases... {
+ using Bases::operator typename Ts::target_type...; // { dg-error "lengths" }
+ };
+};
+
+cls<A>::nested<A, B> v1; // { dg-message "required from here" }
diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic3.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic3.C
new file mode 100644
index 0000000..4e1d689
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic3.C
@@ -0,0 +1,8 @@
+// PR c++/108090
+// { dg-do compile { target c++17 } }
+
+template<typename T> struct As { operator T(); };
+template<typename ...T> struct AsAll : As<T>... {
+ using As<T>::operator T...;
+};
+AsAll<int, float, char> x;
diff --git a/gcc/testsuite/g++.dg/cpp23/ext-floating13.C b/gcc/testsuite/g++.dg/cpp23/ext-floating13.C
new file mode 100644
index 0000000..fd36c50
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp23/ext-floating13.C
@@ -0,0 +1,35 @@
+// P1467R9 - Extended floating-point types and standard names.
+// { dg-do link { target c++23 } }
+// { dg-options "" }
+
+#include <typeinfo>
+
+#ifdef __STDCPP_FLOAT16_T__
+const std::type_info &a = typeid(decltype(0.0f16));
+#endif
+#ifdef __STDCPP_BFLOAT16_T__
+const std::type_info &b = typeid(decltype(0.0bf16));
+#endif
+#ifdef __STDCPP_FLOAT32_T__
+const std::type_info &c = typeid(decltype(0.0f32));
+#endif
+#ifdef __STDCPP_FLOAT64_T__
+const std::type_info &d = typeid(decltype(0.0f64));
+#endif
+#ifdef __STDCPP_FLOAT128_T__
+const std::type_info &e = typeid(decltype(0.0f128));
+#endif
+#ifdef __FLT32X_MAX__
+const std::type_info &f = typeid(decltype(0.0f32x));
+#endif
+#ifdef __FLT64X_MAX__
+const std::type_info &g = typeid(decltype(0.0f64x));
+#endif
+#ifdef __FLT128X_MAX__
+const std::type_info &h = typeid(decltype(0.0f128x));
+#endif
+
+int
+main ()
+{
+}
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder11.C b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder11.C
new file mode 100644
index 0000000..61eef74
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder11.C
@@ -0,0 +1,10 @@
+// PR c++/107188
+// { dg-do compile { target c++20 } }
+
+namespace N {
+ template<class, class> concept C = true;
+}
+
+struct X {
+ N::C<int> auto f() { return 0; }
+};
diff --git a/gcc/testsuite/g++.dg/template/ptrmem33.C b/gcc/testsuite/g++.dg/template/ptrmem33.C
new file mode 100644
index 0000000..dca741a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ptrmem33.C
@@ -0,0 +1,30 @@
+// PR c++/108104
+// { dg-do compile { target c++11 } }
+
+struct A {
+ void x();
+ void y();
+};
+
+enum State { On };
+
+template<State state, void (A::*)()>
+struct B {
+ static void f();
+};
+
+template<State state>
+struct B<state, nullptr> {
+ static void g();
+};
+
+template<State state>
+struct B<state, &A::y> {
+ static void h();
+};
+
+int main() {
+ B<State::On, &A::x>::f();
+ B<State::On, nullptr>::g();
+ B<State::On, &A::y>::h();
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr106751.c b/gcc/testsuite/gcc.c-torture/compile/pr106751.c
new file mode 100644
index 0000000..5fbf93b
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr106751.c
@@ -0,0 +1,17 @@
+/* PR rtl-optimization/106751 */
+
+int *foo (void);
+
+void
+bar (void)
+{
+ asm goto ("" : : : : lab);
+ __builtin_unreachable ();
+lab:
+ while (1)
+ {
+ int o;
+ asm ("" : "=r" (o) : "g" (1));
+ *foo () = o;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-1.c b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-1.c
index d36ba4d..65c9fec 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-1.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-1.c
@@ -1,6 +1,6 @@
-/* Test -fstrict-flex-arrays + -Warray-bounds. */
+/* Test -fstrict-flex-arrays + -Warray-bounds + -Wstrict-flex-arrays. */
/* { dg-do compile} */
-/* { dg-options "-O2 -fstrict-flex-arrays=1 -Warray-bounds" } */
+/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=1 -Warray-bounds" } */
struct trailing_array_1 {
int a;
@@ -32,6 +32,7 @@ void __attribute__((__noinline__)) stuff(
struct trailing_array_4 *trailing_flex)
{
normal->c[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */
+ /*{ dg-warning "should not be used as a flexible array member for level 1 and above" "" { target *-*-* } .-1 } */
trailing_1->c[2] = 2; /* { dg-bogus "array subscript " } */
trailing_0->c[1] = 1; /* { dg-bogus "array subscript " } */
trailing_flex->c[10] = 10; /* { dg-bogus "array subscript " } */
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-2.c b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-2.c
index f63206e..2b5a895 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-2.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-2.c
@@ -1,6 +1,6 @@
-/* Test -fstrict-flex-arrays + -Warray-bounds. */
+/* Test -fstrict-flex-arrays + -Warray-bounds + -Wstrict-flex-arrays. */
/* { dg-do compile } */
-/* { dg-options "-O2 -fstrict-flex-arrays=2 -Warray-bounds" } */
+/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=2 -Warray-bounds" } */
struct trailing_array_1 {
int a;
@@ -32,7 +32,9 @@ void __attribute__((__noinline__)) stuff(
struct trailing_array_4 *trailing_flex)
{
normal->c[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */
+ /*{ dg-warning "should not be used as a flexible array member for level 1 and above" "" { target *-*-* } .-1 } */
trailing_1->c[2] = 2; /* { dg-warning "array subscript 2 is above array bounds of" } */
+ /* { dg-warning "should not be used as a flexible array member for level 2 and above" "" { target *-*-* } .-1 } */
trailing_0->c[1] = 1; /* { dg-bogus "array subscript " } */
trailing_flex->c[10] = 10; /* { dg-bogus "array subscript " } */
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-3.c b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-3.c
index e327371..25b903f 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-3.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-3.c
@@ -1,6 +1,6 @@
-/* Test -fstrict-flex-arrays + -Warray-bounds. */
+/* Test -fstrict-flex-arrays + -Warray-bounds + -Wstrict-flex-arrays. */
/* { dg-do compile } */
-/* { dg-options "-O2 -fstrict-flex-arrays=3 -Warray-bounds" } */
+/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=3 -Warray-bounds" } */
struct trailing_array_1 {
int a;
@@ -32,8 +32,11 @@ void __attribute__((__noinline__)) stuff(
struct trailing_array_4 *trailing_flex)
{
normal->c[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */
+ /*{ dg-warning "should not be used as a flexible array member for level 1 and above" "" { target *-*-* } .-1 } */
trailing_1->c[2] = 2; /*{ dg-warning "array subscript 2 is above array bounds of" } */
+ /* { dg-warning "should not be used as a flexible array member for level 2 and above" "" { target *-*-* } .-1 } */
trailing_0->c[1] = 1; /*{ dg-warning "array subscript 1 is outside array bounds of" } */
+ /* { dg-warning "should not be used as a flexible array member for level 3" "" { target *-*-* } .-1 } */
trailing_flex->c[10] = 10; /* { dg-bogus "array subscript" } */
}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-4.c b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-4.c
index cabaea7..5fc500a 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-4.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-4.c
@@ -1,6 +1,6 @@
-/* Test -fstrict-flex-arrays + -Warray-bounds=2. */
+/* Test -fstrict-flex-arrays + -Warray-bounds=2 + -Wstrict-flex-arrays. */
/* { dg-do compile } */
-/* { dg-options "-O2 -fstrict-flex-arrays=1 -Warray-bounds=2" } */
+/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=1 -Warray-bounds=2" } */
struct trailing_array_1 {
int a;
@@ -32,6 +32,7 @@ void __attribute__((__noinline__)) stuff(
struct trailing_array_4 *trailing_flex)
{
normal->c[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */
+ /*{ dg-warning "should not be used as a flexible array member for level 1 and above" "" { target *-*-* } .-1 } */
trailing_1->c[2] = 2; /* { dg-bogus "array subscript " } */
trailing_0->c[1] = 1; /* { dg-bogus "array subscript " } */
trailing_flex->c[10] = 10; /* { dg-bogus "array subscript " } */
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-5.c b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-5.c
index 8b7db6e..30bb4ca 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-5.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-5.c
@@ -1,6 +1,6 @@
-/* Test -fstrict-flex-arrays + -Warray-bounds=2. */
+/* Test -fstrict-flex-arrays + -Warray-bounds=2 + -Wstrict-flex-arrays. */
/* { dg-do compile } */
-/* { dg-options "-O2 -fstrict-flex-arrays=2 -Warray-bounds=2" } */
+/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=2 -Warray-bounds=2" } */
struct trailing_array_1 {
int a;
@@ -32,7 +32,9 @@ void __attribute__((__noinline__)) stuff(
struct trailing_array_4 *trailing_flex)
{
normal->c[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */
+ /*{ dg-warning "should not be used as a flexible array member for level 1 and above" "" { target *-*-* } .-1 } */
trailing_1->c[2] = 2; /*{ dg-warning "array subscript 2 is above array bounds of" } */
+ /* { dg-warning "should not be used as a flexible array member for level 2 and above" "" { target *-*-* } .-1 } */
trailing_0->c[1] = 1; /* { dg-bogus "array subscript " } */
trailing_flex->c[10] = 10; /* { dg-bogus "array subscript " } */
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-6.c b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-6.c
index 035bf48..e847a44 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-6.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-flex-arrays-6.c
@@ -1,6 +1,6 @@
-/* Test -fstrict-flex-arrays + -Warray-bounds=2. */
+/* Test -fstrict-flex-arrays + -Warray-bounds=2 + -Wstrict-flex-arrays. */
/* { dg-do compile } */
-/* { dg-options "-O2 -fstrict-flex-arrays=3 -Warray-bounds=2" } */
+/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=3 -Warray-bounds=2" } */
struct trailing_array_1 {
int a;
@@ -32,8 +32,11 @@ void __attribute__((__noinline__)) stuff(
struct trailing_array_4 *trailing_flex)
{
normal->c[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */
+ /*{ dg-warning "should not be used as a flexible array member for level 1 and above" "" { target *-*-* } .-1 } */
trailing_1->c[2] = 2; /*{ dg-warning "array subscript 2 is above array bounds of" } */
+ /* { dg-warning "should not be used as a flexible array member for level 2 and above" "" { target *-*-* } .-1 } */
trailing_0->c[1] = 1; /*{ dg-warning "array subscript 1 is outside array bounds of" } */
+ /* { dg-warning "should not be used as a flexible array member for level 3" "" { target *-*-* } .-1 } */
trailing_flex->c[10] = 10; /* { dg-bogus "array subscript " } */
}
diff --git a/gcc/testsuite/gcc.dg/Wstrict-flex-arrays-2.c b/gcc/testsuite/gcc.dg/Wstrict-flex-arrays-2.c
new file mode 100644
index 0000000..2e241f9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstrict-flex-arrays-2.c
@@ -0,0 +1,39 @@
+/* Test -Wstrict-flex-arrays. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=2" } */
+
+struct trailing_array_1 {
+ int a;
+ int b;
+ int c[4];
+};
+
+struct trailing_array_2 {
+ int a;
+ int b;
+ int c[1];
+};
+
+struct trailing_array_3 {
+ int a;
+ int b;
+ int c[0];
+};
+struct trailing_array_4 {
+ int a;
+ int b;
+ int c[];
+};
+
+void __attribute__((__noinline__)) stuff(
+ struct trailing_array_1 *normal,
+ struct trailing_array_2 *trailing_1,
+ struct trailing_array_3 *trailing_0,
+ struct trailing_array_4 *trailing_flex)
+{
+ normal->c[5] = 5; /*{ dg-warning "should not be used as a flexible array member for level 1 and above" } */
+ trailing_1->c[2] = 2; /* { dg-warning "should not be used as a flexible array member for level 2 and above" } */
+ trailing_0->c[1] = 1; /* { dg-bogus "should not be used as a flexible array member for level 2 and above" } */
+ trailing_flex->c[10] = 10; /* { dg-bogus "should not be used as a flexible array member for level 2 and above" } */
+
+}
diff --git a/gcc/testsuite/gcc.dg/Wstrict-flex-arrays-3.c b/gcc/testsuite/gcc.dg/Wstrict-flex-arrays-3.c
new file mode 100644
index 0000000..97eb65b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstrict-flex-arrays-3.c
@@ -0,0 +1,39 @@
+/* Test -Wstrict-flex-arrays. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=3" } */
+
+struct trailing_array_1 {
+ int a;
+ int b;
+ int c[4];
+};
+
+struct trailing_array_2 {
+ int a;
+ int b;
+ int c[1];
+};
+
+struct trailing_array_3 {
+ int a;
+ int b;
+ int c[0];
+};
+struct trailing_array_4 {
+ int a;
+ int b;
+ int c[];
+};
+
+void __attribute__((__noinline__)) stuff(
+ struct trailing_array_1 *normal,
+ struct trailing_array_2 *trailing_1,
+ struct trailing_array_3 *trailing_0,
+ struct trailing_array_4 *trailing_flex)
+{
+ normal->c[5] = 5; /*{ dg-warning "should not be used as a flexible array member for level 1 and above" } */
+ trailing_1->c[2] = 2; /* { dg-warning "should not be used as a flexible array member for level 2 and above" } */
+ trailing_0->c[1] = 1; /* { dg-warning "should not be used as a flexible array member for level 3" } */
+ trailing_flex->c[10] = 10; /* { dg-bogus "should not be used as a flexible array member for level 3" } */
+
+}
diff --git a/gcc/testsuite/gcc.dg/Wstrict-flex-arrays.c b/gcc/testsuite/gcc.dg/Wstrict-flex-arrays.c
new file mode 100644
index 0000000..110fdc7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstrict-flex-arrays.c
@@ -0,0 +1,39 @@
+/* Test -Wstrict-flex-arrays. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=1" } */
+
+struct trailing_array_1 {
+ int a;
+ int b;
+ int c[4];
+};
+
+struct trailing_array_2 {
+ int a;
+ int b;
+ int c[1];
+};
+
+struct trailing_array_3 {
+ int a;
+ int b;
+ int c[0];
+};
+struct trailing_array_4 {
+ int a;
+ int b;
+ int c[];
+};
+
+void __attribute__((__noinline__)) stuff(
+ struct trailing_array_1 *normal,
+ struct trailing_array_2 *trailing_1,
+ struct trailing_array_3 *trailing_0,
+ struct trailing_array_4 *trailing_flex)
+{
+ normal->c[5] = 5; /*{ dg-warning "should not be used as a flexible array member for level 1 and above" } */
+ trailing_1->c[2] = 2; /* { dg-bogus "should not be used as a flexible array member for level 1 and above" } */
+ trailing_0->c[1] = 1; /* { dg-bogus "should not be used as a flexible array member for level 1 and above" } */
+ trailing_flex->c[10] = 10; /* { dg-bogus "should not be used as a flexible array member for level 1 and above" } */
+
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr104308.c b/gcc/testsuite/gcc.dg/analyzer/pr104308.c
index e6a2c88..a3a0cbb 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr104308.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr104308.c
@@ -6,7 +6,7 @@
int test_memmove_within_uninit (void)
{
- char s[5]; /* { dg-message "region created on stack here" "" { xfail riscv*-*-* } } */
+ char s[5]; /* { dg-message "region created on stack here" } */
memmove(s, s + 1, 2); /* { dg-warning "use of uninitialized value" } */
return 0;
}
diff --git a/gcc/testsuite/gcc.target/i386/cmpccxadd-1.c b/gcc/testsuite/gcc.target/i386/cmpccxadd-1.c
index c825717..537b79b 100644
--- a/gcc/testsuite/gcc.target/i386/cmpccxadd-1.c
+++ b/gcc/testsuite/gcc.target/i386/cmpccxadd-1.c
@@ -26,36 +26,36 @@ long long e, f;
void extern
cmpccxadd_test(void)
{
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_O);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_O);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_NO);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_NO);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_B);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_B);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_NB);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_NB);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_Z);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_Z);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_NZ);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_NZ);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_BE);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_BE);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_NBE);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_NBE);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_S);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_S);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_NS);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_NS);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_P);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_P);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_NP);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_NP);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_L);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_L);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_NL);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_NL);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_LE);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_LE);
- b = __cmpccxadd_epi32 (a, b, c, _CMPCCX_NLE);
- e = __cmpccxadd_epi64 (d, e, f, _CMPCCX_NLE);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_O);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_O);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_NO);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_NO);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_B);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_B);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_NB);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_NB);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_Z);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_Z);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_NZ);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_NZ);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_BE);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_BE);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_NBE);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_NBE);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_S);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_S);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_NS);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_NS);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_P);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_P);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_NP);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_NP);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_L);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_L);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_NL);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_NL);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_LE);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_LE);
+ b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_NLE);
+ e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_NLE);
}
diff --git a/gcc/testsuite/gcc.target/i386/cmpccxadd-2.c b/gcc/testsuite/gcc.target/i386/cmpccxadd-2.c
index e713344..5e897b1 100644
--- a/gcc/testsuite/gcc.target/i386/cmpccxadd-2.c
+++ b/gcc/testsuite/gcc.target/i386/cmpccxadd-2.c
@@ -92,39 +92,39 @@ main()
_srcdest2_64[i] = srcdest1_64[i];
}
- res[0] = __cmpccxadd_epi32 (&srcdest1[0], srcdest2[0], src3[0], _CMPCCX_O);
- res[1] = __cmpccxadd_epi32 (&srcdest1[1], srcdest2[1], src3[1], _CMPCCX_NO);
- res[2] = __cmpccxadd_epi32 (&srcdest1[2], srcdest2[2], src3[2], _CMPCCX_B);
- res[3] = __cmpccxadd_epi32 (&srcdest1[3], srcdest2[3], src3[3], _CMPCCX_NB);
- res[4] = __cmpccxadd_epi32 (&srcdest1[4], srcdest2[4], src3[4], _CMPCCX_Z);
- res[5] = __cmpccxadd_epi32 (&srcdest1[5], srcdest2[5], src3[5], _CMPCCX_NZ);
- res[6] = __cmpccxadd_epi32 (&srcdest1[6], srcdest2[6], src3[6], _CMPCCX_BE);
- res[7] = __cmpccxadd_epi32 (&srcdest1[7], srcdest2[7], src3[7], _CMPCCX_NBE);
- res[8] = __cmpccxadd_epi32 (&srcdest1[8], srcdest2[8], src3[8], _CMPCCX_S);
- res[9] = __cmpccxadd_epi32 (&srcdest1[9], srcdest2[9], src3[9], _CMPCCX_NS);
- res[10] = __cmpccxadd_epi32 (&srcdest1[10], srcdest2[10], src3[10], _CMPCCX_P);
- res[11] = __cmpccxadd_epi32 (&srcdest1[11], srcdest2[11], src3[11], _CMPCCX_NP);
- res[12] = __cmpccxadd_epi32 (&srcdest1[12], srcdest2[12], src3[12], _CMPCCX_L);
- res[13] = __cmpccxadd_epi32 (&srcdest1[13], srcdest2[13], src3[13], _CMPCCX_NL);
- res[14] = __cmpccxadd_epi32 (&srcdest1[14], srcdest2[14], src3[14], _CMPCCX_LE);
- res[15] = __cmpccxadd_epi32 (&srcdest1[15], srcdest2[15], src3[15], _CMPCCX_NLE);
+ res[0] = _cmpccxadd_epi32 (&srcdest1[0], srcdest2[0], src3[0], _CMPCCX_O);
+ res[1] = _cmpccxadd_epi32 (&srcdest1[1], srcdest2[1], src3[1], _CMPCCX_NO);
+ res[2] = _cmpccxadd_epi32 (&srcdest1[2], srcdest2[2], src3[2], _CMPCCX_B);
+ res[3] = _cmpccxadd_epi32 (&srcdest1[3], srcdest2[3], src3[3], _CMPCCX_NB);
+ res[4] = _cmpccxadd_epi32 (&srcdest1[4], srcdest2[4], src3[4], _CMPCCX_Z);
+ res[5] = _cmpccxadd_epi32 (&srcdest1[5], srcdest2[5], src3[5], _CMPCCX_NZ);
+ res[6] = _cmpccxadd_epi32 (&srcdest1[6], srcdest2[6], src3[6], _CMPCCX_BE);
+ res[7] = _cmpccxadd_epi32 (&srcdest1[7], srcdest2[7], src3[7], _CMPCCX_NBE);
+ res[8] = _cmpccxadd_epi32 (&srcdest1[8], srcdest2[8], src3[8], _CMPCCX_S);
+ res[9] = _cmpccxadd_epi32 (&srcdest1[9], srcdest2[9], src3[9], _CMPCCX_NS);
+ res[10] = _cmpccxadd_epi32 (&srcdest1[10], srcdest2[10], src3[10], _CMPCCX_P);
+ res[11] = _cmpccxadd_epi32 (&srcdest1[11], srcdest2[11], src3[11], _CMPCCX_NP);
+ res[12] = _cmpccxadd_epi32 (&srcdest1[12], srcdest2[12], src3[12], _CMPCCX_L);
+ res[13] = _cmpccxadd_epi32 (&srcdest1[13], srcdest2[13], src3[13], _CMPCCX_NL);
+ res[14] = _cmpccxadd_epi32 (&srcdest1[14], srcdest2[14], src3[14], _CMPCCX_LE);
+ res[15] = _cmpccxadd_epi32 (&srcdest1[15], srcdest2[15], src3[15], _CMPCCX_NLE);
- res_64[0] = __cmpccxadd_epi64 (&srcdest1_64[0], srcdest2_64[0], src3_64[0], _CMPCCX_O);
- res_64[1] = __cmpccxadd_epi64 (&srcdest1_64[1], srcdest2_64[1], src3_64[1], _CMPCCX_NO);
- res_64[2] = __cmpccxadd_epi64 (&srcdest1_64[2], srcdest2_64[2], src3_64[2], _CMPCCX_B);
- res_64[3] = __cmpccxadd_epi64 (&srcdest1_64[3], srcdest2_64[3], src3_64[3], _CMPCCX_NB);
- res_64[4] = __cmpccxadd_epi64 (&srcdest1_64[4], srcdest2_64[4], src3_64[4], _CMPCCX_Z);
- res_64[5] = __cmpccxadd_epi64 (&srcdest1_64[5], srcdest2_64[5], src3_64[5], _CMPCCX_NZ);
- res_64[6] = __cmpccxadd_epi64 (&srcdest1_64[6], srcdest2_64[6], src3_64[6], _CMPCCX_BE);
- res_64[7] = __cmpccxadd_epi64 (&srcdest1_64[7], srcdest2_64[7], src3_64[7], _CMPCCX_NBE);
- res_64[8] = __cmpccxadd_epi64 (&srcdest1_64[8], srcdest2_64[8], src3_64[8], _CMPCCX_S);
- res_64[9] = __cmpccxadd_epi64 (&srcdest1_64[9], srcdest2_64[9], src3_64[9], _CMPCCX_NS);
- res_64[10] = __cmpccxadd_epi64 (&srcdest1_64[10], srcdest2_64[10], src3_64[10], _CMPCCX_P);
- res_64[11] = __cmpccxadd_epi64 (&srcdest1_64[11], srcdest2_64[11], src3_64[11], _CMPCCX_NP);
- res_64[12] = __cmpccxadd_epi64 (&srcdest1_64[12], srcdest2_64[12], src3_64[12], _CMPCCX_L);
- res_64[13] = __cmpccxadd_epi64 (&srcdest1_64[13], srcdest2_64[13], src3_64[13], _CMPCCX_NL);
- res_64[14] = __cmpccxadd_epi64 (&srcdest1_64[14], srcdest2_64[14], src3_64[14], _CMPCCX_LE);
- res_64[15] = __cmpccxadd_epi64 (&srcdest1_64[15], srcdest2_64[15], src3_64[15], _CMPCCX_NLE);
+ res_64[0] = _cmpccxadd_epi64 (&srcdest1_64[0], srcdest2_64[0], src3_64[0], _CMPCCX_O);
+ res_64[1] = _cmpccxadd_epi64 (&srcdest1_64[1], srcdest2_64[1], src3_64[1], _CMPCCX_NO);
+ res_64[2] = _cmpccxadd_epi64 (&srcdest1_64[2], srcdest2_64[2], src3_64[2], _CMPCCX_B);
+ res_64[3] = _cmpccxadd_epi64 (&srcdest1_64[3], srcdest2_64[3], src3_64[3], _CMPCCX_NB);
+ res_64[4] = _cmpccxadd_epi64 (&srcdest1_64[4], srcdest2_64[4], src3_64[4], _CMPCCX_Z);
+ res_64[5] = _cmpccxadd_epi64 (&srcdest1_64[5], srcdest2_64[5], src3_64[5], _CMPCCX_NZ);
+ res_64[6] = _cmpccxadd_epi64 (&srcdest1_64[6], srcdest2_64[6], src3_64[6], _CMPCCX_BE);
+ res_64[7] = _cmpccxadd_epi64 (&srcdest1_64[7], srcdest2_64[7], src3_64[7], _CMPCCX_NBE);
+ res_64[8] = _cmpccxadd_epi64 (&srcdest1_64[8], srcdest2_64[8], src3_64[8], _CMPCCX_S);
+ res_64[9] = _cmpccxadd_epi64 (&srcdest1_64[9], srcdest2_64[9], src3_64[9], _CMPCCX_NS);
+ res_64[10] = _cmpccxadd_epi64 (&srcdest1_64[10], srcdest2_64[10], src3_64[10], _CMPCCX_P);
+ res_64[11] = _cmpccxadd_epi64 (&srcdest1_64[11], srcdest2_64[11], src3_64[11], _CMPCCX_NP);
+ res_64[12] = _cmpccxadd_epi64 (&srcdest1_64[12], srcdest2_64[12], src3_64[12], _CMPCCX_L);
+ res_64[13] = _cmpccxadd_epi64 (&srcdest1_64[13], srcdest2_64[13], src3_64[13], _CMPCCX_NL);
+ res_64[14] = _cmpccxadd_epi64 (&srcdest1_64[14], srcdest2_64[14], src3_64[14], _CMPCCX_LE);
+ res_64[15] = _cmpccxadd_epi64 (&srcdest1_64[15], srcdest2_64[15], src3_64[15], _CMPCCX_NLE);
for (int i = 0; i < 16; i++)
{
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 6102678..dccd1ae 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1218,6 +1218,9 @@ proc check_effective_target_static {} {
# Return 1 if the target supports -fstack-protector
proc check_effective_target_fstack_protector {} {
+ if { [istarget hppa*-*-*] } {
+ return 0;
+ }
return [check_runtime fstack_protector {
#include <string.h>
int main (int argc, char *argv[]) {
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index addfe7f..c6c86af 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -183,7 +183,7 @@ remap_ssa_name (tree name, copy_body_data *id)
return name;
}
- return unshare_expr (*n);
+ return *n;
}
if (processing_debug_stmt)
@@ -1535,7 +1535,7 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
if (id->reset_location)
gimple_set_location (bind, input_location);
id->debug_stmts.safe_push (bind);
- gimple_seq_add_stmt (&stmts, bind);
+ gimple_seq_add_stmt_without_update (&stmts, bind);
return stmts;
}
@@ -1765,7 +1765,7 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
}
else
{
- if (gimple_assign_copy_p (stmt)
+ if (gimple_assign_single_p (stmt)
&& gimple_assign_lhs (stmt) == gimple_assign_rhs1 (stmt)
&& auto_var_in_fn_p (gimple_assign_lhs (stmt), id->src_fn))
{
@@ -1833,7 +1833,7 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
if (id->reset_location)
gimple_set_location (copy, input_location);
id->debug_stmts.safe_push (copy);
- gimple_seq_add_stmt (&stmts, copy);
+ gimple_seq_add_stmt_without_update (&stmts, copy);
return stmts;
}
if (gimple_debug_source_bind_p (stmt))
@@ -1845,7 +1845,7 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
if (id->reset_location)
gimple_set_location (copy, input_location);
id->debug_stmts.safe_push (copy);
- gimple_seq_add_stmt (&stmts, copy);
+ gimple_seq_add_stmt_without_update (&stmts, copy);
return stmts;
}
if (gimple_debug_nonbind_marker_p (stmt))
@@ -1859,7 +1859,7 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
gdebug *copy = as_a <gdebug *> (gimple_copy (stmt));
id->debug_stmts.safe_push (copy);
- gimple_seq_add_stmt (&stmts, copy);
+ gimple_seq_add_stmt_without_update (&stmts, copy);
return stmts;
}
@@ -1967,7 +1967,7 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
!gsi_end_p (egsi);
gsi_next (&egsi))
walk_gimple_op (gsi_stmt (egsi), remap_gimple_op_r, &wi);
- gimple_seq_add_seq (&stmts, extra_stmts);
+ gimple_seq_add_seq_without_update (&stmts, extra_stmts);
}
}
@@ -2006,14 +2006,14 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
gimple_cond_code (cond),
gimple_cond_lhs (cond),
gimple_cond_rhs (cond));
- gimple_seq_add_stmt (&stmts, cmp);
+ gimple_seq_add_stmt_without_update (&stmts, cmp);
gimple_cond_set_code (cond, NE_EXPR);
gimple_cond_set_lhs (cond, gimple_assign_lhs (cmp));
gimple_cond_set_rhs (cond, boolean_false_node);
}
}
- gimple_seq_add_stmt (&stmts, copy);
+ gimple_seq_add_stmt_without_update (&stmts, copy);
return stmts;
}
@@ -2074,21 +2074,6 @@ copy_bb (copy_body_data *id, basic_block bb,
gimple_duplicate_stmt_histograms (cfun, stmt, id->src_cfun,
orig_stmt);
- /* With return slot optimization we can end up with
- non-gimple (foo *)&this->m, fix that here. */
- if (is_gimple_assign (stmt)
- && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt))
- && !is_gimple_val (gimple_assign_rhs1 (stmt)))
- {
- tree new_rhs;
- new_rhs = force_gimple_operand_gsi (&seq_gsi,
- gimple_assign_rhs1 (stmt),
- true, NULL, false,
- GSI_CONTINUE_LINKING);
- gimple_assign_set_rhs1 (stmt, new_rhs);
- id->regimplify = false;
- }
-
gsi_insert_after (&seq_gsi, stmt, GSI_NEW_STMT);
if (id->regimplify)
@@ -2569,13 +2554,17 @@ copy_edges_for_bb (basic_block bb, profile_count num, profile_count den,
&& !old_edge->src->aux)
new_bb->count -= old_edge->count ().apply_scale (num, den);
- for (si = gsi_start_bb (new_bb); !gsi_end_p (si);)
+ /* Walk stmts from end to start so that splitting will adjust the BB
+ pointer for each stmt at most once, even when we split the block
+ multiple times. */
+ bool seen_nondebug = false;
+ for (si = gsi_last_bb (new_bb); !gsi_end_p (si);)
{
bool can_throw, nonlocal_goto;
gimple *copy_stmt = gsi_stmt (si);
/* Do this before the possible split_block. */
- gsi_next (&si);
+ gsi_prev (&si);
/* If this tree could throw an exception, there are two
cases where we need to add abnormal edge(s): the
@@ -2595,25 +2584,23 @@ copy_edges_for_bb (basic_block bb, profile_count num, profile_count den,
if (can_throw || nonlocal_goto)
{
- if (!gsi_end_p (si))
- {
- while (!gsi_end_p (si) && is_gimple_debug (gsi_stmt (si)))
- gsi_next (&si);
- if (gsi_end_p (si))
- need_debug_cleanup = true;
- }
- if (!gsi_end_p (si))
- /* Note that bb's predecessor edges aren't necessarily
- right at this point; split_block doesn't care. */
+ /* If there's only debug insns after copy_stmt don't split
+ the block but instead mark the block for cleanup. */
+ if (!seen_nondebug)
+ need_debug_cleanup = true;
+ else
{
+ /* Note that bb's predecessor edges aren't necessarily
+ right at this point; split_block doesn't care. */
edge e = split_block (new_bb, copy_stmt);
-
- new_bb = e->dest;
- new_bb->aux = e->src->aux;
- si = gsi_start_bb (new_bb);
+ e->dest->aux = new_bb->aux;
+ seen_nondebug = false;
}
}
+ if (!is_gimple_debug (copy_stmt))
+ seen_nondebug = true;
+
bool update_probs = false;
if (gimple_code (copy_stmt) == GIMPLE_EH_DISPATCH)
diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc
index 3846dc1..e6c6c5a 100644
--- a/gcc/tree-vrp.cc
+++ b/gcc/tree-vrp.cc
@@ -1087,7 +1087,7 @@ execute_ranger_vrp (struct function *fun, bool warn_array_bounds_p,
if (dump_file && (dump_flags & TDF_DETAILS))
ranger->dump (dump_file);
- if (warn_array_bounds && warn_array_bounds_p)
+ if ((warn_array_bounds || warn_strict_flex_arrays) && warn_array_bounds_p)
{
// Set all edges as executable, except those ranger says aren't.
int non_exec_flag = ranger->non_executable_edge_flag;