summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/overloadable.c
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2017-05-09 04:06:24 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2017-05-09 04:06:24 +0000
commit1dbfa856b1172d045baecaeab6711b0d01377970 (patch)
treed8a1ed1a754cc6a2fd02a45b4f70625882ec122e /clang/test/Sema/overloadable.c
parentb35ef2a599aa71b4aac027429e0c19d16dc274b7 (diff)
downloadbcm5719-llvm-1dbfa856b1172d045baecaeab6711b0d01377970.tar.gz
bcm5719-llvm-1dbfa856b1172d045baecaeab6711b0d01377970.zip
[Sema] Make typeof(OverloadedFunctionName) not a pointer.
We were sometimes doing a function->pointer conversion in Sema::CheckPlaceholderExpr, which isn't the job of CheckPlaceholderExpr. So, when we saw typeof(OverloadedFunctionName), where OverloadedFunctionName referenced a name with only one function that could have its address taken, we'd give back a function pointer type instead of a function type. This is incorrect. I kept the logic for doing the function pointer conversion in resolveAndFixAddressOfOnlyViableOverloadCandidate because it was more consistent with existing ResolveAndFix* methods. llvm-svn: 302506
Diffstat (limited to 'clang/test/Sema/overloadable.c')
-rw-r--r--clang/test/Sema/overloadable.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/Sema/overloadable.c b/clang/test/Sema/overloadable.c
index f5e17d21191..49d8085651d 100644
--- a/clang/test/Sema/overloadable.c
+++ b/clang/test/Sema/overloadable.c
@@ -151,3 +151,18 @@ void dropping_qualifiers_is_incompatible() {
foo(ccharbuf); // expected-error{{call to 'foo' is ambiguous}} expected-note@148{{candidate function}} expected-note@149{{candidate function}}
foo(vcharbuf); // expected-error{{call to 'foo' is ambiguous}} expected-note@148{{candidate function}} expected-note@149{{candidate function}}
}
+
+// Bug: we used to treat `__typeof__(foo)` as though it was `__typeof__(&foo)`
+// if `foo` was overloaded with only one function that could have its address
+// taken.
+void typeof_function_is_not_a_pointer() {
+ void not_a_pointer(void *) __attribute__((overloadable));
+ void not_a_pointer(char *__attribute__((pass_object_size(1))))
+ __attribute__((overloadable));
+
+ __typeof__(not_a_pointer) *fn;
+
+ void take_fn(void (*)(void *));
+ // if take_fn is passed a void (**)(void *), we'll get a warning.
+ take_fn(fn);
+}
OpenPOWER on IntegriCloud