[binutils-gdb] gas: improve unrecognized command line option diagnostic

Jan Beulich jbeulich@sourceware.org
Wed Aug 7 14:32:53 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=544248c027aa17845f7b35efc11316892f9af326

commit 544248c027aa17845f7b35efc11316892f9af326
Author: Jan Beulich <jbeulich@suse.com>
Date:   Wed Aug 7 16:31:00 2024 +0200

    gas: improve unrecognized command line option diagnostic
    
    Printing optc with %c makes sense only when optc is actually a
    character. Add logic to also deal with unrecognized long options,
    rejected by md_parse_option() rather than get_opt_long_only(). Also
    quote the reproduced strings, such that possible included whitespace
    can be recognized.

Diff:
---
 gas/as.c                                      | 6 +++++-
 gas/testsuite/gas/arm/armv2-mp-bad.l          | 2 +-
 gas/testsuite/gas/arm/dotprod-legacy-arch.l   | 2 +-
 gas/testsuite/gas/arm/forbid-armv7-idiv-ext.l | 2 +-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gas/as.c b/gas/as.c
index 259dc0ee580..28aa4e38b34 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -666,8 +666,12 @@ parse_args (int * pargc, char *** pargv)
 		verbose = 1;
 	      break;
 	    }
+	  else if (is_a_char (optc))
+	    as_bad (_("unrecognized option `-%c%s'"), optc, optarg ? optarg : "");
+	  else if (optarg)
+	    as_bad (_("unrecognized option `--%s=%s'"), longopts[longind].name, optarg);
 	  else
-	    as_bad (_("unrecognized option -%c%s"), optc, optarg ? optarg : "");
+	    as_bad (_("unrecognized option `--%s'"), longopts[longind].name);
 	  /* Fall through.  */
 
 	case '?':
diff --git a/gas/testsuite/gas/arm/armv2-mp-bad.l b/gas/testsuite/gas/arm/armv2-mp-bad.l
index eb97135033e..d0159b0c77b 100644
--- a/gas/testsuite/gas/arm/armv2-mp-bad.l
+++ b/gas/testsuite/gas/arm/armv2-mp-bad.l
@@ -1,3 +1,3 @@
 Assembler messages:
 [^:]*: extension does not apply to the base architecture
-[^:]*: unrecognized option -march=armv2\+mp
+[^:]*: unrecognized option .*-march=armv2\+mp.*
diff --git a/gas/testsuite/gas/arm/dotprod-legacy-arch.l b/gas/testsuite/gas/arm/dotprod-legacy-arch.l
index a627a36fb12..7bbdf6381b1 100644
--- a/gas/testsuite/gas/arm/dotprod-legacy-arch.l
+++ b/gas/testsuite/gas/arm/dotprod-legacy-arch.l
@@ -1,3 +1,3 @@
 Assembler messages:
 [^:]*: extension does not apply to the base architecture
-[^:]*: unrecognized option -march=armv8.1-a\+dotprod
+[^:]*: unrecognized option .*-march=armv8\.1-a\+dotprod.*
diff --git a/gas/testsuite/gas/arm/forbid-armv7-idiv-ext.l b/gas/testsuite/gas/arm/forbid-armv7-idiv-ext.l
index 76208d2bcbc..a6fc3dcb7f0 100644
--- a/gas/testsuite/gas/arm/forbid-armv7-idiv-ext.l
+++ b/gas/testsuite/gas/arm/forbid-armv7-idiv-ext.l
@@ -1,3 +1,3 @@
 Assembler messages:
 [^:]*: extension does not apply to the base architecture
-[^:]*: unrecognized option -march=armv7\+idiv
+[^:]*: unrecognized option .*-march=armv7\+idiv.*


More information about the Binutils-cvs mailing list