r363113 - Mark declarations as referenced by a default argument in a
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 11 16:51:46 PDT 2019
Author: rsmith
Date: Tue Jun 11 16:51:46 2019
New Revision: 363113
URL: http://llvm.org/viewvc/llvm-project?rev=363113&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaTemplate/default-arguments.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=363113&r1=363112&r2=363113&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jun 11 16:51:46 2019
@@ -4855,6 +4855,8 @@ bool Sema::CheckCXXDefaultArgExpr(Source
// 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;
Modified: cfe/trunk/test/SemaTemplate/default-arguments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments.cpp?rev=363113&r1=363112&r2=363113&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/default-arguments.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-arguments.cpp Tue Jun 11 16:51:46 2019
@@ -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());
+}
More information about the cfe-commits
mailing list