]> granicus.if.org Git - clang/commitdiff
Require a complete type for the lhs of member pointer dereference operations if the...
authorSebastian Redl <sebastian.redl@getdesigned.at>
Fri, 23 Apr 2010 17:18:26 +0000 (17:18 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Fri, 23 Apr 2010 17:18:26 +0000 (17:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102186 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/member-pointer.cpp

index 7df1c5683c381a3314cd930000fcb77dbb818817..007eecd0e85e755f28fd7bb58d29ea039cec6718 100644 (file)
@@ -1868,6 +1868,11 @@ QualType Sema::CheckPointerToMemberOperands(
   }
 
   if (!Context.hasSameUnqualifiedType(Class, LType)) {
+    // If we want to check the hierarchy, we need a complete type.
+    if (RequireCompleteType(Loc, LType, PDiag(diag::err_bad_memptr_lhs)
+        << OpSpelling << (int)isIndirect)) {
+      return QualType();
+    }
     CXXBasePaths Paths(/*FindAmbiguities=*/true, /*RecordPaths=*/false,
                        /*DetectVirtual=*/false);
     // FIXME: Would it be useful to print full ambiguity paths, or is that
index aa941a19f61b89b924e2375bdbbb4f01533e8eb2..be25cbdb7ed0308efc9feb33a16ef74537e00ea4 100644 (file)
@@ -147,3 +147,13 @@ namespace pr5985 {
     }
   };
 }
+
+namespace pr6783 {
+  struct Base {};
+  struct X; // expected-note {{forward declaration}}
+
+  int test1(int Base::* p2m, X* object)
+  {
+    return object->*p2m; // expected-error {{left hand operand to ->*}}
+  }
+}