From 9a54961e0174ff95efc69bfcac94d5772f2ad7f0 Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 8 Nov 2011 22:54:08 +0000 Subject: Bind function "r-values" as l-values when emitting them as opaque values. Silly C type system. llvm-svn: 144144 --- clang/lib/CodeGen/CodeGenFunction.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.h') diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 3a0be7a5627..383eb587ca5 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -970,7 +970,14 @@ public: OpaqueValueMappingData() : OpaqueValue(0) {} static bool shouldBindAsLValue(const Expr *expr) { - return expr->isGLValue() || expr->getType()->isRecordType(); + // gl-values should be bound as l-values for obvious reasons. + // Records should be bound as l-values because IR generation + // always keeps them in memory. Expressions of function type + // act exactly like l-values but are formally required to be + // r-values in C. + return expr->isGLValue() || + expr->getType()->isRecordType() || + expr->getType()->isFunctionType(); } static OpaqueValueMappingData bind(CodeGenFunction &CGF, -- cgit v1.2.3