This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR 15862
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 11 Jun 2004 11:18:04 -0700
- Subject: C++ PATCH: PR 15862
- Reply-to: mark at codesourcery dot com
This patch fixes another problem coming from the fact that we store
builtins in the symbol table even before they have been declared.
Here's a work-around for this specific test case, tested on
i686-pc-linux-gnu, and applied on the 3.4 branch and on the mainline.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2004-06-11 Mark Mitchell <mark@codesourcery.com>
PR c++/15862
* name-lookup.c (unqualified_namespace_lookup): Do not ignore type
bindings for undeclared built-ins.
2004-06-11 Mark Mitchell <mark@codesourcery.com>
PR c++/15862
* g++.dg/parse/enum1.C: New test.
Index: cp/name-lookup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.c,v
retrieving revision 1.34.2.14
diff -c -5 -p -r1.34.2.14 name-lookup.c
*** cp/name-lookup.c 31 May 2004 21:04:11 -0000 1.34.2.14
--- cp/name-lookup.c 11 Jun 2004 17:42:14 -0000
*************** unqualified_namespace_lookup (tree name,
*** 3741,3760 ****
for (; !val; scope = CP_DECL_CONTEXT (scope))
{
cxx_binding *b =
cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
! /* Ignore anticipated built-in functions. */
! if (b && b->value && DECL_P (b->value)
! && DECL_LANG_SPECIFIC (b->value) && DECL_ANTICIPATED (b->value))
! /* Keep binding cleared. */;
! else if (b)
! {
! /* Initialize binding for this context. */
! binding.value = b->value;
! binding.type = b->type;
! }
/* Add all _DECLs seen through local using-directives. */
for (level = current_binding_level;
level->kind != sk_namespace;
level = level->level_chain)
--- 3741,3761 ----
for (; !val; scope = CP_DECL_CONTEXT (scope))
{
cxx_binding *b =
cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
! if (b)
! {
! if (b->value && DECL_P (b->value)
! && DECL_LANG_SPECIFIC (b->value)
! && DECL_ANTICIPATED (b->value))
! /* Ignore anticipated built-in functions. */
! ;
! else
! binding.value = b->value;
! binding.type = b->type;
! }
/* Add all _DECLs seen through local using-directives. */
for (level = current_binding_level;
level->kind != sk_namespace;
level = level->level_chain)
Index: testsuite/g++.dg/parse/enum1.C
===================================================================
RCS file: testsuite/g++.dg/parse/enum1.C
diff -N testsuite/g++.dg/parse/enum1.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/enum1.C 11 Jun 2004 17:42:17 -0000
***************
*** 0 ****
--- 1,4 ----
+ // PR c++/15862
+
+ enum yn { Y, N };
+ enum yn x = Y;