re PR c/70651 (ICE on invalid code on x86_64-linux-gnu in build_va_arg, at c-family...
authorMarek Polacek <polacek@redhat.com>
Fri, 15 Apr 2016 13:15:23 +0000 (13:15 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 15 Apr 2016 13:15:23 +0000 (13:15 +0000)
PR c/70651
* c-common.c (build_va_arg): Change two asserts into errors and return
error_mark_node.

* c-c++-common/pr70651.c: New test.

From-SVN: r235027

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr70651.c [new file with mode: 0644]

index f842efc8d4e39ed3c8279291e8417e00f675ae51..ec79edbaa931788b1e7999e8ff430c5fa6278e82 100644 (file)
@@ -1,3 +1,9 @@
+2016-04-15  Marek Polacek  <polacek@redhat.com>
+
+       PR c/70651
+       * c-common.c (build_va_arg): Change two asserts into errors and return
+       error_mark_node.
+
 2016-04-13  Marek Polacek  <polacek@redhat.com>
 
        PR c++/70639
index 30c815d5381cbfaba05933bb47ad7ed225ddff07..f2846bb26e7ce77d6a80e25ca7ae670c7e6eddaa 100644 (file)
@@ -5725,7 +5725,12 @@ build_va_arg (location_t loc, tree expr, tree type)
       /* Verify that &ap is still recognized as having va_list type.  */
       tree canon_expr_type
        = targetm.canonical_va_list_type (TREE_TYPE (expr));
-      gcc_assert (canon_expr_type != NULL_TREE);
+      if (canon_expr_type == NULL_TREE)
+       {
+         error_at (loc,
+                   "first argument to %<va_arg%> not of type %<va_list%>");
+         return error_mark_node;
+       }
 
       return build_va_arg_1 (loc, type, expr);
     }
@@ -5793,7 +5798,12 @@ build_va_arg (location_t loc, tree expr, tree type)
       /* Verify that &ap is still recognized as having va_list type.  */
       tree canon_expr_type
        = targetm.canonical_va_list_type (TREE_TYPE (expr));
-      gcc_assert (canon_expr_type != NULL_TREE);
+      if (canon_expr_type == NULL_TREE)
+       {
+         error_at (loc,
+                   "first argument to %<va_arg%> not of type %<va_list%>");
+         return error_mark_node;
+       }
     }
   else
     {
index 8eb124fa9c0f6fe53ab2886391389f2da442f6c9..9b395d93e9a284392c9f8c19ae37eda5661bd5f3 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-15  Marek Polacek  <polacek@redhat.com>
+
+       PR c/70651
+       * c-c++-common/pr70651.c: New test.
+
 2016-04-15  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        PR rtl-optimization/70681
diff --git a/gcc/testsuite/c-c++-common/pr70651.c b/gcc/testsuite/c-c++-common/pr70651.c
new file mode 100644 (file)
index 0000000..a91a2d8
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR c/70651 */
+/* { dg-do compile } */
+/* { dg-prune-output "\[^\n\r\]*first argument to .va_arg. not of type .va_list.\[^\n\r\]*" } */
+
+void fn1 ()
+{
+  char **a = 0;
+  __builtin_va_arg (a, char **);
+}