}
/* Attempt to convert GCC evaluated CST to a D Frontend Expression.
+ LOC is the location in the source file where this CST is being evaluated.
This is used for getting the CTFE value out of a const-folded builtin,
returns NULL if it cannot convert CST. */
Expression *
-d_eval_constant_expression (tree cst)
+d_eval_constant_expression (const Loc &loc, tree cst)
{
STRIP_TYPE_NOPS (cst);
Type *type = build_frontend_type (TREE_TYPE (cst));
real_value re = TREE_REAL_CST (TREE_REALPART (cst));
real_value im = TREE_REAL_CST (TREE_IMAGPART (cst));
complex_t value = complex_t (ldouble (re), ldouble (im));
- return ComplexExp::create (Loc (), value, type);
+ return ComplexExp::create (loc, value, type);
}
else if (code == INTEGER_CST)
{
dinteger_t value = TREE_INT_CST_LOW (cst);
- return IntegerExp::create (Loc (), value, type);
+ return IntegerExp::create (loc, value, type);
}
else if (code == REAL_CST)
{
real_value value = TREE_REAL_CST (cst);
- return RealExp::create (Loc (), ldouble (value), type);
+ return RealExp::create (loc, ldouble (value), type);
}
else if (code == STRING_CST)
{
const void *string = TREE_STRING_POINTER (cst);
size_t len = TREE_STRING_LENGTH (cst);
- return StringExp::create (Loc (), CONST_CAST (void *, string), len);
+ return StringExp::create (loc, CONST_CAST (void *, string), len);
}
else if (code == VECTOR_CST)
{
for (size_t i = 0; i < nunits; i++)
{
Expression *elem
- = d_eval_constant_expression (VECTOR_CST_ELT (cst, i));
+ = d_eval_constant_expression (loc, VECTOR_CST_ELT (cst, i));
if (elem == NULL)
return NULL;
(*elements)[i] = elem;
}
- Expression *e = ArrayLiteralExp::create (Loc (), elements);
+ Expression *e = ArrayLiteralExp::create (loc, elements);
e->type = type->isTypeVector ()->basetype;
- return VectorExp::create (Loc (), e, type);
+ return VectorExp::create (loc, e, type);
}
}
cst = native_interpret_expr (vectype, buffer, len);
- Expression *e = d_eval_constant_expression (cst);
+ Expression *e = d_eval_constant_expression (expr->loc, cst);
gcc_assert (e != NULL && e->op == TOKvector);
return e->isVectorExp ()->e1;
/* Normal interpret cast. */
cst = native_interpret_expr (build_ctype (type), buffer, len);
- Expression *e = d_eval_constant_expression (cst);
+ Expression *e = d_eval_constant_expression (expr->loc, cst);
gcc_assert (e != NULL);
return e;