diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2005-07-24 21:38:02 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2005-07-24 21:38:02 +0000 |
commit | 104f8784d2e90e6f6da405a8071a59ede65b411a (patch) | |
tree | 082c7830d8aa5ffdf45a79a0fea424679a91db14 /gcc/c-common.c | |
parent | 1b8452d093bd8c1642cda1c3369b9f3d7009fe6f (diff) | |
download | gcc-104f8784d2e90e6f6da405a8071a59ede65b411a.tar.gz |
c-common.c (check_missing_format_attribute): New.
* c-common.c (check_missing_format_attribute): New.
* c-common.h (check_missing_format_attribute): Likewise.
* c-typeck.c (convert_for_assignment): Use it.
cp:
* call.c (convert_for_arg_passing): Check function pointers when
-Wmissing-format-attribute is activated.
* typeck.c (convert_for_assignment): Likewise.
testsuite:
* g++.dg/warn/miss-format-1.C, g++.dg/warn/miss-format-2.C,
g++.dg/warn/miss-format-3.C, g++.dg/warn/miss-format-4.C,
g++.dg/warn/miss-format-5.C, g++.dg/warn/miss-format-6.C: New.
From-SVN: r102338
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 8646b4cc7ee..10350f3751d 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -6208,4 +6208,30 @@ same_scalar_type_ignoring_signedness (tree t1, tree t2) == lang_hooks.types.signed_type (t2); } +/* Check for missing format attributes on function pointers. LTYPE is + the new type or left-hand side type. RTYPE is the old type or + right-hand side type. Returns TRUE if LTYPE is missing the desired + attribute. */ + +bool +check_missing_format_attribute (tree ltype, tree rtype) +{ + tree const ttr = TREE_TYPE (rtype), ttl = TREE_TYPE (ltype); + tree ra; + + for (ra = TYPE_ATTRIBUTES (ttr); ra; ra = TREE_CHAIN (ra)) + if (is_attribute_p ("format", TREE_PURPOSE (ra))) + break; + if (ra) + { + tree la; + for (la = TYPE_ATTRIBUTES (ttl); la; la = TREE_CHAIN (la)) + if (is_attribute_p ("format", TREE_PURPOSE (la))) + break; + return !la; + } + else + return false; +} + #include "gt-c-common.h" |