This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: new __builtin_choose_type (patch)
On Tue, 2001-10-02 at 15:04, Joseph S. Myers wrote:
> On 2 Oct 2001, Aldy Hernandez wrote:
>
> > it was suggested to have a builtin analogous to the ?: operator that
> > will work as follows:
> >
> > __builtin_choose_type (exp0, type, exp1, exp2);
> >
> > if <exp0> is of type <type>, evaluate <exp1> else evaluate <exp2>.
> >
> > i have a patch for this feature and i'd like some comments.
>
> Since your patch doesn't add documentation or testcases, I don't know what
> it really intends. In a case like this, the documentation and the
well i didn't add documentation or testcases because i didn't want to
code the entire thing, docs and all, and have everyone say-- "oh, that's
not the right approach". that's what i posted info on what i wanted to
do.
example:
int b;
double a;
float float_type;
foo(){
__builtin_choose_type(a, float_type, b=8, b=10);
}
in this case, b=10 is evaluated because the type of "a" (double) is not
the type of "float_type" (float). the value of the entire
builtin_choose_type instruction is 10.
so, in pseudo code:
typeof(a) == typeof(float_type) ? b=8 : b=10
b=8 is not evaluated at all.
--
Aldy Hernandez E-mail: aldyh@redhat.com
Professional Gypsy on a Motorcycle
Red Hat, Inc.