r262747 - Implement P0036R0: remove support for empty unary folds of +, *, |, &.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 4 13:27:21 PST 2016
Author: rsmith
Date: Fri Mar 4 15:27:21 2016
New Revision: 262747
URL: http://llvm.org/viewvc/llvm-project?rev=262747&view=rev
Log:
Implement P0036R0: remove support for empty unary folds of +, *, |, &.
Modified:
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/test/SemaTemplate/cxx1z-fold-expressions.cpp
cfe/trunk/www/cxx_status.html
Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=262747&r1=262746&r2=262747&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Fri Mar 4 15:27:21 2016
@@ -996,10 +996,6 @@ ExprResult Sema::BuildEmptyCXXFoldExpr(S
BinaryOperatorKind Operator) {
// [temp.variadic]p9:
// If N is zero for a unary fold-expression, the value of the expression is
- // * -> 1
- // + -> int()
- // & -> -1
- // | -> int()
// && -> true
// || -> false
// , -> void()
@@ -1009,17 +1005,6 @@ ExprResult Sema::BuildEmptyCXXFoldExpr(S
// prevent the result from being a null pointer constant.
QualType ScalarType;
switch (Operator) {
- case BO_Add:
- ScalarType = Context.IntTy;
- break;
- case BO_Mul:
- return ActOnIntegerConstant(EllipsisLoc, 1);
- case BO_Or:
- ScalarType = Context.IntTy;
- break;
- case BO_And:
- return CreateBuiltinUnaryOp(EllipsisLoc, UO_Minus,
- ActOnIntegerConstant(EllipsisLoc, 1).get());
case BO_LOr:
return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_false);
case BO_LAnd:
Modified: cfe/trunk/test/SemaTemplate/cxx1z-fold-expressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/cxx1z-fold-expressions.cpp?rev=262747&r1=262746&r2=262747&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/cxx1z-fold-expressions.cpp (original)
+++ cfe/trunk/test/SemaTemplate/cxx1z-fold-expressions.cpp Fri Mar 4 15:27:21 2016
@@ -25,10 +25,6 @@ constexpr bool check() {
static_assert(check());
template<int ...N> void empty() {
- static_assert((N + ...) == 0);
- static_assert((N * ...) == 1);
- static_assert((N | ...) == 0);
- static_assert((N & ...) == -1);
static_assert((N || ...) == false);
static_assert((N && ...) == true);
(N, ...);
@@ -36,14 +32,19 @@ template<int ...N> void empty() {
template void empty<>();
// An empty fold-expression isn't a null pointer just because it's an integer
-// with value 0.
+// with value 0. (This is no longer an issue since empty pack expansions don't
+// produce integers any more.)
template<int ...N> void null_ptr() {
- void *p = (N + ...); // expected-error {{rvalue of type 'int'}}
- void *q = (N | ...); // expected-error {{rvalue of type 'int'}}
+ void *p = (N || ...); // expected-error {{rvalue of type 'bool'}}
+ void *q = (N , ...); // expected-error {{rvalue of type 'void'}}
}
template void null_ptr<>(); // expected-note {{in instantiation of}}
template<int ...N> void bad_empty() {
+ (N + ...); // expected-error {{empty expansion for operator '+' with no fallback}}
+ (N * ...); // expected-error {{empty expansion for operator '*' with no fallback}}
+ (N | ...); // expected-error {{empty expansion for operator '|' with no fallback}}
+ (N & ...); // expected-error {{empty expansion for operator '&' with no fallback}}
(N - ...); // expected-error {{empty expansion for operator '-' with no fallback}}
(N / ...); // expected-error {{empty expansion for operator '/' with no fallback}}
(N % ...); // expected-error {{empty expansion for operator '%' with no fallback}}
Modified: cfe/trunk/www/cxx_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=262747&r1=262746&r2=262747&view=diff
==============================================================================
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Fri Mar 4 15:27:21 2016
@@ -577,7 +577,7 @@ as the draft C++1z standard evolves.</p>
</tr>
<tr> <!-- from Jacksonville -->
<td><a href="http://wg21.link/p0036r0">P0036R0</a></td>
- <td class="no" align="center">No</td>
+ <td class="svn" align="center">SVN</td>
</tr>
<tr>
<td><tt>u8</tt> character literals</td>
More information about the cfe-commits
mailing list