From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 29C163858C42; Sun, 31 Dec 2023 12:34:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29C163858C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704026096; bh=1iL3fRsQUKlJAa/JED7eRU36auG2u8AwGj+9nk/DovA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=i3rcqiGy/NtCrXg4b//rTP6a26wJfoc+ZCl7snEvdgUvXCIitDlOcxe0KB44peOsb 46Yf8O0OAq2wjCZndOSGbP1Yt5GQpJ1bUs26XwFk4wRvhCccCvewmEI+Aj9stZRZxN +pQ0mEWOH/f40+tI1aJRng8ryNBzjunRspsqU2g8= From: "y.koj.eel at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/86440] -Wignored-qualifiers diagnostic highlights wrong token with pointer Date: Sun, 31 Dec 2023 12:34:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 8.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: y.koj.eel 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=3D86440 Yohei Kojima changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |y.koj.eel at gmail dot com --- Comment #3 from Yohei Kojima --- gcc 13.2.0 reports warnings as follows: $ g++ -Wignored-qualifiers -c a.cc a.cc:1:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] 1 | int const f() { return 0; } | ^~~ a.cc:3:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] 3 | int * const g() { return 0; } | ^~~ Also, with the following C source b.c, gcc reports errors at the wrong confusing location. $ cat b.c void f(void *const (*)(void)) { } void g(void *const (*h)(void)) { } The reported error was like below. Error report on g() is fine, but gcc points to the return type of outer function on f(), which was confu= sing to me. $ gcc -c -Wignored-qualifiers b.c b.c:1:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] 1 | void f(void *const (*)(void)) { | ^~~~ b.c:4:22: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] 4 | void g(void *const (*h)(void)) { | ^ Tested environment is gcc 13.2.0 on Docker (The current latest release available from https://hub.docker.com/_/gcc): $ gcc -v Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/local/libexec/gcc/x86_64-linux-gnu/13.2.0/lto-wr= apper Target: x86_64-linux-gnu Configured with: /usr/src/gcc/configure --build=3Dx86_64-linux-gnu --disable-multilib --enable-languages=3Dc,c++,fortran,go Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.0 (GCC)=20 I'm interested in fixing this bug, and I've started digging into the code.=