https://gcc.gnu.org/g:6a9e70ecbc4507e92308e13acb6db207e94c74d1

commit 6a9e70ecbc4507e92308e13acb6db207e94c74d1
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Tue Feb 11 21:34:11 2025 +0100

    Interdiction non-lvalue as lhs

Diff:
---
 gcc/gimplify.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 58a9d2a748d6..e81a1dc5522e 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -6838,6 +6838,12 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, 
gimple_seq *post_p,
   gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR
              || TREE_CODE (*expr_p) == INIT_EXPR);
 
+  if (TREE_CODE (*to_p) == NON_LVALUE_EXPR)
+    {
+      error ("non-lvalue %qE used as lhs", *to_p);
+      return GS_ERROR;
+    }
+
   /* Trying to simplify a clobber using normal logic doesn't work,
      so handle it here.  */
   if (TREE_CLOBBER_P (*from_p))

Reply via email to