]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
loongarch gcc-4.9 build error
authorAlan Modra <amodra@gmail.com>
Fri, 17 Jul 2026 00:07:37 +0000 (09:37 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 17 Jul 2026 00:15:24 +0000 (09:45 +0930)
gas/config/tc-loongarch.c: In function ‘md_apply_fix’:
gas/config/tc-loongarch.c:1886:7: error: a label can only be part of a statement and a declaration is not a statement
       unsigned int subtype;
       ^

* config/tc-loongarch.c (md_apply_fix <BFD_RELOC_LARCH_CFA>):
Avoid gcc-4.9 error.

gas/config/tc-loongarch.c

index e67394c460c5d3506eed389170bbf2a02896d919..bd7d8dabb7a49fdf04aea9595e779cbc27a428ff 100644 (file)
@@ -1883,70 +1883,72 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
       break;
 
     case BFD_RELOC_LARCH_CFA:
-      unsigned int subtype;
-      fragS *opfrag = (fragS *) fixP->fx_frag->fr_opcode;
-      subtype = bfd_get_8 (NULL, opfrag->fr_literal + fixP->fx_where);
-
-      /* Update to the real size after relax_segment.  */
-      if (subtype == DW_CFA_advance_loc2)
-       fixP->fx_size = 2;
-      if (subtype == DW_CFA_advance_loc4)
-       fixP->fx_size = 4;
-
-      if (fixP->fx_addsy && fixP->fx_subsy)
-       {
-         fixP->fx_next = xmemdup (fixP, sizeof (*fixP), sizeof (*fixP));
-         fixP->fx_next->fx_addsy = fixP->fx_subsy;
-         fixP->fx_next->fx_subsy = NULL;
-         fixP->fx_next->fx_offset = 0;
-         fixP->fx_subsy = NULL;
-
-         offsetT loc;
-         loc = fixP->fx_frag->fr_fix - (subtype & 7);
-         switch (subtype)
-           {
-           case DW_CFA_advance_loc1:
-             fixP->fx_where = loc + 1;
-             fixP->fx_next->fx_where = loc + 1;
-             fixP->fx_r_type = BFD_RELOC_LARCH_ADD8;
-             fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB8;
-             md_number_to_chars (buf+1, 0, fixP->fx_size);
-             break;
-
-           case DW_CFA_advance_loc2:
-             fixP->fx_where = loc + 1;
-             fixP->fx_next->fx_where = loc + 1;
-             fixP->fx_r_type = BFD_RELOC_LARCH_ADD16;
-             fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB16;
-             md_number_to_chars (buf+1, 0, fixP->fx_size);
-             break;
+      {
+       unsigned int subtype;
+       fragS *opfrag = (fragS *) fixP->fx_frag->fr_opcode;
+       subtype = bfd_get_8 (NULL, opfrag->fr_literal + fixP->fx_where);
 
-           case DW_CFA_advance_loc4:
-             fixP->fx_where = loc;
-             fixP->fx_next->fx_where = loc;
-             fixP->fx_r_type = BFD_RELOC_LARCH_ADD32;
-             fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB32;
-             md_number_to_chars (buf+1, 0, fixP->fx_size);
-             break;
+       /* Update to the real size after relax_segment.  */
+       if (subtype == DW_CFA_advance_loc2)
+         fixP->fx_size = 2;
+       if (subtype == DW_CFA_advance_loc4)
+         fixP->fx_size = 4;
 
-           default:
-             if (subtype < 0x80 && (subtype & 0x40))
-               {
-                 /* DW_CFA_advance_loc.  */
-                 fixP->fx_frag = opfrag;
-                 fixP->fx_next->fx_frag = fixP->fx_frag;
-                 fixP->fx_r_type = BFD_RELOC_LARCH_ADD6;
-                 fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB6;
-                 md_number_to_chars (buf, 0x40, fixP->fx_size);
+       if (fixP->fx_addsy && fixP->fx_subsy)
+         {
+           fixP->fx_next = xmemdup (fixP, sizeof (*fixP), sizeof (*fixP));
+           fixP->fx_next->fx_addsy = fixP->fx_subsy;
+           fixP->fx_next->fx_subsy = NULL;
+           fixP->fx_next->fx_offset = 0;
+           fixP->fx_subsy = NULL;
+
+           offsetT loc;
+           loc = fixP->fx_frag->fr_fix - (subtype & 7);
+           switch (subtype)
+             {
+             case DW_CFA_advance_loc1:
+               fixP->fx_where = loc + 1;
+               fixP->fx_next->fx_where = loc + 1;
+               fixP->fx_r_type = BFD_RELOC_LARCH_ADD8;
+               fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB8;
+               md_number_to_chars (buf+1, 0, fixP->fx_size);
+               break;
+
+             case DW_CFA_advance_loc2:
+               fixP->fx_where = loc + 1;
+               fixP->fx_next->fx_where = loc + 1;
+               fixP->fx_r_type = BFD_RELOC_LARCH_ADD16;
+               fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB16;
+               md_number_to_chars (buf+1, 0, fixP->fx_size);
+               break;
+
+             case DW_CFA_advance_loc4:
+               fixP->fx_where = loc;
+               fixP->fx_next->fx_where = loc;
+               fixP->fx_r_type = BFD_RELOC_LARCH_ADD32;
+               fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB32;
+               md_number_to_chars (buf+1, 0, fixP->fx_size);
+               break;
+
+             default:
+               if (subtype < 0x80 && (subtype & 0x40))
+                 {
+                   /* DW_CFA_advance_loc.  */
+                   fixP->fx_frag = opfrag;
+                   fixP->fx_next->fx_frag = fixP->fx_frag;
+                   fixP->fx_r_type = BFD_RELOC_LARCH_ADD6;
+                   fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB6;
+                   md_number_to_chars (buf, 0x40, fixP->fx_size);
                  }
-             else
-               as_fatal (_("internal: bad CFA value #%d"), subtype);
-             break;
-           }
-       }
+               else
+                 as_fatal (_("internal: bad CFA value #%d"), subtype);
+               break;
+             }
+         }
 
-      if (fixP->fx_addsy == NULL)
-       fixP->fx_done = 1;
+       if (fixP->fx_addsy == NULL)
+         fixP->fx_done = 1;
+      }
       break;
 
     case BFD_RELOC_LARCH_B16: