When marking declarations referenced within an expression (e.g.,

within a default argument), recurse into default arguments. Fixes
PR8401, a regression I introduced in r113700 while refactoring our
handling of "used" declarations in default arguments.

llvm-svn: 116817
This commit is contained in:
Douglas Gregor 2010-10-19 17:17:35 +00:00
parent 418204e523
commit f0873f4c85
2 changed files with 22 additions and 0 deletions

View File

@ -8019,6 +8019,10 @@ namespace {
void VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
S.MarkDeclarationReferenced(E->getLocation(), E->getDecl());
}
void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Visit(E->getExpr());
}
};
}

View File

@ -274,3 +274,21 @@ namespace rdar8427926 {
x->g();
}
}
namespace PR8401 {
template<typename T>
struct A {
A() { T* x = 1; } // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
};
template<typename T>
struct B {
B(const A<T>& a = A<T>()); // expected-note{{in instantiation of}}
};
void f(B<int> b = B<int>());
void g() {
f();
}
}