diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-11-17 05:17:33 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-11-17 05:17:33 +0000 |
| commit | 3fad61786e7c78ee8acd08f95e26824b0d215594 (patch) | |
| tree | c614e3350f5ae43812f270b0c48735c6021ae32d /clang/lib | |
| parent | a9d7cdf55215374186891dda278a5f3dde44a177 (diff) | |
| download | bcm5719-llvm-3fad61786e7c78ee8acd08f95e26824b0d215594.tar.gz bcm5719-llvm-3fad61786e7c78ee8acd08f95e26824b0d215594.zip | |
Require the object type of a member access expression ("." or "->") to
be complete.
llvm-svn: 89042
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 12 |
2 files changed, 14 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index fdce0e6c2dc..dd3fd2c5c1a 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -2141,12 +2141,19 @@ Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc, return move(Base); } + // The object type must be complete (or dependent). + if (!BaseType->isDependentType() && + RequireCompleteType(OpLoc, BaseType, + PDiag(diag::err_incomplete_member_access))) + return ExprError(); + // C++ [basic.lookup.classref]p2: // If the id-expression in a class member access (5.2.5) is an - // unqualified-id, and the type of the object expres- sion is of a class + // unqualified-id, and the type of the object expression is of a class // type C (or of pointer to a class type C), the unqualified-id is looked // up in the scope of class C. [...] ObjectType = BaseType.getAsOpaquePtr(); + return move(Base); } diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 317d1339540..a799ddb24bf 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -130,12 +130,17 @@ TemplateNameKind Sema::isTemplateName(Scope *S, QualType ObjectType = QualType::getFromOpaquePtr(ObjectTypePtr); LookupCtx = computeDeclContext(ObjectType); isDependent = ObjectType->isDependentType(); + assert((isDependent || !ObjectType->isIncompleteType()) && + "Caller should have completed object type"); } else if (SS.isSet()) { // This nested-name-specifier occurs after another nested-name-specifier, // so long into the context associated with the prior nested-name-specifier. - LookupCtx = computeDeclContext(SS, EnteringContext); isDependent = isDependentScopeSpecifier(SS); + + // The declaration context must be complete. + if (LookupCtx && RequireCompleteDeclContext(SS)) + return TNK_Non_template; } LookupResult Found(*this, TName, SourceLocation(), LookupOrdinaryName); @@ -145,11 +150,6 @@ TemplateNameKind Sema::isTemplateName(Scope *S, // computed, which is either the type of the base of a member access // expression or the declaration context associated with a prior // nested-name-specifier. - - // The declaration context must be complete. - if (!LookupCtx->isDependentContext() && RequireCompleteDeclContext(SS)) - return TNK_Non_template; - LookupQualifiedName(Found, LookupCtx); if (ObjectTypePtr && Found.empty()) { |

