From 7def8e7641788a3706671a6a2902fb3ae540334e Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 16 Aug 2022 10:53:00 +0200 Subject: i386: add 'final' and 'override' to scalar_chain In c3ed9e0d6e96d8697e4bab994f8acbc5506240ee, David added some "final override" and since that there are 2 new warnings that need the same treatment: gcc/config/i386/i386-features.h:186:8: warning: 'convert_op' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/config/i386/i386-features.h:186:8: warning: 'convert_op' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/config/i386/i386-features.h:199:8: warning: 'convert_op' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/config/i386/i386-features.h:199:8: warning: 'convert_op' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/ChangeLog: * config/i386/i386-features.h (class general_scalar_chain): Add final override for a method. (class timode_scalar_chain): Likewise. --- gcc/config/i386/i386-features.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/config/i386/i386-features.h b/gcc/config/i386/i386-features.h index 3d88a88..f898e67 100644 --- a/gcc/config/i386/i386-features.h +++ b/gcc/config/i386/i386-features.h @@ -183,7 +183,7 @@ class general_scalar_chain : public scalar_chain private: void convert_insn (rtx_insn *insn) final override; - void convert_op (rtx *op, rtx_insn *insn); + void convert_op (rtx *op, rtx_insn *insn) final override; int vector_const_cost (rtx exp); }; @@ -196,7 +196,7 @@ class timode_scalar_chain : public scalar_chain private: void fix_debug_reg_uses (rtx reg); void convert_insn (rtx_insn *insn) final override; - void convert_op (rtx *op, rtx_insn *insn); + void convert_op (rtx *op, rtx_insn *insn) final override; }; } // anon namespace -- cgit v1.1 From bdd385b2c61a7fcca4b5f754c2bce90071b5420e Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 16 Aug 2022 11:00:14 +0200 Subject: analyzer: add more final override keywords gcc/analyzer/ChangeLog: * region-model.cc: Fix -Winconsistent-missing-override clang warning. * region.h: Likewise. --- gcc/analyzer/region-model.cc | 4 ++-- gcc/analyzer/region.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'gcc') diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index b05b709..b5bc3efd 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -3425,7 +3425,7 @@ public: result_set.add (sval); } - void visit_unaryop_svalue (const unaryop_svalue *sval) + void visit_unaryop_svalue (const unaryop_svalue *sval) final override { const svalue *arg = sval->get_arg (); if (result_set.contains (arg)) @@ -3449,7 +3449,7 @@ public: } } - void visit_repeated_svalue (const repeated_svalue *sval) + void visit_repeated_svalue (const repeated_svalue *sval) final override { sval->get_inner_svalue ()->accept (this); if (result_set.contains (sval->get_inner_svalue ())) diff --git a/gcc/analyzer/region.h b/gcc/analyzer/region.h index 20dffc7..d37584b 100644 --- a/gcc/analyzer/region.h +++ b/gcc/analyzer/region.h @@ -919,7 +919,8 @@ public: const svalue *get_byte_offset () const { return m_byte_offset; } bool get_relative_concrete_offset (bit_offset_t *out) const final override; - const svalue * get_byte_size_sval (region_model_manager *mgr) const; + const svalue * get_byte_size_sval (region_model_manager *mgr) + const final override; private: -- cgit v1.1 From bae12e2f832b2fb0189348c2650362ce9308e4f5 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 16 Aug 2022 11:06:04 +0200 Subject: VR: add missing override keyworks Address: gcc/value-range-equiv.h:57:8: warning: 'set_undefined' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/value-range-equiv.h:58:8: warning: 'set_varying' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/ChangeLog: * value-range-equiv.h (class value_range_equiv): --- gcc/value-range-equiv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/value-range-equiv.h b/gcc/value-range-equiv.h index 0a52d13..ad8c640 100644 --- a/gcc/value-range-equiv.h +++ b/gcc/value-range-equiv.h @@ -54,8 +54,8 @@ class GTY((user)) value_range_equiv : public value_range bool equal_p (const value_range_equiv &, bool ignore_equivs) const; /* Types of value ranges. */ - void set_undefined (); - void set_varying (tree); + void set_undefined () override; + void set_varying (tree) override; /* Equivalence bitmap methods. */ bitmap equiv () const { return m_equiv; } -- cgit v1.1 From 5e88fccf4be7e8ab22734d87f8e520b25d92d845 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 16 Aug 2022 09:43:24 +0200 Subject: middle-end/106630 - avoid ping-pong between extract_muldiv and match.pd The following avoids ping-pong between the match.pd pattern changing (sizetype) ((a_9 + 1) * 48) to (sizetype)(a_9 + 1) * 48 and extract_muldiv performing the reverse transform by restricting the match.pd pattern to narrowing conversions as the comment indicates. PR middle-end/106630 * match.pd ((T)(x * CST) -> (T)x * CST): Restrict to narrowing conversions. * gcc.dg/torture/pr106630.c: New testcase. --- gcc/match.pd | 2 +- gcc/testsuite/gcc.dg/torture/pr106630.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr106630.c (limited to 'gcc') diff --git a/gcc/match.pd b/gcc/match.pd index e32bda6..07d0a61 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1917,7 +1917,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (convert (mult@0 zero_one_valued_p@1 INTEGER_CST@2)) (if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (@0)) - && TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (@0))) + && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@0))) (mult (convert @1) (convert @2)))) /* (X << C) != 0 can be simplified to X, when C is zero_one_valued_p. diff --git a/gcc/testsuite/gcc.dg/torture/pr106630.c b/gcc/testsuite/gcc.dg/torture/pr106630.c new file mode 100644 index 0000000..d608b91 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr106630.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +short d, e; +int f; +extern short g[][24]; +char c; +void h() { + char a = 6; + c = a; + for (unsigned long a = (d || e) - 1; a < c; a += f) + for (signed b = 0; b < 24; b++) + g[a][b] = 4; +} -- cgit v1.1 From 83bacf93844116c43d8a671b279875713f37e351 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 16 Aug 2022 11:15:30 +0200 Subject: VR: add more virtual dtors Add 2 virtual destructors in order to address: gcc/alloc-pool.h:522:5: warning: destructor called on non-final 'value_range_equiv' that has virtual functions but non-virtual destructor [-Wdelete-non-abstract-non-virtual-dtor] gcc/ggc.h:166:3: warning: destructor called on non-final 'int_range<1>' that has virtual functions but non-virtual destructor [-Wdelete-non-abstract-non-virtual-dtor] gcc/ChangeLog: * value-range-equiv.h (class value_range_equiv): Add virtual destructor. * value-range.h: Likewise. --- gcc/value-range-equiv.h | 3 +++ gcc/value-range.h | 1 + 2 files changed, 4 insertions(+) (limited to 'gcc') diff --git a/gcc/value-range-equiv.h b/gcc/value-range-equiv.h index ad8c640..1a8014d 100644 --- a/gcc/value-range-equiv.h +++ b/gcc/value-range-equiv.h @@ -37,6 +37,9 @@ class GTY((user)) value_range_equiv : public value_range /* Shallow-copies equiv bitmap. */ value_range_equiv& operator=(const value_range_equiv &) /* = delete */; + /* Virtual destructor. */ + virtual ~value_range_equiv () = default; + /* Move equiv bitmap from source range. */ void move (value_range_equiv *); diff --git a/gcc/value-range.h b/gcc/value-range.h index 856947d..f0075d0 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -228,6 +228,7 @@ public: int_range (tree type); int_range (const int_range &); int_range (const irange &); + virtual ~int_range () = default; int_range& operator= (const int_range &); private: template friend void gt_ggc_mx (int_range *); -- cgit v1.1 From 8699a0eb620ad076ed377c6652d1326a47235721 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 16 Aug 2022 11:23:43 +0200 Subject: VR: mitigate -Wfinal-dtor-non-final-class clang warnings Fixes: gcc/value-range-storage.h:129:40: warning: class with destructor marked 'final' cannot be inherited from [-Wfinal-dtor-non-final-class] gcc/value-range-storage.h:146:36: warning: class with destructor marked 'final' cannot be inherited from [-Wfinal-dtor-non-final-class] gcc/ChangeLog: * value-range-storage.h (class obstack_vrange_allocator): Mark the class as final. (class ggc_vrange_allocator): Likewise. --- gcc/value-range-storage.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/value-range-storage.h b/gcc/value-range-storage.h index 3fac5ea..9cd6b9f 100644 --- a/gcc/value-range-storage.h +++ b/gcc/value-range-storage.h @@ -119,7 +119,7 @@ class GTY (()) frange_storage_slot frange_props m_props; }; -class obstack_vrange_allocator : public vrange_allocator +class obstack_vrange_allocator final: public vrange_allocator { public: obstack_vrange_allocator () @@ -139,7 +139,7 @@ private: obstack m_obstack; }; -class ggc_vrange_allocator : public vrange_allocator +class ggc_vrange_allocator final: public vrange_allocator { public: ggc_vrange_allocator () { } -- cgit v1.1 From 3856c6e24c70cfa0e2eaa2b66e2b28c422b3f150 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Tue, 16 Aug 2022 10:52:37 +0200 Subject: Rename imports nomenclature in path_range_query to exit_dependencies. The purpose of this change is to disambiguate the imports name with its use in GORI. gcc/ChangeLog: * gimple-range-path.cc (path_range_query::import_p): Rename to... (path_range_query::exit_dependency_p): ...this. (path_range_query::dump): Rename imports to exit dependencies. (path_range_query::compute_ranges_in_phis): Same. (path_range_query::compute_ranges_in_block): Same. (path_range_query::adjust_for_non_null_uses): Same. (path_range_query::compute_ranges): Same. (path_range_query::compute_phi_relations): Same. (path_range_query::add_to_imports): Rename to... (path_range_query::add_to_exit_dependencies): ...this. (path_range_query::compute_imports): Rename to... (path_range_query::compute_exit_dependencies): ...this. * gimple-range-path.h (class path_range_query): Rename imports to exit dependencies. --- gcc/gimple-range-path.cc | 79 +++++++++++++++++++++++------------------------- gcc/gimple-range-path.h | 19 +++++++++--- 2 files changed, 51 insertions(+), 47 deletions(-) (limited to 'gcc') diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index 78146f5..c99d77d 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -62,13 +62,13 @@ path_range_query::~path_range_query () delete m_cache; } -// Return TRUE if NAME is in the import bitmap. +// Return TRUE if NAME is an exit depenency for the path. bool -path_range_query::import_p (tree name) +path_range_query::exit_dependency_p (tree name) { return (TREE_CODE (name) == SSA_NAME - && bitmap_bit_p (m_imports, SSA_NAME_VERSION (name))); + && bitmap_bit_p (m_exit_dependencies, SSA_NAME_VERSION (name))); } // Mark cache entry for NAME as unused. @@ -118,8 +118,8 @@ path_range_query::dump (FILE *dump_file) dump_ranger (dump_file, m_path); - fprintf (dump_file, "Imports:\n"); - EXECUTE_IF_SET_IN_BITMAP (m_imports, 0, i, bi) + fprintf (dump_file, "Exit dependencies:\n"); + EXECUTE_IF_SET_IN_BITMAP (m_exit_dependencies, 0, i, bi) { tree name = ssa_name (i); print_generic_expr (dump_file, name, TDF_SLIM); @@ -356,7 +356,7 @@ path_range_query::compute_ranges_in_phis (basic_block bb) gphi *phi = iter.phi (); tree name = gimple_phi_result (phi); - if (!import_p (name)) + if (!exit_dependency_p (name)) continue; Value_Range r (TREE_TYPE (name)); @@ -400,17 +400,17 @@ path_range_query::compute_ranges_in_block (basic_block bb) // Force recalculation of any names in the cache that are defined in // this block. This can happen on interdependent SSA/phis in loops. - EXECUTE_IF_SET_IN_BITMAP (m_imports, 0, i, bi) + EXECUTE_IF_SET_IN_BITMAP (m_exit_dependencies, 0, i, bi) { tree name = ssa_name (i); if (ssa_defined_in_bb (name, bb)) clear_cache (name); } - // Solve imports defined in this block, starting with the PHIs... + // Solve dependencies defined in this block, starting with the PHIs... compute_ranges_in_phis (bb); - // ...and then the rest of the imports. - EXECUTE_IF_SET_IN_BITMAP (m_imports, 0, i, bi) + // ...and then the rest of the dependencies. + EXECUTE_IF_SET_IN_BITMAP (m_exit_dependencies, 0, i, bi) { tree name = ssa_name (i); Value_Range r (TREE_TYPE (name)); @@ -423,7 +423,7 @@ path_range_query::compute_ranges_in_block (basic_block bb) if (at_exit ()) return; - // Solve imports that are exported to the next block. + // Solve dependencies that are exported to the next block. basic_block next = next_bb (); edge e = find_edge (bb, next); @@ -444,7 +444,7 @@ path_range_query::compute_ranges_in_block (basic_block bb) gori_compute &g = m_ranger->gori (); bitmap exports = g.exports (bb); - EXECUTE_IF_AND_IN_BITMAP (m_imports, exports, 0, i, bi) + EXECUTE_IF_AND_IN_BITMAP (m_exit_dependencies, exports, 0, i, bi) { tree name = ssa_name (i); Value_Range r (TREE_TYPE (name)); @@ -472,7 +472,7 @@ path_range_query::compute_ranges_in_block (basic_block bb) compute_outgoing_relations (bb, next); } -// Adjust all pointer imports in BB with non-null information. +// Adjust all pointer exit dependencies in BB with non-null information. void path_range_query::adjust_for_non_null_uses (basic_block bb) @@ -481,7 +481,7 @@ path_range_query::adjust_for_non_null_uses (basic_block bb) bitmap_iterator bi; unsigned i; - EXECUTE_IF_SET_IN_BITMAP (m_imports, 0, i, bi) + EXECUTE_IF_SET_IN_BITMAP (m_exit_dependencies, 0, i, bi) { tree name = ssa_name (i); @@ -501,39 +501,33 @@ path_range_query::adjust_for_non_null_uses (basic_block bb) } } -// If NAME is a supported SSA_NAME, add it the bitmap in IMPORTS. +// If NAME is a supported SSA_NAME, add it to the bitmap in dependencies. bool -path_range_query::add_to_imports (tree name, bitmap imports) +path_range_query::add_to_exit_dependencies (tree name, bitmap dependencies) { if (TREE_CODE (name) == SSA_NAME && Value_Range::supports_type_p (TREE_TYPE (name))) - return bitmap_set_bit (imports, SSA_NAME_VERSION (name)); + return bitmap_set_bit (dependencies, SSA_NAME_VERSION (name)); return false; } -// Compute the imports to PATH. These are -// essentially the SSA names used to calculate the final conditional -// along the path. -// -// They are hints for the solver. Adding more elements doesn't slow -// us down, because we don't solve anything that doesn't appear in the -// path. On the other hand, not having enough imports will limit what -// we can solve. +// Compute the exit dependencies to PATH. These are essentially the +// SSA names used to calculate the final conditional along the path. void -path_range_query::compute_imports (bitmap imports, const vec &path) +path_range_query::compute_exit_dependencies (bitmap dependencies, + const vec &path) { // Start with the imports from the exit block... basic_block exit = path[0]; gori_compute &gori = m_ranger->gori (); - bitmap r_imports = gori.imports (exit); - bitmap_copy (imports, r_imports); + bitmap_copy (dependencies, gori.imports (exit)); - auto_vec worklist (bitmap_count_bits (imports)); + auto_vec worklist (bitmap_count_bits (dependencies)); bitmap_iterator bi; unsigned i; - EXECUTE_IF_SET_IN_BITMAP (imports, 0, i, bi) + EXECUTE_IF_SET_IN_BITMAP (dependencies, 0, i, bi) { tree name = ssa_name (i); worklist.quick_push (name); @@ -557,7 +551,7 @@ path_range_query::compute_imports (bitmap imports, const vec &path) if (TREE_CODE (arg) == SSA_NAME && path.contains (e->src) - && bitmap_set_bit (imports, SSA_NAME_VERSION (arg))) + && bitmap_set_bit (dependencies, SSA_NAME_VERSION (arg))) worklist.safe_push (arg); } } @@ -581,7 +575,7 @@ path_range_query::compute_imports (bitmap imports, const vec &path) for (unsigned j = 0; j < 3; ++j) { tree rhs = ssa[j]; - if (rhs && add_to_imports (rhs, imports)) + if (rhs && add_to_exit_dependencies (rhs, dependencies)) worklist.safe_push (rhs); } } @@ -594,19 +588,20 @@ path_range_query::compute_imports (bitmap imports, const vec &path) tree name; FOR_EACH_GORI_EXPORT_NAME (gori, bb, name) if (TREE_CODE (TREE_TYPE (name)) == BOOLEAN_TYPE) - bitmap_set_bit (imports, SSA_NAME_VERSION (name)); + bitmap_set_bit (dependencies, SSA_NAME_VERSION (name)); } } -// Compute the ranges for IMPORTS along PATH. +// Compute the ranges for DEPENDENCIES along PATH. // -// IMPORTS are the set of SSA names, any of which could potentially -// change the value of the final conditional in PATH. Default to the -// imports of the last block in the path if none is given. +// DEPENDENCIES are path exit dependencies. They are the set of SSA +// names, any of which could potentially change the value of the final +// conditional in PATH. If none is given, the exit dependencies are +// calculated from the final conditional in the path. void path_range_query::compute_ranges (const vec &path, - const bitmap_head *imports) + const bitmap_head *dependencies) { if (DEBUG_SOLVER) fprintf (dump_file, "\n==============================================\n"); @@ -614,10 +609,10 @@ path_range_query::compute_ranges (const vec &path, set_path (path); m_undefined_path = false; - if (imports) - bitmap_copy (m_imports, imports); + if (dependencies) + bitmap_copy (m_exit_dependencies, dependencies); else - compute_imports (m_imports, m_path); + compute_exit_dependencies (m_exit_dependencies, m_path); if (m_resolve) get_path_oracle ()->reset_path (); @@ -809,7 +804,7 @@ path_range_query::compute_phi_relations (basic_block bb, basic_block prev) tree result = gimple_phi_result (phi); unsigned nargs = gimple_phi_num_args (phi); - if (!import_p (result)) + if (!exit_dependency_p (result)) continue; for (size_t i = 0; i < nargs; ++i) diff --git a/gcc/gimple-range-path.h b/gcc/gimple-range-path.h index e783e00..3cb794e 100644 --- a/gcc/gimple-range-path.h +++ b/gcc/gimple-range-path.h @@ -35,9 +35,10 @@ public: path_range_query (bool resolve = true, class gimple_ranger *ranger = NULL); virtual ~path_range_query (); void compute_ranges (const vec &, - const bitmap_head *imports = NULL); + const bitmap_head *dependencies = NULL); void compute_ranges (edge e); - void compute_imports (bitmap imports, const vec &); + void compute_exit_dependencies (bitmap dependencies, + const vec &); bool range_of_expr (vrange &r, tree name, gimple * = NULL) override; bool range_of_stmt (vrange &r, gimple *, tree name = NULL) override; bool unreachable_path_p (); @@ -64,8 +65,8 @@ private: void compute_outgoing_relations (basic_block bb, basic_block next); void compute_phi_relations (basic_block bb, basic_block prev); void maybe_register_phi_relation (gphi *, edge e); - bool add_to_imports (tree name, bitmap imports); - bool import_p (tree name); + bool add_to_exit_dependencies (tree name, bitmap dependencies); + bool exit_dependency_p (tree name); bool ssa_defined_in_bb (tree name, basic_block bb); bool relations_may_be_invalidated (edge); @@ -89,7 +90,15 @@ private: // Path being analyzed. auto_vec m_path; - auto_bitmap m_imports; + // This is a list of SSA names that may have relevant context + // information for solving the final conditional along the path. + // Ranges for these SSA names are pre-calculated and cached during a + // top-down traversal of the path, and are then used to answer + // questions at the path exit. + auto_bitmap m_exit_dependencies; + + // A ranger used to resolve ranges for SSA names whose values come + // from outside the path. gimple_ranger *m_ranger; // Current path position. -- cgit v1.1 From e56b695aa3aed3c0c80616bba569bbeb4a06b5e5 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Tue, 16 Aug 2022 12:22:10 +0200 Subject: d: Update DIP links in gdc documentation to point at upstream repository The wiki links probably worked at some point in the distant past, but now the official location of tracking all D Improvement Proposals is on the upstream dlang/DIPs GitHub repository. PR d/106638 gcc/d/ChangeLog: * gdc.texi: Update DIP links to point at upstream dlang/DIPs repository. --- gcc/d/gdc.texi | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'gcc') diff --git a/gcc/d/gdc.texi b/gcc/d/gdc.texi index 2be3154..2bff627 100644 --- a/gcc/d/gdc.texi +++ b/gcc/d/gdc.texi @@ -326,14 +326,17 @@ values are supported: @item all Turns on all upcoming D language features. @item dip1000 -Implements @uref{https://wiki.dlang.org/DIP1000} (Scoped pointers). +Implements @uref{https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1000.md} +(Scoped pointers). @item dip1008 -Implements @uref{https://wiki.dlang.org/DIP1008} (Allow exceptions in -@code{@@nogc} code). +Implements @uref{https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1008.md} +(Allow exceptions in @code{@@nogc} code). @item dip1021 -Implements @uref{https://wiki.dlang.org/DIP1021} (Mutable function arguments). +Implements @uref{https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1021.md} +(Mutable function arguments). @item dip25 -Implements @uref{https://wiki.dlang.org/DIP25} (Sealed references). +Implements @uref{https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md} +(Sealed references). @item dtorfields Turns on generation for destructing fields of partially constructed objects. @item fieldwise @@ -383,7 +386,8 @@ are supported: @item all Turns off all revertable D language features. @item dip25 -Reverts @uref{https://wiki.dlang.org/DIP25} (Sealed references). +Reverts @uref{https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md} +(Sealed references). @item dtorfields Turns off generation for destructing fields of partially constructed objects. @item markdown -- cgit v1.1 From 6e790ca4615443fa395ac5cdba1ab6c87810985c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 16 Aug 2022 13:15:32 +0200 Subject: c++: Implement P2327R1 - De-deprecating volatile compound operations From what I can see, this has been voted in as a DR and as it means we warn less often than before in -std={gnu,c}++2{0,3} modes or with -Wvolatile, I wonder if it shouldn't be backported to affected release branches as well. 2022-08-16 Jakub Jelinek * typeck.cc (cp_build_modify_expr): Implement P2327R1 - De-deprecating volatile compound operations. Don't warn for |=, &= or ^= with volatile lhs. * expr.cc (mark_use) : Adjust warning wording, leave out simple. * g++.dg/cpp2a/volatile1.C: Adjust for de-deprecation of volatile compound |=, &= and ^= operations. * g++.dg/cpp2a/volatile3.C: Likewise. * g++.dg/cpp2a/volatile5.C: Likewise. --- gcc/cp/expr.cc | 4 ++-- gcc/cp/typeck.cc | 8 ++++++-- gcc/testsuite/g++.dg/cpp2a/volatile1.C | 11 ++++++++--- gcc/testsuite/g++.dg/cpp2a/volatile3.C | 11 ++++++++--- gcc/testsuite/g++.dg/cpp2a/volatile5.C | 8 ++++---- 5 files changed, 28 insertions(+), 14 deletions(-) (limited to 'gcc') diff --git a/gcc/cp/expr.cc b/gcc/cp/expr.cc index 56fc11f..f3e155b 100644 --- a/gcc/cp/expr.cc +++ b/gcc/cp/expr.cc @@ -220,7 +220,7 @@ mark_use (tree expr, bool rvalue_p, bool read_p, case MODIFY_EXPR: { tree lhs = TREE_OPERAND (expr, 0); - /* [expr.ass] "A simple assignment whose left operand is of + /* [expr.ass] "An assignment whose left operand is of a volatile-qualified type is deprecated unless the assignment is either a discarded-value expression or appears in an unevaluated context." */ @@ -230,7 +230,7 @@ mark_use (tree expr, bool rvalue_p, bool read_p, && !TREE_THIS_VOLATILE (expr)) { if (warning_at (location_of (expr), OPT_Wvolatile, - "using value of simple assignment with " + "using value of assignment with " "%-qualified left operand is " "deprecated")) /* Make sure not to warn about this assignment again. */ diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 15548e5..6b38c8c 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -9136,10 +9136,14 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode, /* An expression of the form E1 op= E2. [expr.ass] says: "Such expressions are deprecated if E1 has volatile-qualified - type." We warn here rather than in cp_genericize_r because + type and op is not one of the bitwise operators |, &, ^." + We warn here rather than in cp_genericize_r because for compound assignments we are supposed to warn even if the assignment is a discarded-value expression. */ - if (TREE_THIS_VOLATILE (lhs) || CP_TYPE_VOLATILE_P (lhstype)) + if (modifycode != BIT_AND_EXPR + && modifycode != BIT_IOR_EXPR + && modifycode != BIT_XOR_EXPR + && (TREE_THIS_VOLATILE (lhs) || CP_TYPE_VOLATILE_P (lhstype))) warning_at (loc, OPT_Wvolatile, "compound assignment with %-qualified left " "operand is deprecated"); diff --git a/gcc/testsuite/g++.dg/cpp2a/volatile1.C b/gcc/testsuite/g++.dg/cpp2a/volatile1.C index 7ea6b47..a0264a4 100644 --- a/gcc/testsuite/g++.dg/cpp2a/volatile1.C +++ b/gcc/testsuite/g++.dg/cpp2a/volatile1.C @@ -56,6 +56,9 @@ fn2 () vi = i; vi = i = 42; i = vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + i = vi |= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + i = vi &= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + i = vi ^= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } &(vi = i); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } (vi = 42, 45); (i = vi = 42, 10); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } @@ -74,8 +77,9 @@ fn2 () vi += i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } vi -= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } vi %= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } - vi ^= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } - vi |= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + vi ^= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } + vi |= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } + vi &= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } vi /= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } vi = vi += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } vi += vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } @@ -131,7 +135,8 @@ void raccoon () volatile T t, u; t = 42; u = t = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } - t &= 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + t += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + t &= 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } } void diff --git a/gcc/testsuite/g++.dg/cpp2a/volatile3.C b/gcc/testsuite/g++.dg/cpp2a/volatile3.C index f10a297..58816dc 100644 --- a/gcc/testsuite/g++.dg/cpp2a/volatile3.C +++ b/gcc/testsuite/g++.dg/cpp2a/volatile3.C @@ -57,6 +57,9 @@ fn2 () vi = i; vi = i = 42; i = vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } + i = vi |= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" } + i = vi &= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" } + i = vi ^= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" } &(vi = i); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } (vi = 42, 45); (i = vi = 42, 10); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } @@ -75,8 +78,9 @@ fn2 () vi += i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } vi -= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } vi %= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } - vi ^= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } - vi |= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } + vi ^= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } + vi |= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } + vi &= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } vi /= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } vi = vi += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } vi += vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } @@ -132,7 +136,8 @@ void raccoon () volatile T t, u; t = 42; u = t = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } - t &= 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } + t += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } + t &= 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } } void diff --git a/gcc/testsuite/g++.dg/cpp2a/volatile5.C b/gcc/testsuite/g++.dg/cpp2a/volatile5.C index 1f9d238..3684be9 100644 --- a/gcc/testsuite/g++.dg/cpp2a/volatile5.C +++ b/gcc/testsuite/g++.dg/cpp2a/volatile5.C @@ -8,8 +8,8 @@ f (bool b) { (b ? x : y) = 1; (b ? x : y) += 1; // { dg-warning "compound assignment" "" { target c++20 } } - z = (b ? x : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } } - ((z = 2) ? x : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } } - (b ? (x = 2) : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } } - (b ? x : (y = 5)) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } } + z = (b ? x : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } } + ((z = 2) ? x : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } } + (b ? (x = 2) : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } } + (b ? x : (y = 5)) = 1; // { dg-warning "using value of assignment" "" { target c++20 } } } -- cgit v1.1