diff options
author | George Burgess IV <george.burgess.iv@gmail.com> | 2016-01-07 02:26:57 +0000 |
---|---|---|
committer | George Burgess IV <george.burgess.iv@gmail.com> | 2016-01-07 02:26:57 +0000 |
commit | 7204ed97dd930e0cb159985a5973bc9993740726 (patch) | |
tree | 3422df717a6c911af7f97fdc06baca35553b5055 /clang/test/SemaCXX/pass-object-size.cpp | |
parent | 103d2381d67cef5cc0febed84da7bdd01d1a2cb1 (diff) | |
download | bcm5719-llvm-7204ed97dd930e0cb159985a5973bc9993740726.tar.gz bcm5719-llvm-7204ed97dd930e0cb159985a5973bc9993740726.zip |
[Sema] Teach overload resolution about unaddressable functions.
Given an expression like `(&Foo)();`, we perform overload resolution as
if we are calling `Foo` directly. This causes problems if `Foo` is a
function that can't have its address taken. This patch teaches overload
resolution to ignore functions that can't have their address taken in
such cases.
Differential Revision: http://reviews.llvm.org/D15590
llvm-svn: 257016
Diffstat (limited to 'clang/test/SemaCXX/pass-object-size.cpp')
-rw-r--r-- | clang/test/SemaCXX/pass-object-size.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/pass-object-size.cpp b/clang/test/SemaCXX/pass-object-size.cpp index bec0c1c55f2..94c9cc9c8aa 100644 --- a/clang/test/SemaCXX/pass-object-size.cpp +++ b/clang/test/SemaCXX/pass-object-size.cpp @@ -120,3 +120,17 @@ void Bar() { (void)+[](void *const p __attribute__((pass_object_size(0)))) {}; //expected-error-re{{invalid argument type '(lambda at {{.*}})' to unary expression}} } } + +namespace ovlbug { +// Directly calling an address-of function expression (e.g. in (&foo)(args...)) +// doesn't go through regular address-of-overload logic. This caused the above +// code to generate an ICE. +void DirectAddrOf(void *__attribute__((pass_object_size(0)))); +void DirectAddrOfOvl(void *__attribute__((pass_object_size(0)))); +void DirectAddrOfOvl(int *); + +void Test() { + (&DirectAddrOf)(nullptr); //expected-error{{cannot take address of function 'DirectAddrOf' because parameter 1 has pass_object_size attribute}} + (&DirectAddrOfOvl)((char*)nullptr); //expected-error{{no matching function}} expected-note@129{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@130{{candidate function not viable: no known conversion from 'char *' to 'int *' for 1st argument}} +} +} |