summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-06-11 23:51:46 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-06-11 23:51:46 +0000
commitf80fa1d28cd7d31f1744cfffa90f804e4578e9ac (patch)
tree775c1ede9f097cdb5e265a240fbc373704df8412
parente75ebf573f7f71e65e7bdfa288254237eb563255 (diff)
downloadclang-f80fa1d28cd7d31f1744cfffa90f804e4578e9ac.tar.gz
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@363113 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp2
-rw-r--r--test/SemaTemplate/default-arguments.cpp6
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index ed39278b1a..d444a35be8 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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;
diff --git a/test/SemaTemplate/default-arguments.cpp b/test/SemaTemplate/default-arguments.cpp
index b5b042c64a..882b279de1 100644
--- a/test/SemaTemplate/default-arguments.cpp
+++ b/test/SemaTemplate/default-arguments.cpp
@@ -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());
+}