/* Return node that alias is aliasing. */
inline symtab_node *get_alias_target (void);
+ /* Return DECL that alias is aliasing. */
+ inline tree get_alias_target_tree ();
+
/* Set section for symbol and its aliases. */
void set_section (const char *section);
return ref->referred;
}
+/* Return the DECL (or identifier) that alias is aliasing. Unlike the above,
+ this works whether or not the alias has been analyzed already. */
+
+inline tree
+symtab_node::get_alias_target_tree ()
+{
+ if (alias_target)
+ return alias_target;
+ return get_alias_target ()->decl;
+}
+
/* Return next reachable static symbol with initializer after the node. */
inline symtab_node *
if (node->alias
&& lookup_attribute ("flatten", DECL_ATTRIBUTES (decl)))
{
- warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes,
- "%<flatten%> attribute is ignored on aliases");
+ tree tdecl = node->get_alias_target_tree ();
+ if (!tdecl || !DECL_P (tdecl)
+ || !lookup_attribute ("flatten", DECL_ATTRIBUTES (tdecl)))
+ warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
+ "%<flatten%> attribute is ignored on aliases");
}
if (DECL_PRESERVE_P (decl))
node->mark_force_output ();
--- /dev/null
+// PR c++/96078
+// { dg-do compile { target c++11 } }
+
+struct A {
+ [[gnu::flatten]] A() {}
+ [[gnu::flatten]] ~A() {}
+};
+
+A a;