Another suspicious code hunk in c-family/c-common.c
Jeff Law
law@redhat.com
Wed Jan 27 23:26:00 GMT 2016
On 01/27/2016 03:41 PM, Andrew MacLeod wrote:
> another chock with the static type code in
> c-family/c-common:handle_deprecated_attribute()
> around line 8919-8923
>
>
> handle_deprecated_attribute (tree *node, tree name,
> tree args, int flags,
> bool *no_add_attrs)
> {
> <...>
> if (DECL_P (*node))
> {
> tree decl = *node;
> type = TREE_TYPE (decl);
> <...>
> }
> else if (TYPE_P (*node))
> {
> if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
> *node = build_variant_type_copy (*node);
> TREE_DEPRECATED (*node) = 1;
> type = *node;
> }
> <...>
>
> if (type && TYPE_NAME (type))
> {
> if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
> (*) what = TYPE_NAME (*node);
> else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
> && DECL_NAME (TYPE_NAME (type)))
> what = DECL_NAME (TYPE_NAME (type));
> }
> if (what)
> warning (OPT_Wattributes, "%qE attribute ignored for %qE",
> name, what);
>
>
> I think the (*) line is suppose to be
> what = TYPE_NAME (type);
>
> It will work fine for the case where a type is passed in since type is
> equivilent to *name, but in some cases of DECL I'd say it's not looking
> at the correct field..
That would be my suspicion as well.
Good to see this work exposing this kind of issue at compile time --
that was definitely one of the things I want to get out of this class of
infrastructure changes.
jeff
More information about the Gcc-patches
mailing list