[llvm-branch-commits] [cfe-branch] r295375 - Merging r295224:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Feb 16 13:13:06 PST 2017
Author: hans
Date: Thu Feb 16 15:13:06 2017
New Revision: 295375
URL: http://llvm.org/viewvc/llvm-project?rev=295375&view=rev
Log:
Merging r295224:
------------------------------------------------------------------------
r295224 | rsmith | 2017-02-15 11:57:10 -0800 (Wed, 15 Feb 2017) | 2 lines
PR24440: Do not silently discard a fold-expression appearing as the operand of a cast-expression.
------------------------------------------------------------------------
Modified:
cfe/branches/release_40/ (props changed)
cfe/branches/release_40/lib/Parse/ParseExpr.cpp
cfe/branches/release_40/lib/Sema/SemaTemplateVariadic.cpp
cfe/branches/release_40/test/Parser/cxx1z-fold-expressions.cpp
Propchange: cfe/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 16 15:13:06 2017
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:291850,291853,291865,291871,291877,291879,291881,291907,291955,291963-291964,292032,292052,292183,292194,292247,292265,292497,292555,292558-292559,292561,292590,292800,292847,292874,292991,293043,293134,293360,293369,293596,293678,293787,294008,294800,294855,295149-295150,295313
+/cfe/trunk:291850,291853,291865,291871,291877,291879,291881,291907,291955,291963-291964,292032,292052,292183,292194,292247,292265,292497,292555,292558-292559,292561,292590,292800,292847,292874,292991,293043,293134,293360,293369,293596,293678,293787,294008,294800,294855,295149-295150,295224,295313
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_40/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/lib/Parse/ParseExpr.cpp?rev=295375&r1=295374&r2=295375&view=diff
==============================================================================
--- cfe/branches/release_40/lib/Parse/ParseExpr.cpp (original)
+++ cfe/branches/release_40/lib/Parse/ParseExpr.cpp Thu Feb 16 15:13:06 2017
@@ -2408,7 +2408,7 @@ Parser::ParseParenExpression(ParenParseO
// fold-expressions, we'll need to allow multiple ArgExprs here.
if (ArgExprs.size() == 1 && isFoldOperator(Tok.getKind()) &&
NextToken().is(tok::ellipsis))
- return ParseFoldExpression(Result, T);
+ return ParseFoldExpression(ArgExprs[0], T);
ExprType = SimpleExpr;
Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
Modified: cfe/branches/release_40/lib/Sema/SemaTemplateVariadic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/lib/Sema/SemaTemplateVariadic.cpp?rev=295375&r1=295374&r2=295375&view=diff
==============================================================================
--- cfe/branches/release_40/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/branches/release_40/lib/Sema/SemaTemplateVariadic.cpp Thu Feb 16 15:13:06 2017
@@ -1014,6 +1014,11 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
CheckFoldOperand(*this, LHS);
CheckFoldOperand(*this, RHS);
+ auto DiscardOperands = [&] {
+ CorrectDelayedTyposInExpr(LHS);
+ CorrectDelayedTyposInExpr(RHS);
+ };
+
// [expr.prim.fold]p3:
// In a binary fold, op1 and op2 shall be the same fold-operator, and
// either e1 shall contain an unexpanded parameter pack or e2 shall contain
@@ -1021,6 +1026,7 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
if (LHS && RHS &&
LHS->containsUnexpandedParameterPack() ==
RHS->containsUnexpandedParameterPack()) {
+ DiscardOperands();
return Diag(EllipsisLoc,
LHS->containsUnexpandedParameterPack()
? diag::err_fold_expression_packs_both_sides
@@ -1034,6 +1040,7 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
if (!LHS || !RHS) {
Expr *Pack = LHS ? LHS : RHS;
assert(Pack && "fold expression with neither LHS nor RHS");
+ DiscardOperands();
if (!Pack->containsUnexpandedParameterPack())
return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
<< Pack->getSourceRange();
Modified: cfe/branches/release_40/test/Parser/cxx1z-fold-expressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/test/Parser/cxx1z-fold-expressions.cpp?rev=295375&r1=295374&r2=295375&view=diff
==============================================================================
--- cfe/branches/release_40/test/Parser/cxx1z-fold-expressions.cpp (original)
+++ cfe/branches/release_40/test/Parser/cxx1z-fold-expressions.cpp Thu Feb 16 15:13:06 2017
@@ -34,3 +34,12 @@ template<int ...N> int bad9() { return (
template<int ...N> int bad10() { return (3 ? ... : N); } // expected-error +{{}} expected-note {{to match}}
template<int ...N> int bad11() { return (N + ... 0); } // expected-error {{expected a foldable binary operator}} expected-error {{expected expression}}
template<int ...N> int bad12() { return (... N); } // expected-error {{expected expression}}
+
+template<typename ...T> void as_operand_of_cast(int a, T ...t) {
+ return
+ (int)(a + ... + undeclared_junk) + // expected-error {{undeclared}} expected-error {{does not contain any unexpanded}}
+ (int)(t + ... + undeclared_junk) + // expected-error {{undeclared}}
+ (int)(... + undeclared_junk) + // expected-error {{undeclared}} expected-error {{does not contain any unexpanded}}
+ (int)(undeclared_junk + ...) + // expected-error {{undeclared}}
+ (int)(a + ...); // expected-error {{does not contain any unexpanded}}
+}
More information about the llvm-branch-commits
mailing list