This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: 16637
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 20 Jul 2004 11:00:22 -0700
- Subject: C++ PATCH: 16637
- Reply-to: mark at codesourcery dot com
This patch fixes PR c++/16637, a regression that caused us to reject
valid code.
Tested on i686-pc-linux-gnu, applied on the 3.4 branch and on the
mainline.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2004-07-20 Mark Mitchell <mark@codesourcery.com>
PR c++/16637
* parser.c (cp_parser_simple_type_specifier): Do not record usage
of globally-qualified names.
2004-07-20 Mark Mitchell <mark@codesourcery.com>
PR c++/16637
* g++.dg/parse/lookup4.C: New test.
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.228
diff -c -5 -p -r1.228 parser.c
*** cp/parser.c 13 Jul 2004 21:11:50 -0000 1.228
--- cp/parser.c 20 Jul 2004 17:55:04 -0000
*************** cp_parser_simple_type_specifier (cp_pars
*** 9457,9475 ****
/* The type-specifier must be a user-defined type. */
if (!(flags & CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES))
{
bool qualified_p;
/* Don't gobble tokens or issue error messages if this is an
optional type-specifier. */
if (flags & CP_PARSER_FLAGS_OPTIONAL)
cp_parser_parse_tentatively (parser);
/* Look for the optional `::' operator. */
! cp_parser_global_scope_opt (parser,
! /*current_scope_valid_p=*/false);
/* Look for the nested-name specifier. */
qualified_p
= (cp_parser_nested_name_specifier_opt (parser,
/*typename_keyword_p=*/false,
/*check_dependency_p=*/true,
--- 9457,9477 ----
/* The type-specifier must be a user-defined type. */
if (!(flags & CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES))
{
bool qualified_p;
+ bool global_p;
/* Don't gobble tokens or issue error messages if this is an
optional type-specifier. */
if (flags & CP_PARSER_FLAGS_OPTIONAL)
cp_parser_parse_tentatively (parser);
/* Look for the optional `::' operator. */
! global_p
! = cp_parser_global_scope_opt (parser,
! /*current_scope_valid_p=*/false);
/* Look for the nested-name specifier. */
qualified_p
= (cp_parser_nested_name_specifier_opt (parser,
/*typename_keyword_p=*/false,
/*check_dependency_p=*/true,
*************** cp_parser_simple_type_specifier (cp_pars
*** 9497,9506 ****
--- 9499,9509 ----
/* Otherwise, look for a type-name. */
else
type = cp_parser_type_name (parser);
/* Keep track of all name-lookups performed in class scopes. */
if (type
+ && !global_p
&& !qualified_p
&& TREE_CODE (type) == TYPE_DECL
&& TREE_CODE (DECL_NAME (type)) == IDENTIFIER_NODE)
maybe_note_name_used_in_class (DECL_NAME (type), type);
/* If it didn't work out, we don't have a TYPE. */
Index: testsuite/g++.dg/parse/lookup4.C
===================================================================
RCS file: testsuite/g++.dg/parse/lookup4.C
diff -N testsuite/g++.dg/parse/lookup4.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/lookup4.C 20 Jul 2004 17:55:04 -0000
***************
*** 0 ****
--- 1,7 ----
+ // PR c++/16637
+
+ typedef int I;
+
+ struct S {
+ ::I I;
+ };