aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/cp-gimplify.c2
-rw-r--r--gcc/cp/expr.c17
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const10.C11
4 files changed, 34 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5a5256f..9208f1e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2019-01-11 Jason Merrill <jason@redhat.com>
+
+ PR c++/88613 - ICE with use of const var in lambda.
+ * expr.c (mark_use): Fix location wrapper handling.
+ * cp-gimplify.c (cp_fold_maybe_rvalue): Call mark_rvalue_use.
+
2019-01-11 Tobias Burnus <burnus@net-b.de>
PR C++/88114
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 726adac..121dfa4 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -2124,6 +2124,8 @@ cp_fold_maybe_rvalue (tree x, bool rval)
while (true)
{
x = cp_fold (x);
+ if (rval)
+ x = mark_rvalue_use (x);
if (rval && DECL_P (x)
&& !TYPE_REF_P (TREE_TYPE (x)))
{
diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c
index 071c6fb..9160043 100644
--- a/gcc/cp/expr.c
+++ b/gcc/cp/expr.c
@@ -187,10 +187,23 @@ mark_use (tree expr, bool rvalue_p, bool read_p,
}
break;
- CASE_CONVERT:
case VIEW_CONVERT_EXPR:
if (location_wrapper_p (expr))
- loc = EXPR_LOCATION (expr);
+ {
+ loc = EXPR_LOCATION (expr);
+ tree op = TREE_OPERAND (expr, 0);
+ tree nop = RECUR (op);
+ if (nop == error_mark_node)
+ return error_mark_node;
+ TREE_OPERAND (expr, 0) = nop;
+ /* If we're replacing a DECL with a constant, we also need to change
+ the TREE_CODE of the location wrapper. */
+ if (op != nop && rvalue_p)
+ TREE_SET_CODE (expr, NON_LVALUE_EXPR);
+ return expr;
+ }
+ gcc_fallthrough();
+ CASE_CONVERT:
recurse_op[0] = true;
break;
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const10.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const10.C
new file mode 100644
index 0000000..3112f08
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const10.C
@@ -0,0 +1,11 @@
+// PR c++/88613
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -Wtautological-compare }
+
+void a() {
+ const int b = 5;
+ [=] {
+ if (b != 5)
+ ;
+ }();
+}