summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2016-11-19 00:13:03 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2016-11-19 00:13:03 +0000
commitf7d563c76c40acc361417ec1bdef6f15739516e4 (patch)
tree3eda79eca38a6ec8a17bedae6c9ad00fc64652d2 /clang/lib
parenteb4a0cb16b74f6b973c11bd0b371f387853e48fc (diff)
downloadbcm5719-llvm-f7d563c76c40acc361417ec1bdef6f15739516e4.tar.gz
bcm5719-llvm-f7d563c76c40acc361417ec1bdef6f15739516e4.zip
[Sema] Don't allow applying address-of operator to a call to a function
with __unknown_anytype return type. When the following code is compiled, Sema infers that the type of __unknown_anytype is double: extern __unknown_anytype func(); double *d = (double*)&func(); This triggers an assert in CodeGenFunction::EmitCallExprLValue because it doesn't expect to see a call to a function with a non-reference scalar return type. This commit prevents the assert by making VisitUnaryAddrOf error out if the address-of operator is applied to a call to a function with __unknown_anytype return type. rdar://problem/20287610 Differential revision: https://reviews.llvm.org/D26808 llvm-svn: 287410
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index fae8bf0f548..9d0d55e6876 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -14774,6 +14774,13 @@ namespace {
<< E->getSourceRange();
return ExprError();
}
+
+ if (isa<CallExpr>(E->getSubExpr())) {
+ S.Diag(E->getOperatorLoc(), diag::err_unknown_any_addrof_call)
+ << E->getSourceRange();
+ return ExprError();
+ }
+
assert(E->getValueKind() == VK_RValue);
assert(E->getObjectKind() == OK_Ordinary);
E->setType(DestType);
OpenPOWER on IntegriCloud