C++ 5.2.10p2 has a note that mentions that, subject to all other restrictions,
a cast to the same type is allowed so long as it does not cast away constness.

Fix for PR11747. Patch by Aaron Ballman. Reviewed by Eli.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149664 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/reinterpret-cast.cpp b/test/SemaCXX/reinterpret-cast.cpp
index 68005a5..7f41b93 100644
--- a/test/SemaCXX/reinterpret-cast.cpp
+++ b/test/SemaCXX/reinterpret-cast.cpp
@@ -9,13 +9,27 @@
 // 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.