Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Provide access to target attributes via gcc.attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw authored and jpf91 committed Apr 15, 2014
1 parent 3d820cd commit 50f4465
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
27 changes: 18 additions & 9 deletions gcc/d/d-codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -792,20 +792,29 @@ d_attribute_p (const char* name)
{
static StringTable* table;

if(!table)
if(table == NULL)
{
// Build the table of attributes exposed to the language.
// Common and format attributes are kept internal.
size_t n = 0;
for (const attribute_spec *p = d_attribute_table; p->name; p++)
n++;
table = new StringTable();

if(n == 0)
return false;
for (const attribute_spec *p = lang_hooks.attribute_table; p->name; p++)
n++;

table = new StringTable();
table->_init(n);
for (const attribute_spec *p = targetm.attribute_table; p->name; p++)
n++;

if(n != 0)
{
table->_init(n);

for (const attribute_spec *p = lang_hooks.attribute_table; p->name; p++)
table->insert(p->name, strlen(p->name));

for (const attribute_spec *p = d_attribute_table; p->name; p++)
table->insert(p->name, strlen(p->name));
for (const attribute_spec *p = targetm.attribute_table; p->name; p++)
table->insert(p->name, strlen(p->name));
}
}

return table->lookup(name, strlen(name)) != NULL;
Expand Down
2 changes: 1 addition & 1 deletion gcc/d/d-lang.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static tree d_handle_target_attribute (tree *, tree, tree, int, bool *);

static char lang_name[6] = "GNU D";

const attribute_spec d_attribute_table[] =
static const attribute_spec d_attribute_table[] =
{
{ "noinline", 0, 0, true, false, false,
d_handle_noinline_attribute, false },
Expand Down
1 change: 0 additions & 1 deletion gcc/d/d-lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ extern void set_block (tree);

/* In d-builtins.c */
extern const attribute_spec d_builtins_attribute_table[];
extern const attribute_spec d_attribute_table[];
extern const attribute_spec d_format_attribute_table[];
tree d_builtin_function (tree);
void d_init_builtins (void);
Expand Down

0 comments on commit 50f4465

Please sign in to comment.