]> granicus.if.org Git - clang/commitdiff
Fix for PR5659: correct a rather nasty oversight in the type conversion for
authorEli Friedman <eli.friedman@gmail.com>
Thu, 3 Dec 2009 12:44:31 +0000 (12:44 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 3 Dec 2009 12:44:31 +0000 (12:44 +0000)
member pointer types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90450 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenTypes.cpp
test/CodeGenCXX/member-pointer-type-convert.cpp [new file with mode: 0644]

index c89879fdb6c40c45f6ead6bbc52a7cb1ebd764f7..cd3575c132ce83b3eca05c4e3fae9b8b8e937943 100644 (file)
@@ -379,13 +379,13 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
     // If we ever want to support other ABIs this needs to be abstracted.
 
     QualType ETy = cast<MemberPointerType>(Ty).getPointeeType();
+    const llvm::Type *PtrDiffTy =
+        ConvertTypeRecursive(Context.getPointerDiffType());
     if (ETy->isFunctionType()) {
-      return llvm::StructType::get(TheModule.getContext(),
-                                   ConvertType(Context.getPointerDiffType()),
-                                   ConvertType(Context.getPointerDiffType()),
+      return llvm::StructType::get(TheModule.getContext(), PtrDiffTy, PtrDiffTy,
                                    NULL);
     } else
-      return ConvertType(Context.getPointerDiffType());
+      return PtrDiffTy;
   }
 
   case Type::TemplateSpecialization:
diff --git a/test/CodeGenCXX/member-pointer-type-convert.cpp b/test/CodeGenCXX/member-pointer-type-convert.cpp
new file mode 100644 (file)
index 0000000..6969e0d
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: clang-cc -emit-llvm %s -o - | FileCheck %s
+
+struct A;
+typedef int A::*param_t;
+struct {
+  const char *name;
+  param_t par;
+} *ptr;
+
+// CHECK: type { i8*, i32 }