]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
except.c (is_admissible_throw_operand_or_catch_parameter): Check variably_modified_ty...
authorJason Merrill <jason@redhat.com>
Thu, 9 May 2013 03:58:07 +0000 (23:58 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 9 May 2013 03:58:07 +0000 (23:58 -0400)
* except.c (is_admissible_throw_operand_or_catch_parameter): Check
variably_modified_type_p.
(expand_start_catch_block): Mark the typeinfo used here.
* semantics.c (finish_handler_parms): Not here.

* error.c (dump_type_suffix): Try harder on VLA length.

From-SVN: r198732

gcc/cp/ChangeLog
gcc/cp/error.c
gcc/cp/except.c
gcc/cp/semantics.c
gcc/testsuite/g++.dg/ext/vla4.C

index c2ce5d93087014edbcd6b60e5c58d7736b6b8b47..7a1484fa43f253b04ae507de1b67d7c64c3944fb 100644 (file)
@@ -1,5 +1,12 @@
 2013-05-08  Jason Merrill  <jason@redhat.com>
 
+       * except.c (is_admissible_throw_operand_or_catch_parameter): Check
+       variably_modified_type_p.
+       (expand_start_catch_block): Mark the typeinfo used here.
+       * semantics.c (finish_handler_parms): Not here.
+
+       * error.c (dump_type_suffix): Try harder on VLA length.
+
        Core 624/N2932
        * init.c (throw_bad_array_new_length): New.
        (build_new_1): Use it.  Don't warn about braced-init-list.
index bd463eaa80f2291302d511afd7867800ffdd0191..a75fc4e7b33b9dd20aa6e0ab97f2e188235e94c0 100644 (file)
@@ -848,14 +848,24 @@ dump_type_suffix (tree t, int flags)
            pp_character (cxx_pp, '0');
          else if (host_integerp (max, 0))
            pp_wide_integer (cxx_pp, tree_low_cst (max, 0) + 1);
-         else if (TREE_CODE (max) == MINUS_EXPR)
-           dump_expr (TREE_OPERAND (max, 0),
-                      flags & ~TFF_EXPR_IN_PARENS);
          else
-           dump_expr (fold_build2_loc (input_location,
-                                   PLUS_EXPR, dtype, max,
-                                   build_int_cst (dtype, 1)),
-                      flags & ~TFF_EXPR_IN_PARENS);
+           {
+             STRIP_NOPS (max);
+             if (TREE_CODE (max) == SAVE_EXPR)
+               max = TREE_OPERAND (max, 0);
+             if (TREE_CODE (max) == MINUS_EXPR
+                 || TREE_CODE (max) == PLUS_EXPR)
+               {
+                 max = TREE_OPERAND (max, 0);
+                 while (CONVERT_EXPR_P (max))
+                   max = TREE_OPERAND (max, 0);
+               }
+             else
+               max = fold_build2_loc (input_location,
+                                      PLUS_EXPR, dtype, max,
+                                      build_int_cst (dtype, 1));
+             dump_expr (max, flags & ~TFF_EXPR_IN_PARENS);
+           }
        }
       pp_cxx_right_bracket (cxx_pp);
       dump_type_suffix (TREE_TYPE (t), flags);
index b762a51c67a02796cf0c4068ae0afba15f6aa59d..be003d2994bf0af23c14ef0104dc48be558a23ba 100644 (file)
@@ -490,6 +490,7 @@ expand_start_catch_block (tree decl)
        decl = error_mark_node;
 
       type = prepare_eh_type (TREE_TYPE (decl));
+      mark_used (eh_type_info (type));
     }
   else
     type = NULL_TREE;
@@ -982,6 +983,16 @@ is_admissible_throw_operand_or_catch_parameter (tree t, bool is_throw)
             "reference type %qT", type);
       return false;
     }
+  else if (variably_modified_type_p (type, NULL_TREE))
+    {
+      if (is_throw)
+       error ("cannot throw expression of type %qT because it involves "
+              "types of variable size", type);
+      else
+       error ("cannot catch type %qT because it involves types of "
+              "variable size", type);
+      return false;
+    }
 
   return true;
 }
index a06a23a13ac71c7176f5fc54ece4fd10cfdc7a10..2165649313d4f6c143a8e390a7dbf3790f2dee5a 100644 (file)
@@ -1199,8 +1199,6 @@ finish_handler_parms (tree decl, tree handler)
   else
     type = expand_start_catch_block (decl);
   HANDLER_TYPE (handler) = type;
-  if (!processing_template_decl && type)
-    mark_used (eh_type_info (type));
 }
 
 /* Finish a handler, which may be given by HANDLER.  The BLOCKs are
index ecec908074d55f725d33743bf345753e70921d3f..90e4160679a9cd102efe27aaa567bec9a92952fb 100644 (file)
@@ -6,7 +6,7 @@
 void f(int i) {
   try {
     int a[i];
-    throw &a; // { dg-error "variable size" }
+    throw &a; // { dg-error "int \\(\\*\\)\\\[i\\\]" }
   } catch (int (*)[i]) { // { dg-error "variable size" }
   }
 }