summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-11-08 03:40:48 +0000
committerDouglas Gregor <dgregor@apple.com>2010-11-08 03:40:48 +0000
commite81f58e1801176942d2d47b1b7027c4dfb7d9d1b (patch)
treebe6b8cd51cd38166f5f36c0c08ef97fcb21c9a50 /clang/test
parent21184644afefd30f76098b2b48abe6d6ae0fc115 (diff)
downloadbcm5719-llvm-e81f58e1801176942d2d47b1b7027c4dfb7d9d1b.tar.gz
bcm5719-llvm-e81f58e1801176942d2d47b1b7027c4dfb7d9d1b.zip
Properly diagnose invalid casts to function references. Patch by
Faisal Vali, tweaked by me. Fixes PR8230. llvm-svn: 118400
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp6
-rw-r--r--clang/test/CXX/over/over.over/p2.cpp3
-rw-r--r--clang/test/CXX/over/over.over/p4.cpp3
-rw-r--r--clang/test/SemaCXX/addr-of-overloaded-function.cpp12
-rw-r--r--clang/test/SemaCXX/static-cast.cpp4
5 files changed, 12 insertions, 16 deletions
diff --git a/clang/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp b/clang/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp
index 170c734fd30..06cc6107402 100644
--- a/clang/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp
+++ b/clang/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp
@@ -7,8 +7,7 @@ namespace test0 {
template<typename T> void g(T);
void test() {
- // FIXME: this diagnostic is terrible
- foo(&g<int>); // expected-error {{cannot initialize a parameter of type 'void (test0::A::*)(int)' with an rvalue of type '<overloaded function type>'}}
+ foo(&g<int>); // expected-error {{can't form member pointer of type 'void (test0::A::*)(int)' without '&' and class name}}
}
};
}
@@ -39,7 +38,6 @@ namespace test2 {
};
void A::test() {
- // FIXME: This diagnostic is terrible.
- int (A::*ptr)(int) = &(A::foo); // expected-error {{cannot initialize a variable of type 'int (test2::A::*)(int)' with an rvalue of type '<overloaded function type>'}}
+ int (A::*ptr)(int) = &(A::foo); // expected-error {{can't form member pointer of type 'int (test2::A::*)(int)' without '&' and class name}}
}
}
diff --git a/clang/test/CXX/over/over.over/p2.cpp b/clang/test/CXX/over/over.over/p2.cpp
index e8840d205e8..1c3d036b153 100644
--- a/clang/test/CXX/over/over.over/p2.cpp
+++ b/clang/test/CXX/over/over.over/p2.cpp
@@ -5,6 +5,5 @@ template<typename T> T f0(T, T);
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/clang/test/CXX/over/over.over/p4.cpp b/clang/test/CXX/over/over.over/p4.cpp
index 4189218f652..7b5009ab6fa 100644
--- a/clang/test/CXX/over/over.over/p4.cpp
+++ b/clang/test/CXX/over/over.over/p4.cpp
@@ -17,7 +17,6 @@ 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;
}
diff --git a/clang/test/SemaCXX/addr-of-overloaded-function.cpp b/clang/test/SemaCXX/addr-of-overloaded-function.cpp
index ab80d8f1416..c095e946c8b 100644
--- a/clang/test/SemaCXX/addr-of-overloaded-function.cpp
+++ b/clang/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-int f(double);
-int f(int);
+int f(double); // expected-note{{candidate function}}
+int f(int); // expected-note{{candidate function}}
int (*pfd)(double) = f; // selects f(double)
int (*pfd2)(double) = &f; // selects f(double)
@@ -9,7 +9,7 @@ int (*pfi)(int) = &f; // selects f(int)
// FIXME: This error message is not very good. We need to keep better
// track of what went wrong when the implicit conversion failed to
// give a better error message here.
-int (*pfe)(...) = &f; // expected-error{{cannot initialize a variable of type 'int (*)(...)' with an rvalue of type '<overloaded function type>'}}
+int (*pfe)(...) = &f; // expected-error{{address of overloaded function 'f' does not match required type 'int (...)'}}
int (&rfi)(int) = f; // selects f(int)
int (&rfd)(double) = f; // selects f(double)
@@ -98,10 +98,10 @@ namespace PR7971 {
}
namespace PR8033 {
- template <typename T1, typename T2> int f(T1 *, const T2 *); // expected-note{{candidate function [with T1 = const int, T2 = int]}}
- template <typename T1, typename T2> int f(const T1 *, T2 *); // expected-note{{candidate function [with T1 = int, T2 = const int]}}
+ template <typename T1, typename T2> int f(T1 *, const T2 *); // expected-note 2{{candidate function [with T1 = const int, T2 = int]}}
+ template <typename T1, typename T2> int f(const T1 *, T2 *); // expected-note 2{{candidate function [with T1 = int, T2 = const int]}}
int (*p)(const int *, const int *) = f; // expected-error{{address of overloaded function 'f' is ambiguous}} \
- // expected-error{{cannot initialize a variable of type}}
+ // expected-error{{address of overloaded function 'f' is ambiguous}}
}
diff --git a/clang/test/SemaCXX/static-cast.cpp b/clang/test/SemaCXX/static-cast.cpp
index c8639a95440..46c6eee2c4e 100644
--- a/clang/test/SemaCXX/static-cast.cpp
+++ b/clang/test/SemaCXX/static-cast.cpp
@@ -184,7 +184,7 @@ void PR5897() { (void)static_cast<const int(*)[1]>((const void*)0); }
namespace PR6072 {
struct A { };
- struct B : A { void f(int); void f(); };
+ struct B : A { void f(int); void f(); }; // expected-note 2{{candidate function}}
struct C : B { };
struct D { };
@@ -192,6 +192,6 @@ namespace PR6072 {
(void)static_cast<void (A::*)()>(&B::f);
(void)static_cast<void (B::*)()>(&B::f);
(void)static_cast<void (C::*)()>(&B::f);
- (void)static_cast<void (D::*)()>(&B::f); // expected-error{{static_cast from '<overloaded function type>' to 'void (PR6072::D::*)()' is not allowed}}
+ (void)static_cast<void (D::*)()>(&B::f); // expected-error{{address of overloaded function 'f' cannot be static_cast to type 'void (PR6072::D::*)()'}}
}
}
OpenPOWER on IntegriCloud