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, Oct 05, 2001 at 12:02:32PM +0100, Joseph S. Myers wrote:
> I think the following (which would need to be grammer symbols rather than
> simple built-in functions) should suffice:
> 
> __builtin_types_compatible_p (T1, T2) - returns 1 if the unqualified
> versions of the types T1 and T2 (which are types, not expressions) are
> compatible, 0 otherwise, and can be used in integer constant expressions.

Yep.

> __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.


r~


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