as: Reject unknown -gXXX option
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 16 Apr 2022 17:46:05 +0000 (10:46 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 19 Apr 2022 17:35:41 +0000 (10:35 -0700)
* as.c (parse_args): Reject unknown -gXXX option.
* testsuite/gas/all/empty.s: New file.
* testsuite/gas/all/pr29067.d: Likewise.
* testsuite/gas/all/pr29067.err: Likewise.
* testsuite/gas/all/gas.exp: Run pr29067.

gas/as.c
gas/testsuite/gas/all/empty.s [new file with mode: 0644]
gas/testsuite/gas/all/gas.exp
gas/testsuite/gas/all/pr29067.d [new file with mode: 0644]
gas/testsuite/gas/all/pr29067.err [new file with mode: 0644]

index f320bac89b56376a3bfe5e636f2196018b647ed3..0262a6fec9875ef38da6f4fb851d2a61d247e8c4 100644 (file)
--- a/gas/as.c
+++ b/gas/as.c
@@ -836,6 +836,8 @@ This program has absolutely no warranty.\n"));
             versions/sections/options.  */
          if (startswith (old_argv[optind - 1], "-gdwarf"))
            as_fatal (_("unknown DWARF option %s\n"), old_argv[optind - 1]);
+         else if (old_argv[optind - 1][1] == 'g' && optarg != NULL)
+           as_fatal (_("unknown option `%s'"), old_argv[optind - 1]);
 
          if (md_debug_format_selector)
            debug_type = md_debug_format_selector (& use_gnu_debug_info_extensions);
diff --git a/gas/testsuite/gas/all/empty.s b/gas/testsuite/gas/all/empty.s
new file mode 100644 (file)
index 0000000..6ac6c76
--- /dev/null
@@ -0,0 +1 @@
+/* Empty input.  */
index ae7957b2ee014d1d52bd561746807c1e28b64a3b..db927121f638cbd29e1e041a42552273ffb20357 100644 (file)
@@ -506,3 +506,4 @@ run_dump_test "pr27384"
 run_dump_test "pr27381"
 run_dump_test "multibyte1"
 run_dump_test "multibyte2"
+run_dump_test "pr29067"
diff --git a/gas/testsuite/gas/all/pr29067.d b/gas/testsuite/gas/all/pr29067.d
new file mode 100644 (file)
index 0000000..17a8eef
--- /dev/null
@@ -0,0 +1,2 @@
+#as: -gsomething-not-already-a-long-option
+#error_output: pr29067.err
diff --git a/gas/testsuite/gas/all/pr29067.err b/gas/testsuite/gas/all/pr29067.err
new file mode 100644 (file)
index 0000000..e5a1b27
--- /dev/null
@@ -0,0 +1,2 @@
+Assembler messages:
+Fatal error: unknown option `-gsomething-not-already-a-long-option'