[cfe-commits] r102186 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaCXX/member-pointer.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Fri Apr 23 10:18:26 PDT 2010
Author: cornedbee
Date: Fri Apr 23 12:18:26 2010
New Revision: 102186
URL: http://llvm.org/viewvc/llvm-project?rev=102186&view=rev
Log:
Require a complete type for the lhs of member pointer dereference operations if the type isn't exactly the same as the container class. Fixes PR6783.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/member-pointer.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=102186&r1=102185&r2=102186&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Apr 23 12:18:26 2010
@@ -1868,6 +1868,11 @@
}
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
Modified: cfe/trunk/test/SemaCXX/member-pointer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-pointer.cpp?rev=102186&r1=102185&r2=102186&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-pointer.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-pointer.cpp Fri Apr 23 12:18:26 2010
@@ -147,3 +147,13 @@
}
};
}
+
+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 ->*}}
+ }
+}
More information about the cfe-commits
mailing list