Special-case default argument expression in instantiation. This should fix PR4301. Doug, please double-check my assumptions. Read the PR for more details.
llvm-svn: 86465
This commit is contained in:
parent
b0a05f7ca1
commit
14236c8e82
|
|
@ -427,6 +427,9 @@ namespace {
|
|||
Sema::OwningExprResult TransformDeclRefExpr(DeclRefExpr *E,
|
||||
bool isAddressOfOperand);
|
||||
|
||||
Sema::OwningExprResult TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E,
|
||||
bool isAddressOfOperand);
|
||||
|
||||
/// \brief Transforms a template type parameter type by performing
|
||||
/// substitution of the corresponding template type argument.
|
||||
QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
|
||||
|
|
@ -648,6 +651,15 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E,
|
|||
isAddressOfOperand);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult TemplateInstantiator::TransformCXXDefaultArgExpr(
|
||||
CXXDefaultArgExpr *E, bool isAddressOfOperand) {
|
||||
assert(!cast<FunctionDecl>(E->getParam()->getDeclContext())->
|
||||
getDescribedFunctionTemplate() &&
|
||||
"Default arg expressions are never formed in dependent cases.");
|
||||
return SemaRef.Owned(E->Retain());
|
||||
}
|
||||
|
||||
|
||||
QualType
|
||||
TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB,
|
||||
TemplateTypeParmTypeLoc TL) {
|
||||
|
|
|
|||
|
|
@ -108,3 +108,26 @@ struct D {
|
|||
};
|
||||
D::D() { } // expected-note {{in instantiation of default function argument expression for 'A<int *>' required he}}
|
||||
}
|
||||
|
||||
// PR5301
|
||||
namespace pr5301 {
|
||||
void f(int, int = 0);
|
||||
|
||||
template <typename T>
|
||||
void g(T, T = 0);
|
||||
|
||||
template <int I>
|
||||
void i(int a = I);
|
||||
|
||||
template <typename T>
|
||||
void h(T t) {
|
||||
f(0);
|
||||
g(1);
|
||||
g(t);
|
||||
i<2>();
|
||||
}
|
||||
|
||||
void test() {
|
||||
h(0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue