From: mpolacek Date: Fri, 15 Apr 2016 13:15:23 +0000 (+0000) Subject: PR c/70651 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=926f9422390be1e7f91bce9a23f39e246aad4907;p=thirdparty%2Fgcc.git 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235027 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index f842efc8d4e3..ec79edbaa931 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2016-04-15 Marek Polacek + + PR c/70651 + * c-common.c (build_va_arg): Change two asserts into errors and return + error_mark_node. + 2016-04-13 Marek Polacek PR c++/70639 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 30c815d5381c..f2846bb26e7c 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -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 % not of type %"); + 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 % not of type %"); + return error_mark_node; + } } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8eb124fa9c0f..9b395d93e9a2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-04-15 Marek Polacek + + PR c/70651 + * c-c++-common/pr70651.c: New test. + 2016-04-15 Kyrylo Tkachov 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 index 000000000000..a91a2d8fc884 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr70651.c @@ -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 **); +}