]> granicus.if.org Git - clang/commitdiff
Err on incomplete class types in member pointers when compiling for the
authorCharles Davis <cdavis@mines.edu>
Mon, 16 Aug 2010 04:01:50 +0000 (04:01 +0000)
committerCharles Davis <cdavis@mines.edu>
Mon, 16 Aug 2010 04:01:50 +0000 (04:01 +0000)
Microsoft C++ ABI, for now.

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

lib/Sema/SemaType.cpp
test/SemaCXX/member-pointer-ms.cpp [new file with mode: 0644]

index 28d1f1377518c6776e0bcc379bd832a252c80bfc..6df16bd300b190ae215d35f49e5e7f89138404c5 100644 (file)
@@ -20,6 +20,7 @@
 #include "clang/AST/TypeLocVisitor.h"
 #include "clang/AST/Expr.h"
 #include "clang/Basic/PartialDiagnostic.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Parse/DeclSpec.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -882,6 +883,14 @@ QualType Sema::BuildMemberPointerType(QualType T, QualType Class,
     return QualType();
   }
 
+  // In the Microsoft ABI, the class is allowed to be an incomplete
+  // type. In such cases, the compiler makes a worst-case assumption.
+  // We make no such assumption right now, so emit an error if the
+  // class isn't a complete type.
+  if (Context.Target.getCXXABI() == "microsoft" &&
+      RequireCompleteType(Loc, Class, diag::err_incomplete_type))
+    return QualType();
+
   return Context.getMemberPointerType(T, Class.getTypePtr());
 }
 
diff --git a/test/SemaCXX/member-pointer-ms.cpp b/test/SemaCXX/member-pointer-ms.cpp
new file mode 100644 (file)
index 0000000..8987f6d
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -cxx-abi microsoft -fsyntax-only -verify %s
+
+// Test that we reject pointers to members of incomplete classes (for now)
+struct A; //expected-note{{forward declaration of 'A'}}
+int A::*pai1; //expected-error{{incomplete type 'A'}}
+