GCC 5 and earlier applied array-to-pointer decay too early,
which affected the new attribute namespace code. A reduced
example of the construct that the attribute code uses is:
struct S { template<__SIZE_TYPE__ N> S(int (&)[N]); };
struct T { int a; S b; };
int a[] = { 1 };
T t = { 1, a };
This was fixed by
f85e1317f8ea933f5c615680353bd646f480f7d3
(PR 16333 et al).
This patch tries to add a minimally-invasive workaround.
gcc/ada/
* gcc-interface/utils.cc (gnat_internal_attribute_table): Add extra
braces to work around PR 16333 in older compilers.
gcc/
* attribs.cc (handle_ignored_attributes_option): Add extra
braces to work around PR 16333 in older compilers.
* config/aarch64/aarch64.cc (aarch64_gnu_attribute_table): Likewise.
(aarch64_arm_attribute_table): Likewise.
* config/arm/arm.cc (arm_gnu_attribute_table): Likewise.
* config/i386/i386-options.cc (ix86_gnu_attribute_table): Likewise.
* config/ia64/ia64.cc (ia64_gnu_attribute_table): Likewise.
* config/rs6000/rs6000.cc (rs6000_gnu_attribute_table): Likewise.
* target-def.h (TARGET_GNU_ATTRIBUTES): Likewise.
* genhooks.cc (emit_init_macros): Likewise, when emitting the
instantiation of TARGET_ATTRIBUTE_TABLE.
* langhooks-def.h (LANG_HOOKS_INITIALIZER): Likewise, when
instantiating LANG_HOOKS_ATTRIBUTE_TABLE.
(LANG_HOOKS_ATTRIBUTE_TABLE): Define to be empty by default.
* target.def (attribute_table): Likewise.
gcc/c-family/
* c-attribs.cc (c_common_gnu_attribute_table): Add extra
braces to work around PR 16333 in older compilers.
gcc/c/
* c-decl.cc (std_attribute_table): Add extra braces to work
around PR 16333 in older compilers.
gcc/cp/
* tree.cc (cxx_gnu_attribute_table): Add extra braces to work
around PR 16333 in older compilers.
gcc/d/
* d-attribs.cc (d_langhook_common_attribute_table): Add extra braces
to work around PR 16333 in older compilers.
(d_langhook_gnu_attribute_table): Likewise.
gcc/fortran/
* f95-lang.cc (gfc_gnu_attribute_table): Add extra braces to work
around PR 16333 in older compilers.
gcc/jit/
* dummy-frontend.cc (jit_gnu_attribute_table): Add extra braces
to work around PR 16333 in older compilers.
(jit_format_attribute_table): Likewise.
gcc/lto/
* lto-lang.cc (lto_gnu_attribute_table): Add extra braces to work
around PR 16333 in older compilers.
(lto_format_attribute_table): Likewise.
const scoped_attribute_specs gnat_internal_attribute_table =
{
- "gnu", gnat_internal_attributes
+ "gnu", { gnat_internal_attributes }
};
/* Associates a GNAT tree node to a GCC tree node. It is used in
attrs = { table, 1 };
}
const scoped_attribute_specs scoped_specs = {
- IDENTIFIER_POINTER (vendor_id), attrs
+ IDENTIFIER_POINTER (vendor_id), { attrs }
};
register_scoped_attributes (scoped_specs, attrs.empty ());
}
const struct scoped_attribute_specs c_common_gnu_attribute_table =
{
- "gnu", c_common_gnu_attributes
+ "gnu", { c_common_gnu_attributes }
};
/* Give the specifications for the format attributes, used by C and all
const struct scoped_attribute_specs c_common_format_attribute_table =
{
- "gnu", c_common_format_attributes
+ "gnu", { c_common_format_attributes }
};
/* Returns TRUE iff the attribute indicated by ATTR_ID takes a plain
const scoped_attribute_specs std_attribute_table =
{
- nullptr, std_attributes
+ nullptr, { std_attributes }
};
/* Create the predefined scalar types of C,
static const scoped_attribute_specs aarch64_gnu_attribute_table =
{
- "gnu", aarch64_gnu_attributes
+ "gnu", { aarch64_gnu_attributes }
};
static const attribute_spec aarch64_arm_attributes[] =
static const scoped_attribute_specs aarch64_arm_attribute_table =
{
- "arm", aarch64_arm_attributes
+ "arm", { aarch64_arm_attributes }
};
static const scoped_attribute_specs *const aarch64_attribute_table[] =
static const scoped_attribute_specs arm_gnu_attribute_table =
{
- "gnu", arm_gnu_attributes
+ "gnu", { arm_gnu_attributes }
};
static const scoped_attribute_specs *const arm_attribute_table[] =
const scoped_attribute_specs ix86_gnu_attribute_table =
{
- "gnu", ix86_gnu_attributes
+ "gnu", { ix86_gnu_attributes }
};
#include "gt-i386-options.h"
static const scoped_attribute_specs ia64_gnu_attribute_table =
{
- "gnu", ia64_gnu_attributes
+ "gnu", { ia64_gnu_attributes }
};
static const scoped_attribute_specs *const ia64_attribute_table[] =
static const scoped_attribute_specs rs6000_gnu_attribute_table =
{
- "gnu", rs6000_gnu_attributes
+ "gnu", { rs6000_gnu_attributes }
};
static const scoped_attribute_specs *const rs6000_attribute_table[] =
const scoped_attribute_specs cxx_gnu_attribute_table =
{
- "gnu", cxx_gnu_attributes
+ "gnu", { cxx_gnu_attributes }
};
/* Table of C++ standard attributes. */
handle_contract_attribute, NULL }
};
-const scoped_attribute_specs std_attribute_table = { nullptr, std_attributes };
+const scoped_attribute_specs std_attribute_table =
+{
+ nullptr, { std_attributes }
+};
/* Handle an "init_priority" attribute; arguments as in
struct attribute_spec.handler. */
const scoped_attribute_specs d_langhook_common_attribute_table =
{
- "gnu", d_langhook_common_attributes
+ "gnu", { d_langhook_common_attributes }
};
/* Table of D language attributes exposed by `gcc.attribute' UDAs. */
const scoped_attribute_specs d_langhook_gnu_attribute_table =
{
- "gnu", d_langhook_gnu_attributes
+ "gnu", { d_langhook_gnu_attributes }
};
/* Insert the type attribute ATTRNAME with value VALUE into TYPE.
static const scoped_attribute_specs gfc_gnu_attribute_table =
{
- "gnu", gfc_gnu_attributes
+ "gnu", { gfc_gnu_attributes }
};
static const scoped_attribute_specs *const gfc_attribute_table[] =
name, name, hook_array[i].init);
}
if (nest == print_nest)
- printf (" %s, \\\n", name);
+ {
+ if (strcmp (name, "TARGET_ATTRIBUTE_TABLE") == 0)
+ printf (" { %s }, \\\n", name);
+ else
+ printf (" %s, \\\n", name);
+ }
}
}
}
static const scoped_attribute_specs jit_gnu_attribute_table =
{
- "gnu", jit_gnu_attributes
+ "gnu", { jit_gnu_attributes }
};
/* Give the specifications for the format attributes, used by C and all
static const scoped_attribute_specs jit_format_attribute_table =
{
- "gnu", jit_format_attributes
+ "gnu", { jit_format_attributes }
};
static const scoped_attribute_specs *const jit_attribute_table[] =
#define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE lhd_get_sarif_source_language
/* Attribute hooks. */
-#define LANG_HOOKS_ATTRIBUTE_TABLE {}
+#define LANG_HOOKS_ATTRIBUTE_TABLE
/* Tree inlining hooks. */
#define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P \
LANG_HOOKS_TYPES_COMPATIBLE_P, \
LANG_HOOKS_PRINT_ERROR_FUNCTION, \
LANG_HOOKS_TO_TARGET_CHARSET, \
- LANG_HOOKS_ATTRIBUTE_TABLE, \
+ { LANG_HOOKS_ATTRIBUTE_TABLE }, \
LANG_HOOKS_TREE_INLINING_INITIALIZER, \
LANG_HOOKS_TREE_DUMP_INITIALIZER, \
LANG_HOOKS_DECLS, \
static const scoped_attribute_specs lto_gnu_attribute_table =
{
- "gnu", lto_gnu_attributes
+ "gnu", { lto_gnu_attributes }
};
/* Give the specifications for the format attributes, used by C and all
static const scoped_attribute_specs lto_format_attribute_table =
{
- "gnu", lto_format_attributes
+ "gnu", { lto_format_attributes }
};
static const scoped_attribute_specs *const lto_attribute_table[] =
#define TARGET_GNU_ATTRIBUTES(NAME, ...) \
static const attribute_spec NAME##_2[] = __VA_ARGS__; \
- static const scoped_attribute_specs NAME##_1 = { "gnu", NAME##_2 }; \
+ static const scoped_attribute_specs NAME##_1 = { "gnu", { NAME##_2 } }; \
static const scoped_attribute_specs *const NAME[] = { &NAME##_1 }
#include "target-hooks-def.h"
@{ \"@var{attributen}\", @dots{} @},\n\
@});\n\
@end smallexample",
- array_slice<const struct scoped_attribute_specs *const>, {})
+ array_slice<const struct scoped_attribute_specs *const>,)
/* Return true iff attribute NAME expects a plain identifier as its first
argument. */