From 8ee39e31bb40aea70afb40611b0cc39d23175552 Mon Sep 17 00:00:00 2001
From: Richard Smith
Date: Fri, 4 Mar 2016 21:27:21 +0000
Subject: [PATCH] Implement P0036R0: remove support for empty unary folds of +,
*, |, &.
llvm-svn: 262747
---
clang/lib/Sema/SemaTemplateVariadic.cpp | 15 ---------------
clang/test/SemaTemplate/cxx1z-fold-expressions.cpp | 15 ++++++++-------
clang/www/cxx_status.html | 2 +-
3 files changed, 9 insertions(+), 23 deletions(-)
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index cb67d71f..c692c9f 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -996,10 +996,6 @@ ExprResult Sema::BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
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(SourceLocation EllipsisLoc,
// 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:
diff --git a/clang/test/SemaTemplate/cxx1z-fold-expressions.cpp b/clang/test/SemaTemplate/cxx1z-fold-expressions.cpp
index 8bb7911..aefee92 100644
--- a/clang/test/SemaTemplate/cxx1z-fold-expressions.cpp
+++ b/clang/test/SemaTemplate/cxx1z-fold-expressions.cpp
@@ -25,10 +25,6 @@ constexpr bool check() {
static_assert(check());
template 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 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 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 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}}
diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index b2a13ac..f116aee 100644
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -577,7 +577,7 @@ as the draft C++1z standard evolves.
P0036R0 |
- No |
+ SVN |
u8 character literals |
--
2.7.4