From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 730F4385ED4B; Tue, 7 Jul 2020 17:41:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 730F4385ED4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594143679; bh=rpMjkplQEWF3lnO8QMc6RJIiJVIb0sAj/Bn2iQGN7Qg=; h=From:To:Subject:Date:From; b=Mgvaq8yLERMSJnsrEsKfLBnXCJiXFFek9NnPbi1LgGuD3bksmeBl03SMqDn65B8Ka 6D792ZBroicVJBsZ3xLVCp3+cCKxq4Q17Ntfs3ooU6PAJi8SuqEUb2Y9vq5QBIw7Ag +aIV0OsneHtwgyUgNfkItuNajsNPXkE71/Uyqxlo= From: "haoxintu at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96103] New: Unclear diagnostic for a function return with "decltype(auto)" Date: Tue, 07 Jul 2020 17:41:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: haoxintu at gmail dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jul 2020 17:41:19 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96103 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.=20 $cat test.cc decltype(auto) foo () {} $g++ -c -std=3Dc++11 test.cc test.cc:1:10: error: expected primary-expression before =E2=80=98auto=E2=80= =99 1 | decltype(auto) foo () {} | ^~~~ test.cc: In function =E2=80=98int foo()=E2=80=99: test.cc:1:24: warning: no return statement in function returning non-void [-Wreturn-type] 1 | decltype(auto) foo () {} | ^ $g++ -c -std=3Dc++14 test.cc //emits nothing While in Clang: $clang++ -c -std=3Dc++11 test.cc=20 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 th= ey realized this is a C++14 extension.=20 Should GCC recognizes the C++14 extension first when parsing this code and = then emits the appropriate diagnostic information? Thanks, Haoxin=