Functions that return references can be rvalues as well.

llvm-svn: 72457
This commit is contained in:
Anders Carlsson 2009-05-27 03:37:57 +00:00
parent d6f2834496
commit d8b7ae205e
3 changed files with 9 additions and 0 deletions

View File

@ -255,6 +255,9 @@ VisitImaginaryLiteral(const ImaginaryLiteral *IL) {
ComplexPairTy ComplexExprEmitter::VisitCallExpr(const CallExpr *E) {
if (E->getCallReturnType()->isReferenceType())
return EmitLoadOfLValue(E);
return CGF.EmitCallExpr(E).getComplexVal();
}

View File

@ -223,6 +223,9 @@ public:
Value *EmitCastExpr(const Expr *E, QualType T);
Value *VisitCallExpr(const CallExpr *E) {
if (E->getCallReturnType()->isReferenceType())
return EmitLoadOfLValue(E);
return CGF.EmitCallExpr(E).getScalarVal();
}

View File

@ -38,6 +38,7 @@ void test_bool() {
f(true);
bool_reference_return() = true;
a = bool_reference_return();
}
void test_scalar() {
@ -53,6 +54,7 @@ void test_scalar() {
f((vec4){1,2,3,4}[0]);
int_reference_return() = 10;
a = int_reference_return();
}
void test_complex() {
@ -62,6 +64,7 @@ void test_complex() {
f(10i);
complex_int_reference_return() = 10i;
a = complex_int_reference_return();
}
void test_aggregate() {