call.c (convert_class_to_reference): Fix typos.

* call.c (convert_class_to_reference): Fix typos.
	(build_conditional_expr): Handle errors gracefully.
	* class.c (push_nested_class): Likewise.
	* cp-tree.h (VAR_FUNCTION_OR_PARM_DECL_CHECK): New macro.
	(DECL_THIS_EXTERN): Use it.
	(DECL_THIS_STATIC): Likewise.
	* cvt.c (convert_to_void): Handle errors gracefully.
	(build_expr_type_conversion): Likewise.
	* decl.c (maybe_push_decl): Likewise.
	(start_decl_1): Likewise.
	(require_complete_types_for_parms): Likewise.
	* parse.y (structsp): Likewise.
	(base_class): Likewise.
	* parse.c: Regenerated.
	* pt.c (finish_member_template_decl): Likewise.

From-SVN: r31363
This commit is contained in:
Mark Mitchell 2000-01-12 23:27:46 +00:00 committed by Mark Mitchell
parent 6e090c767a
commit 07c88314a3
10 changed files with 468 additions and 404 deletions

View File

@ -1,5 +1,22 @@
2000-01-12 Mark Mitchell <mark@codesourcery.com>
* call.c (convert_class_to_reference): Fix typos.
(build_conditional_expr): Handle errors gracefully.
* class.c (push_nested_class): Likewise.
* cp-tree.h (VAR_FUNCTION_OR_PARM_DECL_CHECK): New macro.
(DECL_THIS_EXTERN): Use it.
(DECL_THIS_STATIC): Likewise.
* cvt.c (convert_to_void): Handle errors gracefully.
(build_expr_type_conversion): Likewise.
* decl.c (maybe_push_decl): Likewise.
(start_decl_1): Likewise.
(require_complete_types_for_parms): Likewise.
* parse.y (structsp): Likewise.
(base_class): Likewise.
* parse.c: Regenerated.
* pt.c (finish_member_template_decl): Likewise.
* typeck.c (decay_conversion): Likewise.
* cp-tree.h (dfs_skip_vbases): New function.
(find_vbase_instance): Likewise.
* class.c (determine_primary_base): Allow a nearly empty base to

View File

@ -928,10 +928,10 @@ convert_class_to_reference (t, s, expr)
if (!cand)
return NULL_TREE;
conv = build_conv (IDENTITY_CONV, s, expr);
conv = build1 (IDENTITY_CONV, s, expr);
conv = build_conv (USER_CONV,
non_reference (TREE_TYPE (TREE_TYPE (cand->fn))),
expr);
conv);
TREE_OPERAND (conv, 1) = build_expr_ptr_wrapper (cand);
ICS_USER_FLAG (conv) = 1;
if (cand->viable == -1)
@ -2770,6 +2770,12 @@ build_conditional_expr (arg1, arg2, arg3)
arg1 = arg2 = save_expr (arg1);
}
/* [expr.cond]
The first expr ession is implicitly converted to bool (clause
_conv_). */
arg1 = cp_convert (boolean_type_node, arg1);
/* If something has already gone wrong, just pass that fact up the
tree. */
if (arg1 == error_mark_node
@ -2780,12 +2786,6 @@ build_conditional_expr (arg1, arg2, arg3)
|| TREE_TYPE (arg3) == error_mark_node)
return error_mark_node;
/* [expr.cond]
The first expr ession is implicitly converted to bool (clause
_conv_). */
arg1 = cp_convert (boolean_type_node, arg1);
/* Convert from reference types to ordinary types; no expressions
really have reference type in C++. */
arg2 = convert_from_reference (arg2);

View File

@ -5279,8 +5279,10 @@ push_nested_class (type, modify)
tree context;
/* A namespace might be passed in error cases, like A::B:C. */
if (type == NULL_TREE || type == error_mark_node || ! IS_AGGR_TYPE (type)
if (type == NULL_TREE
|| type == error_mark_node
|| TREE_CODE (type) == NAMESPACE_DECL
|| ! IS_AGGR_TYPE (type)
|| TREE_CODE (type) == TEMPLATE_TYPE_PARM
|| TREE_CODE (type) == TEMPLATE_TEMPLATE_PARM)
return;

View File

@ -140,6 +140,16 @@ Boston, MA 02111-1307, USA. */
__LINE__, __PRETTY_FUNCTION__); \
__t; })
#define VAR_FUNCTION_OR_PARM_DECL_CHECK(NODE) \
({ const tree __t = NODE; \
enum tree_code __c = TREE_CODE(__t); \
if (__c != VAR_DECL \
&& __c != FUNCTION_DECL \
&& __c != PARM_DECL) \
tree_check_failed (__t, VAR_DECL, __FILE__, \
__LINE__, __PRETTY_FUNCTION__); \
__t; })
#define VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK(NODE) \
({ const tree __t = NODE; \
enum tree_code __c = TREE_CODE(__t); \
@ -162,6 +172,7 @@ Boston, MA 02111-1307, USA. */
#else /* not ENABLE_TREE_CHECKING, or not gcc */
#define VAR_OR_FUNCTION_DECL_CHECK(NODE) NODE
#define VAR_FUNCTION_OR_PARM_DECL_CHECK(NODE) NODE
#define VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK(NODE) NODE
#define RECORD_OR_UNION_TYPE_CHECK(NODE) NODE
@ -2380,14 +2391,16 @@ extern int flag_new_for_scope;
#define PTRMEM_CST_MEMBER(NODE) (((ptrmem_cst_t)PTRMEM_CST_CHECK (NODE))->member)
/* Nonzero for VAR_DECL and FUNCTION_DECL node means that `extern' was
specified in its declaration. */
specified in its declaration. This can also be set for an
erroneously declared PARM_DECL. */
#define DECL_THIS_EXTERN(NODE) \
DECL_LANG_FLAG_2 (VAR_OR_FUNCTION_DECL_CHECK (NODE))
DECL_LANG_FLAG_2 (VAR_FUNCTION_OR_PARM_DECL_CHECK (NODE))
/* Nonzero for VAR_DECL and FUNCTION_DECL node means that `static' was
specified in its declaration. */
specified in its declaration. This can also be set for an
erroneously declared PARM_DECL. */
#define DECL_THIS_STATIC(NODE) \
DECL_LANG_FLAG_6 (VAR_OR_FUNCTION_DECL_CHECK (NODE))
DECL_LANG_FLAG_6 (VAR_FUNCTION_OR_PARM_DECL_CHECK (NODE))
/* Nonzero in FUNCTION_DECL means it is really an operator.
Just used to communicate formatting information to dbxout.c. */

View File

@ -1,5 +1,5 @@
/* Language-level data type conversion for GNU C++.
Copyright (C) 1987-1988, 1992-1999 Free Software Foundation, Inc.
Copyright (C) 1987-1988, 1992-2000 Free Software Foundation, Inc.
Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
@ -851,8 +851,9 @@ convert_to_void (expr, implicit)
tree expr;
const char *implicit;
{
if (expr == error_mark_node)
return expr;
if (expr == error_mark_node
|| TREE_TYPE (expr) == error_mark_node)
return error_mark_node;
if (!TREE_TYPE (expr))
return expr;
if (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (expr)), void_type_node))
@ -1092,6 +1093,9 @@ build_expr_type_conversion (desires, expr, complain)
expr = convert_from_reference (expr);
basetype = TREE_TYPE (expr);
if (basetype == error_mark_node)
return error_mark_node;
if (! IS_AGGR_TYPE (basetype))
switch (TREE_CODE (basetype))
{

View File

@ -1,5 +1,5 @@
/* Process declarations and variables for C compiler.
Copyright (C) 1988, 92-98, 1999 Free Software Foundation, Inc.
Copyright (C) 1988, 92-98, 1999, 2000 Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
@ -4169,11 +4169,12 @@ maybe_push_decl (decl)
/* Add this decl to the current binding level, but not if it comes
from another scope, e.g. a static member variable. TEM may equal
DECL or it may be a previous decl of the same name. */
if ((TREE_CODE (decl) != PARM_DECL
&& DECL_CONTEXT (decl) != NULL_TREE
/* Definitions of namespace members outside their namespace are
possible. */
&& TREE_CODE (DECL_CONTEXT (decl)) != NAMESPACE_DECL)
if (decl == error_mark_node
|| (TREE_CODE (decl) != PARM_DECL
&& DECL_CONTEXT (decl) != NULL_TREE
/* Definitions of namespace members outside their namespace are
possible. */
&& TREE_CODE (DECL_CONTEXT (decl)) != NAMESPACE_DECL)
|| (TREE_CODE (decl) == TEMPLATE_DECL && !namespace_bindings_p ())
|| TREE_CODE (type) == UNKNOWN_TYPE
/* The declaration of a template specialization does not affect
@ -6871,7 +6872,9 @@ start_decl_1 (decl)
if (!initialized
&& TREE_CODE (decl) != TYPE_DECL
&& TREE_CODE (decl) != TEMPLATE_DECL
&& IS_AGGR_TYPE (type) && ! DECL_EXTERNAL (decl))
&& type != error_mark_node
&& IS_AGGR_TYPE (type)
&& ! DECL_EXTERNAL (decl))
{
if ((! processing_template_decl || ! uses_template_parms (type))
&& TYPE_SIZE (complete_type (type)) == NULL_TREE)
@ -11309,10 +11312,17 @@ static void
require_complete_types_for_parms (parms)
tree parms;
{
while (parms)
for (; parms; parms = TREE_CHAIN (parms))
{
tree type = TREE_TYPE (parms);
if (TYPE_SIZE (complete_type (type)) == NULL_TREE)
/* Try to complete the TYPE. */
type = complete_type (type);
if (type == error_mark_node)
continue;
if (TYPE_SIZE (type) == NULL_TREE)
{
if (DECL_NAME (parms))
error ("parameter `%s' has incomplete type",
@ -11323,8 +11333,6 @@ require_complete_types_for_parms (parms)
}
else
layout_decl (parms, 0);
parms = TREE_CHAIN (parms);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* YACC parser for C++ syntax.
Copyright (C) 1988, 89, 93-98, 1999 Free Software Foundation, Inc.
Copyright (C) 1988, 89, 93-98, 1999, 2000 Free Software Foundation, Inc.
Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
@ -2124,7 +2124,9 @@ structsp:
{
$$.t = $1.t;
/* struct B: public A; is not accepted by the WP grammar. */
if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
if (CLASS_TYPE_P ($$.t)
&& TYPE_BINFO_BASETYPES ($$.t)
&& !TYPE_SIZE ($$.t)
&& ! TYPE_BEING_DEFINED ($$.t))
cp_error ("base clause without member specification for `%#T'",
$$.t);
@ -2298,7 +2300,12 @@ base_class:
base_class.1:
typename_sub
{ if ($$ != error_mark_node) $$ = TYPE_MAIN_DECL ($1); }
{ if ($$ == error_mark_node)
;
else if (!TYPE_P ($$))
$$ = error_mark_node;
else
$$ = TYPE_MAIN_DECL ($1); }
| nonnested_type
;

View File

@ -1,5 +1,5 @@
/* Handle parameterized types (templates) for GNU C++.
Copyright (C) 1992, 93-97, 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1992, 93-97, 1998, 1999, 2000 Free Software Foundation, Inc.
Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
Rewritten by Jason Merrill (jason@cygnus.com).
@ -197,6 +197,8 @@ finish_member_template_decl (decl)
}
return NULL_TREE;
}
else if (TREE_CODE (decl) == FIELD_DECL)
cp_error ("data member `%D' cannot be a member template", decl);
else if (DECL_TEMPLATE_INFO (decl))
{
if (!DECL_TEMPLATE_SPECIALIZATION (decl))
@ -6214,7 +6216,9 @@ tsubst (t, args, complain, in_decl)
if (pedantic)
pedwarn ("creating array with size zero");
}
else if (integer_zerop (max) || INT_CST_LT (max, integer_zero_node))
else if (integer_zerop (max)
|| (TREE_CODE (max) == INTEGER_CST
&& INT_CST_LT (max, integer_zero_node)))
{
/* [temp.deduct]

View File

@ -1705,6 +1705,9 @@ decay_conversion (exp)
code = TREE_CODE (type);
}
if (type == error_mark_node)
return error_mark_node;
/* Constants can be used directly unless they're not loadable. */
if (TREE_CODE (exp) == CONST_DECL)
exp = DECL_INITIAL (exp);