mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Recursive constant definition not properly detected, leading to assert #2780
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
- Second value in switch range not checked properly, causing an error on non-const values. #2777
|
||||
- Broken cast from fault to array pointer #2778.
|
||||
- $typeof untyped list crashes when trying to create typeid from it. #2779
|
||||
- Recursive constant definition not properly detected, leading to assert #2780
|
||||
|
||||
### Fixes
|
||||
- Regression with npot vector in struct triggering an assert #2219.
|
||||
|
||||
@@ -1312,6 +1312,10 @@ static inline bool sema_expr_analyse_identifier(SemaContext *context, Type *to,
|
||||
case VARDECL_CONST:
|
||||
if (!decl->type)
|
||||
{
|
||||
if (decl->var.init_expr->resolve_status == RESOLVE_RUNNING)
|
||||
{
|
||||
RETURN_SEMA_ERROR(decl->var.init_expr, "The evaluation of this expression is recursive.");
|
||||
}
|
||||
Expr *copy = copy_expr_single(decl->var.init_expr);
|
||||
if (!sema_analyse_expr_rvalue(context, copy)) return false;
|
||||
if (!expr_is_runtime_const(copy))
|
||||
|
||||
4
test/test_suite/constants/recursive_constant.c3
Normal file
4
test/test_suite/constants/recursive_constant.c3
Normal file
@@ -0,0 +1,4 @@
|
||||
fn int main()
|
||||
{
|
||||
const A = x'1234' +++ (ichar[A]); // #error: The evaluation of this expression is recursive.
|
||||
}
|
||||
Reference in New Issue
Block a user