Hi!
On 2022-12-15T16:17:05+0100, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Dec 15, 2022 at 04:01:33PM +0100, Thomas Schwinge wrote:
>> Or, options are applicable to just one front end, and can just be a no-op
>> for others, for shared-language compilation. For example, '-nostdinc++',
>> or '-frust-incomplete-and-experimental-compiler-do-not-use' need not
>> necessarily emit a diagnostic, but can just just be ignored by 'cc1',
>> 'f951', 'lto1'.
>
> One simple change could be to add a new warning option and use it for
> complain_wrong_lang warnings:
> else if (ok_langs[0] != '\0')
> /* Eventually this should become a hard error IMO. */
> warning (0, "command-line option %qs is valid for %s but not for %s",
> text, ok_langs, bad_lang);
(By the way, that comment was originally added in 2003-06-07
commit 2772ef3ef33609dd64209323e9418a847685971a
"Move handling of lang-specific switches to toplev".)
> else
> /* Happens for -Werror=warning_name. */
> warning (0, "%<-Werror=%> argument %qs is not valid for %s",
> text, bad_lang);
> We could keep the existing behavior, but give users (and our testsuite)
> a way to silence that warning if they are ok with it applying only to a
> subset of languages.
> Then one could use
> -frust-incomplete-and-experimental-compiler-do-not-use -Wno-whatever
> or add that -Wno-whatever in check_compile if the snippet is different
> language from main language of the testsuite (or always) etc.
Like in the attaached
"Add '-Wno-complain-wrong-lang', and use it in 'gcc/testsuite/lib/target-supports.exp:check_compile' and elsewhere",
for example?
Anything that 'gcc/opts-global.cc:complain_wrong_lang' might do is cut
short by '-Wno-complain-wrong-lang', not just the one 'warning'
diagnostic. This corresponds to what already exists via
'lang_hooks.complain_wrong_lang_p'.
The 'gcc/opts-common.cc:prune_options' changes follow the same rationale
as PR67640 "driver passes -fdiagnostics-color= always last": we need to
process '-Wno-complain-wrong-lang' early, so that it properly affects
other options appearing before it on the command line.
In the test suites, a number of existing test cases explicitly match the
"command-line option [...] is valid for [...] but not for [...]"
diagnostic with 'dg-warning'; I've left those alone. On the other hand,
I've changed 'dg-prune-output' of this diagnostic into
'-Wno-complain-wrong-lang' usage. I'm happy to adjust that in either way
anyone may prefer. I've not looked for test cases that just to silence
this diagnostic use more general 'dg-prune-output', 'dg-excess-errors',
'-w', etc.
In the GCC/D test suite, I see a number of:
cc1plus: warning: command-line option '-fpreview=in' is valid for D but not for C++
cc1plus: warning: command-line option '-fextern-std=c++11' is valid for D but not for C++
It's not clear to me how they, despite this, do achieve
'PASS: [...] (test for excess errors)'? Maybe I haven't found where that
gets pruned/ignored?
In addition to the test suites, I'm also seeing:
build-gcc/build-x86_64-pc-linux-gnu/libcpp/config.log:cc1: warning: command line option '-fno-rtti' is valid for C++/ObjC++ but not for C [enabled by default]
build-gcc/gcc/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/gcc/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/libbacktrace/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/libcc1/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/libcpp/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/lto-plugin/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libatomic/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libbacktrace/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libffi/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libgfortran/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libgo/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libgomp/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libitm/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libobjc/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libphobos/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libquadmath/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libsanitizer/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libssp/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libstdc++-v3/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/libvtv/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/x86_64-pc-linux-gnu/zlib/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
build-gcc/zlib/config.log:cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
(Trimmed down.)
Maybe there's a point to be made about fixing those (all the same:
'-fno-rtti'?), and then "Eventually this should become a hard error IMO"
(see above) implemented -- at least for GCC-internal use (for example,
via '-Wcomplain-wrong-lang=error', set during GCC bootstrap)? (I still
don't have a strong opinion.)
Grüße
Thomas
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
From e248eade7540923962878e1442a0d96e70506318 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Wed, 14 Dec 2022 17:16:42 +0100
Subject: [PATCH] Add '-Wno-complain-wrong-lang', and use it in
'gcc/testsuite/lib/target-supports.exp:check_compile' and elsewhere
I noticed that GCC/Rust recently lost all LTO variants in torture testing:
PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O0 (test for excess errors)
PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O1 (test for excess errors)
PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O2 (test for excess errors)
-PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors)
-PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors)
PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O3 -g (test for excess errors)
PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -Os (test for excess errors)
Etc.
The reason is that when probing for availability of LTO, we run into:
spawn [...]/build-gcc/gcc/testsuite/rust/../../gccrs -B[...]/build-gcc/gcc/testsuite/rust/../../ -fdiagnostics-plain-output -frust-incomplete-and-experimental-compiler-do-not-use -flto -c -o lto8274.o lto8274.c
cc1: warning: command-line option '-frust-incomplete-and-experimental-compiler-do-not-use' is valid for Rust but not for C
For GCC/Rust testing, this flag is (as of recently) defaulted in
'gcc/testsuite/lib/rust.exp:rust_init':
lappend ALWAYS_RUSTFLAGS "additional_flags=-frust-incomplete-and-experimental-compiler-do-not-use"
A few more "command-line option [...] is valid for [...] but not for [...]"
issues were found in the test suite logs, when more than one language is
involved.
With '-Wno-complain-wrong-lang' used in
'gcc/testsuite/lib/target-supports.exp:check_compile', we get back:
PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O0 (test for excess errors)
PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O1 (test for excess errors)
PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O2 (test for excess errors)
+PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O2 -flto -fno-use-linker-plugin -flto-partition=none (test for excess errors)
+PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects (test for excess errors)
PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -O3 -g (test for excess errors)
PASS: rust/compile/torture/all_doc_comment_line_blocks.rs -Os (test for excess errors)
Etc., and in total:
=== rust Summary for unix ===
# of expected passes [-4990-]{+6718+}
# of expected failures [-39-]{+51+}
The 'gcc/opts-common.cc:prune_options' changes follow the same rationale as
PR67640 "driver passes -fdiagnostics-color= always last": we need to process
'-Wno-complain-wrong-lang' first, so that it properly affect other options
appearing before it on the command line.
gcc/
* common.opt (-Wcomplain-wrong-lang): New.
* doc/invoke.texi (-Wno-complain-wrong-lang): Document it.
* opts-common.cc (prune_options): Handle it.
* opts-global.cc (complain_wrong_lang): Use it.
gcc/testsuite/
* gcc.dg/Wcomplain-wrong-lang-1.c: New.
* gcc.dg/Wcomplain-wrong-lang-2.c: Likewise.
* gcc.dg/Wcomplain-wrong-lang-3.c: Likewise.
* gcc.dg/Wcomplain-wrong-lang-4.c: Likewise.
* gcc.dg/Wcomplain-wrong-lang-5.c: Likewise.
* lib/target-supports.exp (check_compile): Use
'-Wno-complain-wrong-lang'.
* g++.dg/abi/empty12.C: Likewise.
* g++.dg/abi/empty13.C: Likewise.
* g++.dg/abi/empty14.C: Likewise.
* g++.dg/abi/empty15.C: Likewise.
* g++.dg/abi/empty16.C: Likewise.
* g++.dg/abi/empty17.C: Likewise.
* g++.dg/abi/empty18.C: Likewise.
* g++.dg/abi/empty19.C: Likewise.
* g++.dg/abi/empty22.C: Likewise.
* g++.dg/abi/empty25.C: Likewise.
* g++.dg/abi/empty26.C: Likewise.
* gfortran.dg/bind-c-contiguous-1.f90: Likewise.
* gfortran.dg/bind-c-contiguous-4.f90: Likewise.
* gfortran.dg/bind-c-contiguous-5.f90: Likewise.
libgomp/
* testsuite/libgomp.fortran/alloc-10.f90: Use
'-Wno-complain-wrong-lang'.
* testsuite/libgomp.fortran/alloc-11.f90: Likewise.
* testsuite/libgomp.fortran/alloc-7.f90: Likewise.
* testsuite/libgomp.fortran/alloc-9.f90: Likewise.
* testsuite/libgomp.fortran/allocate-1.f90: Likewise.
* testsuite/libgomp.fortran/depend-4.f90: Likewise.
* testsuite/libgomp.fortran/depend-5.f90: Likewise.
* testsuite/libgomp.fortran/depend-6.f90: Likewise.
* testsuite/libgomp.fortran/depend-7.f90: Likewise.
* testsuite/libgomp.fortran/depend-inoutset-1.f90: Likewise.
* testsuite/libgomp.fortran/examples-4/declare_target-1.f90:
Likewise.
* testsuite/libgomp.fortran/examples-4/declare_target-2.f90:
Likewise.
* testsuite/libgomp.fortran/order-reproducible-1.f90: Likewise.
* testsuite/libgomp.fortran/order-reproducible-2.f90: Likewise.
* testsuite/libgomp.oacc-fortran/parallel-dims.f90: Likewise.
* testsuite/libgomp.fortran/task-detach-6.f90: Remove left-over
'dg-prune-output'.
---
gcc/common.opt | 4 ++
gcc/doc/invoke.texi | 8 ++++
gcc/opts-common.cc | 46 +++++++++++++++----
gcc/opts-global.cc | 3 ++
gcc/testsuite/g++.dg/abi/empty12.C | 2 +-
gcc/testsuite/g++.dg/abi/empty13.C | 2 +-
gcc/testsuite/g++.dg/abi/empty14.C | 2 +-
gcc/testsuite/g++.dg/abi/empty15.C | 2 +-
gcc/testsuite/g++.dg/abi/empty16.C | 2 +-
gcc/testsuite/g++.dg/abi/empty17.C | 2 +-
gcc/testsuite/g++.dg/abi/empty18.C | 2 +-
gcc/testsuite/g++.dg/abi/empty19.C | 2 +-
gcc/testsuite/g++.dg/abi/empty22.C | 2 +-
gcc/testsuite/g++.dg/abi/empty25.C | 2 +-
gcc/testsuite/g++.dg/abi/empty26.C | 2 +-
gcc/testsuite/gcc.dg/Wcomplain-wrong-lang-1.c | 2 +
gcc/testsuite/gcc.dg/Wcomplain-wrong-lang-2.c | 2 +
gcc/testsuite/gcc.dg/Wcomplain-wrong-lang-3.c | 2 +
gcc/testsuite/gcc.dg/Wcomplain-wrong-lang-4.c | 2 +
gcc/testsuite/gcc.dg/Wcomplain-wrong-lang-5.c | 2 +
.../gfortran.dg/bind-c-contiguous-1.f90 | 2 +-
.../gfortran.dg/bind-c-contiguous-4.f90 | 2 +-
.../gfortran.dg/bind-c-contiguous-5.f90 | 2 +-
gcc/testsuite/lib/target-supports.exp | 4 ++
.../testsuite/libgomp.fortran/alloc-10.f90 | 3 +-
.../testsuite/libgomp.fortran/alloc-11.f90 | 3 +-
libgomp/testsuite/libgomp.fortran/alloc-7.f90 | 3 +-
libgomp/testsuite/libgomp.fortran/alloc-9.f90 | 3 +-
.../testsuite/libgomp.fortran/allocate-1.f90 | 2 +-
.../testsuite/libgomp.fortran/depend-4.f90 | 2 +-
.../testsuite/libgomp.fortran/depend-5.f90 | 2 +-
.../testsuite/libgomp.fortran/depend-6.f90 | 2 +-
.../testsuite/libgomp.fortran/depend-7.f90 | 2 +-
.../libgomp.fortran/depend-inoutset-1.f90 | 2 +-
.../examples-4/declare_target-1.f90 | 2 +-
.../examples-4/declare_target-2.f90 | 2 +-
.../libgomp.fortran/order-reproducible-1.f90 | 3 +-
.../libgomp.fortran/order-reproducible-2.f90 | 3 +-
.../libgomp.fortran/task-detach-6.f90 | 2 -
.../libgomp.oacc-fortran/parallel-dims.f90 | 2 +-
40 files changed, 100 insertions(+), 41 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/Wcomplain-wrong-lang-1.c
create mode 100644 gcc/testsuite/gcc.dg/Wcomplain-wrong-lang-2.c
create mode 100644 gcc/testsuite/gcc.dg/Wcomplain-wrong-lang-3.c
create mode 100644 gcc/testsuite/gcc.dg/Wcomplain-wrong-lang-4.c
create mode 100644 gcc/testsuite/gcc.dg/Wcomplain-wrong-lang-5.c
@@ -582,6 +582,10 @@ Wcast-align=strict
Common Var(warn_cast_align,2) Warning
Warn about pointer casts which increase alignment.
+Wcomplain-wrong-lang
+Common Var(warn_complain_wrong_lang) Init(1) Warning
+Complain when a command-line option is not valid for this front end.
+
Wcpp
Common Var(warn_cpp) Init(1) Warning
Warn when a #warning directive is encountered.
@@ -343,6 +343,7 @@ Objective-C and Objective-C++ Dialects}.
-Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual @gol
-Wchar-subscripts @gol
-Wclobbered -Wcomment @gol
+-Wno-complain-wrong-lang @gol
-Wconversion -Wno-coverage-mismatch -Wno-cpp @gol
-Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n} @gol
-Wdate-time @gol
@@ -8896,6 +8897,13 @@ programs.
Warn for variables that might be changed by @code{longjmp} or
@code{vfork}. This warning is also enabled by @option{-Wextra}.
+@item -Wno-complain-wrong-lang
+@opindex Wcomplain-wrong-lang
+@opindex Wno-complain-wrong-lang
+By default, we complain about command-line options that are not valid
+for this front end.
+This may be disabled with @code{-Wno-complain-wrong-lang}.
+
@item -Wconversion
@opindex Wconversion
@opindex Wno-conversion
@@ -1112,7 +1112,8 @@ cancel_option (int opt_idx, int next_opt_idx, int orig_next_opt_idx)
return false;
}
-/* Filter out options canceled by the ones after them. */
+/* Filter out options canceled by the ones after them, and related
+ rearrangement. */
static void
prune_options (struct cl_decoded_option **decoded_options,
@@ -1125,6 +1126,8 @@ prune_options (struct cl_decoded_option **decoded_options,
= XNEWVEC (struct cl_decoded_option, old_decoded_options_count);
unsigned int i;
const struct cl_option *option;
+ unsigned int options_to_prepend = 0;
+ unsigned int Wcomplain_wrong_lang_idx = 0;
unsigned int fdiagnostics_color_idx = 0;
/* Remove arguments which are negated by others after them. */
@@ -1146,8 +1149,17 @@ prune_options (struct cl_decoded_option **decoded_options,
case OPT_SPECIAL_input_file:
goto keep;
- /* Do not save OPT_fdiagnostics_color_, just remember the last one. */
+ /* Do not handle the following yet, just remember the last one. */
+ case OPT_Wcomplain_wrong_lang:
+ gcc_checking_assert (i != 0);
+ if (Wcomplain_wrong_lang_idx == 0)
+ ++options_to_prepend;
+ Wcomplain_wrong_lang_idx = i;
+ continue;
case OPT_fdiagnostics_color_:
+ gcc_checking_assert (i != 0);
+ if (fdiagnostics_color_idx == 0)
+ ++options_to_prepend;
fdiagnostics_color_idx = i;
continue;
@@ -1191,15 +1203,29 @@ keep:
}
}
- if (fdiagnostics_color_idx >= 1)
+ /* For those not yet handled, put (only) the last at a front position after
+ 'argv[0]', so they can take effect immediately. */
+ if (options_to_prepend)
{
- /* We put the last -fdiagnostics-color= at the first position
- after argv[0] so it can take effect immediately. */
- memmove (new_decoded_options + 2, new_decoded_options + 1,
- sizeof (struct cl_decoded_option)
- * (new_decoded_options_count - 1));
- new_decoded_options[1] = old_decoded_options[fdiagnostics_color_idx];
- new_decoded_options_count++;
+ const unsigned int argv_0 = 1;
+ memmove (new_decoded_options + argv_0 + options_to_prepend,
+ new_decoded_options + argv_0,
+ sizeof (struct cl_decoded_option)
+ * (new_decoded_options_count - argv_0));
+ unsigned int options_prepended = 0;
+ if (Wcomplain_wrong_lang_idx != 0)
+ {
+ new_decoded_options[argv_0 + options_prepended++]
+ = old_decoded_options[Wcomplain_wrong_lang_idx];
+ new_decoded_options_count++;
+ }
+ if (fdiagnostics_color_idx != 0)
+ {
+ new_decoded_options[argv_0 + options_prepended++]
+ = old_decoded_options[fdiagnostics_color_idx];
+ new_decoded_options_count++;
+ }
+ gcc_checking_assert (options_to_prepend == options_prepended);
}
free (old_decoded_options);
@@ -91,6 +91,9 @@ complain_wrong_lang (const struct cl_decoded_option *decoded,
char *ok_langs = NULL, *bad_lang = NULL;
unsigned int opt_flags = option->flags;
+ if (!warn_complain_wrong_lang)
+ return;
+
if (!lang_hooks.complain_wrong_lang_p (option))
return;
@@ -2,7 +2,7 @@
// { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } }
// { dg-options "-Wabi=11 -x c" }
// { dg-additional-sources "empty12a.c" }
-// { dg-prune-output "command-line option" }
+// { dg-additional-options -Wno-complain-wrong-lang }
#include "empty12.h"
extern "C" void fun(struct dummy, struct foo);
@@ -2,7 +2,7 @@
// { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } }
// { dg-options "-x c -fabi-version=11" }
// { dg-additional-sources "empty13a.c" }
-// { dg-prune-output "command-line option" }
+// { dg-additional-options -Wno-complain-wrong-lang }
#include "empty13.h"
extern "C" void fun(struct dummy, struct foo);
@@ -2,7 +2,7 @@
// { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } }
// { dg-options "-Wabi=11 -x c" }
// { dg-additional-sources "empty14a.c" }
-// { dg-prune-output "command-line option" }
+// { dg-additional-options -Wno-complain-wrong-lang }
#include "empty14.h"
extern "C" void fun(struct dummy, struct foo);
@@ -2,7 +2,7 @@
// { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } }
// { dg-options "-Wabi=11 -x c" }
// { dg-additional-sources "empty15a.c" }
-// { dg-prune-output "command-line option" }
+// { dg-additional-options -Wno-complain-wrong-lang }
#include "empty15.h"
extern "C" void fun(struct dummy, struct foo);
@@ -2,7 +2,7 @@
// { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } }
// { dg-options "-Wabi=11 -x c" }
// { dg-additional-sources "empty16a.c" }
-// { dg-prune-output "command-line option" }
+// { dg-additional-options -Wno-complain-wrong-lang }
#include "empty16.h"
extern "C" void fun(struct dummy, struct foo);
@@ -2,7 +2,7 @@
// { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } }
// { dg-options "-Wabi=11 -x c" }
// { dg-additional-sources "empty17a.c" }
-// { dg-prune-output "command-line option" }
+// { dg-additional-options -Wno-complain-wrong-lang }
#include "empty17.h"
extern "C" void fun(struct dummy, struct foo);
@@ -2,7 +2,7 @@
// { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } }
// { dg-options "-Wabi=11 -x c" }
// { dg-additional-sources "empty18a.c" }
-// { dg-prune-output "command-line option" }
+// { dg-additional-options -Wno-complain-wrong-lang }
#include "empty18.h"
extern "C" void fun(struct dummy, struct foo);
@@ -2,7 +2,7 @@
// { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } }
// { dg-options "-Wabi=11 -x c" }
// { dg-additional-sources "empty19a.c" }
-// { dg-prune-output "command-line option" }
+// { dg-additional-options -Wno-complain-wrong-lang }
#include "empty19.h"
extern "C" void fun(struct dummy, struct foo);
@@ -2,7 +2,7 @@
// { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } }
// { dg-options "-Wabi=11 -x c" }
// { dg-additional-sources "empty22a.c" }
-// { dg-prune-output "command-line option" }
+// { dg-additional-options -Wno-complain-wrong-lang }
#include "empty22.h"
extern "C" void fun(struct dummy, struct foo);
@@ -2,7 +2,7 @@
// { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } }
// { dg-options "-Wabi=11 -x c" }
// { dg-additional-sources "empty25a.c" }
-// { dg-prune-output "command-line option" }
+// { dg-additional-options -Wno-complain-wrong-lang }
#include "empty25.h"
extern "C" void fun(struct dummy, struct foo);
@@ -2,7 +2,7 @@
// { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } }
// { dg-options "-Wabi=11 -x c" }
// { dg-additional-sources "empty26a.c" }
-// { dg-prune-output "command-line option" }
+// { dg-additional-options -Wno-complain-wrong-lang }
#include "empty26.h"
extern "C" void fun(struct dummy, struct foo);
new file mode 100644
@@ -0,0 +1,2 @@
+/* { dg-options -Wctad-maybe-unsupported } and '-Wcomplain-wrong-lang' enabled by default:
+ { dg-warning {command-line option '-Wctad-maybe-unsupported' is valid for C\+\+/ObjC\+\+ but not for C} {} { target *-*-* } 0 } */
new file mode 100644
@@ -0,0 +1,2 @@
+/* { dg-options {-Wcomplain-wrong-lang -Wctad-maybe-unsupported} }
+ { dg-warning {command-line option '-Wctad-maybe-unsupported' is valid for C\+\+/ObjC\+\+ but not for C} {} { target *-*-* } 0 } */
new file mode 100644
@@ -0,0 +1,2 @@
+/* { dg-options {-Wctad-maybe-unsupported -Wno-complain-wrong-lang} }
+ { dg-bogus {command-line option '-Wctad-maybe-unsupported' is valid for C\+\+/ObjC\+\+ but not for C} {} { target *-*-* } 0 } */
new file mode 100644
@@ -0,0 +1,2 @@
+/* { dg-options {-Wno-complain-wrong-lang -Wctad-maybe-unsupported} }
+ { dg-bogus {command-line option '-Wctad-maybe-unsupported' is valid for C\+\+/ObjC\+\+ but not for C} {} { target *-*-* } 0 } */
new file mode 100644
@@ -0,0 +1,2 @@
+/* { dg-options {-Wcomplain-wrong-lang -Wctad-maybe-unsupported -Wno-complain-wrong-lang} }
+ { dg-bogus {command-line option '-Wctad-maybe-unsupported' is valid for C\+\+/ObjC\+\+ but not for C} {} { target *-*-* } 0 } */
@@ -1,7 +1,7 @@
! { dg-do run }
! { dg-additional-sources bind-c-contiguous-1.c }
! { dg-additional-options "-fcheck=all" }
-! { dg-prune-output "command-line option '-fcheck=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
! Fortran demands that with bind(C), the callee ensure that for
! * 'contiguous'
@@ -4,7 +4,7 @@
!
! { dg-additional-sources bind-c-contiguous-4.c }
! { dg-additional-options "-fcheck=all" }
-! { dg-prune-output "command-line option '-fcheck=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
! Fortran demands that with bind(C), the callee ensure that for
! * 'contiguous'
@@ -1,7 +1,7 @@
! { dg-do run }
! { dg-additional-sources bind-c-contiguous-5.c }
! { dg-additional-options "-fcheck=all" }
-! { dg-prune-output "command-line option '-fcheck=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
! ---- Same as bind-c-contiguous-1.f90 - but with kind=4 characters
! Fortran demands that with bind(C), the callee ensure that for
! * 'contiguous'
@@ -57,6 +57,10 @@ proc check_compile {basename type contents args} {
} else {
set options ""
}
+ # Silence "command-line option [...] is valid for [...] but not for [...]"
+ # that we may easily run into here, if more than one language is involved.
+ lappend options additional_flags=-Wno-complain-wrong-lang
+
switch -glob -- $contents {
"*/* Assembly*" { set src ${basename}[pid].S }
"*! Fortran*" { set src ${basename}[pid].f90 }
@@ -1,5 +1,6 @@
! { dg-additional-sources alloc-7.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
+
module m
use omp_lib
use iso_c_binding
@@ -1,5 +1,6 @@
! { dg-additional-sources alloc-7.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
+
module m
use omp_lib
use iso_c_binding
@@ -1,5 +1,6 @@
! { dg-additional-sources alloc-7.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
+
module m
use omp_lib
use iso_c_binding
@@ -1,5 +1,6 @@
! { dg-additional-sources alloc-7.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
+
module m
use omp_lib
use iso_c_binding
@@ -1,6 +1,6 @@
! { dg-do run }
! { dg-additional-sources allocate-1.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
module m
use omp_lib
@@ -1,7 +1,7 @@
! { dg-additional-options "-fdump-tree-gimple" }
!
! { dg-additional-sources my-usleep.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
!
! Ensure that 'depend(...: var)' and 'depobj(...) depend(...: var)'
! depend on the same variable when 'var' is a pointer
@@ -1,5 +1,5 @@
! { dg-additional-sources my-usleep.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
module m
implicit none
@@ -1,5 +1,5 @@
! { dg-additional-sources my-usleep.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
module m
use omp_lib
@@ -1,5 +1,5 @@
! { dg-additional-sources my-usleep.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
program main
implicit none
@@ -1,5 +1,5 @@
! { dg-additional-sources my-usleep.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
program main
use omp_lib
@@ -1,6 +1,6 @@
! { dg-do run }
! { dg-additional-sources ../on_device_arch.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
module e_53_1_mod
integer :: THRESHOLD = 20
@@ -1,6 +1,6 @@
! { dg-do run }
! { dg-additional-sources ../on_device_arch.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
program e_53_2
!$omp declare target (fib)
@@ -1,5 +1,6 @@
! { dg-additional-sources my-usleep.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
+
program main
implicit none
interface
@@ -1,5 +1,6 @@
! { dg-additional-sources my-usleep.c }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
+! { dg-additional-options -Wno-complain-wrong-lang }
+
program main
implicit none
interface
@@ -1,7 +1,5 @@
! { dg-do run }
- ! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
-
! Test tasks with detach clause on an offload device. Each device
! thread spawns off a chain of tasks, that can then be executed by
! any available thread.
@@ -2,8 +2,8 @@
! vector_length.
! { dg-additional-sources parallel-dims-aux.c }
+! { dg-additional-options -Wno-complain-wrong-lang }
! { dg-do run }
-! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
! { dg-additional-options "-DEXPENSIVE" { target run_expensive_tests } }
! { dg-additional-options "-cpp" }
--
2.25.1