summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-04 13:35:07 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-04 13:35:07 +0000
commita522693f66f631c54057d77271aedfbab2f950e6 (patch)
treed97618d4fa5e03233306402637d6ac8348dd9139 /clang/lib/Sema
parent789adec6bde00e42fddc7db5973a7834512a6acf (diff)
downloadbcm5719-llvm-a522693f66f631c54057d77271aedfbab2f950e6.tar.gz
bcm5719-llvm-a522693f66f631c54057d77271aedfbab2f950e6.zip
Improve our handling of the current instantiation for qualified
id-expression, e.g., CurrentClass<T>::member Previously, if CurrentClass<T> was dependent and not complete, we would treat it as a dependent-scoped declaration reference expression, even if CurrentClass<T> referred to the current instantiation. Fixes PR8966 and improves type checking of templates. llvm-svn: 124867
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp36
1 files changed, 11 insertions, 25 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 0d4950fd16c..a4649777792 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1035,28 +1035,6 @@ static void DecomposeUnqualifiedId(Sema &SemaRef,
}
}
-/// Determines whether the given record is "fully-formed" at the given
-/// location, i.e. whether a qualified lookup into it is assured of
-/// getting consistent results already.
-static bool IsFullyFormedScope(Sema &SemaRef, CXXRecordDecl *Record) {
- if (!Record->hasDefinition())
- return false;
-
- for (CXXRecordDecl::base_class_iterator I = Record->bases_begin(),
- E = Record->bases_end(); I != E; ++I) {
- CanQualType BaseT = SemaRef.Context.getCanonicalType((*I).getType());
- CanQual<RecordType> BaseRT = BaseT->getAs<RecordType>();
- if (!BaseRT) return false;
-
- CXXRecordDecl *BaseRecord = cast<CXXRecordDecl>(BaseRT->getDecl());
- if (!BaseRecord->hasDefinition() ||
- !IsFullyFormedScope(SemaRef, BaseRecord))
- return false;
- }
-
- return true;
-}
-
/// Determines if the given class is provably not derived from all of
/// the prospective base classes.
static bool IsProvablyNotDerivedFrom(Sema &SemaRef,
@@ -1489,9 +1467,6 @@ ExprResult Sema::ActOnIdExpression(Scope *S,
if (DC) {
if (RequireCompleteDeclContext(SS, DC))
return ExprError();
- // FIXME: We should be checking whether DC is the current instantiation.
- if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC))
- DependentID = !IsFullyFormedScope(*this, RD);
} else {
DependentID = true;
}
@@ -1513,10 +1488,21 @@ ExprResult Sema::ActOnIdExpression(Scope *S,
bool MemberOfUnknownSpecialization;
LookupTemplateName(R, S, SS, QualType(), /*EnteringContext=*/false,
MemberOfUnknownSpecialization);
+
+ if (MemberOfUnknownSpecialization ||
+ (R.getResultKind() == LookupResult::NotFoundInCurrentInstantiation))
+ return ActOnDependentIdExpression(SS, NameInfo, isAddressOfOperand,
+ TemplateArgs);
} else {
IvarLookupFollowUp = (!SS.isSet() && II && getCurMethodDecl());
LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
+ // If the result might be in a dependent base class, this is a dependent
+ // id-expression.
+ if (R.getResultKind() == LookupResult::NotFoundInCurrentInstantiation)
+ return ActOnDependentIdExpression(SS, NameInfo, isAddressOfOperand,
+ TemplateArgs);
+
// If this reference is in an Objective-C method, then we need to do
// some special Objective-C lookup, too.
if (IvarLookupFollowUp) {
OpenPOWER on IntegriCloud