Commit b7698cf0 by Jason Merrill

decl.c (start_decl): Always pedwarn about vacuously redeclaring a member.

	* decl.c (start_decl): Always pedwarn about vacuously redeclaring
	a member.
	(start_function): Call check_default_args.
	* decl2.c (grokfield): Don't call check_default_args.
	(check_default_args): Use cp_error_at.
	* lex.c (do_pending_defargs): Call check_default_args.
	* call.c (build_scoped_method_call): Make sure get_type_value returns
	something before we try to use its TYPE_MAIN_VARIANT.

From-SVN: r20113
parent be3a14bb
1998-05-28 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (start_decl): Always pedwarn about vacuously redeclaring
a member.
(start_function): Call check_default_args.
* decl2.c (grokfield): Don't call check_default_args.
(check_default_args): Use cp_error_at.
* lex.c (do_pending_defargs): Call check_default_args.
1998-05-27 Brendan Kehoe <brendan@cygnus.com> 1998-05-27 Brendan Kehoe <brendan@cygnus.com>
* call.c (build_method_call): Make sure get_type_value returns * call.c (build_method_call): Make sure get_type_value returns
something before we try to use its TYPE_MAIN_VARIANT. something before we try to use its TYPE_MAIN_VARIANT.
(build_scoped_method_call): Likewise.
1998-05-27 Jason Merrill <jason@yorick.cygnus.com> 1998-05-27 Jason Merrill <jason@yorick.cygnus.com>
......
...@@ -389,13 +389,15 @@ build_scoped_method_call (exp, basetype, name, parms) ...@@ -389,13 +389,15 @@ build_scoped_method_call (exp, basetype, name, parms)
and template parms. */ and template parms. */
if (TREE_CODE (name) == BIT_NOT_EXPR && ! IS_AGGR_TYPE (basetype)) if (TREE_CODE (name) == BIT_NOT_EXPR && ! IS_AGGR_TYPE (basetype))
{ {
tree tmp;
if (TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (basetype)) if (TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (basetype))
cp_error ("type of `%E' does not match destructor type `%T' (type was `%T')", cp_error ("type of `%E' does not match destructor type `%T' (type was `%T')",
exp, basetype, type); exp, basetype, type);
name = TREE_OPERAND (name, 0); name = TREE_OPERAND (name, 0);
if (TYPE_MAIN_VARIANT (basetype) != name if (! (name == TYPE_MAIN_VARIANT (basetype)
&& (TYPE_MAIN_VARIANT (basetype) || ((tmp = get_type_value (name))
!= TYPE_MAIN_VARIANT (get_type_value (name)))) && (TYPE_MAIN_VARIANT (basetype)
== TYPE_MAIN_VARIANT (tmp)))))
cp_error ("qualified type `%T' does not match destructor name `~%T'", cp_error ("qualified type `%T' does not match destructor name `~%T'",
basetype, name); basetype, name);
return cp_convert (void_type_node, exp); return cp_convert (void_type_node, exp);
......
...@@ -6219,9 +6219,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) ...@@ -6219,9 +6219,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
|| CLASSTYPE_USE_TEMPLATE (context)) || CLASSTYPE_USE_TEMPLATE (context))
SET_DECL_TEMPLATE_SPECIALIZATION (decl); SET_DECL_TEMPLATE_SPECIALIZATION (decl);
/* Stupid stupid stupid stupid (jason 7/21/95) */ if (DECL_EXTERNAL (decl) && ! DECL_TEMPLATE_SPECIALIZATION (decl))
if (pedantic && DECL_EXTERNAL (decl)
&& ! DECL_TEMPLATE_SPECIALIZATION (decl))
cp_pedwarn ("declaration of `%#D' outside of class is not definition", cp_pedwarn ("declaration of `%#D' outside of class is not definition",
decl); decl);
...@@ -11815,9 +11813,13 @@ start_function (declspecs, declarator, attrs, pre_parsed_p) ...@@ -11815,9 +11813,13 @@ start_function (declspecs, declarator, attrs, pre_parsed_p)
&& ! DECL_FUNCTION_MEMBER_P (decl1)) && ! DECL_FUNCTION_MEMBER_P (decl1))
decl1 = pushdecl (decl1); decl1 = pushdecl (decl1);
else else
/* We need to set the DECL_CONTEXT. */ {
if (!DECL_CONTEXT (decl1) && DECL_TEMPLATE_INFO (decl1)) /* We need to set the DECL_CONTEXT. */
DECL_CONTEXT (decl1) = DECL_CONTEXT (DECL_TI_TEMPLATE (decl1)); if (!DECL_CONTEXT (decl1) && DECL_TEMPLATE_INFO (decl1))
DECL_CONTEXT (decl1) = DECL_CONTEXT (DECL_TI_TEMPLATE (decl1));
/* And make sure we have enough default args. */
check_default_args (decl1);
}
DECL_MAIN_VARIANT (decl1) = decl1; DECL_MAIN_VARIANT (decl1) = decl1;
fntype = TREE_TYPE (decl1); fntype = TREE_TYPE (decl1);
} }
......
...@@ -1755,7 +1755,6 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist) ...@@ -1755,7 +1755,6 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
} }
if (TREE_CODE (value) == FUNCTION_DECL) if (TREE_CODE (value) == FUNCTION_DECL)
{ {
check_default_args (value);
if (asmspec) if (asmspec)
{ {
/* This must override the asm specifier which was placed /* This must override the asm specifier which was placed
...@@ -4500,8 +4499,8 @@ check_default_args (x) ...@@ -4500,8 +4499,8 @@ check_default_args (x)
saw_def = 1; saw_def = 1;
else if (saw_def) else if (saw_def)
{ {
cp_error ("default argument missing for parameter %P of `%#D'", cp_error_at ("default argument missing for parameter %P of `%+#D'",
i, x); i, x);
break; break;
} }
} }
......
...@@ -1930,7 +1930,11 @@ do_pending_defargs () ...@@ -1930,7 +1930,11 @@ do_pending_defargs ()
} }
if (TREE_CODE (defarg_fn) == FUNCTION_DECL) if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
maybe_end_member_template_processing (defarg_fn); {
maybe_end_member_template_processing (defarg_fn);
check_default_args (defarg_fn);
}
poplevel (0, 0, 0); poplevel (0, 0, 0);
pop_nested_class (1); pop_nested_class (1);
} }
......
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