Commit 07c88314 by Mark Mitchell Committed by Mark Mitchell

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
parent 6e090c76
2000-01-12 Mark Mitchell <mark@codesourcery.com> 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. * cp-tree.h (dfs_skip_vbases): New function.
(find_vbase_instance): Likewise. (find_vbase_instance): Likewise.
* class.c (determine_primary_base): Allow a nearly empty base to * class.c (determine_primary_base): Allow a nearly empty base to
......
...@@ -928,10 +928,10 @@ convert_class_to_reference (t, s, expr) ...@@ -928,10 +928,10 @@ convert_class_to_reference (t, s, expr)
if (!cand) if (!cand)
return NULL_TREE; return NULL_TREE;
conv = build_conv (IDENTITY_CONV, s, expr); conv = build1 (IDENTITY_CONV, s, expr);
conv = build_conv (USER_CONV, conv = build_conv (USER_CONV,
non_reference (TREE_TYPE (TREE_TYPE (cand->fn))), non_reference (TREE_TYPE (TREE_TYPE (cand->fn))),
expr); conv);
TREE_OPERAND (conv, 1) = build_expr_ptr_wrapper (cand); TREE_OPERAND (conv, 1) = build_expr_ptr_wrapper (cand);
ICS_USER_FLAG (conv) = 1; ICS_USER_FLAG (conv) = 1;
if (cand->viable == -1) if (cand->viable == -1)
...@@ -2770,6 +2770,12 @@ build_conditional_expr (arg1, arg2, arg3) ...@@ -2770,6 +2770,12 @@ build_conditional_expr (arg1, arg2, arg3)
arg1 = arg2 = save_expr (arg1); 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 /* If something has already gone wrong, just pass that fact up the
tree. */ tree. */
if (arg1 == error_mark_node if (arg1 == error_mark_node
...@@ -2780,12 +2786,6 @@ build_conditional_expr (arg1, arg2, arg3) ...@@ -2780,12 +2786,6 @@ build_conditional_expr (arg1, arg2, arg3)
|| TREE_TYPE (arg3) == error_mark_node) || TREE_TYPE (arg3) == error_mark_node)
return 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 /* Convert from reference types to ordinary types; no expressions
really have reference type in C++. */ really have reference type in C++. */
arg2 = convert_from_reference (arg2); arg2 = convert_from_reference (arg2);
......
...@@ -5279,8 +5279,10 @@ push_nested_class (type, modify) ...@@ -5279,8 +5279,10 @@ push_nested_class (type, modify)
tree context; tree context;
/* A namespace might be passed in error cases, like A::B:C. */ /* 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 || TREE_CODE (type) == NAMESPACE_DECL
|| ! IS_AGGR_TYPE (type)
|| TREE_CODE (type) == TEMPLATE_TYPE_PARM || TREE_CODE (type) == TEMPLATE_TYPE_PARM
|| TREE_CODE (type) == TEMPLATE_TEMPLATE_PARM) || TREE_CODE (type) == TEMPLATE_TEMPLATE_PARM)
return; return;
......
...@@ -140,6 +140,16 @@ Boston, MA 02111-1307, USA. */ ...@@ -140,6 +140,16 @@ Boston, MA 02111-1307, USA. */
__LINE__, __PRETTY_FUNCTION__); \ __LINE__, __PRETTY_FUNCTION__); \
__t; }) __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) \ #define VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK(NODE) \
({ const tree __t = NODE; \ ({ const tree __t = NODE; \
enum tree_code __c = TREE_CODE(__t); \ enum tree_code __c = TREE_CODE(__t); \
...@@ -162,6 +172,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -162,6 +172,7 @@ Boston, MA 02111-1307, USA. */
#else /* not ENABLE_TREE_CHECKING, or not gcc */ #else /* not ENABLE_TREE_CHECKING, or not gcc */
#define VAR_OR_FUNCTION_DECL_CHECK(NODE) NODE #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 VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK(NODE) NODE
#define RECORD_OR_UNION_TYPE_CHECK(NODE) NODE #define RECORD_OR_UNION_TYPE_CHECK(NODE) NODE
...@@ -2380,14 +2391,16 @@ extern int flag_new_for_scope; ...@@ -2380,14 +2391,16 @@ extern int flag_new_for_scope;
#define PTRMEM_CST_MEMBER(NODE) (((ptrmem_cst_t)PTRMEM_CST_CHECK (NODE))->member) #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 /* 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) \ #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 /* 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) \ #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. /* Nonzero in FUNCTION_DECL means it is really an operator.
Just used to communicate formatting information to dbxout.c. */ Just used to communicate formatting information to dbxout.c. */
......
/* Language-level data type conversion for GNU C++. /* 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) Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -851,8 +851,9 @@ convert_to_void (expr, implicit) ...@@ -851,8 +851,9 @@ convert_to_void (expr, implicit)
tree expr; tree expr;
const char *implicit; const char *implicit;
{ {
if (expr == error_mark_node) if (expr == error_mark_node
return expr; || TREE_TYPE (expr) == error_mark_node)
return error_mark_node;
if (!TREE_TYPE (expr)) if (!TREE_TYPE (expr))
return expr; return expr;
if (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (expr)), void_type_node)) if (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (expr)), void_type_node))
...@@ -1092,6 +1093,9 @@ build_expr_type_conversion (desires, expr, complain) ...@@ -1092,6 +1093,9 @@ build_expr_type_conversion (desires, expr, complain)
expr = convert_from_reference (expr); expr = convert_from_reference (expr);
basetype = TREE_TYPE (expr); basetype = TREE_TYPE (expr);
if (basetype == error_mark_node)
return error_mark_node;
if (! IS_AGGR_TYPE (basetype)) if (! IS_AGGR_TYPE (basetype))
switch (TREE_CODE (basetype)) switch (TREE_CODE (basetype))
{ {
......
/* Process declarations and variables for C compiler. /* 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) Contributed by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -4169,11 +4169,12 @@ maybe_push_decl (decl) ...@@ -4169,11 +4169,12 @@ maybe_push_decl (decl)
/* Add this decl to the current binding level, but not if it comes /* 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 from another scope, e.g. a static member variable. TEM may equal
DECL or it may be a previous decl of the same name. */ DECL or it may be a previous decl of the same name. */
if ((TREE_CODE (decl) != PARM_DECL if (decl == error_mark_node
&& DECL_CONTEXT (decl) != NULL_TREE || (TREE_CODE (decl) != PARM_DECL
/* Definitions of namespace members outside their namespace are && DECL_CONTEXT (decl) != NULL_TREE
possible. */ /* Definitions of namespace members outside their namespace are
&& TREE_CODE (DECL_CONTEXT (decl)) != NAMESPACE_DECL) possible. */
&& TREE_CODE (DECL_CONTEXT (decl)) != NAMESPACE_DECL)
|| (TREE_CODE (decl) == TEMPLATE_DECL && !namespace_bindings_p ()) || (TREE_CODE (decl) == TEMPLATE_DECL && !namespace_bindings_p ())
|| TREE_CODE (type) == UNKNOWN_TYPE || TREE_CODE (type) == UNKNOWN_TYPE
/* The declaration of a template specialization does not affect /* The declaration of a template specialization does not affect
...@@ -6871,7 +6872,9 @@ start_decl_1 (decl) ...@@ -6871,7 +6872,9 @@ start_decl_1 (decl)
if (!initialized if (!initialized
&& TREE_CODE (decl) != TYPE_DECL && TREE_CODE (decl) != TYPE_DECL
&& TREE_CODE (decl) != TEMPLATE_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)) if ((! processing_template_decl || ! uses_template_parms (type))
&& TYPE_SIZE (complete_type (type)) == NULL_TREE) && TYPE_SIZE (complete_type (type)) == NULL_TREE)
...@@ -11309,10 +11312,17 @@ static void ...@@ -11309,10 +11312,17 @@ static void
require_complete_types_for_parms (parms) require_complete_types_for_parms (parms)
tree parms; tree parms;
{ {
while (parms) for (; parms; parms = TREE_CHAIN (parms))
{ {
tree type = TREE_TYPE (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)) if (DECL_NAME (parms))
error ("parameter `%s' has incomplete type", error ("parameter `%s' has incomplete type",
...@@ -11323,8 +11333,6 @@ require_complete_types_for_parms (parms) ...@@ -11323,8 +11333,6 @@ require_complete_types_for_parms (parms)
} }
else else
layout_decl (parms, 0); layout_decl (parms, 0);
parms = TREE_CHAIN (parms);
} }
} }
......
/* YACC parser for C++ syntax. /* 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) Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -2124,7 +2124,9 @@ structsp: ...@@ -2124,7 +2124,9 @@ structsp:
{ {
$$.t = $1.t; $$.t = $1.t;
/* struct B: public A; is not accepted by the WP grammar. */ /* 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)) && ! TYPE_BEING_DEFINED ($$.t))
cp_error ("base clause without member specification for `%#T'", cp_error ("base clause without member specification for `%#T'",
$$.t); $$.t);
...@@ -2298,7 +2300,12 @@ base_class: ...@@ -2298,7 +2300,12 @@ base_class:
base_class.1: base_class.1:
typename_sub 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 | nonnested_type
; ;
......
/* Handle parameterized types (templates) for GNU C++. /* 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. Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
Rewritten by Jason Merrill (jason@cygnus.com). Rewritten by Jason Merrill (jason@cygnus.com).
...@@ -197,6 +197,8 @@ finish_member_template_decl (decl) ...@@ -197,6 +197,8 @@ finish_member_template_decl (decl)
} }
return NULL_TREE; 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)) else if (DECL_TEMPLATE_INFO (decl))
{ {
if (!DECL_TEMPLATE_SPECIALIZATION (decl)) if (!DECL_TEMPLATE_SPECIALIZATION (decl))
...@@ -6214,7 +6216,9 @@ tsubst (t, args, complain, in_decl) ...@@ -6214,7 +6216,9 @@ tsubst (t, args, complain, in_decl)
if (pedantic) if (pedantic)
pedwarn ("creating array with size zero"); 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] /* [temp.deduct]
......
...@@ -1705,6 +1705,9 @@ decay_conversion (exp) ...@@ -1705,6 +1705,9 @@ decay_conversion (exp)
code = TREE_CODE (type); code = TREE_CODE (type);
} }
if (type == error_mark_node)
return error_mark_node;
/* Constants can be used directly unless they're not loadable. */ /* Constants can be used directly unless they're not loadable. */
if (TREE_CODE (exp) == CONST_DECL) if (TREE_CODE (exp) == CONST_DECL)
exp = DECL_INITIAL (exp); exp = DECL_INITIAL (exp);
......
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