@@ -2735,18 +2735,21 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
27352735 throw SemanticAbort ();
27362736 }
27372737 if (ASR::is_a<ASR::Struct_t>(*asr_alloc_type)) {
2738- ASR::StructType_t *st = ASR::down_cast<ASR::StructType_t>(ASR::down_cast<ASR::Struct_t>(asr_alloc_type)->m_derived_type );
2739- if (st->m_abi != ASR::abiType::BindC) {
2740- diag.add (diag::Diagnostic (
2741- " The struct in c_p_pointer must be C interoperable" ,
2742- diag::Level::Error, diag::Stage::Semantic, {
2743- diag::Label (" not C interoperable" ,
2744- {asr_alloc_type->base .loc }),
2745- diag::Label (" help: add the @ccallable decorator to this struct to make it C interoperable" ,
2746- {st->base .base .loc }, false )
2747- })
2748- );
2749- throw SemanticAbort ();
2738+ ASR::symbol_t *sym = ASR::down_cast<ASR::Struct_t>(asr_alloc_type)->m_derived_type ;
2739+ if (ASR::is_a<ASR::StructType_t>(*sym)) {
2740+ ASR::StructType_t *st = ASR::down_cast<ASR::StructType_t>(sym);
2741+ if (st->m_abi != ASR::abiType::BindC) {
2742+ diag.add (diag::Diagnostic (
2743+ " The struct in c_p_pointer must be C interoperable" ,
2744+ diag::Level::Error, diag::Stage::Semantic, {
2745+ diag::Label (" not C interoperable" ,
2746+ {asr_alloc_type->base .loc }),
2747+ diag::Label (" help: add the @ccallable decorator to this struct to make it C interoperable" ,
2748+ {st->base .base .loc }, false )
2749+ })
2750+ );
2751+ throw SemanticAbort ();
2752+ }
27502753 }
27512754 }
27522755 fill_shape_and_lower_bound_for_CPtrToPointer ();
0 commit comments