[cfe-commits] r124867 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaTemplate/dependent-names.cpp
Douglas Gregor
dgregor at apple.com
Fri Feb 4 05:35:07 PST 2011
Author: dgregor
Date: Fri Feb 4 07:35:07 2011
New Revision: 124867
URL: http://llvm.org/viewvc/llvm-project?rev=124867&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaTemplate/dependent-names.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=124867&r1=124866&r2=124867&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Feb 4 07:35:07 2011
@@ -1035,28 +1035,6 @@
}
}
-/// 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 @@
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 @@
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) {
Modified: cfe/trunk/test/SemaTemplate/dependent-names.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-names.cpp?rev=124867&r1=124866&r2=124867&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/dependent-names.cpp (original)
+++ cfe/trunk/test/SemaTemplate/dependent-names.cpp Fri Feb 4 07:35:07 2011
@@ -102,3 +102,30 @@
template struct Derived<int>; // expected-note {{requested here}}
}
+
+namespace PR8966 {
+ template <class T>
+ class MyClassCore
+ {
+ };
+
+ template <class T>
+ class MyClass : public MyClassCore<T>
+ {
+ public:
+ enum {
+ N
+ };
+
+ // static member declaration
+ static const char* array [N];
+
+ void f() {
+ MyClass<T>::InBase = 17;
+ }
+ };
+
+ // static member definition
+ template <class T>
+ const char* MyClass<T>::array [MyClass<T>::N] = { "A", "B", "C" };
+}
More information about the cfe-commits
mailing list