Add a few more tests for casts.

llvm-svn: 184392
This commit is contained in:
Eli Friedman 2013-06-20 01:35:13 +00:00
parent 8e5e97690d
commit 61a511ff5b
3 changed files with 14 additions and 2 deletions

View File

@ -65,3 +65,11 @@ void *intToPointer4() {
void *intToPointer5(long l) {
return (void*)l;
}
struct AmbiguousCast {
operator int(); // expected-note {{candidate function}}
operator unsigned int(); // expected-note {{candidate function}}
};
long long AmbiguousCastFunc(AmbiguousCast& a) {
return static_cast<long long>(a); // expected-error {{ambiguous conversion for static_cast from 'AmbiguousCast' to 'long long'}}
}

View File

@ -5,8 +5,6 @@
// 2012, which supports C++11 and static_assert. It should pass for both 64-bit
// and 32-bit x86.
//
// expected-no-diagnostics
// Test the size of various member pointer combinations:
// - complete and incomplete
// - single, multiple, and virtual inheritance (and unspecified for incomplete)
@ -165,3 +163,6 @@ struct MemPtrInTemplate {
int T::*data_ptr;
void (T::*func_ptr)();
};
int Virtual::*CastTest = reinterpret_cast<int Virtual::*>(&AA::x);
// expected-error@-1 {{cannot reinterpret_cast from member pointer type}}

View File

@ -64,6 +64,9 @@ nullptr_t f(nullptr_t null)
(void)reinterpret_cast<uintptr_t>(nullptr);
(void)reinterpret_cast<uintptr_t>(*pn);
// You can't reinterpret_cast nullptr to any integer
(void)reinterpret_cast<char>(nullptr); // expected-error {{cast from pointer to smaller type 'char' loses information}}
int *ip = *pn;
if (*pn) { }