Always use a function's decl context when building default arguments. Fixes http://http://llvm.org/pr8479.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120299 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nico Weber 2010-11-29 18:19:25 +00:00
Родитель 03013fa9a0
Коммит 08e41a6565
2 изменённых файлов: 45 добавлений и 4 удалений

Просмотреть файл

@ -3862,7 +3862,15 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
InstantiatingTemplate Inst(*this, CallLoc, Param, Innermost.first, InstantiatingTemplate Inst(*this, CallLoc, Param, Innermost.first,
Innermost.second); Innermost.second);
ExprResult Result = SubstExpr(UninstExpr, ArgList); ExprResult Result;
{
// C++ [dcl.fct.default]p5:
// The names in the [default argument] expression are bound, and
// the semantic constraints are checked, at the point where the
// default argument expression appears.
ContextRAII SavedContext(*this, FD->getDeclContext());
Result = SubstExpr(UninstExpr, ArgList);
}
if (Result.isInvalid()) if (Result.isInvalid())
return ExprError(); return ExprError();

Просмотреть файл

@ -79,3 +79,36 @@ namespace test5 {
struct B { friend void B(); }; struct B { friend void B(); };
} }
// PR8479
namespace test6_1 {
class A {
public:
private:
friend class vectorA;
A() {}
};
class vectorA {
public:
vectorA(int i, const A& t = A()) {}
};
void f() {
vectorA v(1);
}
}
namespace test6_2 {
template<class T>
class vector {
public:
vector(int i, const T& t = T()) {}
};
class A {
public:
private:
friend class vector<A>;
A() {}
};
void f() {
vector<A> v(1);
}
}