This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR 17393
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 10 Oct 2004 14:48:34 -0700
- Subject: C++ PATCH: PR 17393
- Reply-to: mark at codesourcery dot com
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" }
+ }
+