This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] Don't coerce arrays if they're vectors.
- From: Michael Snyder <msnyder at redhat dot com>
- To: Elena Zannoni <ezannoni at redhat dot com>, Michael Snyder <msnyder at cygnus dot com>, gdb-patches at sources dot redhat dot com
- Date: Tue, 10 Sep 2002 16:54:16 -0700
- Subject: Re: [RFA] Don't coerce arrays if they're vectors.
- Organization: Red Hat, Inc.
- References: <200205162224.g4GMOmD22402@reddwarf.sfbay.redhat.com> <15588.17465.708260.732100@localhost.redhat.com> <3CE53E43.3EA3DBD0@redhat.com>
Michael Snyder wrote:
>
> Elena Zannoni wrote:
> >
> > Michael Snyder writes:
> >
> > Which problem does this fix? i.e. which call(s) of value_cast?
> >
> > Elena
>
> It gets called when I do "print foo(vec_arg)".
Elena, this thread got dropped. Do you think this change is OK?
>
> >
> > >
> > > This seem reasonable to you vector-savvy folk?
> > >
> > > Michael
> > >
> > > 2002-05-16 Michael Snyder <msnyder@redhat.com>
> > >
> > > * valops.c (value_cast): Don't coerce arrays if they're vectors.
> > >
> > > Index: valops.c
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/valops.c,v
> > > retrieving revision 1.59
> > > diff -p -r1.59 valops.c
> > > *** valops.c 13 May 2002 14:00:36 -0000 1.59
> > > --- valops.c 16 May 2002 22:32:40 -0000
> > > *************** value_cast (struct type *type, struct va
> > > *** 210,217 ****
> > > }
> > > }
> > >
> > > if (current_language->c_style_arrays
> > > ! && TYPE_CODE (type2) == TYPE_CODE_ARRAY)
> > > arg2 = value_coerce_array (arg2);
> > >
> > > if (TYPE_CODE (type2) == TYPE_CODE_FUNC)
> > > --- 210,221 ----
> > > }
> > > }
> > >
> > > + /* Arrays are coerced to pointers to their first element, unless
> > > + they are vectors, in which case we want to leave them alone,
> > > + because they are passed by value. */
> > > if (current_language->c_style_arrays
> > > ! && TYPE_CODE (type2) == TYPE_CODE_ARRAY
> > > ! && !TYPE_VECTOR (type2))
> > > arg2 = value_coerce_array (arg2);
> > >
> > > if (TYPE_CODE (type2) == TYPE_CODE_FUNC)