[PATCH v2] Reject ambiguous C++ field accesses

Gary Benson gbenson@redhat.com
Tue Oct 13 08:47:32 GMT 2020


Pedro Alves wrote:
> On 8/28/20 9:22 PM, Pedro Alves wrote:
> > gdb/ChangeLog:
> > 
> > 	* valops.c (struct struct_field_searcher): New.
> > 	(update_search_result): Rename to ...
> > 	(struct_field_searcher::update_result): ... this.  Simplify
> > 	prototype.  Record all found fields.
> > 	(do_search_struct_field): Rename to ...
> > 	(struct_field_searcher::search): ... this.  Simplify prototype.
> > 	Maintain stack of visited baseclass path.  Call update_result for
> > 	fields too.  Keep searching fields in baseclasses instead of
> > 	stopping at the first found field.
> > 	(search_struct_field): Use struct_field_searcher.  When looking
> > 	for fields, report ambiguous access attempts.
> > 
> > gdb/testsuite/ChangeLog:
> > 
> > 	PR c++/26550
> > 	* gdb.cp/ambiguous.cc (marker1): Delete.
> > 	(main): Initialize all the fields of the locals.  Replace marker1
> > 	call with a "set breakpoint here" marker.
> > 	* gdb.cp/ambiguous.exp: Modernize.  Use gdb_continue_to_breakpoint
> > 	instead of running to marker1.  Add tests printing all the
> > 	variables and all the fields of the variables.
> > 	(test_ambiguous): New proc, expecting the new GDB output when a
> > 	field access is ambiguous.  Change all "warning: X ambiguous"
> > 	tests to use it.
> 
> I've merged this now.

Thanks Pedro.

Cheers,
Gary

-- 
Gary Benson - he / him / his
Principal Software Engineer, Red Hat



More information about the Gdb-patches mailing list