diff options
author | John McCall <rjmccall@apple.com> | 2011-11-08 22:54:08 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-11-08 22:54:08 +0000 |
commit | 9a54961e0174ff95efc69bfcac94d5772f2ad7f0 (patch) | |
tree | 71cdd757d5bbfee75e216fa3f64fe668fa7b76e1 | |
parent | 557fc9a99d50a8302c98196da346b19da76be291 (diff) | |
download | bcm5719-llvm-9a54961e0174ff95efc69bfcac94d5772f2ad7f0.tar.gz bcm5719-llvm-9a54961e0174ff95efc69bfcac94d5772f2ad7f0.zip |
Bind function "r-values" as l-values when emitting them as
opaque values. Silly C type system.
llvm-svn: 144144
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 9 | ||||
-rw-r--r-- | clang/test/CodeGenObjC/property.m | 11 |
3 files changed, 20 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index d7e3168a3a8..4d14d18e595 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -2137,7 +2137,7 @@ LValue CodeGenFunction::EmitNullInitializationLValue( } LValue CodeGenFunction::EmitOpaqueValueLValue(const OpaqueValueExpr *e) { - assert(e->isGLValue() || e->getType()->isRecordType()); + assert(OpaqueValueMappingData::shouldBindAsLValue(e)); return getOpaqueLValueMapping(e); } 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, diff --git a/clang/test/CodeGenObjC/property.m b/clang/test/CodeGenObjC/property.m index 3cc9200f333..30f68e5b27f 100644 --- a/clang/test/CodeGenObjC/property.m +++ b/clang/test/CodeGenObjC/property.m @@ -112,3 +112,14 @@ void test4(Test4 *t) { @implementation Test5 @synthesize x = _x; @end + +// rdar://problem/10410531 +@interface Test6 +@property void (*prop)(void); +@end + +void test6_func(void); +void test6(Test6 *a) { + a.prop = test6_func; +} + |