Commit c7e2d7ad by Jason Merrill Committed by Jason Merrill

PR c++/85963 - -Wunused-but-set with ?: in template.

	* pt.c (tsubst_copy_and_build) [COND_EXPR]: Call mark_rvalue_use.

From-SVN: r261458
parent 8731c0fb
2018-06-11 Jason Merrill <jason@redhat.com>
PR c++/85963 - -Wunused-but-set with ?: in template.
* pt.c (tsubst_copy_and_build) [COND_EXPR]: Call mark_rvalue_use.
2018-06-11 Paolo Carlini <paolo.carlini@oracle.com> 2018-06-11 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (grok_op_properties): Consistently use the location * decl.c (grok_op_properties): Consistently use the location
......
...@@ -18511,6 +18511,7 @@ tsubst_copy_and_build (tree t, ...@@ -18511,6 +18511,7 @@ tsubst_copy_and_build (tree t,
case COND_EXPR: case COND_EXPR:
{ {
tree cond = RECUR (TREE_OPERAND (t, 0)); tree cond = RECUR (TREE_OPERAND (t, 0));
cond = mark_rvalue_use (cond);
tree folded_cond = fold_non_dependent_expr (cond); tree folded_cond = fold_non_dependent_expr (cond);
tree exp1, exp2; tree exp1, exp2;
......
// PR c++/85963
// { dg-additional-options -Wall }
template<typename T>
struct foo {
T val, alpha;
foo() : val(0), alpha(0) {}
};
template<typename T>
inline void bar(const foo<T>& A, const foo<T>& B, foo<T>& C) {
const bool use_alpha = true;
const T alpha = use_alpha ? (A.alpha * B.alpha) : T(0);
C.val = A.val * B.val;
C.alpha = alpha;
}
int main() {
foo<double> A,B,C;
bar(A,B,C);
return 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