[C++ PATCH]: Better diagnostics on bogus base

Nathan Sidwell nathan@codesourcery.com
Tue Nov 28 02:31:00 GMT 2000


Hi,
I've installed the attached patch which provides better diagnostics
about bogus bases, and checks a cv qualified base is not being used
(via a typedef).

built & tested on i686-pc-linux-gnu, approved by Mark.

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-11-27  Nathan Sidwell  <nathan@codesourcery.com>

	* parse.y (base_class.1): Produce a _TYPE not a _DECL.
	* semantics.c (finish_base_specifier): Accept a _TYPE not a
	_DECL.

Index: cp/parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/parse.y,v
retrieving revision 1.202
diff -c -3 -p -r1.202 parse.y
*** parse.y	2000/11/24 10:30:45	1.202
--- parse.y	2000/11/27 08:30:16
*************** base_class:
*** 2460,2472 ****
  
  base_class.1:
  	  typename_sub
! 		{ if ($$ == error_mark_node)
! 		    ;
!                   else if (!TYPE_P ($$))
! 		    $$ = error_mark_node;
! 		  else 
! 		    $$ = TYPE_MAIN_DECL ($1); }
  	| nonnested_type
  	;
  
  base_class_access_list:
--- 2460,2469 ----
  
  base_class.1:
  	  typename_sub
! 		{ if (!TYPE_P ($$))
! 		    $$ = error_mark_node; }
  	| nonnested_type
+ 		{ $$ = TREE_TYPE ($$); }
  	;
  
  base_class_access_list:
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/semantics.c,v
retrieving revision 1.180
diff -c -3 -p -r1.180 semantics.c
*** semantics.c	2000/11/24 09:56:26	1.180
--- semantics.c	2000/11/27 08:30:17
*************** finish_base_specifier (access_specifier,
*** 2068,2088 ****
       tree access_specifier;
       tree base_class;
  {
-   tree type;
    tree result;
  
!   if (base_class == NULL_TREE)
!     {
!       error ("invalid base class");
!       type = error_mark_node;
!     }
!   else
!     type = TREE_TYPE (base_class);
! 
!   if (! is_aggr_type (type, 1))
      result = NULL_TREE;
    else
!     result = build_tree_list (access_specifier, type);
  
    return result;
  }
--- 2068,2086 ----
       tree access_specifier;
       tree base_class;
  {
    tree result;
  
!   if (! is_aggr_type (base_class, 1))
      result = NULL_TREE;
    else
!     {
!       if (CP_TYPE_QUALS (base_class) != 0)
!         {
!           cp_error ("base class `%T' has cv qualifiers", base_class);
!           base_class = TYPE_MAIN_VARIANT (base_class);
!         }
!       result = build_tree_list (access_specifier, base_class);
!     }
  
    return result;
  }


More information about the Gcc-patches mailing list