]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d,ada/spec: only sub nostd{inc,lib} rather than nostd{inc,lib}*
authorArsen Arsenović <arsen@aarsen.me>
Mon, 2 Sep 2024 19:29:53 +0000 (21:29 +0200)
committerArsen Arsenović <arsen@gcc.gnu.org>
Wed, 22 Jan 2025 19:11:24 +0000 (20:11 +0100)
This prevents the gcc driver erroneously accepting -nostdlib++ when it
should not when Ada was enabled.

Also, similarly, -nostdinc* (where * is nonempty) is unhandled by either
the Ada or D compiler, so the spec should not substitute those
either (thanks for pointing that out, Jakub).

Brought to my attention by Michał Górny <mgorny@gentoo.org>.

gcc/ada/ChangeLog:

* gcc-interface/lang-specs.h: Replace %{nostdinc*} %{nostdlib*}
with %{nostdinc} %{nostdlib}.

gcc/d/ChangeLog:

* lang-specs.h: Replace %{nostdinc*} with %{nostdinc}.

gcc/testsuite/ChangeLog:

* gcc.dg/driver-nostdlibstar.c: New test.

gcc/ada/gcc-interface/lang-specs.h
gcc/d/lang-specs.h
gcc/testsuite/gcc.dg/driver-nostdlibstar.c [new file with mode: 0644]

index 2ba0f1d20a7427361d9807a25eaff89824ec5a4e..bfa41afe621b145e9a8c0e080c2b3a5da0b2a313 100644 (file)
@@ -37,7 +37,7 @@
  %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
  %{!S:%{!c:%e-c or -S required for Ada}}\
  gnat1 %{I*} %{k8:-gnatk8} %{!Q:-quiet}\
-    %{nostdinc*} %{nostdlib*}\
+    %{nostdinc} %{nostdlib}\
     %{fcompare-debug-second:-gnatd_A} \
     %{O*} %{W*} %{w} %{p} %{pg:-p} " ADA_DUMPS_OPTIONS " \
     %{coverage:-fprofile-arcs -ftest-coverage} "
@@ -55,7 +55,7 @@
    "\
  %{!c:%e-c required for gnat2why}\
  gnat1why %{I*} %{k8:-gnatk8} %{!Q:-quiet}\
-    %{nostdinc*} %{nostdlib*}\
+    %{nostdinc} %{nostdlib}\
     %{a} " ADA_DUMPS_OPTIONS " \
     %{gnatea:-gnatez} %{g*&m*&f*} \
     %1 %{o*:%w%*-gnatO} \
@@ -66,7 +66,7 @@
    "\
  %{!c:%e-c required for gnat2scil}\
  gnat1scil %{I*} %{k8:-gnatk8} %{!Q:-quiet}\
-    %{nostdinc*} %{nostdlib*}\
+    %{nostdinc} %{nostdlib}\
     %{a} " ADA_DUMPS_OPTIONS " \
     %{gnatea:-gnatez} %{g*&m*&f*} \
     %1 %{o*:%w%*-gnatO} \
index 2292e7eac9fae3714ce6912932f5cb3dd85d2de6..64e7a5f259884460303bb80ff26af47609ebeca1 100644 (file)
@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 {".dd", "@d", 0, 1, 0 },
 {".di", "@d", 0, 1, 0 },
 {"@d",
-  "%{!E:d21 %i %(cc1_options) %I %{nostdinc*} %{i*} %{I*} %{J*} \
+  "%{!E:d21 %i %(cc1_options) %I %{nostdinc} %{i*} %{I*} %{J*} \
     %{H} %{Hd*} %{Hf*} %{MD:-MD %b.deps} %{MMD:-MMD %b.deps} \
     %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*} \
     %{X:-Xf %b.json} %{Xf*} \
diff --git a/gcc/testsuite/gcc.dg/driver-nostdlibstar.c b/gcc/testsuite/gcc.dg/driver-nostdlibstar.c
new file mode 100644 (file)
index 0000000..b3b2082
--- /dev/null
@@ -0,0 +1,4 @@
+// Test that the GCC driver (which has no concept of libstdc++) rejects -nostdlib++
+// { dg-additional-options "-nostdlib++" }
+// { dg-prune-output "compilation terminated" }
+// { dg-error "unrecognized command-line option '-nostdlib\\+\\+'" "" { target *-*-* } 0 }