diff options
| author | gingerBill <bill@gingerbill.org> | 2021-04-22 17:36:28 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-04-22 17:36:28 +0100 |
| commit | 17bbb48d8a04aaf6cc53777fe4da6ba1b7fff61b (patch) | |
| tree | 564ed4869a9b44641b43a33ba748751c12f34356 /src | |
| parent | ac53577e9b8f310bfdd663b6bdac38246165d1ff (diff) | |
Warn on redundant `auto_cast`, and make an error on `-vet`
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_expr.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index a915aa92f..9818b5015 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -10075,7 +10075,16 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type return kind; } if (type_hint) { + Type *type = type_of_expr(ac->expr); check_cast(c, o, type_hint); + if (is_type_typed(type) && are_types_identical(type, type_hint)) { + if (build_context.vet) { + error(node, "Redundant 'auto_cast' applied to expression"); + } else { + warning(node, "Redundant 'auto_cast' applied to expression"); + } + } + } o->expr = node; return Expr_Expr; |