diff options
author | John McCall <rjmccall@apple.com> | 2011-06-27 21:24:11 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-06-27 21:24:11 +0000 |
commit | d68b2d043865e1c106432f2ab9c1b99a5a2ba86e (patch) | |
tree | e5a12236d90a7c07f69fbc53bffd7f7e51847f20 | |
parent | 1ee9fc02c9b73f8fb57e6d1ac84a73c104a5f98b (diff) | |
download | bcm5719-llvm-d68b2d043865e1c106432f2ab9c1b99a5a2ba86e.tar.gz bcm5719-llvm-d68b2d043865e1c106432f2ab9c1b99a5a2ba86e.zip |
Fix PR10204 in a better way.
llvm-svn: 133943
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 11 |
2 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 5bdb016738b..a3f8301578f 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -791,9 +791,7 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV) { return RValue::get(EmitARCLoadWeak(LV.getAddress())); if (LV.isSimple()) { - // Functions are l-values that don't require loading. - if (LV.getType()->isFunctionType()) - return RValue::get(LV.getAddress()); + assert(!LV.getType()->isFunctionType()); // Everything needs a load. return RValue::get(EmitLoadOfScalar(LV)); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index f8da76bf848..c6443e988bc 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -4461,7 +4461,16 @@ ExprResult Sema::IgnoredValueConversions(Expr *E) { // [Except in specific positions,] an lvalue that does not have // array type is converted to the value stored in the // designated object (and is no longer an lvalue). - if (E->isRValue()) return Owned(E); + if (E->isRValue()) { + // In C, function designators (i.e. expressions of function type) + // are r-values, but we still want to do function-to-pointer decay + // on them. This is both technically correct and convenient for + // some clients. + if (!getLangOptions().CPlusPlus && E->getType()->isFunctionType()) + return DefaultFunctionArrayConversion(E); + + return Owned(E); + } // We always want to do this on ObjC property references. if (E->getObjectKind() == OK_ObjCProperty) { |