public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96103] New: Unclear diagnostic for a function return with "decltype(auto)"
@ 2020-07-07 17:41 haoxintu at gmail dot com
2020-07-07 20:19 ` [Bug c++/96103] " mpolacek at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: haoxintu at gmail dot com @ 2020-07-07 17:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96103
Bug ID: 96103
Summary: Unclear diagnostic for a function return with
"decltype(auto)"
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: haoxintu at gmail dot com
Target Milestone: ---
Hi, all.
This code, "decltype(auto)" in return type is a c++14 extension and I guess GCC
might diagnose this better.
$cat test.cc
decltype(auto) foo () {}
$g++ -c -std=c++11 test.cc
test.cc:1:10: error: expected primary-expression before ‘auto’
1 | decltype(auto) foo () {}
| ^~~~
test.cc: In function ‘int foo()’:
test.cc:1:24: warning: no return statement in function returning non-void
[-Wreturn-type]
1 | decltype(auto) foo () {}
| ^
$g++ -c -std=c++14 test.cc
//emits nothing
While in Clang:
$clang++ -c -std=c++11 test.cc
test.cc:1:10: warning: 'decltype(auto)' type specifier is a C++14 extension
[-Wc++14-extensions]
decltype(auto) foo () {}
^
test.cc:1:1: error: deduced return types are a C++14 extension
decltype(auto) foo () {}
^
1 warning and 1 error generated.
I guess users can not fix the code according to the errors emitted until they
realized this is a C++14 extension.
Should GCC recognizes the C++14 extension first when parsing this code and then
emits the appropriate diagnostic information?
Thanks,
Haoxin
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96103] Unclear diagnostic for a function return with "decltype(auto)"
2020-07-07 17:41 [Bug c++/96103] New: Unclear diagnostic for a function return with "decltype(auto)" haoxintu at gmail dot com
@ 2020-07-07 20:19 ` mpolacek at gcc dot gnu.org
2020-07-07 21:13 ` mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-07 20:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96103
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-07-07
CC| |mpolacek at gcc dot gnu.org
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed, we should tweak cp_parser_decltype to give a better error.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96103] Unclear diagnostic for a function return with "decltype(auto)"
2020-07-07 17:41 [Bug c++/96103] New: Unclear diagnostic for a function return with "decltype(auto)" haoxintu at gmail dot com
2020-07-07 20:19 ` [Bug c++/96103] " mpolacek at gcc dot gnu.org
@ 2020-07-07 21:13 ` mpolacek at gcc dot gnu.org
2020-07-08 13:33 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-07 21:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96103
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96103] Unclear diagnostic for a function return with "decltype(auto)"
2020-07-07 17:41 [Bug c++/96103] New: Unclear diagnostic for a function return with "decltype(auto)" haoxintu at gmail dot com
2020-07-07 20:19 ` [Bug c++/96103] " mpolacek at gcc dot gnu.org
2020-07-07 21:13 ` mpolacek at gcc dot gnu.org
@ 2020-07-08 13:33 ` cvs-commit at gcc dot gnu.org
2020-07-08 13:34 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-08 13:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96103
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:a51de1af063b0a9233762dcd6ecf2ea0bdf4cdff
commit r11-1913-ga51de1af063b0a9233762dcd6ecf2ea0bdf4cdff
Author: Marek Polacek <polacek@redhat.com>
Date: Tue Jul 7 17:09:42 2020 -0400
c++: Better diagnostic for decltype(auto) in C++11 [PR96103]
If you try to use decltype(auto) in C++11, we emit obscure
error: expected primary-expression before 'auto'
giving the user no hint as to what's wrong. This patch improves that
diagnostic. Since we've been giving an error, I'm also using error().
gcc/cp/ChangeLog:
PR c++/96103
* parser.c (cp_parser_decltype): Print error about using
decltype(auto)
in C++11. Check that the token following "auto" is ")".
gcc/testsuite/ChangeLog:
PR c++/96103
* g++.dg/cpp0x/decltype77.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96103] Unclear diagnostic for a function return with "decltype(auto)"
2020-07-07 17:41 [Bug c++/96103] New: Unclear diagnostic for a function return with "decltype(auto)" haoxintu at gmail dot com
` (2 preceding siblings ...)
2020-07-08 13:33 ` cvs-commit at gcc dot gnu.org
@ 2020-07-08 13:34 ` mpolacek at gcc dot gnu.org
2021-09-07 17:07 ` pinskia at gcc dot gnu.org
2021-09-07 17:07 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-08 13:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96103
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96103] Unclear diagnostic for a function return with "decltype(auto)"
2020-07-07 17:41 [Bug c++/96103] New: Unclear diagnostic for a function return with "decltype(auto)" haoxintu at gmail dot com
` (3 preceding siblings ...)
2020-07-08 13:34 ` mpolacek at gcc dot gnu.org
@ 2021-09-07 17:07 ` pinskia at gcc dot gnu.org
2021-09-07 17:07 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-07 17:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96103
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96103] Unclear diagnostic for a function return with "decltype(auto)"
2020-07-07 17:41 [Bug c++/96103] New: Unclear diagnostic for a function return with "decltype(auto)" haoxintu at gmail dot com
` (4 preceding siblings ...)
2021-09-07 17:07 ` pinskia at gcc dot gnu.org
@ 2021-09-07 17:07 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-07 17:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96103
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 95658 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-09-07 17:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 17:41 [Bug c++/96103] New: Unclear diagnostic for a function return with "decltype(auto)" haoxintu at gmail dot com
2020-07-07 20:19 ` [Bug c++/96103] " mpolacek at gcc dot gnu.org
2020-07-07 21:13 ` mpolacek at gcc dot gnu.org
2020-07-08 13:33 ` cvs-commit at gcc dot gnu.org
2020-07-08 13:34 ` mpolacek at gcc dot gnu.org
2021-09-07 17:07 ` pinskia at gcc dot gnu.org
2021-09-07 17:07 ` pinskia at gcc dot gnu.org
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).