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'}}
+}
// 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)
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}}
(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) { }