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, 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);