This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++, diagnostic] PR 33495
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Gabriel Dos Reis <gdr at cs dot tamu dot edu>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 02 Nov 2007 15:08:00 +0100
- Subject: Re: [C++, diagnostic] PR 33495
- References: <472B1A14.5080609@suse.de> <87sl3opx4o.fsf@soliton.cs.tamu.edu>
Hi Gaby,
> Paolo Carlini <pcarlini@suse.de> writes:
>
> | Hi all, hi Gaby,
> |
> | I'm trying to make progress on this PR, taking also into account Jakub'
> | comment in the audit trail about the unbounded size of statements.
> | Currently I have the below, which passes regtesting on x86_64-linux,
> | makes sense to you?
>
> If we had `diagnostics with carret', we would just point to the locus
> of the error. Currently, we don't. Just printing the statement would
> not be good either -- because the internal representation does not
> always accurately reflect the source code.
I see...
> So, yes you're is OK if
> you changed
>
> | + pp_cxx_identifier (cxx_pp, "<expression>");
>
>
> to
>
> + pp_cxx_identifier (cxx_pp, "<statement>");
>
The below is what I actually committed.
Thanks,
Paolo.
/////////////////
2007-11-02 Paolo Carlini <pcarlini@suse.de>
PR c++/33495
* error.c (dump_expr): Deal specially with statements.
2007-11-02 Paolo Carlini <pcarlini@suse.de>
PR c++/33495
* g++.dg/other/error19.C: New.
Index: testsuite/g++.dg/other/error19.C
===================================================================
*** testsuite/g++.dg/other/error19.C (revision 0)
--- testsuite/g++.dg/other/error19.C (revision 0)
***************
*** 0 ****
--- 1,7 ----
+ // PR c++/33495
+
+ void foo()
+ {
+ if (({while(true);})) // { dg-error "forbids|<statement>" }
+ ;
+ }
Index: cp/error.c
===================================================================
*** cp/error.c (revision 129845)
--- cp/error.c (working copy)
*************** dump_expr (tree t, int flags)
*** 1437,1442 ****
--- 1437,1448 ----
if (t == 0)
return;
+ if (STATEMENT_CLASS_P (t))
+ {
+ pp_cxx_identifier (cxx_pp, "<statement>");
+ return;
+ }
+
switch (TREE_CODE (t))
{
case VAR_DECL: