diff options
author | Marek Polacek <polacek@redhat.com> | 2024-03-01 13:36:51 -0500 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2024-05-07 15:09:20 -0400 |
commit | 7887d808876c00e682e11c19caae1a0dbc9fa3a8 (patch) | |
tree | 2f8ff1e33989dc8d18641b15ad2e548b53128c60 | |
parent | 76e591200f54226290ddb49b8ac6231a694bf882 (diff) | |
download | gcc-7887d808876c00e682e11c19caae1a0dbc9fa3a8.zip gcc-7887d808876c00e682e11c19caae1a0dbc9fa3a8.tar.gz gcc-7887d808876c00e682e11c19caae1a0dbc9fa3a8.tar.bz2 |
c++: DECL_DECOMPOSITION_P cleanup
DECL_DECOMPOSITION_P already checks VAR_P but we repeat the check
in a lot of places.
gcc/cp/ChangeLog:
* decl.cc (duplicate_decls): Don't check VAR_P before
DECL_DECOMPOSITION_P.
* init.cc (build_aggr_init): Likewise.
* parser.cc (cp_parser_range_for): Likewise.
(do_range_for_auto_deduction): Likewise.
(cp_convert_range_for): Likewise.
(cp_convert_omp_range_for): Likewise.
(cp_finish_omp_range_for): Likewise.
* pt.cc (extract_locals_r): Likewise.
(tsubst_omp_for_iterator): Likewise.
(tsubst_decomp_names): Likewise.
(tsubst_stmt): Likewise.
* typeck.cc (maybe_warn_about_returning_address_of_local): Likewise.
-rw-r--r-- | gcc/cp/decl.cc | 3 | ||||
-rw-r--r-- | gcc/cp/init.cc | 2 | ||||
-rw-r--r-- | gcc/cp/parser.cc | 11 | ||||
-rw-r--r-- | gcc/cp/pt.cc | 11 | ||||
-rw-r--r-- | gcc/cp/typeck.cc | 3 |
5 files changed, 10 insertions, 20 deletions
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index b112b70..e025624 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -1938,8 +1938,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) inform (olddecl_loc, "previous declaration %q#D", olddecl); return error_mark_node; } - else if ((VAR_P (olddecl) && DECL_DECOMPOSITION_P (olddecl)) - || (VAR_P (newdecl) && DECL_DECOMPOSITION_P (newdecl))) + else if (DECL_DECOMPOSITION_P (olddecl) || DECL_DECOMPOSITION_P (newdecl)) /* A structured binding must be unique in its declarative region. */; else if (DECL_IMPLICIT_TYPEDEF_P (olddecl) || DECL_IMPLICIT_TYPEDEF_P (newdecl)) diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index a93ce00..c1b5b74 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -2008,7 +2008,7 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) tree itype = init ? TREE_TYPE (init) : NULL_TREE; int from_array = 0; - if (VAR_P (exp) && DECL_DECOMPOSITION_P (exp)) + if (DECL_DECOMPOSITION_P (exp)) { from_array = 1; init = mark_rvalue_use (init); diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 66ce161..775067e 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -14122,7 +14122,6 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl, /* For decomposition declaration get all of the corresponding declarations out of the way. */ if (TREE_CODE (v) == ARRAY_REF - && VAR_P (TREE_OPERAND (v, 0)) && DECL_DECOMPOSITION_P (TREE_OPERAND (v, 0))) { tree d = range_decl; @@ -14243,7 +14242,7 @@ do_range_for_auto_deduction (tree decl, tree range_expr, cp_decomp *decomp) iter_decl, auto_node, tf_warning_or_error, adc_variable_type); - if (VAR_P (decl) && DECL_DECOMPOSITION_P (decl)) + if (DECL_DECOMPOSITION_P (decl)) cp_finish_decomp (decl, decomp); } } @@ -14442,7 +14441,7 @@ cp_convert_range_for (tree statement, tree range_decl, tree range_expr, cp_finish_decl (range_decl, deref_begin, /*is_constant_init*/false, NULL_TREE, LOOKUP_ONLYCONVERTING, decomp); - if (VAR_P (range_decl) && DECL_DECOMPOSITION_P (range_decl)) + if (DECL_DECOMPOSITION_P (range_decl)) cp_finish_decomp (range_decl, decomp); warn_for_range_copy (range_decl, deref_begin); @@ -44440,7 +44439,6 @@ cp_convert_omp_range_for (tree &this_pre_body, tree &sl, { tree v = DECL_VALUE_EXPR (decl); if (TREE_CODE (v) == ARRAY_REF - && VAR_P (TREE_OPERAND (v, 0)) && DECL_DECOMPOSITION_P (TREE_OPERAND (v, 0))) { d = TREE_OPERAND (v, 0); @@ -44545,7 +44543,6 @@ cp_convert_omp_range_for (tree &this_pre_body, tree &sl, { tree v = DECL_VALUE_EXPR (orig_decl); if (TREE_CODE (v) == ARRAY_REF - && VAR_P (TREE_OPERAND (v, 0)) && DECL_DECOMPOSITION_P (TREE_OPERAND (v, 0))) { tree d = orig_decl; @@ -44623,7 +44620,7 @@ cp_finish_omp_range_for (tree orig, tree begin) tree decl = TREE_VEC_ELT (TREE_CHAIN (orig), 2); cp_decomp decomp_d, *decomp = NULL; - if (VAR_P (decl) && DECL_DECOMPOSITION_P (decl)) + if (DECL_DECOMPOSITION_P (decl)) { decomp = &decomp_d; decomp_d.decl = TREE_VEC_ELT (TREE_CHAIN (orig), 3); @@ -44649,7 +44646,7 @@ cp_finish_omp_range_for (tree orig, tree begin) NULL_TREE, tf_warning_or_error), /*is_constant_init*/false, NULL_TREE, LOOKUP_ONLYCONVERTING, decomp); - if (VAR_P (decl) && DECL_DECOMPOSITION_P (decl)) + if (DECL_DECOMPOSITION_P (decl)) cp_finish_decomp (decl, decomp); } diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index d68d688..7a3a4e7 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -13378,14 +13378,12 @@ extract_locals_r (tree *tp, int *walk_subtrees, void *data_) { tree decl = DECL_EXPR_DECL (*tp); data.internal.add (decl); - if (VAR_P (decl) - && DECL_DECOMPOSITION_P (decl) + if (DECL_DECOMPOSITION_P (decl) && TREE_TYPE (decl) != error_mark_node) { gcc_assert (DECL_NAME (decl) == NULL_TREE); for (tree decl2 = DECL_CHAIN (decl); decl2 - && VAR_P (decl2) && DECL_DECOMPOSITION_P (decl2) && DECL_NAME (decl2) && TREE_TYPE (decl2) != error_mark_node; @@ -17917,7 +17915,6 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree &orig_declv, { tree v = DECL_VALUE_EXPR (decl); if (TREE_CODE (v) == ARRAY_REF - && VAR_P (TREE_OPERAND (v, 0)) && DECL_DECOMPOSITION_P (TREE_OPERAND (v, 0))) { cp_decomp decomp_d = { NULL_TREE, 0 }; @@ -18266,7 +18263,6 @@ tsubst_decomp_names (tree decl, tree pattern_decl, tree args, gcc_assert (DECL_NAME (decl) == NULL_TREE); for (decl2 = DECL_CHAIN (pattern_decl); decl2 - && VAR_P (decl2) && DECL_DECOMPOSITION_P (decl2) && DECL_NAME (decl2); decl2 = DECL_CHAIN (decl2)) @@ -18577,8 +18573,7 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl) && DECL_OMP_PRIVATIZED_MEMBER (decl)) break; - if (VAR_P (decl) - && DECL_DECOMPOSITION_P (decl) + if (DECL_DECOMPOSITION_P (decl) && TREE_TYPE (pattern_decl) != error_mark_node) { decomp = &decomp_d; @@ -18652,7 +18647,7 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl) expr = RECUR (RANGE_FOR_EXPR (t)); cp_decomp decomp_d, *decomp = NULL; - if (VAR_P (decl) && DECL_DECOMPOSITION_P (decl)) + if (DECL_DECOMPOSITION_P (decl)) { decomp = &decomp_d; decl = tsubst_decomp_names (decl, RANGE_FOR_DECL (t), args, diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index a25f862..5f16994 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -10651,8 +10651,7 @@ maybe_warn_about_returning_address_of_local (tree retval, location_t loc) && !(TREE_STATIC (whats_returned) || TREE_PUBLIC (whats_returned))) { - if (VAR_P (whats_returned) - && DECL_DECOMPOSITION_P (whats_returned) + if (DECL_DECOMPOSITION_P (whats_returned) && DECL_DECOMP_BASE (whats_returned) && DECL_HAS_VALUE_EXPR_P (whats_returned)) { |