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>
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.
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,11 +2399,13 @@ next_arg:;
if (DECL_VIRTUAL_P (newdecl))
SET_DECL_THUNKS (newdecl, DECL_THUNKS (olddecl));
}
else if (VAR_P (newdecl))
{
/* Only variables have this field. */
else if (VAR_P (newdecl)
&& VAR_HAD_UNKNOWN_BOUND (olddecl))
if (VAR_HAD_UNKNOWN_BOUND (olddecl))
SET_VAR_HAD_UNKNOWN_BOUND (newdecl);
}
}
if (TREE_CODE (newdecl) == FUNCTION_DECL)
{
......
......@@ -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
......
......@@ -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);
}
/*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
......
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