Commit 6e3ae7e6 by Paolo Carlini Committed by Paolo Carlini

re PR c++/67980 (left shift count is negative [-Wshift-count-negative] generated…

re PR c++/67980 (left shift count is negative [-Wshift-count-negative] generated for unreachable code)

/cp
2016-11-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67980
	* pt.c (tsubst_expr, case IF_STMT): Use fold_non_dependent_expr
	to suppress unwanted warnings.

/testsuite
2016-11-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67980
	* g++.dg/cpp1y/pr67980.C: New.

From-SVN: r241858
parent fff6ed28
2016-11-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/67980
* pt.c (tsubst_expr, case IF_STMT): Use fold_non_dependent_expr
to suppress unwanted warnings.
2016-11-03 Jason Merrill <jason@redhat.com> 2016-11-03 Jason Merrill <jason@redhat.com>
PR c++/78198 PR c++/78198
......
...@@ -15437,15 +15437,27 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, ...@@ -15437,15 +15437,27 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
if (IF_STMT_CONSTEXPR_P (t) && integer_zerop (tmp)) if (IF_STMT_CONSTEXPR_P (t) && integer_zerop (tmp))
/* Don't instantiate the THEN_CLAUSE. */; /* Don't instantiate the THEN_CLAUSE. */;
else else
RECUR (THEN_CLAUSE (t)); {
bool inhibit = integer_zerop (fold_non_dependent_expr (tmp));
if (inhibit)
++c_inhibit_evaluation_warnings;
RECUR (THEN_CLAUSE (t));
if (inhibit)
--c_inhibit_evaluation_warnings;
}
finish_then_clause (stmt); finish_then_clause (stmt);
if (IF_STMT_CONSTEXPR_P (t) && integer_nonzerop (tmp)) if (IF_STMT_CONSTEXPR_P (t) && integer_nonzerop (tmp))
/* Don't instantiate the ELSE_CLAUSE. */; /* Don't instantiate the ELSE_CLAUSE. */;
else if (ELSE_CLAUSE (t)) else if (ELSE_CLAUSE (t))
{ {
bool inhibit = integer_nonzerop (fold_non_dependent_expr (tmp));
begin_else_clause (stmt); begin_else_clause (stmt);
if (inhibit)
++c_inhibit_evaluation_warnings;
RECUR (ELSE_CLAUSE (t)); RECUR (ELSE_CLAUSE (t));
if (inhibit)
--c_inhibit_evaluation_warnings;
finish_else_clause (stmt); finish_else_clause (stmt);
} }
......
2016-11-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/67980
* g++.dg/cpp1y/pr67980.C: New.
2016-11-04 Bill Schmidt <wschmidt@linux.vnet.ibm.com> 2016-11-04 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
* gcc.target/powerpc/fold-vec-add-1.c: New. * gcc.target/powerpc/fold-vec-add-1.c: New.
......
// { dg-do compile { target c++14 } }
template <int Y, class T>
constexpr T cpp14_constexpr_then(T value) {
if (Y < 0)
return (value << -Y);
else
return 0;
}
template <int Y, class T>
constexpr T cpp14_constexpr_else(T value) {
if (Y > 0)
return 0;
else
return (value << -Y);
}
int main()
{
cpp14_constexpr_then<1>(0);
cpp14_constexpr_else<1>(0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment