aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTom Schollenberger <tss2344@g.rit.edu>2025-05-08 07:26:07 -0400
committerPhilip Herron <philip.herron@embecosm.com>2025-05-08 15:37:43 +0000
commit339415a5a865649972b255cc697691d493453e41 (patch)
tree2fb95faafcae346041be6043cbe0a48fae61a637 /gcc
parentfc6b54365731c2ebfa1974058c48772e03203fdd (diff)
downloadgcc-339415a5a865649972b255cc697691d493453e41.zip
gcc-339415a5a865649972b255cc697691d493453e41.tar.gz
gcc-339415a5a865649972b255cc697691d493453e41.tar.bz2
gccrs: fix ICE on empty constexpr loops
Empty loops have no body which means this is a NULL_TREE during const evaluation which needs a check. Fixes Rust-GCC #3618. gcc/rust/ChangeLog: * backend/rust-constexpr.cc (eval_constant_expression): Check if t is a NULL_TREE gcc/testsuite/ChangeLog: * rust/compile/issue-3618.rs: Test empty loops error properly. Signed-off-by: Tom Schollenberger <tss2344@g.rit.edu>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/backend/rust-constexpr.cc3
-rw-r--r--gcc/testsuite/rust/compile/issue-3618.rs1
2 files changed, 4 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc
index dc2d6b1..0ed56c7 100644
--- a/gcc/rust/backend/rust-constexpr.cc
+++ b/gcc/rust/backend/rust-constexpr.cc
@@ -1901,6 +1901,9 @@ eval_constant_expression (const constexpr_ctx *ctx, tree t, bool lval,
location_t loc = EXPR_LOCATION (t);
+ if (t == NULL_TREE)
+ return NULL_TREE;
+
if (CONSTANT_CLASS_P (t))
{
if (TREE_OVERFLOW (t))
diff --git a/gcc/testsuite/rust/compile/issue-3618.rs b/gcc/testsuite/rust/compile/issue-3618.rs
new file mode 100644
index 0000000..9728613
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3618.rs
@@ -0,0 +1 @@
+static _X: () = loop {}; // { dg-error "loop iteration count exceeds limit" }