Commit 7437519c by Zack Weinberg Committed by Zack Weinberg

Make-lang.in (parse.c): Adjust expected number of shift-reduce conflicts.

	* Make-lang.in (parse.c): Adjust expected number of
	shift-reduce conflicts.
	(decl.o): Depend on diagnostic.h.
	* decl.c: Include diagnostic.h.
	(grokdeclarator): Check for null pointer.
	(finish_function): Don't abort when
	current_binding_level->parm_flag != 1, if errors have
	occurred; throw away the statement tree and extra binding
	levels, and continue.
	* lex.c (note_list_got_semicolon): Check for null pointer.
	* method.c (hack_identifier): Just return error_mark_node if
	value is error_mark_node.
	* parse.y (primary: TYPEID(type_id)): No need to use
	TYPE_MAIN_VARIANT here.
	(handler_seq): Accept an empty list of catch clauses and
	generate a fake handler block to avoid later crashes.
	(ansi_raise_identifier): Accept the error token too.
	* semantics.c (begin_class_definition,
	finish_class_definition): Check for error_mark_node.

From-SVN: r49163
parent 709619d9
2002-01-23 Zack Weinberg <zack@codesourcery.com> 2002-01-23 Zack Weinberg <zack@codesourcery.com>
* Make-lang.in (parse.c): Adjust expected number of
shift-reduce conflicts.
(decl.o): Depend on diagnostic.h.
* decl.c: Include diagnostic.h.
(grokdeclarator): Check for null pointer.
(finish_function): Don't abort when
current_binding_level->parm_flag != 1, if errors have
occurred; throw away the statement tree and extra binding
levels, and continue.
* lex.c (note_list_got_semicolon): Check for null pointer.
* method.c (hack_identifier): Just return error_mark_node if
value is error_mark_node.
* parse.y (primary: TYPEID(type_id)): No need to use
TYPE_MAIN_VARIANT here.
(handler_seq): Accept an empty list of catch clauses and
generate a fake handler block to avoid later crashes.
(ansi_raise_identifier): Accept the error token too.
* semantics.c (begin_class_definition,
finish_class_definition): Check for error_mark_node.
2002-01-23 Zack Weinberg <zack@codesourcery.com>
* typeck2.c (friendly_abort): Delete definition. * typeck2.c (friendly_abort): Delete definition.
* cp-tree.h (friendly_abort): Don't prototype. * cp-tree.h (friendly_abort): Don't prototype.
(my_friendly_assert): Use fancy_abort. (my_friendly_assert): Use fancy_abort.
......
...@@ -120,7 +120,7 @@ $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf ...@@ -120,7 +120,7 @@ $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
$(srcdir)/cp/parse.h: $(srcdir)/cp/parse.c $(srcdir)/cp/parse.h: $(srcdir)/cp/parse.c
$(srcdir)/cp/parse.c: $(srcdir)/cp/parse.y $(srcdir)/cp/parse.c: $(srcdir)/cp/parse.y
@echo "Expect 34 shift/reduce conflicts and 58 reduce/reduce conflicts." @echo "Expect 36 shift/reduce conflicts and 58 reduce/reduce conflicts."
cd $(srcdir)/cp; $(BISON) $(BISONFLAGS) -d -o p$$$$.c parse.y ; \ cd $(srcdir)/cp; $(BISON) $(BISONFLAGS) -d -o p$$$$.c parse.y ; \
grep '^#define[ ]*YYEMPTY' p$$$$.c >> p$$$$.h ; \ grep '^#define[ ]*YYEMPTY' p$$$$.c >> p$$$$.h ; \
mv -f p$$$$.c parse.c ; mv -f p$$$$.h parse.h mv -f p$$$$.c parse.c ; mv -f p$$$$.h parse.h
...@@ -249,7 +249,7 @@ cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) toplev.h langhooks.h langhooks-def.h \ ...@@ -249,7 +249,7 @@ cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) toplev.h langhooks.h langhooks-def.h \
c-common.h c-common.h
cp/decl.o: cp/decl.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h stack.h \ cp/decl.o: cp/decl.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h stack.h \
output.h $(EXPR_H) except.h toplev.h hash.h $(GGC_H) $(RTL_H) \ output.h $(EXPR_H) except.h toplev.h hash.h $(GGC_H) $(RTL_H) \
cp/operators.def $(TM_P_H) tree-inline.h cp/operators.def $(TM_P_H) tree-inline.h diagnostic.h
cp/decl2.o: cp/decl2.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h $(EXPR_H) \ cp/decl2.o: cp/decl2.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h $(EXPR_H) \
output.h except.h toplev.h $(GGC_H) $(RTL_H) output.h except.h toplev.h $(GGC_H) $(RTL_H)
cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) flags.h toplev.h output.h $(TM_P_H) \ cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) flags.h toplev.h output.h $(TM_P_H) \
......
...@@ -46,6 +46,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -46,6 +46,7 @@ Boston, MA 02111-1307, USA. */
#include "tm_p.h" #include "tm_p.h"
#include "target.h" #include "target.h"
#include "c-common.h" #include "c-common.h"
#include "diagnostic.h"
extern const struct attribute_spec *lang_attribute_table; extern const struct attribute_spec *lang_attribute_table;
...@@ -10144,7 +10145,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -10144,7 +10145,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
common. With no options, it is allowed. With -Wreturn-type, common. With no options, it is allowed. With -Wreturn-type,
it is a warning. It is only an error with -pedantic-errors. */ it is a warning. It is only an error with -pedantic-errors. */
is_main = (funcdef_flag is_main = (funcdef_flag
&& MAIN_NAME_P (dname) && dname && MAIN_NAME_P (dname)
&& ctype == NULL_TREE && ctype == NULL_TREE
&& in_namespace == NULL_TREE && in_namespace == NULL_TREE
&& current_namespace == global_namespace); && current_namespace == global_namespace);
...@@ -14163,8 +14164,28 @@ finish_function (flags) ...@@ -14163,8 +14164,28 @@ finish_function (flags)
/* This must come after expand_function_end because cleanups might /* This must come after expand_function_end because cleanups might
have declarations (from inline functions) that need to go into have declarations (from inline functions) that need to go into
this function's blocks. */ this function's blocks. */
/* If the current binding level isn't the outermost binding level
for this function, either there is a bug, or we have experienced
syntax errors and the statement tree is malformed. */
if (current_binding_level->parm_flag != 1) if (current_binding_level->parm_flag != 1)
abort (); {
/* Make sure we have already experienced errors. */
if (errorcount == 0)
abort ();
/* Throw away the broken statement tree and extra binding
levels. */
DECL_SAVED_TREE (fndecl) = build_stmt (COMPOUND_STMT, NULL_TREE);
while (current_binding_level->parm_flag != 1)
{
if (current_binding_level->parm_flag == 2)
pop_nested_class ();
else
poplevel (0, 0, 0);
}
}
poplevel (1, 0, 1); poplevel (1, 0, 1);
/* Set up the named return value optimization, if we can. Here, we /* Set up the named return value optimization, if we can. Here, we
......
...@@ -1026,7 +1026,7 @@ note_list_got_semicolon (declspecs) ...@@ -1026,7 +1026,7 @@ note_list_got_semicolon (declspecs)
for (link = declspecs; link; link = TREE_CHAIN (link)) for (link = declspecs; link; link = TREE_CHAIN (link))
{ {
tree type = TREE_VALUE (link); tree type = TREE_VALUE (link);
if (TYPE_P (type)) if (type && TYPE_P (type))
note_got_semicolon (type); note_got_semicolon (type);
} }
clear_anon_tags (); clear_anon_tags ();
......
...@@ -145,38 +145,7 @@ hack_identifier (value, name) ...@@ -145,38 +145,7 @@ hack_identifier (value, name)
tree type; tree type;
if (value == error_mark_node) if (value == error_mark_node)
{ return error_mark_node;
if (current_class_name)
{
tree fields = lookup_fnfields (TYPE_BINFO (current_class_type),
name, 1);
if (fields == error_mark_node)
return error_mark_node;
if (fields)
{
tree fndecl;
fndecl = TREE_VALUE (fields);
my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 251);
/* I could not trigger this code. MvL */
abort ();
#ifdef DEAD
if (DECL_CHAIN (fndecl) == NULL_TREE)
{
warning ("methods cannot be converted to function pointers");
return fndecl;
}
else
{
error ("ambiguous request for method pointer `%s'",
IDENTIFIER_POINTER (name));
return error_mark_node;
}
#endif
}
}
return error_mark_node;
}
type = TREE_TYPE (value); type = TREE_TYPE (value);
if (TREE_CODE (value) == FIELD_DECL) if (TREE_CODE (value) == FIELD_DECL)
......
...@@ -1650,7 +1650,7 @@ primary: ...@@ -1650,7 +1650,7 @@ primary:
| TYPEID '(' type_id ')' | TYPEID '(' type_id ')'
{ tree type = groktypename ($3.t); { tree type = groktypename ($3.t);
check_for_new_type ("typeid", $3); check_for_new_type ("typeid", $3);
$$ = get_typeid (TYPE_MAIN_VARIANT (type)); } $$ = get_typeid (type); }
| global_scope IDENTIFIER | global_scope IDENTIFIER
{ $$ = do_scoped_id ($2, 1); } { $$ = do_scoped_id ($2, 1); }
| global_scope template_id | global_scope template_id
...@@ -3505,6 +3505,15 @@ try_block: ...@@ -3505,6 +3505,15 @@ try_block:
handler_seq: handler_seq:
handler handler
| handler_seq handler | handler_seq handler
| /* empty */
{ /* Generate a fake handler block to avoid later aborts. */
tree fake_handler = begin_handler ();
finish_handler_parms (NULL_TREE, fake_handler);
finish_handler (fake_handler);
$<ttype>$ = fake_handler;
error ("must have at least one catch per try block");
}
; ;
handler: handler:
...@@ -3809,6 +3818,8 @@ ansi_raise_identifier: ...@@ -3809,6 +3818,8 @@ ansi_raise_identifier:
check_for_new_type ("exception specifier", $1); check_for_new_type ("exception specifier", $1);
$$ = groktypename ($1.t); $$ = groktypename ($1.t);
} }
| error
{ $$ = error_mark_node; }
; ;
ansi_raise_identifiers: ansi_raise_identifiers:
......
...@@ -1669,6 +1669,9 @@ tree ...@@ -1669,6 +1669,9 @@ tree
begin_class_definition (t) begin_class_definition (t)
tree t; tree t;
{ {
if (t == error_mark_node)
return error_mark_node;
/* Check the bases are accessible. */ /* Check the bases are accessible. */
decl_type_access_control (TYPE_NAME (t)); decl_type_access_control (TYPE_NAME (t));
reset_type_access_control (); reset_type_access_control ();
...@@ -1878,6 +1881,9 @@ finish_class_definition (t, attributes, semi, pop_scope_p) ...@@ -1878,6 +1881,9 @@ finish_class_definition (t, attributes, semi, pop_scope_p)
int semi; int semi;
int pop_scope_p; int pop_scope_p;
{ {
if (t == error_mark_node)
return error_mark_node;
/* finish_struct nukes this anyway; if finish_exception does too, /* finish_struct nukes this anyway; if finish_exception does too,
then it can go. */ then it can go. */
if (semi) if (semi)
......
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