Mark declarations as referenced by a default argument in a

potentially-evaluated context.

This applies even if the use of the default argument is within an
unevaluated context.

llvm-svn: 363113
This commit is contained in:
Richard Smith 2019-06-11 23:51:46 +00:00
parent 02f0b379f5
commit 7f61d44178
2 changed files with 8 additions and 0 deletions

View File

@ -4855,6 +4855,8 @@ bool Sema::CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD,
// We already type-checked the argument, so we know it works.
// Just mark all of the declarations in this potentially-evaluated expression
// as being "referenced".
EnterExpressionEvaluationContext EvalContext(
*this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
MarkDeclarationsReferencedInExpr(Param->getDefaultArg(),
/*SkipLocalVariables=*/true);
return false;

View File

@ -223,3 +223,9 @@ namespace friends {
X<int> *p;
}
}
namespace unevaluated {
int a;
template<int = 0> int f(int = a); // expected-warning 0-1{{extension}}
int k = sizeof(f());
}