From: Marek Polacek Date: Mon, 16 Feb 2015 11:16:33 +0000 (+0000) Subject: re PR c/65066 (ICE: Segmentation fault with -Wformat=2) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3d5cb23da1ea830d33eea2a1a19912ee7dd63c45;p=gcc.git re PR c/65066 (ICE: Segmentation fault with -Wformat=2) PR c/65066 * c-format.c (check_format_types): Handle null param. * gcc.dg/pr65066.c: New test. From-SVN: r220732 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 804c1db9ba8..45261cd24e0 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2015-02-16 Marek Polacek + + PR c/65066 + * c-format.c (check_format_types): Handle null param. + 2015-02-13 Marek Polacek PR c/65040 diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index 2f49b2d2d5c..9d03ff03834 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -2492,6 +2492,7 @@ check_format_types (location_t loc, format_wanted_type *types) && TREE_CODE (cur_type) == INTEGER_TYPE && warn_format_signedness && TYPE_UNSIGNED (wanted_type) + && cur_param != NULL_TREE && TREE_CODE (cur_param) == NOP_EXPR) { tree t = TREE_TYPE (TREE_OPERAND (cur_param, 0)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 01dc0725688..edbb95d5618 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-16 Marek Polacek + + PR c/65066 + * gcc.dg/pr65066.c: New test. + 2015-02-16 Ilya Enkovich * gcc.dg/pr65002.C: Move ... diff --git a/gcc/testsuite/gcc.dg/pr65066.c b/gcc/testsuite/gcc.dg/pr65066.c new file mode 100644 index 00000000000..883a87d4131 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr65066.c @@ -0,0 +1,12 @@ +/* PR c/65066 */ +/* { dg-do compile } */ +/* { dg-options "-Wformat=2" } */ + +extern int sscanf (const char *restrict, const char *restrict, ...); +int *a; + +void +foo () +{ + sscanf (0, "0x%x #", a); /* { dg-warning "expects argument of type" } */ +}