In mixed-language builds it may be difficult to restrict -gctf to only
C-language sources. However, the
cc1plus: note: CTF debug info requested, but not supported for ‘GNU C++17’
frontend
warning for non-C languages, which is perfectly benign, may confuse
parts of the build, so it may be useful to disable it.
This patch applies the existing -Wno-complain-wrong-lang option to
suppress it.
Bootstrapped without regressions on i386-pc-solaris2.11
sparc-sun-solaris2.11, also with C/C++-only bootstraps that apply
-gctf/-gsctf via STAGE[23]_CFLAGS and STAGE[23]_TFLAGS.
Ok for trunk?
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2025-12-25 Rainer Orth <[email protected]>
gcc:
PR debug/123259
* toplev.cc (process_options): Guard CTF non-C warning by
-Wcomplain-wrong-lang.
* doc/invoke.texi (Warning Options, -Wno-complain-wrong-lang):
Document effect on -gctf/-gsctf.
# HG changeset patch
# Parent a5ab56979f2c647aea11113bff88ddccba879968
Allow disabling -gctf non-C warning [PR123259]
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -10153,6 +10153,10 @@ 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}.
+This option can also be used to disable warnings like
+@samp{cc1plus: note: CTF debug info requested, but not supported for 'GNU C++20' frontend}
+produced by @option{-gctf} or @option{-gsctf} for unsupported languages.
+
@opindex Wcompare-distinct-pointer-types
@item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)}
Warn if pointers of distinct types are compared without a cast. This
diff --git a/gcc/toplev.cc b/gcc/toplev.cc
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -1436,7 +1436,8 @@ process_options ()
/* CTF is supported for only C at this time. */
if (!lang_GNU_C ()
- && ctf_debug_info_level > CTFINFO_LEVEL_NONE)
+ && ctf_debug_info_level > CTFINFO_LEVEL_NONE
+ && warn_complain_wrong_lang)
{
/* Compiling with -flto results in frontend language of GNU GIMPLE. It
is not useful to warn in that case. */