aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2023-12-05 17:53:50 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2023-12-05 17:53:50 +0000
commit1dad3df1e7f3fd73f157f88561ef424b6853d960 (patch)
tree57dd6e31d5b9a186e95cf7591397f741e8eb04ca
parent3cd73543a1122d3c81409e3e9a26c3e94c3d324f (diff)
downloadgcc-1dad3df1e7f3fd73f157f88561ef424b6853d960.zip
gcc-1dad3df1e7f3fd73f157f88561ef424b6853d960.tar.gz
gcc-1dad3df1e7f3fd73f157f88561ef424b6853d960.tar.bz2
Restore build with GCC 4.8 to GCC 5
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.
-rw-r--r--gcc/ada/gcc-interface/utils.cc2
-rw-r--r--gcc/attribs.cc2
-rw-r--r--gcc/c-family/c-attribs.cc4
-rw-r--r--gcc/c/c-decl.cc2
-rw-r--r--gcc/config/aarch64/aarch64.cc4
-rw-r--r--gcc/config/arm/arm.cc2
-rw-r--r--gcc/config/i386/i386-options.cc2
-rw-r--r--gcc/config/ia64/ia64.cc2
-rw-r--r--gcc/config/rs6000/rs6000.cc2
-rw-r--r--gcc/cp/tree.cc7
-rw-r--r--gcc/d/d-attribs.cc4
-rw-r--r--gcc/fortran/f95-lang.cc2
-rw-r--r--gcc/genhooks.cc7
-rw-r--r--gcc/jit/dummy-frontend.cc4
-rw-r--r--gcc/langhooks-def.h4
-rw-r--r--gcc/lto/lto-lang.cc4
-rw-r--r--gcc/target-def.h2
-rw-r--r--gcc/target.def2
18 files changed, 33 insertions, 25 deletions
diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index f46454d..6629d3f 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -221,7 +221,7 @@ static const attribute_spec gnat_internal_attributes[] =
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
diff --git a/gcc/attribs.cc b/gcc/attribs.cc
index eff9900..1e6369a 100644
--- a/gcc/attribs.cc
+++ b/gcc/attribs.cc
@@ -302,7 +302,7 @@ handle_ignored_attributes_option (vec<char *> *v)
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 ());
}
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 45af074..859dcf2 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -584,7 +584,7 @@ const struct attribute_spec c_common_gnu_attributes[] =
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
@@ -603,7 +603,7 @@ const struct attribute_spec c_common_format_attributes[] =
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
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 248d1bb..92c83e1 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -4653,7 +4653,7 @@ static const attribute_spec std_attributes[] =
const scoped_attribute_specs std_attribute_table =
{
- nullptr, std_attributes
+ nullptr, { std_attributes }
};
/* Create the predefined scalar types of C,
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 0ea5950..107fcd5 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -758,7 +758,7 @@ static const attribute_spec aarch64_gnu_attributes[] =
static const scoped_attribute_specs aarch64_gnu_attribute_table =
{
- "gnu", aarch64_gnu_attributes
+ "gnu", { aarch64_gnu_attributes }
};
static const attribute_spec aarch64_arm_attributes[] =
@@ -782,7 +782,7 @@ 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[] =
diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 5ac67c1..6e3e2e8 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -385,7 +385,7 @@ static const attribute_spec arm_gnu_attributes[] =
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[] =
diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
index 8776592..f86ad33 100644
--- a/gcc/config/i386/i386-options.cc
+++ b/gcc/config/i386/i386-options.cc
@@ -4171,7 +4171,7 @@ static const attribute_spec ix86_gnu_attributes[] =
const scoped_attribute_specs ix86_gnu_attribute_table =
{
- "gnu", ix86_gnu_attributes
+ "gnu", { ix86_gnu_attributes }
};
#include "gt-i386-options.h"
diff --git a/gcc/config/ia64/ia64.cc b/gcc/config/ia64/ia64.cc
index f7766c2..ac566ef 100644
--- a/gcc/config/ia64/ia64.cc
+++ b/gcc/config/ia64/ia64.cc
@@ -375,7 +375,7 @@ static const attribute_spec ia64_gnu_attributes[] =
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[] =
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index bff06f7..2d8afc1 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -1276,7 +1276,7 @@ static const attribute_spec rs6000_gnu_attributes[] =
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[] =
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index e0b9d51..da4d5c5 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -5098,7 +5098,7 @@ static const attribute_spec cxx_gnu_attributes[] =
const scoped_attribute_specs cxx_gnu_attribute_table =
{
- "gnu", cxx_gnu_attributes
+ "gnu", { cxx_gnu_attributes }
};
/* Table of C++ standard attributes. */
@@ -5126,7 +5126,10 @@ static const attribute_spec std_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. */
diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc
index f641105..3b69c53 100644
--- a/gcc/d/d-attribs.cc
+++ b/gcc/d/d-attribs.cc
@@ -194,7 +194,7 @@ static const attribute_spec d_langhook_common_attributes[] =
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. */
@@ -246,7 +246,7 @@ static const attribute_spec d_langhook_gnu_attributes[] =
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.
diff --git a/gcc/fortran/f95-lang.cc b/gcc/fortran/f95-lang.cc
index 99dd762..32fddcd 100644
--- a/gcc/fortran/f95-lang.cc
+++ b/gcc/fortran/f95-lang.cc
@@ -102,7 +102,7 @@ static const attribute_spec gfc_gnu_attributes[] =
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[] =
diff --git a/gcc/genhooks.cc b/gcc/genhooks.cc
index 49414ec..135c523 100644
--- a/gcc/genhooks.cc
+++ b/gcc/genhooks.cc
@@ -304,7 +304,12 @@ emit_init_macros (const char *docname)
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);
+ }
}
}
}
diff --git a/gcc/jit/dummy-frontend.cc b/gcc/jit/dummy-frontend.cc
index 61cc0e1..1ea6ad3 100644
--- a/gcc/jit/dummy-frontend.cc
+++ b/gcc/jit/dummy-frontend.cc
@@ -133,7 +133,7 @@ static const attribute_spec jit_gnu_attributes[] =
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
@@ -151,7 +151,7 @@ static const attribute_spec jit_format_attributes[] =
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[] =
diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h
index c9cb657..042fd01 100644
--- a/gcc/langhooks-def.h
+++ b/gcc/langhooks-def.h
@@ -153,7 +153,7 @@ extern const char *lhd_get_sarif_source_language (const char *);
#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 \
@@ -364,7 +364,7 @@ extern void lhd_end_section (void);
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, \
diff --git a/gcc/lto/lto-lang.cc b/gcc/lto/lto-lang.cc
index 41de35a..62aaa9b 100644
--- a/gcc/lto/lto-lang.cc
+++ b/gcc/lto/lto-lang.cc
@@ -140,7 +140,7 @@ static const attribute_spec lto_gnu_attributes[] =
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
@@ -158,7 +158,7 @@ static const attribute_spec lto_format_attributes[] =
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[] =
diff --git a/gcc/target-def.h b/gcc/target-def.h
index d03b039..79fe8e2 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -129,7 +129,7 @@
#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"
diff --git a/gcc/target.def b/gcc/target.def
index b51939a..52b83e0 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -2247,7 +2247,7 @@ TARGET_GNU_ATTRIBUTES (@var{cpu_attribute_table}, @{\n\
@{ \"@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. */