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)


On 2 Oct 2001, Aldy Hernandez wrote:

> btw, i can't get my builtin to return a given object (irregardless of
> it's type) because the way builtins work seems to force me to choose a
> return value type.  i don't want a specific value type.  i want
> something generic.  see code documentation below.

That's why overloaded builtins need actual new mechanism in the compiler
(to do overload resolution for builtins sufficiently early), not simply
another builtin like this using existing mechanisms.

> +   /* Strip off all NOPs.  */
> +   while (TREE_CODE (arg) == NOP_EXPR
> + 	 || TREE_CODE (arg) == CONVERT_EXPR
> + 	 || TREE_CODE (arg) == NON_LVALUE_EXPR
> + 	 || TREE_CODE (arg) == INDIRECT_REF)
> +     arg = TREE_OPERAND (arg, 0);
> + 
> +   /* Get <exp0> type.  */
> +   exp0_mode = TYPE_MODE (TREE_TYPE (arg));

This looks to me like one of the problems with the current approach -
since explicit casts should be preserved in computing the types, but
implicit conversions from the default argument promotions (which shouldn't
get applied with proper overloaded builtins, but would at present)  
shouldn't be preserved.

-- 
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]