<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59881>59881</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] BIND(C) character argument
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          PeixinQiao
      </td>
    </tr>
</table>

<pre>
    Fortran 2018 18.3.5 (2) point 4: character argument with VALUE attribute.
Fortran 2018 18.3.5 (2) point 5: character argument without VALUE attribute.
Fortran 2018 18.3.5 (2) point 6: character argument with POINTER/ALLOCATABLE attribute.

Please check the discussions in https://reviews.llvm.org/D137254 for more details.

The standard mandates to use a CFI descriptor for assumed-length/deferred length. For BIND(C) scalar assumed length with a Fortran caller and callee, a CFI descriptor (fir.box) is not used as it should for now.

Semantic checks to be done:
1. BIND(C) character argument must have length one if the argument has the VALUE attribute.
2. BIND(C) allocatable or pointer dummy argument of type CHARACTER has deferred character length.
3. It should be allowed for "assumed-shape, assumed-rank without the CONTIGUOUS" attribute with explicit length since it is covered by the third bullet point in (5). The latest gfortran allow this (e.g character(10) :: c2(:)) (but not scalar or explicit shape with explicit length). (quote from @jeanPerier in https://reviews.llvm.org/D137254)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVF9vozgQ_zTmZVQEQ0jggYc0KXeRqrbXTe_d4CF419g52_TPtz8Z0kTRVru6ewmRNf7N78-MuXPyoIkqlt-yfBvx0ffGVk8k36X-S3ITNUZ8VLWx3nINmKQFpEWcxTkwLJBhCUcjtYcFy9bQ9tzy1pMFbg_jQNrDm_Q9_L2-f7kD7r2VzegpZsmWJevfg-a_ADWj_9-4y1-RfXrcPezvnhnW6_v7x816v769_7nJ_PukiDuCtqf2B_ieQEjXjs5Jox1IDb33R8eyNcOaYW3pVdKbi5V6HWJjDwzrbZqtMF9AZywMxhII8lwqd9Vl3xM4z7XgVsAQvp4ceAOjI-CwqXcgyLVWHr2xExR3bhxI3CjSB98zrAV1ZC0JmE9iqI2F293DlmGxCca4lit-vngqmw3h8Oloy5UKfmkx_yWGm58JMCw6aePGvAdg6UAbH6gK4A6kB9ebUYmJpzZvV0q_0cC1l-3s6KSxIRBGUzBxKknjK95fpDiMzkPPX-lThdEEspvyORf13E0HX48QXjfhSpmWe94oAmPnISILYhyGjwuk6cB_HAk2f66f15v93fPU5Oz8hekpg7lVFsPu7ElDU683mu1hiJ9Jup4fZ7tPB5brH-dFCEo2jw_73R8vjy_fGOJF0ZwhvR-VbKX_tMRJ3VIIQzpozSsFgs3HhON7aQU0o1LkT_sidQg1Z1jGEIZRhQH0cOhOczFxDhddqKP4cBHLsEiT4GEIMGwdMiymjSinUyya0U8TcppAYy9kJ9FfCpioMCz-GY0n6KwZgC2S78T1E1lJ9r8sH8MyElUmyqzkEVXpcpWleYFFGfVVV5SrJWLCm3zZLVdtmy9JtAIz3jRlIbpIVphglqRJkSzTFMs4XSxXRcabAM3zYsUWCQ1cqnPjSDo3UpWXRZFGijek3PT6InaK6wNDDA-xrUL9TTMeHFskSjp_oR556dX0ZM838u1vViIaraqu7ThI349N3JqBYR2AT5-bozXfqfUM64mnY1hPVP8NAAD__wFpATk">