+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)
if (! same_type_p (TREE_VALUE (t1), TREE_VALUE (t2)))
break;
-next_arg:;
+ next_arg:;
}
warning_at (newdecl_loc,
}
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),
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)
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
`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)
{
/* 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
&& 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);
/* 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. */
{
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))
}
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