Commit 3e1af1d0 by Iain Buclaw

d: Fix ICE in uda_attribute_p when looking up unknown attribute

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.

(cherry picked from commit 62e02c8729a75c4a859edc18e0bcafb87d717f46)
parent 89da6aab
...@@ -216,10 +216,13 @@ uda_attribute_p (const char *name) ...@@ -216,10 +216,13 @@ uda_attribute_p (const char *name)
return true; return true;
} }
for (const attribute_spec *p = targetm.attribute_table; p->name; p++) if (targetm.attribute_table)
{ {
if (get_identifier (p->name) == ident) for (const attribute_spec *p = targetm.attribute_table; p->name; p++)
return true; {
if (get_identifier (p->name) == ident)
return true;
}
} }
return false; return false;
......
// 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()
{
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment