[cfe-commits] r166496 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaTemplate/current-instantiation.cpp

Richard Smith richard-llvm at metafoo.co.uk
Tue Oct 23 12:56:01 PDT 2012


Author: rsmith
Date: Tue Oct 23 14:56:01 2012
New Revision: 166496

URL: http://llvm.org/viewvc/llvm-project?rev=166496&view=rev
Log:
When rebuilding a DependentScopeDeclRefExpr, perform a lookup into the scope
even if it's dependent, in case it now names a member of the current instantiation.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/SemaTemplate/current-instantiation.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=166496&r1=166495&r2=166496&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Oct 23 14:56:01 2012
@@ -1897,8 +1897,8 @@
 Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
                                         const DeclarationNameInfo &NameInfo,
                                         bool IsAddressOfOperand) {
-  DeclContext *DC;
-  if (!(DC = computeDeclContext(SS, false)) || DC->isDependentContext())
+  DeclContext *DC = computeDeclContext(SS, false);
+  if (!DC)
     return BuildDependentDeclRefExpr(SS, /*TemplateKWLoc=*/SourceLocation(),
                                      NameInfo, /*TemplateArgs=*/0);
 
@@ -1911,6 +1911,10 @@
   if (R.isAmbiguous())
     return ExprError();
 
+  if (R.getResultKind() == LookupResult::NotFoundInCurrentInstantiation)
+    return BuildDependentDeclRefExpr(SS, /*TemplateKWLoc=*/SourceLocation(),
+                                     NameInfo, /*TemplateArgs=*/0);
+
   if (R.empty()) {
     Diag(NameInfo.getLoc(), diag::err_no_member)
       << NameInfo.getName() << DC << SS.getRange();

Modified: cfe/trunk/test/SemaTemplate/current-instantiation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/current-instantiation.cpp?rev=166496&r1=166495&r2=166496&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/current-instantiation.cpp (original)
+++ cfe/trunk/test/SemaTemplate/current-instantiation.cpp Tue Oct 23 14:56:01 2012
@@ -2,7 +2,7 @@
 
 // This test concerns the identity of dependent types within the
 // canonical type system, specifically focusing on the difference
-// between members of the current instantiation and membmers of an
+// between members of the current instantiation and members of an
 // unknown specialization. This considers C++ [temp.type], which
 // specifies type equivalence within a template, and C++0x
 // [temp.dep.type], which defines what it means to be a member of the
@@ -235,3 +235,15 @@
   template<typename X<XT>::Enum>
   class X<XT>::Inner { };
 }
+
+namespace RebuildDependentScopeDeclRefExpr {
+  template<int> struct N {};
+  template<typename T> struct X {
+    static const int thing = 0;
+    N<thing> data();
+    N<thing> foo();
+  };
+  template<typename T> N<X<T>::thing> X<T>::data() {}
+  // FIXME: We should issue a typo-correction here.
+  template<typename T> N<X<T>::think> X<T>::foo() {} // expected-error {{no member named 'think' in 'X<T>'}}
+}





More information about the cfe-commits mailing list