@@ -833,9 +833,11 @@ static void parseBuiltinIOCall(Compiler *comp, Type **type, Const *constant, Bui
833833
834834static void parseBuiltinMathCall (Compiler * comp , Type * * type , Const * constant , BuiltinFunc builtin )
835835{
836- * type = comp -> realType ;
836+ Type * argType = (builtin == BUILTIN_ABS ) ? comp -> intType : comp -> realType ;
837+
838+ * type = argType ;
837839 parseExpr (comp , type , constant );
838- doAssertImplicitTypeConv (comp , comp -> realType , type , constant );
840+ doAssertImplicitTypeConv (comp , argType , type , constant );
839841
840842 Const constant2Val = {.realVal = 0 };
841843 Const * constant2 = NULL ;
@@ -854,11 +856,11 @@ static void parseBuiltinMathCall(Compiler *comp, Type **type, Const *constant, B
854856 }
855857
856858 if (constant )
857- constCallBuiltin (& comp -> consts , constant , constant2 , TYPE_REAL , builtin );
859+ constCallBuiltin (& comp -> consts , constant , constant2 , argType -> kind , builtin );
858860 else
859- genCallBuiltin (& comp -> gen , TYPE_REAL , builtin );
861+ genCallBuiltin (& comp -> gen , argType -> kind , builtin );
860862
861- if (builtin == BUILTIN_ROUND || builtin == BUILTIN_TRUNC || builtin == BUILTIN_CEIL || builtin == BUILTIN_FLOOR )
863+ if (builtin == BUILTIN_ROUND || builtin == BUILTIN_TRUNC || builtin == BUILTIN_CEIL || builtin == BUILTIN_FLOOR || builtin == BUILTIN_ABS )
862864 * type = comp -> intType ;
863865 else
864866 * type = comp -> realType ;
@@ -1515,6 +1517,7 @@ static void parseBuiltinCall(Compiler *comp, Type **type, Const *constant, Built
15151517 case BUILTIN_TRUNC :
15161518 case BUILTIN_CEIL :
15171519 case BUILTIN_FLOOR :
1520+ case BUILTIN_ABS :
15181521 case BUILTIN_FABS :
15191522 case BUILTIN_SQRT :
15201523 case BUILTIN_SIN :
0 commit comments