summaryrefslogtreecommitdiffstats
path: root/test/CXX/over/over.over
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/over/over.over')
-rw-r--r--test/CXX/over/over.over/p2-resolve-single-template-id.cpp95
-rw-r--r--test/CXX/over/over.over/p2.cpp5
-rw-r--r--test/CXX/over/over.over/p4.cpp7
3 files changed, 99 insertions, 8 deletions
diff --git a/test/CXX/over/over.over/p2-resolve-single-template-id.cpp b/test/CXX/over/over.over/p2-resolve-single-template-id.cpp
new file mode 100644
index 0000000..f38a74e
--- /dev/null
+++ b/test/CXX/over/over.over/p2-resolve-single-template-id.cpp
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t;
+
+namespace DontResolveTooEarly_WaitForOverloadResolution
+{
+ template <class T> T* f(int); // #1
+ template <class T, class U> T& f(U); // #2
+
+ void g() {
+ int *ip = f<int>(1); // calls #1
+ }
+
+ template <class T>
+ T* f2(int);
+ template <class T, class U>
+ T& f2(U);
+
+ void g2() {
+ int*ip = (f2<int>)(1); // ok
+ }
+
+} // End namespace
+
+ template<typename T>
+ void twoT() { }
+ template<typename T, typename U>
+ void twoT(T) { }
+
+
+ void two() { }; //expected-note 5{{candidate}}
+ void two(int) { }; //expected-note 5{{candidate}}
+
+
+
+ void one() { }
+ template<class T>
+ void oneT() { }
+
+ template<class T>
+ void cant_resolve() { } //expected-note 3{{candidate}}
+
+ template<class T> void cant_resolve(T) { }//expected-note 3{{candidate}}
+
+
+int main()
+{
+ { static_cast<void>(one); }
+ { (void)(one); }
+ { static_cast<void>(oneT<int>); }
+ { (void)(oneT<int>); }
+
+ { static_cast<void>(two); } // expected-error {{address of overloaded}}
+ { (void)(two); } // expected-error {{address of overloaded}}
+ { static_cast<void>(twoT<int>); }
+ { (void)(twoT<int>); }
+
+
+ { ptrdiff_t x = reinterpret_cast<ptrdiff_t>(oneT<int>); }
+ { (void) reinterpret_cast<int (*)(char, double)>(oneT<int>); }
+ { (void) reinterpret_cast<ptrdiff_t>(one); }
+ { (void) reinterpret_cast<int (*)(char, double)>(one); }
+
+ { ptrdiff_t x = reinterpret_cast<ptrdiff_t>(twoT<int>); }
+ { (void) reinterpret_cast<int (*)(char, double)>(twoT<int>); }
+ { (void) reinterpret_cast<void (*)(int)>(two); } //expected-error {{reinterpret_cast}}
+ { (void) static_cast<void (*)(int)>(two); } //ok
+
+ { (void) reinterpret_cast<int>(two); } //expected-error {{reinterpret_cast}}
+ { (void) reinterpret_cast<int (*)(char, double)>(two); } //expected-error {{reinterpret_cast}}
+
+ { bool b = (twoT<int>); } // ok
+ { bool b = (twoT<int, int>); } //ok
+
+ { bool b = &twoT<int>; //&foo<int>; }
+ b = &(twoT<int>); }
+
+ { ptrdiff_t x = (ptrdiff_t) &twoT<int>;
+ x = (ptrdiff_t) &twoT<int>; }
+
+ { ptrdiff_t x = (ptrdiff_t) twoT<int>;
+ x = (ptrdiff_t) twoT<int>; }
+
+
+ { ptrdiff_t x = (ptrdiff_t) &twoT<int,int>;
+ x = (ptrdiff_t) &twoT<int>; }
+
+ { oneT<int>; &oneT<int>; } //expected-warning 2{{ expression result unused }}
+ { static_cast<void>(cant_resolve<int>); } // expected-error {{address of overload}}
+ { bool b = cant_resolve<int>; } // expected-error {{address of overload}}
+ { (void) cant_resolve<int>; } // expected-error {{address of overload}}
+
+}
+
+
diff --git a/test/CXX/over/over.over/p2.cpp b/test/CXX/over/over.over/p2.cpp
index e8840d2..3e8d0f1 100644
--- a/test/CXX/over/over.over/p2.cpp
+++ b/test/CXX/over/over.over/p2.cpp
@@ -1,10 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-template<typename T> T f0(T, T);
+template<typename T> T f0(T, T); //expected-note{{candidate}}
void test_f0() {
int (*f0a)(int, int) = f0;
int (*f0b)(int, int) = &f0;
- int (*f0c)(int, float) = f0; // expected-error{{cannot initialize}}
- // FIXME: poor error message above!
+ int (*f0c)(int, float) = f0; // expected-error{{address of overloaded function 'f0' does not match required type 'int (int, float)'}}
}
diff --git a/test/CXX/over/over.over/p4.cpp b/test/CXX/over/over.over/p4.cpp
index 4189218..27d070e 100644
--- a/test/CXX/over/over.over/p4.cpp
+++ b/test/CXX/over/over.over/p4.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-template<typename T> T f0(T);
+template<typename T> T f0(T); // expected-note{{candidate function}}
int f0(int); // expected-note{{candidate function}}
void test_f0() {
@@ -13,11 +13,8 @@ namespace N {
int f0(int); // expected-note{{candidate function}}
}
-int f0(int);
-
void test_f0_2() {
using namespace N;
- int (*fp0)(int) = f0; // expected-error{{ambiguous}} \
- // expected-error{{cannot initialize}}
+ int (*fp0)(int) = f0; // expected-error{{address of overloaded function 'f0' is ambiguous}}
float (*fp1)(float) = f0;
}
OpenPOWER on IntegriCloud