This is the mail archive of the gcc@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]

Re: new __builtin_choose_type (patch) (new builtin_equal_types patch)


On Fri, 5 Oct 2001, Richard Henderson wrote:

> > __builtin_choose_expr (C, E1, E2) - returns E1 (and has the type of E1) if
> > C is true, otherwise returns E2 (and has the type of E2).  C must be an
> > integer constant expression.
> 
> Ideally, we would want that if C is true E2 is not checked for
> semantic correctness.  That is,
> 
>   int x;
>   __builtin_choose_expr(1, 2, x->foo)
> 
> evaluates to 2 without error.  I'm not sure we can do this with
> our current front end though.

In C++, I expect that the new parser can do this easily.  In C, you could
perhaps develop a kludge: suppress but store the error and warning
messages while parsing the expressions, then regurgitate them for the
expression that gets selected.  The new parser branch contains the
required diagnostic machinery to do this.  (However, in C an expression
can declare new types, and any declarations from the ignored expression
would still remain in scope.)

-- 
Joseph S. Myers
jsm28@cam.ac.uk


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