From: Marek Polacek Date: Mon, 29 Jan 2018 18:20:01 +0000 (+0000) Subject: re PR c/83966 (ICE in check_function_arguments at gcc/c-family/c-common.c:5617) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7d07a93a52153e7ccda52ce86847d2e365dc9f83;p=gcc.git 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 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 335eeeb10b6..7a142886acc 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2018-01-29 Marek Polacek + + PR c/83966 + * c-format.c (check_function_format): Check current_function_decl. + 2018-01-27 Jakub Jelinek * 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 7a69d5a295c..3f4f83af219 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 18e19afcd0a..3713a81227c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-29 Marek Polacek + + PR c/83966 + * gcc.dg/format/Wsuggest-attribute-1.c: New test. + 2018-01-29 Richard Biener 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 00000000000..5b6fb051e72 --- /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;