Commit 348dd384 by Nathan Sidwell Committed by Nathan Sidwell

[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
parent 07408476
2019-04-29 Nathan Sidwell <nathan@acm.org>
* 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 <jwakely@redhat.com> 2019-04-26 Jonathan Wakely <jwakely@redhat.com>
PR c++/90243 - orphaned note in uninstantiated constexpr function PR c++/90243 - orphaned note in uninstantiated constexpr function
......
/* Process declarations and variables for C++ compiler. /* Process declarations and variables for -*- C++ -*- compiler.
Copyright (C) 1988-2019 Free Software Foundation, Inc. Copyright (C) 1988-2019 Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com) Contributed by Michael Tiemann (tiemann@cygnus.com)
...@@ -1476,7 +1476,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1476,7 +1476,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
if (! same_type_p (TREE_VALUE (t1), TREE_VALUE (t2))) if (! same_type_p (TREE_VALUE (t1), TREE_VALUE (t2)))
break; break;
next_arg:; next_arg:;
} }
warning_at (newdecl_loc, warning_at (newdecl_loc,
...@@ -2386,9 +2386,10 @@ next_arg:; ...@@ -2386,9 +2386,10 @@ next_arg:;
} }
DECL_TEMPLATE_INFO (newdecl) = DECL_TEMPLATE_INFO (olddecl); DECL_TEMPLATE_INFO (newdecl) = DECL_TEMPLATE_INFO (olddecl);
} }
/* Only functions have these fields. */
if (DECL_DECLARES_FUNCTION_P (newdecl)) if (DECL_DECLARES_FUNCTION_P (newdecl))
{ {
/* Only functions have these fields. */
DECL_NONCONVERTING_P (newdecl) = DECL_NONCONVERTING_P (olddecl); DECL_NONCONVERTING_P (newdecl) = DECL_NONCONVERTING_P (olddecl);
DECL_BEFRIENDING_CLASSES (newdecl) DECL_BEFRIENDING_CLASSES (newdecl)
= chainon (DECL_BEFRIENDING_CLASSES (newdecl), = chainon (DECL_BEFRIENDING_CLASSES (newdecl),
...@@ -2398,10 +2399,12 @@ next_arg:; ...@@ -2398,10 +2399,12 @@ next_arg:;
if (DECL_VIRTUAL_P (newdecl)) if (DECL_VIRTUAL_P (newdecl))
SET_DECL_THUNKS (newdecl, DECL_THUNKS (olddecl)); SET_DECL_THUNKS (newdecl, DECL_THUNKS (olddecl));
} }
/* Only variables have this field. */ else if (VAR_P (newdecl))
else if (VAR_P (newdecl) {
&& VAR_HAD_UNKNOWN_BOUND (olddecl)) /* Only variables have this field. */
SET_VAR_HAD_UNKNOWN_BOUND (newdecl); if (VAR_HAD_UNKNOWN_BOUND (olddecl))
SET_VAR_HAD_UNKNOWN_BOUND (newdecl);
}
} }
if (TREE_CODE (newdecl) == FUNCTION_DECL) if (TREE_CODE (newdecl) == FUNCTION_DECL)
......
...@@ -1884,15 +1884,14 @@ maybe_explain_implicit_delete (tree decl) ...@@ -1884,15 +1884,14 @@ maybe_explain_implicit_delete (tree decl)
void void
explain_implicit_non_constexpr (tree decl) explain_implicit_non_constexpr (tree decl)
{ {
tree parm_type = TREE_VALUE (FUNCTION_FIRST_USER_PARMTYPE (decl)); tree parms = FUNCTION_FIRST_USER_PARMTYPE (decl);
bool const_p = CP_TYPE_CONST_P (non_reference (parm_type)); bool const_p = CP_TYPE_CONST_P (non_reference (TREE_VALUE (parms)));
tree inh = DECL_INHERITED_CTOR (decl); tree inh = DECL_INHERITED_CTOR (decl);
bool dummy; bool dummy;
synthesized_method_walk (DECL_CLASS_CONTEXT (decl), synthesized_method_walk (DECL_CLASS_CONTEXT (decl),
special_function_p (decl), const_p, special_function_p (decl), const_p,
NULL, NULL, NULL, &dummy, true, NULL, NULL, NULL, &dummy, true,
&inh, &inh, parms);
FUNCTION_FIRST_USER_PARMTYPE (decl));
} }
/* DECL is an instantiation of an inheriting constructor template. Deduce /* DECL is an instantiation of an inheriting constructor template. Deduce
......
...@@ -3026,7 +3026,7 @@ check_explicit_specialization (tree declarator, ...@@ -3026,7 +3026,7 @@ check_explicit_specialization (tree declarator,
`operator T'. Grab all the conversion operators, and `operator T'. Grab all the conversion operators, and
then select from them. */ then select from them. */
tree fns = get_class_binding (ctype, IDENTIFIER_CONV_OP_P (name) tree fns = get_class_binding (ctype, IDENTIFIER_CONV_OP_P (name)
? conv_op_identifier : name); ? conv_op_identifier : name);
if (fns == NULL_TREE) if (fns == NULL_TREE)
{ {
......
...@@ -3482,16 +3482,12 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use) ...@@ -3482,16 +3482,12 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use)
/* A lambda in an NSDMI (c++/64496). */ /* A lambda in an NSDMI (c++/64496). */
break; break;
if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) == CPLD_NONE)
== CPLD_NONE)
break; break;
lambda_stack = tree_cons (NULL_TREE, lambda_stack = tree_cons (NULL_TREE, lambda_expr, lambda_stack);
lambda_expr,
lambda_stack);
containing_function containing_function = decl_function_context (containing_function);
= decl_function_context (containing_function);
} }
/* In a lambda within a template, wait until instantiation time to implicitly /* 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) ...@@ -3502,8 +3498,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use)
&& DECL_PACK_P (decl)) && DECL_PACK_P (decl))
return decl; return decl;
if (lambda_expr && VAR_P (decl) if (lambda_expr && VAR_P (decl) && DECL_ANON_UNION_VAR_P (decl))
&& DECL_ANON_UNION_VAR_P (decl))
{ {
if (complain & tf_error) if (complain & tf_error)
error ("cannot capture member %qD of anonymous union", decl); 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) ...@@ -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 /* Do lambda capture when processing the id-expression, not when
odr-using a variable. */ odr-using a variable. */
if (!odr_use && context == containing_function) if (!odr_use && context == containing_function)
{ decl = add_default_capture (lambda_stack,
decl = add_default_capture (lambda_stack, /*id=*/DECL_NAME (decl), initializer);
/*id=*/DECL_NAME (decl),
initializer);
}
/* Only an odr-use of an outer automatic variable causes an /* Only an odr-use of an outer automatic variable causes an
error, and a constant variable can decay to a prvalue error, and a constant variable can decay to a prvalue
constant without odr-use. So don't complain yet. */ 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) ...@@ -3528,8 +3520,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use)
{ {
error ("%qD is not captured", decl); error ("%qD is not captured", decl);
tree closure = LAMBDA_EXPR_CLOSURE (lambda_expr); tree closure = LAMBDA_EXPR_CLOSURE (lambda_expr);
if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) == CPLD_NONE)
== CPLD_NONE)
inform (location_of (closure), inform (location_of (closure),
"the lambda has no capture-default"); "the lambda has no capture-default");
else if (TYPE_CLASS_SCOPE_P (closure)) else if (TYPE_CLASS_SCOPE_P (closure))
...@@ -3844,10 +3835,11 @@ finish_id_expression_1 (tree id_expression, ...@@ -3844,10 +3835,11 @@ finish_id_expression_1 (tree id_expression,
} }
else if (is_overloaded_fn (decl)) 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); tree first_fn = get_first_fn (decl);
first_fn = STRIP_TEMPLATE (first_fn);
if (TREE_CODE (first_fn) == TEMPLATE_DECL)
first_fn = DECL_TEMPLATE_RESULT (first_fn);
/* [basic.def.odr]: "A function whose name appears as a /* [basic.def.odr]: "A function whose name appears as a
potentially-evaluated expression is odr-used if it is the unique potentially-evaluated expression is odr-used if it is the unique
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment