diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-07-13 23:16:18 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-07-13 23:16:18 +0000 |
commit | a96c3cc137bf0b63e19601371c082f0ed963dc25 (patch) | |
tree | 0170fc55d95b627aec9918256ba3cf861f269fd3 /gcc/c-family/c-common.c | |
parent | 84fcb947302a8da0d1c0c5dd0d130cc82ea10c06 (diff) | |
download | gcc-a96c3cc137bf0b63e19601371c082f0ed963dc25.tar.gz |
PR c++/55203
c-family/
* c-common.c (c_common_attribute_table): Add warn_unused.
(handle_warn_unused_attribute): New.
cp/
* init.c (build_aggr_init): Check for warn_unused attribute.
* decl.c (poplevel): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200941 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family/c-common.c')
-rw-r--r-- | gcc/c-family/c-common.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 61300cd05c7..970f9f20a08 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -368,6 +368,7 @@ static tree handle_optimize_attribute (tree *, tree, tree, int, bool *); static tree ignore_attribute (tree *, tree, tree, int, bool *); static tree handle_no_split_stack_attribute (tree *, tree, tree, int, bool *); static tree handle_fnspec_attribute (tree *, tree, tree, int, bool *); +static tree handle_warn_unused_attribute (tree *, tree, tree, int, bool *); static void check_function_nonnull (tree, int, tree *); static void check_nonnull_arg (void *, tree, unsigned HOST_WIDE_INT); @@ -738,6 +739,8 @@ const struct attribute_spec c_common_attribute_table[] = The name contains space to prevent its usage in source code. */ { "fn spec", 1, 1, false, true, true, handle_fnspec_attribute, false }, + { "warn_unused", 0, 0, false, false, false, + handle_warn_unused_attribute, false }, { NULL, 0, 0, false, false, false, NULL, false } }; @@ -7950,6 +7953,27 @@ handle_fnspec_attribute (tree *node ATTRIBUTE_UNUSED, tree ARG_UNUSED (name), return NULL_TREE; } +/* Handle a "warn_unused" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_warn_unused_attribute (tree *node, tree name, + tree args ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED, bool *no_add_attrs) +{ + if (TYPE_P (*node)) + /* Do nothing else, just set the attribute. We'll get at + it later with lookup_attribute. */ + ; + else + { + warning (OPT_Wattributes, "%qE attribute ignored", name); + *no_add_attrs = true; + } + + return NULL_TREE; +} + /* Handle a "returns_twice" attribute; arguments as in struct attribute_spec.handler. */ |