[PATCH 1/4] gas: improve unrecognized command line option diagnostic
Jan Beulich
jbeulich@suse.com
Tue Jul 30 05:54:37 GMT 2024
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.
--- 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 '?':
--- 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.*
--- 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.*
--- 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
mailing list