summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2000-12-09 21:26:56 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2000-12-09 21:26:56 +0000
commit7331695b6be9eacdc44a26553649f97fd5c571bd (patch)
tree8a5eb4e052f246c02d053a731de53400bfee8a98 /gcc/c-common.c
parentbb5f4242b54018d2a1c950254f3cb5a06762b5b3 (diff)
downloadgcc-7331695b6be9eacdc44a26553649f97fd5c571bd.tar.gz
* c-common.c (check_function_format): Don't suggest adding format
attributes to functions with no parameter to which to add them. testsuite: * gcc.dg/format-miss-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38163 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 2baba027a1f..1e766e6ecda 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -2047,8 +2047,25 @@ check_function_format (status, name, assembler_name, params)
&& info2->format_type == info->format_type)
break;
if (info2 == NULL)
- warning ("function might be possible candidate for `%s' format attribute",
- format_types[info->format_type].name);
+ {
+ /* Check if the current function has a parameter to which
+ the format attribute could be attached; if not, it
+ can't be a candidate for a format attribute, despite
+ the vprintf-like or vscanf-like call. */
+ tree args;
+ for (args = DECL_ARGUMENTS (current_function_decl);
+ args != 0;
+ args = TREE_CHAIN (args))
+ {
+ if (TREE_CODE (TREE_TYPE (args)) == POINTER_TYPE
+ && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (args)))
+ == char_type_node))
+ break;
+ }
+ if (args != 0)
+ warning ("function might be possible candidate for `%s' format attribute",
+ format_types[info->format_type].name);
+ }
}
break;
}