Don't use dyn_cast on a Type* which might not be canonical. Fixes an extremely obscure record layout bug.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169467 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/empty-class-layout.cpp b/test/SemaCXX/empty-class-layout.cpp
index 951f16c..3cfc491 100644
--- a/test/SemaCXX/empty-class-layout.cpp
+++ b/test/SemaCXX/empty-class-layout.cpp
@@ -156,3 +156,18 @@
   };
   SA(0, sizeof(Test) == 2);
 }
+
+namespace Test8 {
+  // Test that type sugar doesn't make us incorrectly determine the size of an
+  // array of empty classes.
+  struct Empty1 {};
+  struct Empty2 {};
+  struct Empties : Empty1, Empty2 {};
+  typedef Empty1 Sugar[4];
+  struct A : Empty2, Empties {
+    // This must go at offset 2, because if it were at offset 0,
+    // V[0][1] would overlap Empties::Empty1.
+    Sugar V[1];
+  };
+  SA(0, sizeof(A) == 6);
+}