aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index a31f1c871..bcd16ca25 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -2388,6 +2388,14 @@ void check_cast(CheckerContext *c, Operand *x, Type *type) {
update_expr_type(c, x->expr, final_type, true);
}
+ if (build_context.vet_extra) {
+ if (are_types_identical(x->type, type)) {
+ gbString str = type_to_string(type);
+ warning(x->expr, "Unneeded cast to the same type '%s'", str);
+ gb_string_free(str);
+ }
+ }
+
x->type = type;
}
@@ -2429,6 +2437,14 @@ bool check_transmute(CheckerContext *c, Ast *node, Operand *o, Type *t) {
return false;
}
+ if (build_context.vet_extra) {
+ if (are_types_identical(o->type, t)) {
+ gbString str = type_to_string(t);
+ warning(o->expr, "Unneeded transmute to the same type '%s'", str);
+ gb_string_free(str);
+ }
+ }
+
o->mode = Addressing_Value;
o->type = t;
return true;