OSDN Git Service

* decl.c (struct binding_level): Add eh_region field.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 9 Aug 1999 08:53:52 +0000 (08:53 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 9 Aug 1999 08:53:52 +0000 (08:53 +0000)
(push_binding_level): Set it.
(define_label): Complain about jumping into an EH block.

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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/typeck.c

index 41037ae..963b9c6 100644 (file)
@@ -1,10 +1,12 @@
 1999-08-08  Jason Merrill  <jason@yorick.cygnus.com>
 
+       * decl.c (struct binding_level): Add eh_region field.
+       (push_binding_level): Set it.
+       (define_label): Complain about jumping into an EH block.
+
        * ptree.c (print_lang_type): Print the real type of a PMF.
        Print what exceptions a fn type throws.
 
-       * typeck.c (common_type): Use same_type_p.
-
 1999-08-07  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * class.c (count_fields, add_fields_to_vec): Add static prototype.
index 27f915c..93f66b2 100644 (file)
@@ -639,7 +639,10 @@ struct binding_level
        worry about ambiguous (ARM or ANSI) scope rules.  */
     unsigned is_for_scope : 1;
 
-    /* Two bits left for this word.  */
+    /* True if this level corresponds to an EH region, as for a try block.  */
+    unsigned eh_region : 1;
+
+    /* One bit left for this word.  */
 
 #if defined(DEBUG_CP_BINDING_LEVELS)
     /* Binding depth at which this level began.  */
@@ -703,6 +706,12 @@ push_binding_level (newlevel, tag_transparent, keep)
   current_binding_level = newlevel;
   newlevel->tag_transparent = tag_transparent;
   newlevel->more_cleanups_ok = 1;
+
+  /* We are called before expand_start_bindings, but after
+     expand_eh_region_start for a try block; so we check this now,
+     before the EH block is covered up.  */
+  newlevel->eh_region = is_eh_region ();
+
   newlevel->keep = keep;
 #if defined(DEBUG_CP_BINDING_LEVELS)
   newlevel->binding_depth = binding_depth;
@@ -4868,6 +4877,7 @@ define_label (filename, line, name)
     {
       struct named_label_list *uses, *prev;
       int identified = 0;
+      int saw_eh = 0;
 
       /* Mark label as having been defined.  */
       DECL_INITIAL (decl) = error_mark_node;
@@ -4922,7 +4932,7 @@ define_label (filename, line, name)
                                   uses->lineno_o_goto, "  from here");
                              }
                            identified = 1;
-                       }
+                         }
 
                        if (problem)
                          cp_error_at ("  crosses initialization of `%#D'",
@@ -4935,6 +4945,19 @@ define_label (filename, line, name)
                  }
                if (b == uses->binding_level)
                  break;
+               if (b->eh_region && ! saw_eh)
+                 {
+                   if (! identified)
+                     {
+                       cp_error ("jump to label `%D'", decl);
+                       error_with_file_and_line
+                         (uses->filename_o_goto,
+                          uses->lineno_o_goto, "  from here");
+                       identified = 1;
+                     }
+                   error ("  enters exception handling block");
+                   saw_eh = 1;
+                 }
                b = b->level_chain;
              }
 
index 8724548..991234c 100644 (file)
@@ -699,7 +699,7 @@ common_type (t1, t2)
        tt1 = TYPE_MAIN_VARIANT (tt1);
        tt2 = TYPE_MAIN_VARIANT (tt2);
 
-       if (same_type_p (tt1, tt2))
+       if (tt1 == tt2)
          target = tt1;
        else if (b1)
          {