r181076 - <rdar://problem/13806270> A template argument list is a constant-evaluated context.
Douglas Gregor
dgregor at apple.com
Fri May 3 16:44:54 PDT 2013
Author: dgregor
Date: Fri May 3 18:44:54 2013
New Revision: 181076
URL: http://llvm.org/viewvc/llvm-project?rev=181076&view=rev
Log:
<rdar://problem/13806270> A template argument list is a constant-evaluated context.
Modified:
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=181076&r1=181075&r2=181076&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Fri May 3 18:44:54 2013
@@ -1149,6 +1149,9 @@ bool Parser::IsTemplateArgumentList(unsi
/// template-argument-list ',' template-argument
bool
Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs) {
+ // Template argument lists are constant-evaluation contexts.
+ EnterExpressionEvaluationContext EvalContext(Actions,Sema::ConstantEvaluated);
+
while (true) {
ParsedTemplateArgument Arg = ParseTemplateArgument();
if (Tok.is(tok::ellipsis)) {
Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=181076&r1=181075&r2=181076&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Fri May 3 18:44:54 2013
@@ -337,3 +337,12 @@ namespace rdar13000548 {
}
}
+
+namespace rdar13806270 {
+ template <unsigned N> class X { };
+ const unsigned value = 32;
+ struct Y {
+ X<value + 1> x;
+ };
+ void foo() {}
+}
More information about the cfe-commits
mailing list