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 valid, but not applicable to the current front end.
+
Wcpp
Common Var(warn_cpp) Init(1) Warning
Warn when a #warning directive is encountered.
-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
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, language front ends complain when a command-line option is
+valid, but not applicable to that front end.
+This may be disabled with @option{-Wno-complain-wrong-lang},
+which is mostly useful when invoking a single compiler driver for
+multiple source files written in different languages, for example:
+
+@smallexample
+$ g++ -fno-rtti a.cc b.f90
+@end smallexample
+
+The driver @file{g++} invokes the C++ front end to compile @file{a.cc}
+and the Fortran front end to compile @file{b.f90}.
+The latter front end diagnoses
+@samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran},
+which may be disabled with @option{-Wno-complain-wrong-lang}.
+
@item -Wconversion
@opindex Wconversion
@opindex Wno-conversion
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,
= 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. */
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;
}
}
- 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);
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;
// { 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);
// { 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);
// { 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);
// { 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);
// { 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);
// { 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);
// { 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);
// { 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);
// { 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);
// { 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);
// { 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);
--- /dev/null
+/* { 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 } */
--- /dev/null
+/* { 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 } */
--- /dev/null
+/* { 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 } */
--- /dev/null
+/* { 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 } */
--- /dev/null
+/* { 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 } */
! { 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'
!
! { 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'
! { 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'
} 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 }
! { 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
! { 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
! { 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
! { 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
! { 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
! { 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
! { 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
! { 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
! { 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
! { 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
! { 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
! { 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)
! { 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
! { 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
! { 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.
! 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" }