aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-06-29 11:44:45 +0100
committergingerBill <bill@gingerbill.org>2024-06-29 11:44:45 +0100
commit704530497b166dfa6fcee8f2c95a9e492a78a024 (patch)
treec9cd88e03e1db8e02ec0f37224a4c6fd88f6f71e /src/check_expr.cpp
parent4be0fc05bb95b5575b1471619788e0382c77c221 (diff)
Rename `-vet-identical-cast` to `-vet-cast`; with minor code clean up
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 7d2f10c95..2fa491417 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -3382,18 +3382,18 @@ gb_internal void check_cast(CheckerContext *c, Operand *x, Type *type, bool forb
add_package_dependency(c, "runtime", "gnu_f2h_ieee", REQUIRE);
}
}
- if (forbid_identical && check_vet_flags(c) & VetFlag_IdenticalCast) {
+ // If we check polymorphic procedures, we risk erring on
+ // identical casts that cannot be foreseen or otherwise
+ // forbidden, so just skip them.
+ if (forbid_identical && check_vet_flags(c) & VetFlag_Cast &&
+ (c->curr_proc_sig == nullptr || !is_type_polymorphic(c->curr_proc_sig))) {
Type *src_exact = x->type;
Type *dst_exact = type;
if (src_exact != nullptr &&
- dst_exact != nullptr &&
- // If we check polymorphic procedures, we risk erring on
- // identical casts that cannot be foreseen or otherwise
- // forbidden, so just skip them.
- (c->curr_proc_sig == nullptr || !is_type_polymorphic(c->curr_proc_sig)) &&
- src_exact == dst_exact)
- {
+ dst_exact != nullptr &&
+ are_types_identical(src_exact, dst_exact)
+ ) {
gbString oper_str = expr_to_string(x->expr);
gbString to_type = type_to_string(dst_exact);
error(x->expr, "Unneeded cast of `%s` to identical type `%s`", oper_str, to_type);