aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaType.cpp9
-rw-r--r--test/SemaCXX/member-pointer-ms.cpp6
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 28d1f13775..6df16bd300 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -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
index 0000000000..8987f6d66f
--- /dev/null
+++ b/test/SemaCXX/member-pointer-ms.cpp
@@ -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'}}
+