From: Nathan Sidwell Date: Mon, 29 Apr 2019 15:22:41 +0000 (+0000) Subject: [C++ PATCH] some cleanups X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=348dd384c8f647ba56be21932d068d180be243e3;p=gcc.git [C++ PATCH] some cleanups https://gcc.gnu.org/ml/gcc-patches/2019-04/msg01174.html * decl.c (duplicate_decls): Add whitespace, move comments into conditional blocks. * method.c (explain_implicit_non_constexpr): Refactor. * pt.c (check_explicit_specialization): Fix indentation. * semantics.c (process_outer_var_ref): Reformat. (finish_id_expression_1): Use STRIP_TEMPLATE. From-SVN: r270655 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e0a7fb9d5be..56503247233 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2019-04-29 Nathan Sidwell + + * decl.c (duplicate_decls): Add whitespace, move comments into + conditional blocks. + * method.c (explain_implicit_non_constexpr): Refactor. + * pt.c (check_explicit_specialization): Fix indentation. + * semantics.c (process_outer_var_ref): Reformat. + (finish_id_expression_1): Use STRIP_TEMPLATE. + 2019-04-26 Jonathan Wakely PR c++/90243 - orphaned note in uninstantiated constexpr function diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 20a6e2e5b5c..5c4a38e7980 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1,4 +1,4 @@ -/* Process declarations and variables for C++ compiler. +/* Process declarations and variables for -*- C++ -*- compiler. Copyright (C) 1988-2019 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@cygnus.com) @@ -1476,7 +1476,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) if (! same_type_p (TREE_VALUE (t1), TREE_VALUE (t2))) break; -next_arg:; + next_arg:; } warning_at (newdecl_loc, @@ -2386,9 +2386,10 @@ next_arg:; } DECL_TEMPLATE_INFO (newdecl) = DECL_TEMPLATE_INFO (olddecl); } - /* Only functions have these fields. */ + if (DECL_DECLARES_FUNCTION_P (newdecl)) { + /* Only functions have these fields. */ DECL_NONCONVERTING_P (newdecl) = DECL_NONCONVERTING_P (olddecl); DECL_BEFRIENDING_CLASSES (newdecl) = chainon (DECL_BEFRIENDING_CLASSES (newdecl), @@ -2398,10 +2399,12 @@ next_arg:; if (DECL_VIRTUAL_P (newdecl)) SET_DECL_THUNKS (newdecl, DECL_THUNKS (olddecl)); } - /* Only variables have this field. */ - else if (VAR_P (newdecl) - && VAR_HAD_UNKNOWN_BOUND (olddecl)) - SET_VAR_HAD_UNKNOWN_BOUND (newdecl); + else if (VAR_P (newdecl)) + { + /* Only variables have this field. */ + if (VAR_HAD_UNKNOWN_BOUND (olddecl)) + SET_VAR_HAD_UNKNOWN_BOUND (newdecl); + } } if (TREE_CODE (newdecl) == FUNCTION_DECL) diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 03eea408a8f..d92da09a74c 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1884,15 +1884,14 @@ maybe_explain_implicit_delete (tree decl) void explain_implicit_non_constexpr (tree decl) { - tree parm_type = TREE_VALUE (FUNCTION_FIRST_USER_PARMTYPE (decl)); - bool const_p = CP_TYPE_CONST_P (non_reference (parm_type)); + tree parms = FUNCTION_FIRST_USER_PARMTYPE (decl); + bool const_p = CP_TYPE_CONST_P (non_reference (TREE_VALUE (parms))); tree inh = DECL_INHERITED_CTOR (decl); bool dummy; synthesized_method_walk (DECL_CLASS_CONTEXT (decl), special_function_p (decl), const_p, NULL, NULL, NULL, &dummy, true, - &inh, - FUNCTION_FIRST_USER_PARMTYPE (decl)); + &inh, parms); } /* DECL is an instantiation of an inheriting constructor template. Deduce diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e682b6d51be..3e8c70b0d15 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3026,7 +3026,7 @@ check_explicit_specialization (tree declarator, `operator T'. Grab all the conversion operators, and then select from them. */ tree fns = get_class_binding (ctype, IDENTIFIER_CONV_OP_P (name) - ? conv_op_identifier : name); + ? conv_op_identifier : name); if (fns == NULL_TREE) { diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3ae9cf050fb..c9193657333 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3482,16 +3482,12 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use) /* A lambda in an NSDMI (c++/64496). */ break; - if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) - == CPLD_NONE) + if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) == CPLD_NONE) break; - lambda_stack = tree_cons (NULL_TREE, - lambda_expr, - lambda_stack); + lambda_stack = tree_cons (NULL_TREE, lambda_expr, lambda_stack); - containing_function - = decl_function_context (containing_function); + containing_function = decl_function_context (containing_function); } /* In a lambda within a template, wait until instantiation time to implicitly @@ -3502,8 +3498,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use) && DECL_PACK_P (decl)) return decl; - if (lambda_expr && VAR_P (decl) - && DECL_ANON_UNION_VAR_P (decl)) + if (lambda_expr && VAR_P (decl) && DECL_ANON_UNION_VAR_P (decl)) { if (complain & tf_error) error ("cannot capture member %qD of anonymous union", decl); @@ -3512,11 +3507,8 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use) /* Do lambda capture when processing the id-expression, not when odr-using a variable. */ if (!odr_use && context == containing_function) - { - decl = add_default_capture (lambda_stack, - /*id=*/DECL_NAME (decl), - initializer); - } + decl = add_default_capture (lambda_stack, + /*id=*/DECL_NAME (decl), initializer); /* Only an odr-use of an outer automatic variable causes an error, and a constant variable can decay to a prvalue constant without odr-use. So don't complain yet. */ @@ -3528,8 +3520,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use) { error ("%qD is not captured", decl); tree closure = LAMBDA_EXPR_CLOSURE (lambda_expr); - if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) - == CPLD_NONE) + if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) == CPLD_NONE) inform (location_of (closure), "the lambda has no capture-default"); else if (TYPE_CLASS_SCOPE_P (closure)) @@ -3844,10 +3835,11 @@ finish_id_expression_1 (tree id_expression, } else if (is_overloaded_fn (decl)) { + /* We only need to look at the first function, + because all the fns share the attribute we're + concerned with (all member fns or all non-members). */ tree first_fn = get_first_fn (decl); - - if (TREE_CODE (first_fn) == TEMPLATE_DECL) - first_fn = DECL_TEMPLATE_RESULT (first_fn); + first_fn = STRIP_TEMPLATE (first_fn); /* [basic.def.odr]: "A function whose name appears as a potentially-evaluated expression is odr-used if it is the unique