From cd3d76d2927971c932359d3f3861f196e0c6e7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Mon, 10 Jul 2023 00:00:10 -0600 Subject: [PATCH] Only emit the error for Structs for now --- src/lpython/semantics/python_ast_to_asr.cpp | 27 ++++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index ade3a2f39d..947d870e98 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -2735,18 +2735,21 @@ class CommonVisitor : public AST::BaseVisitor { throw SemanticAbort(); } if (ASR::is_a(*asr_alloc_type)) { - ASR::StructType_t *st = ASR::down_cast(ASR::down_cast(asr_alloc_type)->m_derived_type); - if (st->m_abi != ASR::abiType::BindC) { - diag.add(diag::Diagnostic( - "The struct in c_p_pointer must be C interoperable", - diag::Level::Error, diag::Stage::Semantic, { - diag::Label("not C interoperable", - {asr_alloc_type->base.loc}), - diag::Label("help: add the @ccallable decorator to this struct to make it C interoperable", - {st->base.base.loc}, false) - }) - ); - throw SemanticAbort(); + ASR::symbol_t *sym = ASR::down_cast(asr_alloc_type)->m_derived_type; + if (ASR::is_a(*sym)) { + ASR::StructType_t *st = ASR::down_cast(sym); + if (st->m_abi != ASR::abiType::BindC) { + diag.add(diag::Diagnostic( + "The struct in c_p_pointer must be C interoperable", + diag::Level::Error, diag::Stage::Semantic, { + diag::Label("not C interoperable", + {asr_alloc_type->base.loc}), + diag::Label("help: add the @ccallable decorator to this struct to make it C interoperable", + {st->base.base.loc}, false) + }) + ); + throw SemanticAbort(); + } } } fill_shape_and_lower_bound_for_CPtrToPointer();