]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Restore build with GCC 4.8 to GCC 5
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 5 Dec 2023 17:53:50 +0000 (17:53 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 5 Dec 2023 17:53:50 +0000 (17:53 +0000)
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.

18 files changed:
gcc/ada/gcc-interface/utils.cc
gcc/attribs.cc
gcc/c-family/c-attribs.cc
gcc/c/c-decl.cc
gcc/config/aarch64/aarch64.cc
gcc/config/arm/arm.cc
gcc/config/i386/i386-options.cc
gcc/config/ia64/ia64.cc
gcc/config/rs6000/rs6000.cc
gcc/cp/tree.cc
gcc/d/d-attribs.cc
gcc/fortran/f95-lang.cc
gcc/genhooks.cc
gcc/jit/dummy-frontend.cc
gcc/langhooks-def.h
gcc/lto/lto-lang.cc
gcc/target-def.h
gcc/target.def

index f46454d6545a2e8dd7b1ac926d94526e235a0194..6629d3f9b18548bb99b0e3471b1e6d1476895b49 100644 (file)
@@ -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
index eff99002fbb9292c943f911292e02767824eb03b..1e6369a47fe703f7499fee5f272d6c459197a4f2 100644 (file)
@@ -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 ());
     }
index 45af07453ea3c0c60fb4d291b3ebfff545bb0643..859dcf255ba59ebb2cb557e55778bd38b54cd74f 100644 (file)
@@ -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
index 248d1bb3206f4dd800834d066aa379add03ed602..92c83e1bf10de1ee627d0e562835079a212af725 100644 (file)
@@ -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,
index 0ea5950ddca1df1375c20621b8d70658bde5d3c5..107fcd5c6e895aac2aac86e4f0fa5b9d671e02b3 100644 (file)
@@ -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[] =
index 5ac67c1e28b0efc1e4ef03d2a8753edf699111d2..6e3e2e8fb1bfbecbc1acfa47de1edbde9d54cc85 100644 (file)
@@ -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[] =
index 877659229d215f9f3e08e934eb55290a43ed59ce..f86ad332aadb04686feeb5f47244d0292357963b 100644 (file)
@@ -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"
index f7766c256220a23ec4ac0913b3cb3ca41e524625..ac566efcf1901e5d0c5aa0743282b191b1b6edda 100644 (file)
@@ -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[] =
index bff06f73bcfed5baf3c8bdae5262f3f721646e7f..2d8afc1211984baf6d8dd289f32f9442bb70ec03 100644 (file)
@@ -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[] =
index e0b9d512adccb3142d2a3df0e199927db0afc096..da4d5c51f074cd602387c71440f4265e464cfbae 100644 (file)
@@ -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.  */
index f641105807215c23cdf6326f3fb5c67db1258678..3b69c530c1d29f880b7dcdd5b6e9188f07e4c2e8 100644 (file)
@@ -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.
index 99dd76226a2f5b9b22bd43ee7ce225e28413ff27..32fddcde9571977f5a25af892f70db47636d162e 100644 (file)
@@ -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[] =
index 49414eca53152c71fafbe97873d971ff472fb571..135c523bd00a656f00b235352bac45a7f76d07f3 100644 (file)
@@ -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);
+           }
        }
     }
 }
index 61cc0e1ae66ea5560985a87ecd651578f5633c4b..1ea6ad382d893ce19bb659c76562ee8007704008 100644 (file)
@@ -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[] =
index c9cb65759c22ed73be4558ada1797d1b20b28513..042fd0174e3d7db6c28a8f44d2f2692577eafde2 100644 (file)
@@ -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, \
index 41de35a9ff6f05b40584c455c040d233987fdcdd..62aaa9b7d10fe587cd7bee373e6756fdef6979ef 100644 (file)
@@ -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[] =
index d03b039ab24b21c8ebdc059f9b6b30f868932c24..79fe8e28e7e960345d1572601939c59171bbe075 100644 (file)
 
 #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"
index b51939a4f854e612a9a0fbbd41aa2ff5b2d492ba..52b83e091b94bdda8d1584a262a82d8f0f402d58 100644 (file)
@@ -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.  */