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: Fix PR 10381


This patch fixes PR 10381, a mainline regression.

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

--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery dot com

2003-04-15  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/10381
	* parser.c (cp_parser_primary_expression): Reorganize logic for
	dealing with name lookup failures.

2003-04-15  Mark Mitchell  <mark at codesourcery dot com>

	* lib/prune.exp: Ignore more messages.

	PR c++/10381
	* g++.dg/parse/lookup3.C: New test.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.55
diff -c -5 -p -r1.55 parser.c
*** cp/parser.c	10 Apr 2003 08:07:12 -0000	1.55
--- cp/parser.c	15 Apr 2003 20:19:39 -0000
*************** cp_parser_primary_expression (cp_parser 
*** 2556,2602 ****
  			   decl);
  		    return error_mark_node;
  		  }
  	      }
  
! 	    if (!parser->scope 
! 		&& decl == error_mark_node
! 		&& processing_template_decl)
  	      {
! 		/* Unqualified name lookup failed while processing a
! 		   template.  */
! 		*idk = CP_PARSER_ID_KIND_UNQUALIFIED;
! 		/* If the next token is a parenthesis, assume that
! 		   Koenig lookup will succeed when instantiating the
! 		   template.  */
! 		if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN))
! 		  return build_min_nt (LOOKUP_EXPR, id_expression);
! 		/* If we're not doing Koenig lookup, issue an error.  */
! 		error ("`%D' has not been declared", id_expression);
! 		return error_mark_node;
! 	      }
! 	    else if (decl == error_mark_node
! 		     && !processing_template_decl)
! 	      {
! 		if (!parser->scope)
  		  {
  		    /* It may be resolvable as a koenig lookup function
  		       call.  */
  		    *idk = CP_PARSER_ID_KIND_UNQUALIFIED;
  		    return id_expression;
  		  }
- 		else if (TYPE_P (parser->scope)
- 			 && !COMPLETE_TYPE_P (parser->scope))
- 		  error ("incomplete type `%T' used in nested name specifier",
- 			 parser->scope);
- 		else if (parser->scope != global_namespace)
- 		  error ("`%D' is not a member of `%D'",
- 			 id_expression, parser->scope);
- 		else
- 		  error ("`::%D' has not been declared", id_expression);
  	      }
! 	    /* If DECL is a variable would be out of scope under
  	       ANSI/ISO rules, but in scope in the ARM, name lookup
  	       will succeed.  Issue a diagnostic here.  */
  	    else
  	      decl = check_for_out_of_scope_variable (decl);
  
--- 2556,2611 ----
  			   decl);
  		    return error_mark_node;
  		  }
  	      }
  
! 	    if (decl == error_mark_node)
  	      {
! 		/* Name lookup failed.  */
! 		if (!parser->scope 
! 		    && processing_template_decl)
! 		  {
! 		    /* Unqualified name lookup failed while processing a
! 		       template.  */
! 		    *idk = CP_PARSER_ID_KIND_UNQUALIFIED;
! 		    /* If the next token is a parenthesis, assume that
! 		       Koenig lookup will succeed when instantiating the
! 		       template.  */
! 		    if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN))
! 		      return build_min_nt (LOOKUP_EXPR, id_expression);
! 		    /* If we're not doing Koenig lookup, issue an error.  */
! 		    error ("`%D' has not been declared", id_expression);
! 		    return error_mark_node;
! 		  }
! 		else if (parser->scope
! 			 && (!TYPE_P (parser->scope)
! 			     || !dependent_type_p (parser->scope)))
! 		  {
! 		    /* Qualified name lookup failed, and the
! 		       qualifying name was not a dependent type.  That
! 		       is always an error.  */
! 		    if (TYPE_P (parser->scope)
! 			&& !COMPLETE_TYPE_P (parser->scope))
! 		      error ("incomplete type `%T' used in nested name "
! 			     "specifier",
! 			     parser->scope);
! 		    else if (parser->scope != global_namespace)
! 		      error ("`%D' is not a member of `%D'",
! 			     id_expression, parser->scope);
! 		    else
! 		      error ("`::%D' has not been declared", id_expression);
! 		    return error_mark_node;
! 		  }
! 		else if (!parser->scope && !processing_template_decl)
  		  {
  		    /* It may be resolvable as a koenig lookup function
  		       call.  */
  		    *idk = CP_PARSER_ID_KIND_UNQUALIFIED;
  		    return id_expression;
  		  }
  	      }
! 	    /* If DECL is a variable that would be out of scope under
  	       ANSI/ISO rules, but in scope in the ARM, name lookup
  	       will succeed.  Issue a diagnostic here.  */
  	    else
  	      decl = check_for_out_of_scope_variable (decl);
  
Index: testsuite/g++.dg/parse/lookup3.C
===================================================================
RCS file: testsuite/g++.dg/parse/lookup3.C
diff -N testsuite/g++.dg/parse/lookup3.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/lookup3.C	15 Apr 2003 20:19:40 -0000
***************
*** 0 ****
--- 1,12 ----
+ struct X {};
+ 
+ template <int>
+ struct Base {
+     static void foo () { 
+       X::NONEXISTENT (); // { dg-error "" }
+     }
+ };
+ 
+ int main () {
+   Base<2>::foo ();
+ }
Index: testsuite/lib/prune.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/prune.exp,v
retrieving revision 1.9
diff -c -5 -p -r1.9 prune.exp
*** testsuite/lib/prune.exp	25 Nov 2002 00:58:16 -0000	1.9
--- testsuite/lib/prune.exp	15 Apr 2003 20:19:41 -0000
***************
*** 17,27 ****
  # Prune messages from gcc that aren't useful.
  
  proc prune_gcc_output { text } {
      #send_user "Before:$text\n"
  
!     regsub -all "(^|\n)\[^\n\]*: In (function|member|method|(copy )?constructor|instantiation|program|subroutine|block-data) \[^\n\]*" $text "" text
      regsub -all "(^|\n)\[^\n\]*: At (top level|global scope):\[^\n\]*" $text "" text
      regsub -all "(^|\n)collect2: ld returned \[^\n\]*" $text "" text
      regsub -all "(^|\n)Please submit.*instructions\[^\n\]*" $text "" text
  
      # Ignore harmless -fpic warnings.
--- 17,27 ----
  # Prune messages from gcc that aren't useful.
  
  proc prune_gcc_output { text } {
      #send_user "Before:$text\n"
  
!     regsub -all "(^|\n)\[^\n\]*: In ((static member )?function|member|method|(copy )?constructor|instantiation|program|subroutine|block-data) \[^\n\]*" $text "" text
      regsub -all "(^|\n)\[^\n\]*: At (top level|global scope):\[^\n\]*" $text "" text
      regsub -all "(^|\n)collect2: ld returned \[^\n\]*" $text "" text
      regsub -all "(^|\n)Please submit.*instructions\[^\n\]*" $text "" text
  
      # Ignore harmless -fpic warnings.


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