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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Diagnose `extern "C++" int main()`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    This currently just seems to be ignored (the name is not mangled).  
It is explicitly disallowed by https://eel.is/c++draft/basic.start.main#3.sentence-5

> The `main` function shall not be declared with a *linkage-specification*.

This includes `extern "C++" { int main(); }`.

`extern "C" int main()` is also technically ill-formed, but it seems to be used in some places

https://github.com/llvm/llvm-project/blob/98e4413a38f286147b863a6ead9625228ab0ec7d/libc/startup/linux/do_start.cpp#L23
https://github.com/llvm/llvm-project/blob/98e4413a38f286147b863a6ead9625228ab0ec7d/libc/startup/gpu/nvptx/start.cpp#L15

So this should probably just be a warning, not an error.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVE2PpTYQ_DXm0hoEzfeBw3vzghQpOWXvUWM34F0_G9lmPv59ZGZG2Zkoh5xyAcnQ1eWq6qYQ9GqZR9FcRXPL6Iib8-PvOpK5hM39yGanXsdvmw4gD-_ZRvMK348QITDfA0QHM4NerfOsQGAfNwZLdwYdwLoId7KrYSVwyAFEcRPF5deYPvLLbrTUCU_pQMa4Z1Ywv8IW4x5EdRE4CZyYTa6DwEkKvAq8Kk9LFDjNFLTMQyQf8ztpK7Cq8sA2spX80Lx1en9Wv8C3jUG0xflnW8ByWBm1sxA2MuYkOjMolobSPZ513IBA4MVo-4NWfgg7S71oSalK4CX_ucEpj7bSHIpDasMvkb0Fgfj4xlogguiuoG1SJLHtBQ6iuoLobqItPsF9BcCvZW2RBCQTHESWm9WSjHkFbczD4vw9qf0I8xFBf7bpCKxAWwjuzrAbkhx-7vtZ-FXH7Zhz6e4CJ2OePl4Pu3ffWZ4eGDcLnIae67qsqOoX7Nuy7ua-rahlUkOLDWJPc8GyUwlAz1LgdNp27OeBPV4ETsr9-eal3HeB1W9Y_X-c1v0QONmnPb58nH_QKj8F6w8HMVkfNncYBbt3M80f8zEzEDyTt9quyY-UMbLA3jv_bnemxkoN1UAZj2WH2OAwdHW2jdQP3VLWLS1NW7LsmgF56aqmLKmTSzFkesQC66IvyrKtsClz1VZKlVzWXYVtLXtRF3wnbfIkT-78mukQDh7LomxKzAzNbMI59YjSUKKIaQH48dRzPtYg6sLoEMPfEFFHc66Kx7OiucFN02pd4H8N_T-Smx3ejP_Z1ZN82gLv_J9G_CsAAP__oY930w">