[cfe-commits] r157553 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp

David Blaikie dblaikie at gmail.com
Sun May 27 18:26:45 PDT 2012


Author: dblaikie
Date: Sun May 27 20:26:45 2012
New Revision: 157553

URL: http://llvm.org/viewvc/llvm-project?rev=157553&view=rev
Log:
Fix PR12960 by not attempting to correct cases when we're not actually instantiatiating a template.

This comes up in the begin/end calls of a range-for (see the included test
case). Other suggestions are welcome, though this seems to do the trick without
regressing anything.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=157553&r1=157552&r2=157553&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun May 27 20:26:45 2012
@@ -1371,7 +1371,8 @@
   // unqualified lookup.  This is useful when (for example) the
   // original lookup would not have found something because it was a
   // dependent name.
-  DeclContext *DC = SS.isEmpty() ? CurContext : 0;
+  DeclContext *DC = (SS.isEmpty() && !CallsUndergoingInstantiation.empty())
+    ? CurContext : 0;
   while (DC) {
     if (isa<CXXRecordDecl>(DC)) {
       LookupQualifiedName(R, DC);

Modified: cfe/trunk/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp?rev=157553&r1=157552&r2=157553&view=diff
==============================================================================
--- cfe/trunk/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp (original)
+++ cfe/trunk/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp Sun May 27 20:26:45 2012
@@ -1,5 +1,13 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
 
+struct pr12960 {
+  int begin;
+  void foo(int x) {
+    for (int& it : x) { // expected-error {{use of undeclared identifier 'begin'}} expected-note {{range has type 'int'}}
+    }
+  }
+};
+
 namespace std {
   template<typename T>
     auto begin(T &&t) -> decltype(t.begin()) { return t.begin(); } // expected-note 4{{ignored: substitution failure}}
@@ -207,3 +215,4 @@
   for (int &x : array)
     x *= 2;
 }
+





More information about the cfe-commits mailing list