OSDN Git Service

* Make-lang.in (parse.c): Adjust expected number of
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Jan 2002 03:27:30 +0000 (03:27 +0000)
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Jan 2002 03:27:30 +0000 (03:27 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49163 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/Make-lang.in
gcc/cp/decl.c
gcc/cp/lex.c
gcc/cp/method.c
gcc/cp/parse.y
gcc/cp/semantics.c

index 2b9bef5..3ea4070 100644 (file)
@@ -1,5 +1,27 @@
 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.
        * cp-tree.h (friendly_abort): Don't prototype.
        (my_friendly_assert): Use fancy_abort.
index d848e3a..3b14ab1 100644 (file)
@@ -120,7 +120,7 @@ $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
 
 $(srcdir)/cp/parse.h: $(srcdir)/cp/parse.c
 $(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 ; \
        grep '^#define[         ]*YYEMPTY' p$$$$.c >> p$$$$.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 \
   c-common.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) \
-  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) \
   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) \
index 3521113..0bb5dfd 100644 (file)
@@ -46,6 +46,7 @@ Boston, MA 02111-1307, USA.  */
 #include "tm_p.h"
 #include "target.h"
 #include "c-common.h"
+#include "diagnostic.h"
 
 extern const struct attribute_spec *lang_attribute_table;
 
@@ -10144,7 +10145,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
         common.  With no options, it is allowed.  With -Wreturn-type,
         it is a warning.  It is only an error with -pedantic-errors.  */
       is_main = (funcdef_flag
-                && MAIN_NAME_P (dname)
+                && dname && MAIN_NAME_P (dname)
                 && ctype == NULL_TREE
                 && in_namespace == NULL_TREE
                 && current_namespace == global_namespace);
@@ -14163,8 +14164,28 @@ finish_function (flags)
   /* This must come after expand_function_end because cleanups might
      have declarations (from inline functions) that need to go into
      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)
-    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);
 
   /* Set up the named return value optimization, if we can.  Here, we
index b30c817..0287f70 100644 (file)
@@ -1026,7 +1026,7 @@ note_list_got_semicolon (declspecs)
   for (link = declspecs; link; link = TREE_CHAIN (link))
     {
       tree type = TREE_VALUE (link);
-      if (TYPE_P (type))
+      if (type && TYPE_P (type))
        note_got_semicolon (type);
     }
   clear_anon_tags ();
index 0848bd3..b0cc63a 100644 (file)
@@ -145,38 +145,7 @@ hack_identifier (value, name)
   tree type;
 
   if (value == 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;
-    }
+    return error_mark_node;
 
   type = TREE_TYPE (value);
   if (TREE_CODE (value) == FIELD_DECL)
index f6dba7e..83a1cd0 100644 (file)
@@ -1650,7 +1650,7 @@ primary:
        | TYPEID '(' type_id ')'
                { tree type = groktypename ($3.t);
                  check_for_new_type ("typeid", $3);
-                 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
+                 $$ = get_typeid (type); }
        | global_scope IDENTIFIER
                { $$ = do_scoped_id ($2, 1); }
        | global_scope template_id
@@ -3505,6 +3505,15 @@ try_block:
 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:
@@ -3809,6 +3818,8 @@ ansi_raise_identifier:
                  check_for_new_type ("exception specifier", $1);
                  $$ = groktypename ($1.t);
                }
+         | error
+               { $$ = error_mark_node; }
        ;
 
 ansi_raise_identifiers:
index 1f8d481..37729bf 100644 (file)
@@ -1669,6 +1669,9 @@ tree
 begin_class_definition (t)
      tree t;
 {
+  if (t == error_mark_node)
+    return error_mark_node;
+
   /* Check the bases are accessible. */
   decl_type_access_control (TYPE_NAME (t));
   reset_type_access_control ();
@@ -1878,6 +1881,9 @@ finish_class_definition (t, attributes, semi, pop_scope_p)
      int semi;
      int pop_scope_p;
 {
+  if (t == error_mark_node)
+    return error_mark_node;
+
   /* finish_struct nukes this anyway; if finish_exception does too,
      then it can go.  */
   if (semi)