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.

llvm-svn: 157553
This commit is contained in:
David Blaikie 2012-05-28 01:26:45 +00:00
parent 7fb195b683
commit c4c0e8aa9a
2 changed files with 11 additions and 1 deletions

View File

@ -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);

View File

@ -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;
}