From fed1bce12acd0e990e48d23a90453ffdaaf64395 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 30 Apr 2024 11:07:53 +0900 Subject: [PATCH] [qfcc] Add a function to check for error expressions I haven't gone through and replaced all the existing tests, but hiding the details makes sense and fits with many of the other check functions. --- tools/qfcc/include/expr.h | 2 ++ tools/qfcc/source/expr.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/tools/qfcc/include/expr.h b/tools/qfcc/include/expr.h index f09d3df28..e2ef252ca 100644 --- a/tools/qfcc/include/expr.h +++ b/tools/qfcc/include/expr.h @@ -740,6 +740,8 @@ unsigned short expr_ushort (const expr_t *e) __attribute__((pure)); int expr_integral (const expr_t *e) __attribute__((pure)); +bool is_error (const expr_t *e) __attribute__((pure)); + /** Check if the expression refers to a constant value. \param e The expression to check. diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 35a1c7f97..17ddd1766 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -861,6 +861,12 @@ new_short_expr (short short_val) return new_value_expr (new_short_val (short_val), false); } +bool +is_error (const expr_t *e) +{ + return e->type == ex_error; +} + int is_constant (const expr_t *e) {