From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A57DA3858CDB; Mon, 6 Feb 2023 06:14:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A57DA3858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675664065; bh=ky5G5M3EHR3GSUd88D5ehkxFtICoqO7mTLy8Py/EsLI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SOemreES/KR69fqH4/s8xwa1k1BfWLDa5uCq/0heo8W0KNam8r8SnYjR5taH75G3S 9b4ckFfdcnQ+TP+B72HBdzhTCziN452sy2iBbTtm0jImFwM79VrCYw2ysVk9CmUnXw VsqZhsoch5xNVTJ87jCLyAB7FUyQR4S4h4gqSUrc= From: "adrianh.bsc at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/61638] "warning: multi-line comment" unclear and has false positives Date: Mon, 06 Feb 2023 06:14:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Version: unknown X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: adrianh.bsc at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D61638 Jack Adrian Zappa changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |adrianh.bsc at gmail dot c= om --- Comment #9 from Jack Adrian Zappa --- Issue: Cannot turn off the `-Wcomment` option using `#pragma GCC diagnostic igno= red "-Wcomment"`. This is causing issues when I'm trying to document my macr= os and how to write them. Our coding standards at my work state that we are= to use /// for documenting functions/variables/macros and not /** */. I grudgingly tried to use a space after the \, but that didn't work eithe= r. Also inadvertently found that ending with a double backslash (\\) also di= dn't work for some reason, which is odd because the backslash is escaped, so it cannot cause a comment continuation. Suggest fix is to either: 1. Change the phase where this warning/error/ignored is tested so that the #pragma GCC diagnostic is honoured or 2. If a line comment end in an \ but the next line is a comment, then do the same thing as is done for a multi-line comment, ignore it as not an issue. In addition, a line comment ending in an escaped backslash shouldn't cause any issue. It would be also preferable that an escaped whitespace that is not an eol character would be accepted (though it seems that this is unli= kely given bug 8270). GCC versions tested on: 7.5, 11.3 12.2 System type: MSYS2 and whatever is running under godbolt.org Options given: -Wall -Werror Complete command line: g++ -Wall -Werror bug.cpp Source file: $ cat bug.cpp #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcomment" /// #define macro_to_document(x) \ /// blah blah x blah /// /// Also doesn't work with a space after the \ /// as in this case. /// /// Also doesn't work with a double backslash \\ /// as in this case. /// #pragma GCC diagnostic pop Compiler output: $ g++ -v -Wall -Werror -save-temps bug.cpp Using built-in specs. COLLECT_GCC=3Dg++ COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-pc-msys/11.3.0/lto-wrapper.exe Target: x86_64-pc-msys Configured with: /c/S/gcc/src/gcc-11.3.0/configure --build=3Dx86_64-pc-ms= ys --prefix=3D/usr --libexecdir=3D/usr/lib --enable-bootstrap --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-li= bs --with-arch=3Dx86-64 --with-tune=3Dgeneric --disable-multilib --enable-__cx= a_atexit --with-dwarf2 --enable-languages=3Dc,c++,fortran,lto --enable-graphite --enable-threads=3Dposix --enable-libatomic --enable-libgomp --disable-libi= tm --enable-libquadmath --enable-libquadmath-support --disable-libssp --disable-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-check --enable-checking=3Drelease --without-libiconv-= prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=3Dgcc4-compatible --enable-libstdcxx-filesyste= m-ts Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.3.0 (GCC) COLLECT_GCC_OPTIONS=3D'-v' '-Wall' '-Werror' '-save-temps' '-shared-libgc= c' '-mtune=3Dgeneric' '-march=3Dx86-64' '-dumpdir' 'a-' /usr/lib/gcc/x86_64-pc-msys/11.3.0/cc1plus.exe -E -quiet -v -idirafter /usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../lib/../include/w32api -idira= fter /usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/lib/../lib/..= /../include/w32api bug.cpp -mtune=3Dgeneric -march=3Dx86-64 -Wall -Werror -fpch-preprocess -o = a-bug.ii ignoring nonexistent directory "/usr/local/include" ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/include" ignoring duplicate directory "/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/lib/../lib/.= ./../include/w32api" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-pc-msys/11.3.0/include/c++ /usr/lib/gcc/x86_64-pc-msys/11.3.0/include/c++/x86_64-pc-msys /usr/lib/gcc/x86_64-pc-msys/11.3.0/include/c++/backward /usr/lib/gcc/x86_64-pc-msys/11.3.0/include /usr/lib/gcc/x86_64-pc-msys/11.3.0/include-fixed /usr/include /usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../lib/../include/w32api End of search list. bug.cpp:3:1: error: multi-line comment [-Werror=3Dcomment] 3 | /// #define macro_to_document(x) \ | ^ bug.cpp:6:1: error: multi-line comment [-Werror=3Dcomment] 6 | /// Also doesn't work with a space after the \ | ^ bug.cpp:9:1: error: multi-line comment [-Werror=3Dcomment] 9 | /// Also doesn't work with a double backslash \\ | ^ cc1plus: all warnings being treated as errors Preprocessed file: $ cat a-bug.ii # 0 "bug.cpp" # 0 "" # 0 "" # 1 "bug.cpp" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcomment" # 12 "bug.cpp" #pragma GCC diagnostic pop=