This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 14668


This patch fixes PR 14668, a regression where we failed to emit a
diagnostic about the meanining of a name changing in a class.

Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-05-28  Mark Mitchell  <mark@codesourcery.com>

	PR c++/14668
	* parser.c (cp_parser_simple_type_specifier): Call
	maybe_note_name_used_in_class.

2004-05-28  Mark Mitchell  <mark@codesourcery.com>

	PR c++/14668
	* g++.dg/lookup/redecl1.C: New test.
	* g++.old-deja/g++.benjamin/tem04.C: Add error marker.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.157.2.28
diff -c -5 -p -r1.157.2.28 parser.c
*** cp/parser.c	24 May 2004 02:22:15 -0000	1.157.2.28
--- cp/parser.c	28 May 2004 20:09:06 -0000
*************** cp_parser_simple_type_specifier (cp_pars
*** 8853,8876 ****
      }
  
    /* The type-specifier must be a user-defined type.  */
    if (!(flags & CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES)) 
      {
        /* 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.  */
!       cp_parser_nested_name_specifier_opt (parser,
! 					   /*typename_keyword_p=*/false,
! 					   /*check_dependency_p=*/true,
! 					   /*type_p=*/false,
! 					   /*is_declaration=*/false);
        /* If we have seen a nested-name-specifier, and the next token
  	 is `template', then we are using the template-id production.  */
        if (parser->scope 
  	  && cp_parser_optional_template_keyword (parser))
  	{
--- 8853,8880 ----
      }
  
    /* 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,
! 						/*type_p=*/false,
! 						/*is_declaration=*/false)
! 	   != NULL_TREE);
        /* If we have seen a nested-name-specifier, and the next token
  	 is `template', then we are using the template-id production.  */
        if (parser->scope 
  	  && cp_parser_optional_template_keyword (parser))
  	{
*************** cp_parser_simple_type_specifier (cp_pars
*** 8888,8897 ****
--- 8892,8907 ----
  	    }
  	}
        /* 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  
+ 	  && !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.  */
        if ((flags & CP_PARSER_FLAGS_OPTIONAL) 
  	  && !cp_parser_parse_definitely (parser))
  	type = NULL_TREE;
      }
Index: testsuite/g++.dg/lookup/redecl1.C
===================================================================
RCS file: testsuite/g++.dg/lookup/redecl1.C
diff -N testsuite/g++.dg/lookup/redecl1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/lookup/redecl1.C	28 May 2004 20:09:08 -0000
***************
*** 0 ****
--- 1,7 ----
+ // PR c++/14668
+ 
+ class A {}; // { dg-error "" }
+ class B { 
+   static A *A; // { dg-error "" }
+ }; 
+ A *B::A = 0;
Index: testsuite/g++.old-deja/g++.benjamin/tem04.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C,v
retrieving revision 1.7
diff -c -5 -p -r1.7 tem04.C
*** testsuite/g++.old-deja/g++.benjamin/tem04.C	1 May 2003 02:02:33 -0000	1.7
--- testsuite/g++.old-deja/g++.benjamin/tem04.C	28 May 2004 20:09:09 -0000
*************** public:
*** 89,99 ****
  // 18
  // more template template redecl tests
  template <typename T14, template <typename T15> class C12>// { dg-error "" } .*
  class Xeighteen {
  protected:
!   C12<T14> value;
    int C12; // { dg-error "" } .*
  };
  
  
  // 19
--- 89,99 ----
  // 18
  // more template template redecl tests
  template <typename T14, template <typename T15> class C12>// { dg-error "" } .*
  class Xeighteen {
  protected:
!   C12<T14> value; // { dg-error "" }
    int C12; // { dg-error "" } .*
  };
  
  
  // 19


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]