void init_attributes (void) { size_t i; if (attributes_initialized) return; attribute_tables[0] = lang_hooks.common_attribute_table; attribute_tables[1] = lang_hooks.attribute_table; attribute_tables[2] = lang_hooks.format_attribute_table; attribute_tables[3] = targetm.attribute_table; /* Translate NULL pointers to pointers to the empty table. */ for (i = 0; i < ARRAY_SIZE (attribute_tables); i++) if (attribute_tables[i] == NULL) attribute_tables[i] = empty_attribute_table; if (flag_checking) check_attribute_tables (); for (i = 0; i < ARRAY_SIZE (attribute_tables); ++i) /* Put all the GNU attributes into the "gnu" namespace. */ register_scoped_attributes (attribute_tables[i], "gnu"); invoke_plugin_callbacks (PLUGIN_ATTRIBUTES, NULL); attributes_initialized = true; }
void init_attributes (void) { size_t i; if (attributes_initialized) return; attribute_tables[0] = lang_hooks.common_attribute_table; attribute_tables[1] = lang_hooks.attribute_table; attribute_tables[2] = lang_hooks.format_attribute_table; attribute_tables[3] = targetm.attribute_table; /* Translate NULL pointers to pointers to the empty table. */ for (i = 0; i < ARRAY_SIZE (attribute_tables); i++) if (attribute_tables[i] == NULL) attribute_tables[i] = empty_attribute_table; #ifdef ENABLE_CHECKING /* Make some sanity checks on the attribute tables. */ for (i = 0; i < ARRAY_SIZE (attribute_tables); i++) { int j; for (j = 0; attribute_tables[i][j].name != NULL; j++) { /* The name must not begin and end with __. */ const char *name = attribute_tables[i][j].name; int len = strlen (name); gcc_assert (!(name[0] == '_' && name[1] == '_' && name[len - 1] == '_' && name[len - 2] == '_')); /* The minimum and maximum lengths must be consistent. */ gcc_assert (attribute_tables[i][j].min_length >= 0); gcc_assert (attribute_tables[i][j].max_length == -1 || (attribute_tables[i][j].max_length >= attribute_tables[i][j].min_length)); /* An attribute cannot require both a DECL and a TYPE. */ gcc_assert (!attribute_tables[i][j].decl_required || !attribute_tables[i][j].type_required); /* If an attribute requires a function type, in particular it requires a type. */ gcc_assert (!attribute_tables[i][j].function_type_required || attribute_tables[i][j].type_required); } } /* Check that each name occurs just once in each table. */ for (i = 0; i < ARRAY_SIZE (attribute_tables); i++) { int j, k; for (j = 0; attribute_tables[i][j].name != NULL; j++) for (k = j + 1; attribute_tables[i][k].name != NULL; k++) gcc_assert (strcmp (attribute_tables[i][j].name, attribute_tables[i][k].name)); } /* Check that no name occurs in more than one table. Names that begin with '*' are exempt, and may be overridden. */ for (i = 0; i < ARRAY_SIZE (attribute_tables); i++) { size_t j, k, l; for (j = i + 1; j < ARRAY_SIZE (attribute_tables); j++) for (k = 0; attribute_tables[i][k].name != NULL; k++) for (l = 0; attribute_tables[j][l].name != NULL; l++) gcc_assert (attribute_tables[i][k].name[0] == '*' || strcmp (attribute_tables[i][k].name, attribute_tables[j][l].name)); } #endif for (i = 0; i < ARRAY_SIZE (attribute_tables); ++i) /* Put all the GNU attributes into the "gnu" namespace. */ register_scoped_attributes (attribute_tables[i], "gnu"); invoke_plugin_callbacks (PLUGIN_ATTRIBUTES, NULL); attributes_initialized = true; }