[Sema] Don't allow applying address-of operator to a call to a function
authorAkira Hatanaka <ahatanaka@apple.com>
Sat, 19 Nov 2016 00:13:03 +0000 (00:13 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Sat, 19 Nov 2016 00:13:03 +0000 (00:13 +0000)
commitf7d563c76c40acc361417ec1bdef6f15739516e4
tree3eda79eca38a6ec8a17bedae6c9ad00fc64652d2
parenteb4a0cb16b74f6b973c11bd0b371f387853e48fc
[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
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/unknown-anytype.cpp