[binutils-gdb] ld: Make separate clauses where a label was before a declaration
Hans-Peter Nilsson
hp@sourceware.org
Sat Jan 24 05:13:40 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a815cdb41312bc3b8536dcb5a2cf2c263c3418f8
commit a815cdb41312bc3b8536dcb5a2cf2c263c3418f8
Author: Hans-Peter Nilsson <hp@axis.com>
Date: Sat Jan 24 04:53:41 2026 +0100
ld: Make separate clauses where a label was before a declaration
The default behavior of gcc changed from gcc-11. With gcc-10 and
earlier versions, you got:
In file included from ../bfd/bfd.h:45,
from /src/ld/ldmisc.c:23:
/src/ld/ldmisc.c: In function 'vfinfo':
/src/ld/ldmisc.c:186:8: error: a label can only be part of a statement and a declaration is not a statement
186 | bool ll_type = false;
| ^~~~
/src/ld/ldmisc.c:581:8: error: a label can only be part of a statement and a declaration is not a statement
581 | bool ll_type = false;
| ^~~~
make[4]: *** [Makefile:1606: ldmisc.o] Error 1
Since gcc-10 matches the binutils/README requirement ("a C99 compliant
compiler and library") and as binutils policy is to adjust code to
handle earlier gcc versions, an obvious fix is to make a compound
statement for the code after the case-label.
ld:
* ldmisc.c (vfinfo) <case 'l' - two cases>: Make separate
compound statements where case-labels were part of a declaration.
Diff:
---
ld/ldmisc.c | 64 ++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 34 insertions(+), 30 deletions(-)
diff --git a/ld/ldmisc.c b/ld/ldmisc.c
index 3deceb76719..f39e0a3dbe7 100644
--- a/ld/ldmisc.c
+++ b/ld/ldmisc.c
@@ -183,17 +183,19 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning)
break;
case 'l':
- bool ll_type = false;
- if (*scan == 'l')
- {
- ll_type = true;
- ++scan;
- }
- if (*scan == 'd' || *scan == 'u' || *scan == 'x')
- {
- ++scan;
- arg_type = (ll_type ? LongLong : Long);
- }
+ {
+ bool ll_type = false;
+ if (*scan == 'l')
+ {
+ ll_type = true;
+ ++scan;
+ }
+ if (*scan == 'd' || *scan == 'u' || *scan == 'x')
+ {
+ ++scan;
+ arg_type = (ll_type ? LongLong : Long);
+ }
+ }
break;
default:
@@ -578,25 +580,27 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning)
break;
case 'l': /* (Unsigned) (long) long integer, like printf(). */
- bool ll_type = false;
- if (*fmt == 'l')
- {
- fmt++;
- ll_type = true;
- }
- if (*fmt == 'd' || *fmt == 'u' || *fmt == 'x')
- {
- unsigned int mods_len = (ll_type ? 2 : 1);
- cfmt = make_cfmt (fmt - mods_len - mods, mods + mods_len + 1);
- if (ll_type)
- fprintf (fp, cfmt, args[arg_no].ll);
- else
- fprintf (fp, cfmt, args[arg_no].l);
- free (cfmt);
- ++arg_count;
- ++fmt;
- break;
- }
+ {
+ bool ll_type = false;
+ if (*fmt == 'l')
+ {
+ fmt++;
+ ll_type = true;
+ }
+ if (*fmt == 'd' || *fmt == 'u' || *fmt == 'x')
+ {
+ unsigned int mods_len = (ll_type ? 2 : 1);
+ cfmt = make_cfmt (fmt - mods_len - mods, mods + mods_len + 1);
+ if (ll_type)
+ fprintf (fp, cfmt, args[arg_no].ll);
+ else
+ fprintf (fp, cfmt, args[arg_no].l);
+ free (cfmt);
+ ++arg_count;
+ ++fmt;
+ break;
+ }
+ }
/* Fallthru */
default:
More information about the Binutils-cvs
mailing list