summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/addr-of-overloaded-function.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/addr-of-overloaded-function.cpp')
-rw-r--r--test/SemaCXX/addr-of-overloaded-function.cpp37
1 files changed, 34 insertions, 3 deletions
diff --git a/test/SemaCXX/addr-of-overloaded-function.cpp b/test/SemaCXX/addr-of-overloaded-function.cpp
index 096f748..230a1eb 100644
--- a/test/SemaCXX/addr-of-overloaded-function.cpp
+++ b/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -57,11 +57,12 @@ struct B
struct C {
C &getC() {
- return makeAC; // expected-error{{reference to non-static member function must be called}}
+ return makeAC; // expected-error{{reference to non-static member function must be called; did you mean to call it with no arguments?}}
}
- C &makeAC();
- const C &makeAC() const;
+ // FIXME: filter by const so we can unambiguously suggest '()' & point to just the one candidate, probably
+ C &makeAC(); // expected-note{{possible target for call}}
+ const C &makeAC() const; // expected-note{{possible target for call}}
static void f(); // expected-note{{candidate function}}
static void f(int); // expected-note{{candidate function}}
@@ -69,6 +70,32 @@ struct C {
void g() {
int (&fp)() = f; // expected-error{{address of overloaded function 'f' does not match required type 'int ()'}}
}
+
+ template<typename T>
+ void q1(int); // expected-note{{possible target for call}}
+ template<typename T>
+ void q2(T t = T()); // expected-note{{possible target for call}}
+ template<typename T>
+ void q3(); // expected-note{{possible target for call}}
+ template<typename T1, typename T2>
+ void q4(); // expected-note{{possible target for call}}
+ template<typename T1 = int> // expected-warning{{default template arguments for a function template are a C++11 extension}}
+ void q5(); // expected-note{{possible target for call}}
+
+ void h() {
+ // Do not suggest '()' since an int argument is required
+ q1<int>; // expected-error-re{{reference to non-static member function must be called$}}
+ // Suggest '()' since there's a default value for the only argument & the
+ // type argument is already provided
+ q2<int>; // expected-error{{reference to non-static member function must be called; did you mean to call it with no arguments?}}
+ // Suggest '()' since no arguments are required & the type argument is
+ // already provided
+ q3<int>; // expected-error{{reference to non-static member function must be called; did you mean to call it with no arguments?}}
+ // Do not suggest '()' since another type argument is required
+ q4<int>; // expected-error-re{{reference to non-static member function must be called$}}
+ // Suggest '()' since the type parameter has a default value
+ q5; // expected-error{{reference to non-static member function must be called; did you mean to call it with no arguments?}}
+ }
};
// PR6886
@@ -208,3 +235,7 @@ namespace test1 {
void (Qualifiers::*X)() = &Dummy::N; // expected-error{{cannot initialize a variable of type 'void (test1::Qualifiers::*)()' with an rvalue of type 'void (test1::Dummy::*)()': different classes ('test1::Qualifiers' vs 'test1::Dummy')}}
}
+
+template <typename T> class PR16561 {
+ virtual bool f() { if (f) {} return false; } // expected-error {{reference to non-static member function must be called}}
+};
OpenPOWER on IntegriCloud