This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: new __builtin_choose_type (patch) (new builtin_equal_types patch)
- To: Richard Henderson <rth at redhat dot com>
- Subject: Re: new __builtin_choose_type (patch) (new builtin_equal_types patch)
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Sat, 6 Oct 2001 00:38:36 +0100 (BST)
- cc: Jakub Jelinek <jakub at redhat dot com>, <gcc at gcc dot gnu dot org>
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