diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-05-28 01:26:45 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-05-28 01:26:45 +0000 |
commit | 4872e1014844632083690cc1d021b95218a5023b (patch) | |
tree | c4ebaa0ea80f5ad49159d42005d262049de90ed7 | |
parent | fb527dcaba83b130ff7ef9fc454b548d15d1abe6 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157553 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 3 | ||||
-rw-r--r-- | test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index ce4234b7b0..91e0f721b6 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1371,7 +1371,8 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, // 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); diff --git a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp index a45b35f715..96bb472122 100644 --- a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp +++ b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp @@ -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 @@ void example() { for (int &x : array) x *= 2; } + |