diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
| commit | dbe13110f59f48b4dbb7552b3ac2935acdeece7f (patch) | |
| tree | be1815eb79b42ff482a8562b13c2dcbf0c5dcbee /test/SemaCXX/reinterpret-cast.cpp | |
| parent | 9da628931ebf2609493570f87824ca22402cc65f (diff) | |
Notes
Diffstat (limited to 'test/SemaCXX/reinterpret-cast.cpp')
| -rw-r--r-- | test/SemaCXX/reinterpret-cast.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/test/SemaCXX/reinterpret-cast.cpp b/test/SemaCXX/reinterpret-cast.cpp index 68005a5270e4..7f41b93a46e4 100644 --- a/test/SemaCXX/reinterpret-cast.cpp +++ b/test/SemaCXX/reinterpret-cast.cpp @@ -9,13 +9,27 @@ typedef void (*fnptr)(); // Test the conversion to self. void self_conversion() { - // T*->T* is allowed, T->T in general not. + // T->T is allowed per [expr.reinterpret.cast]p2 so long as it doesn't + // cast away constness, and is integral, enumeration, pointer or + // pointer-to-member. int i = 0; - (void)reinterpret_cast<int>(i); // expected-error {{reinterpret_cast from 'int' to 'int' is not allowed}} - structure s; - (void)reinterpret_cast<structure>(s); // expected-error {{reinterpret_cast from 'structure' to 'structure' is not allowed}} + (void)reinterpret_cast<int>(i); + + test e = testval; + (void)reinterpret_cast<test>(e); + + // T*->T* is allowed int *pi = 0; (void)reinterpret_cast<int*>(pi); + + const int structure::*psi = 0; + (void)reinterpret_cast<const int structure::*>(psi); + + structure s; + (void)reinterpret_cast<structure>(s); // expected-error {{reinterpret_cast from 'structure' to 'structure' is not allowed}} + + float f = 0.0f; + (void)reinterpret_cast<float>(f); // expected-error {{reinterpret_cast from 'float' to 'float' is not allowed}} } // Test conversion between pointer and integral types, as in /3 and /4. |
