Skip to content

Commit 54ea97a

Browse files
committed
Address comments
1 parent 24427c9 commit 54ea97a

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

clang/test/SemaCXX/builtin-invoke.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,27 @@ void call() {
8383
__builtin_invoke(malloc, 0);
8484
__builtin_invoke(__builtin_malloc, 0); // expected-error {{builtin functions must be directly called}}
8585

86-
// Member functiom pointer
86+
// Variadic function
87+
void variadic_func(int, ...); // expected-note {{declared here}}
88+
89+
__builtin_invoke(variadic_func); // expected-error {{too few arguments to function call, expected at least 1, have 0}}
90+
__builtin_invoke(variadic_func, 1);
91+
__builtin_invoke(variadic_func, 1, 2, 3);
92+
93+
// static member function
94+
struct StaticMember {
95+
static void func(int);
96+
};
97+
98+
__builtin_invoke(StaticMember::func, 1);
99+
StaticMember sm;
100+
__builtin_invoke(sm.func, 1);
101+
102+
// lambda
103+
__builtin_invoke([] {});
104+
__builtin_invoke([](int) {}, 1);
105+
106+
// Member function pointer
87107
__builtin_invoke(&Callable::func); // expected-error {{too few arguments to function call, expected at least 2, have 1}}
88108
__builtin_invoke(&Callable::func, 1); // expected-error {{indirection requires pointer operand ('int' invalid)}}
89109
__builtin_invoke(&Callable::func, Callable{});
@@ -146,3 +166,19 @@ auto test(T v) {
146166
auto call2() {
147167
test(call);
148168
}
169+
170+
template <class ClassT, class FuncT>
171+
void func(ClassT& c, FuncT&& func) {
172+
__builtin_invoke(func, c, 1, 2, 3); // expected-error {{too many arguments to function call, expected 0, have 3}}
173+
}
174+
175+
struct DependentTest {
176+
void func(int, int, int);
177+
void bad_func();
178+
};
179+
180+
void call3() {
181+
DependentTest d;
182+
func(d, &DependentTest::func);
183+
func(d, &DependentTest::bad_func); // expected-note {{requested here}}
184+
}

0 commit comments

Comments
 (0)