diff options
author | Tom de Vries <tom@codesourcery.com> | 2016-08-29 16:41:33 +0000 |
---|---|---|
committer | Tom de Vries <vries@gcc.gnu.org> | 2016-08-29 16:41:33 +0000 |
commit | ba9bbd6f584afe2939c44c159cbb1c064becad5c (patch) | |
tree | bb66752a765b5b993a5ede281a590b42667c2c1d /gcc/c-family | |
parent | 6c77dacd1cc70db30c4505966a7a636b78e292dd (diff) | |
download | gcc-ba9bbd6f584afe2939c44c159cbb1c064becad5c.zip gcc-ba9bbd6f584afe2939c44c159cbb1c064becad5c.tar.gz gcc-ba9bbd6f584afe2939c44c159cbb1c064becad5c.tar.bz2 |
Handle errors in both args of va_arg
2016-08-29 Tom de Vries <tom@codesourcery.com>
PR c/77398
* c-common.c (build_va_arg): Add first argument error. Build va_arg
with error_mark_node as va_list instead of with illegal va_list.
* gimplify.c (gimplify_va_arg_expr): Replace first argument type error
with assert.
* g++.dg/ext/va-arg1.C: Add error check for illegal first argument.
From-SVN: r239827
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index f8a7425..b6876d4 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2016-08-29 Tom de Vries <tom@codesourcery.com> + + PR c/77398 + * c-common.c (build_va_arg): Add first argument error. Build va_arg + with error_mark_node as va_list instead of with illegal va_list. + 2016-08-25 Marek Polacek <polacek@redhat.com> David Malcolm <dmalcolm@redhat.com> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 001070d..eef8674 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -5806,16 +5806,19 @@ build_va_arg (location_t loc, tree expr, tree type) { tree va_type = TREE_TYPE (expr); tree canon_va_type = (va_type == error_mark_node - ? NULL_TREE + ? error_mark_node : targetm.canonical_va_list_type (va_type)); if (va_type == error_mark_node || canon_va_type == NULL_TREE) { + if (canon_va_type == NULL_TREE) + error_at (loc, "first argument to %<va_arg%> not of type %<va_list%>"); + /* Let's handle things neutrallly, if expr: - has undeclared type, or - is not an va_list type. */ - return build_va_arg_1 (loc, type, expr); + return build_va_arg_1 (loc, type, error_mark_node); } if (TREE_CODE (canon_va_type) != ARRAY_TYPE) |