From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 018E33858C3A; Fri, 21 Jan 2022 15:02:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 018E33858C3A From: "nickhuang99 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104113] invalid template argument causes the type to become int which confuses the rest of the diagnostic Date: Fri, 21 Jan 2022 15:02:41 +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: 12.0 X-Bugzilla-Keywords: diagnostic, FIXME X-Bugzilla-Severity: normal X-Bugzilla-Who: nickhuang99 at hotmail dot com X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 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: Fri, 21 Jan 2022 15:02:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104113 --- Comment #6 from qingzhe huang --- How about this simple fix? (see the patch above.)=20 Instead of return "error_mark_node" by condition of "!cp_parser_simulate_error", we now report error immediately. The rational = of this fix is that "cp_parser_simulate_error" is only making sense when we already see error, i.e. "CP_PARSER_STATUS_KIND_ERROR". Otherwise, we should just report error. I did a full build and check, it seems fine with me. For example,=20 104091.cpp: In function =E2=80=98void g()=E2=80=99: 104091.cpp:8:7: error: =E2=80=98auto=E2=80=99 not permitted in template arg= ument 8 | A x =3D A(); | ^~~~ 104091.cpp:8:13: error: variable =E2=80=98A x=E2=80=99 has initialize= r but incomplete type 8 | A x =3D A(); | ^ Also I noticed previous testcase (i.e. g++.dg/DRs/dr625.C) is too relaxed w= ith error message by allowing inaccurate "invalid template argument" or "cannot convert ..." instead of "auto not permitted". If this makes sense to you, I am happy to provide more testcases and correct those old testcases.=