While looking at PR90451 I noticed that this function was failing to find
the attributes if called with a variant of the struct.
gcc/ChangeLog:
* tree.cc (warn_deprecated_use): Look for TYPE_STUB_DECL
on TYPE_MAIN_VARIANT.
gcc/testsuite/ChangeLog:
* g++.dg/warn/deprecated-16.C: New test.
--- /dev/null
+struct __attribute((deprecated ("foo"))) A { }; // { dg-message "declared" }
+void f(const A&) { } // { dg-warning "deprecated: foo" }
attr = DECL_ATTRIBUTES (node);
else if (TYPE_P (node))
{
- tree decl = TYPE_STUB_DECL (node);
+ tree decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (node));
if (decl)
- attr = lookup_attribute ("deprecated",
- TYPE_ATTRIBUTES (TREE_TYPE (decl)));
+ {
+ node = TREE_TYPE (decl);
+ attr = TYPE_ATTRIBUTES (node);
+ }
}
}