* C++ PATCH: PR 17393
@ 2004-10-10 21:57 Mark Mitchell
0 siblings, 0 replies; only message in thread
From: Mark Mitchell @ 2004-10-10 21:57 UTC (permalink / raw)
To: gcc-patches
This patch fixes a bogus error message, in which we complained that a
compiler-generated variable was unused. This compiler-generated
variable was created when we saw something that looked like a variable
declarations, except that it used an abstract declarator instead of a
direct declarator. There's no reason to try to create a variable at
all in that case; since the variable has no name, nobody can ever talk
about it later, so there's not much point in creating it, even from an
error-recovery perspective.
Tested on i686-pc-linux-gnu, applied on the mainline, and, shortly, on
the 3.4 branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2004-10-10 Mark Mitchell <mark@codesourcery.com>
PR c++/17393
* decl.c (grokdeclarator): Robustify error-recovery on invalid
declarations.
2004-10-10 Mark Mitchell <mark@codesourcery.com>
PR c++/17393
* g++.dg/parse/error21.C: New test.
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1312
diff -c -5 -p -r1.1312 decl.c
*** cp/decl.c 9 Oct 2004 17:32:58 -0000 1.1312
--- cp/decl.c 10 Oct 2004 17:11:13 -0000
*************** grokdeclarator (const cp_declarator *dec
*** 7763,7773 ****
&& decl_context != CATCHPARM
&& TREE_CODE (type) != UNION_TYPE
&& ! bitfield)
{
error ("abstract declarator %qT used as declaration", type);
! unqualified_id = make_anon_name ();
}
/* Only functions may be declared using an operator-function-id. */
if (unqualified_id
&& IDENTIFIER_OPNAME_P (unqualified_id)
--- 7763,7773 ----
&& decl_context != CATCHPARM
&& TREE_CODE (type) != UNION_TYPE
&& ! bitfield)
{
error ("abstract declarator %qT used as declaration", type);
! return error_mark_node;
}
/* Only functions may be declared using an operator-function-id. */
if (unqualified_id
&& IDENTIFIER_OPNAME_P (unqualified_id)
Index: testsuite/g++.dg/parse/error21.C
===================================================================
RCS file: testsuite/g++.dg/parse/error21.C
diff -N testsuite/g++.dg/parse/error21.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/error21.C 10 Oct 2004 21:42:58 -0000
***************
*** 0 ****
--- 1,12 ----
+ // PR c++/17393
+ // { dg-options "-Wall" }
+
+ struct A { };
+
+ void foo()
+ {
+ // Check that we do not complain about an unused
+ // compiler-generated variable.
+ A& = a; // { dg-error "token|declarator|not declared" }
+ }
+
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-10-10 21:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-10 21:57 C++ PATCH: PR 17393 Mark Mitchell
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).