The target attribute table is not guaranteed to be set in all backends.
gcc/d/ChangeLog:
PR d/95173
* d-attribs.cc (uda_attribute_p): Don't search target attribute table
if NULL.
gcc/testsuite/ChangeLog:
PR d/95173
* gdc.dg/pr95173.d: New test.
return true;
}
- for (const attribute_spec *p = targetm.attribute_table; p->name; p++)
+ if (targetm.attribute_table)
{
- if (get_identifier (p->name) == ident)
- return true;
+ for (const attribute_spec *p = targetm.attribute_table; p->name; p++)
+ {
+ if (get_identifier (p->name) == ident)
+ return true;
+ }
}
return false;
--- /dev/null
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95173
+// { dg-do compile }
+// { dg-options "-Wattributes" }
+
+import gcc.attribute;
+
+@attribute("foo") // { dg-warning "unknown attribute .foo." }
+void f95173()
+{
+}