diff options
author | Marek Polacek <polacek@redhat.com> | 2018-01-29 18:20:01 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2018-01-29 18:20:01 +0000 |
commit | 7d07a93a52153e7ccda52ce86847d2e365dc9f83 (patch) | |
tree | c6fcb0f17e591d1fc9a3dd3140db80b5098f1881 | |
parent | 7672aa9bc19e2444c3effa2f12274d60022f7d3c (diff) | |
download | gcc-7d07a93a52153e7ccda52ce86847d2e365dc9f83.zip gcc-7d07a93a52153e7ccda52ce86847d2e365dc9f83.tar.gz gcc-7d07a93a52153e7ccda52ce86847d2e365dc9f83.tar.bz2 |
re PR c/83966 (ICE in check_function_arguments at gcc/c-family/c-common.c:5617)
PR c/83966
* c-format.c (check_function_format): Check current_function_decl.
* gcc.dg/format/Wsuggest-attribute-1.c: New test.
From-SVN: r257159
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c-format.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/format/Wsuggest-attribute-1.c | 9 |
4 files changed, 22 insertions, 1 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 335eeeb..7a14288 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2018-01-29 Marek Polacek <polacek@redhat.com> + + PR c/83966 + * c-format.c (check_function_format): Check current_function_decl. + 2018-01-27 Jakub Jelinek <jakub@redhat.com> * c-cppbuiltin.c (c_cpp_builtins): Use ggc_strdup for the fp_suffix diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index 7a69d5a..3f4f83a 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -1110,7 +1110,9 @@ check_function_format (tree attrs, int nargs, tree *argarray, from the format attribute if the called function is decorated with it. Avoid using calls with string literal formats for guidance since those are unlikely to be viable candidates. */ - if (warn_suggest_attribute_format && info.first_arg_num == 0 + if (warn_suggest_attribute_format + && current_function_decl != NULL_TREE + && info.first_arg_num == 0 && (format_types[info.format_type].flags & (int) FMT_FLAG_ARG_CONVERT) /* c_strlen will fail for a function parameter but succeed diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 18e19af..3713a81 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-29 Marek Polacek <polacek@redhat.com> + + PR c/83966 + * gcc.dg/format/Wsuggest-attribute-1.c: New test. + 2018-01-29 Richard Biener <rguenther@suse.de> PR tree-optimization/84057 diff --git a/gcc/testsuite/gcc.dg/format/Wsuggest-attribute-1.c b/gcc/testsuite/gcc.dg/format/Wsuggest-attribute-1.c new file mode 100644 index 0000000..5b6fb05 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/Wsuggest-attribute-1.c @@ -0,0 +1,9 @@ +/* PR c/83966 */ +/* { dg-do compile } */ +/* { dg-options "-Wsuggest-attribute=format" } */ + +#include "format.h" + +va_list va; +const char *f; +__typeof (vsnprintf ("foo", 0U, f, va)) T; |