public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/86440] -Wignored-qualifiers diagnostic highlights wrong token with pointer
       [not found] <bug-86440-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-19 21:51 ` nightstrike at gmail dot com
  2023-12-31 12:34 ` y.koj.eel at gmail dot com
  2023-12-31 12:43 ` y.koj.eel at gmail dot com
  2 siblings, 0 replies; 3+ messages in thread
From: nightstrike at gmail dot com @ 2021-08-19 21:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86440

--- Comment #2 from nightstrike <nightstrike at gmail dot com> ---
gcc 11.2 changes it somewhat:

a.c:1:5: warning: type qualifiers ignored on function return type
[-Wignored-qualifiers]
    1 | int const f() { return 0; }
      |     ^~~~~
a.c:3:13: warning: type qualifiers ignored on function return type
[-Wignored-qualifiers]
    3 | int * const g() { return 0; }
      |             ^

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/86440] -Wignored-qualifiers diagnostic highlights wrong token with pointer
       [not found] <bug-86440-4@http.gcc.gnu.org/bugzilla/>
  2021-08-19 21:51 ` [Bug c++/86440] -Wignored-qualifiers diagnostic highlights wrong token with pointer nightstrike at gmail dot com
@ 2023-12-31 12:34 ` y.koj.eel at gmail dot com
  2023-12-31 12:43 ` y.koj.eel at gmail dot com
  2 siblings, 0 replies; 3+ messages in thread
From: y.koj.eel at gmail dot com @ 2023-12-31 12:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86440

Yohei Kojima <y.koj.eel at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |y.koj.eel at gmail dot com

--- Comment #3 from Yohei Kojima <y.koj.eel at gmail dot com> ---
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 confusing
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=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-linux-gnu/13.2.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: /usr/src/gcc/configure --build=x86_64-linux-gnu
--disable-multilib --enable-languages=c,c++,fortran,go
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (GCC) 

I'm interested in fixing this bug, and I've started digging into the code.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/86440] -Wignored-qualifiers diagnostic highlights wrong token with pointer
       [not found] <bug-86440-4@http.gcc.gnu.org/bugzilla/>
  2021-08-19 21:51 ` [Bug c++/86440] -Wignored-qualifiers diagnostic highlights wrong token with pointer nightstrike at gmail dot com
  2023-12-31 12:34 ` y.koj.eel at gmail dot com
@ 2023-12-31 12:43 ` y.koj.eel at gmail dot com
  2 siblings, 0 replies; 3+ messages in thread
From: y.koj.eel at gmail dot com @ 2023-12-31 12:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86440

--- Comment #4 from Yohei Kojima <y.koj.eel at gmail dot com> ---
Also, -Wignored-qualifiers messages disappeared with g++ compiling b.c.
Probably it is a bug caused by the same reason as this bug.

$ g++ -c -Wall -Wextra -Wignored-qualifiers b.c
b.c: In function 'void g(void* const (*)())':
b.c:4:22: warning: unused parameter 'h' [-Wunused-parameter]
    4 | void g(void *const (*h)(void)) {
      |        ~~~~~~~~~~~~~~^~~~~~~~

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-31 12:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-86440-4@http.gcc.gnu.org/bugzilla/>
2021-08-19 21:51 ` [Bug c++/86440] -Wignored-qualifiers diagnostic highlights wrong token with pointer nightstrike at gmail dot com
2023-12-31 12:34 ` y.koj.eel at gmail dot com
2023-12-31 12:43 ` y.koj.eel at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).