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]

PR C++/12486


This patch fixes PR c++/12486, which was a case where we were
forgetting to issue an error message before returning error_mark_node.

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

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

2003-10-02  Mark Mitchell  <mark@codesourcery.com>

	PR c++/12486
	* typeck.c (finish_class_member_access_expr): Issue diagnostic
	on erroneous use of qualified name.

2003-10-02  Mark Mitchell  <mark@codesourcery.com>

	PR c++/12486
	* g++.dg/inherit/error1.C: New test.
	
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.436.2.16
diff -c -5 -p -r1.436.2.16 typeck.c
*** cp/typeck.c	2 Oct 2003 12:00:48 -0000	1.436.2.16
--- cp/typeck.c	2 Oct 2003 22:57:21 -0000
*************** finish_class_member_access_expr (tree ob
*** 2172,2183 ****
  	      return error_mark_node;
  	    }
  
  	  /* Find the base of OBJECT_TYPE corresponding to SCOPE.  */
  	  access_path = lookup_base (object_type, scope, ba_check, NULL);
! 	  if (!access_path || access_path == error_mark_node)
  	    return error_mark_node;
  
  	  /* Look up the member.  */
  	  member = lookup_member (access_path, name, /*protect=*/1, 
  				  /*want_type=*/0);
  	  if (member == NULL_TREE)
--- 2172,2188 ----
  	      return error_mark_node;
  	    }
  
  	  /* Find the base of OBJECT_TYPE corresponding to SCOPE.  */
  	  access_path = lookup_base (object_type, scope, ba_check, NULL);
! 	  if (access_path == error_mark_node)
  	    return error_mark_node;
+ 	  if (!access_path)
+ 	    {
+ 	      error ("`%T' is not a base of `%T'", scope, object_type);
+ 	      return error_mark_node;
+ 	    }
  
  	  /* Look up the member.  */
  	  member = lookup_member (access_path, name, /*protect=*/1, 
  				  /*want_type=*/0);
  	  if (member == NULL_TREE)
Index: testsuite/g++.dg/inherit/error1.C
===================================================================
RCS file: testsuite/g++.dg/inherit/error1.C
diff -N testsuite/g++.dg/inherit/error1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/inherit/error1.C	2 Oct 2003 22:57:21 -0000
***************
*** 0 ****
--- 1,10 ----
+ // PR 12486
+ 
+ struct A { int ma; }; 
+ struct B { }; 
+  
+ void foo() 
+ { 
+   B *b; 
+   b->A::ma=0; // { dg-error "" }
+ } 


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