re PR c/65066 (ICE: Segmentation fault with -Wformat=2)
authorMarek Polacek <polacek@redhat.com>
Mon, 16 Feb 2015 11:16:33 +0000 (11:16 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 16 Feb 2015 11:16:33 +0000 (11:16 +0000)
PR c/65066
* c-format.c (check_format_types): Handle null param.

* gcc.dg/pr65066.c: New test.

From-SVN: r220732

gcc/c-family/ChangeLog
gcc/c-family/c-format.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr65066.c [new file with mode: 0644]

index 804c1db9ba80eeac956f5da773dcf7c943b3d4b4..45261cd24e04a04af5a44b9716e704d627ee19cc 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-16  Marek Polacek  <polacek@redhat.com>
+
+       PR c/65066
+       * c-format.c (check_format_types): Handle null param.
+
 2015-02-13  Marek Polacek  <polacek@redhat.com>
 
        PR c/65040
index 2f49b2d2d5c2b06a711537c12685c287d122e931..9d03ff03834df7517cbfaed4cbcf932474193724 100644 (file)
@@ -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));
index 01dc072568895d9ca55bd2e87f83a67db81ffbe8..edbb95d56187de866207b588da7ab9723ca23f86 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-16  Marek Polacek  <polacek@redhat.com>
+
+       PR c/65066
+       * gcc.dg/pr65066.c: New test.
+
 2015-02-16  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        * 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 (file)
index 0000000..883a87d
--- /dev/null
@@ -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" } */
+}