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

    <tr>
        <th>Summary</th>
        <td>
            error: redeclaration of 'foo' cannot add 'dllexport' attribute
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    If a function is declared without `dllexport` and called, but is later defined with `dllexport`, clang generates an error. GCC does not suffer from this issue (the attributes are merged, as if all declarations had `dllexport`).

```c
void
foo(void);

void
bar(void)
  {
    foo();  /* the error goes away if this call is deleted  */
  }

__declspec(dllexport)
void
foo(void)  /* test.c:3:28: error: redeclaration of 'foo' cannot add 'dllexport' attribute */
  {
  }
```


```text
E:\lh_mouse\Desktop>clang --version
clang version 14.0.0
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/MSYS2/clang64/bin
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVE2T2jAM_TXOxUPGOISQQw58LJ099LS99MQ4sZK4NTFjOwv77ys7UNjS3jqTEFnSk96TbWojP6rXlgrajkPjlRmoclRCo4UFSc_K92b0lCyZ1BouJ2M92lQMkjYCPZLwLa0xA1FaeLCIbdVwhf6JC8lYeehoBwNYzHdYioK1xqb0y3ZLpUHXYDx1Y9titdaaI_U9VlfOjUAJX_keqPDeKmwb8BboEWw3URGYiGq0vmoQQZKjvZDPXMqUsB1h6-svuuLTTOt3o-RktcZg27jmJck2j6h7Vi3sQ1Z0UUqKzc2kdKoz1cAQ3xO-pkFN1E-7IF2cxUdQECWHCU_bocHjSBGzDrDfxXePVA6HINmdoMEud6U3Mv_QcycCzqcNydYZvkgzW0-8goFH4T5NalrEFLFKgRyHsF1CyuB8aFvcN-mJ9-ZZwm36n7bkc8jDxU-uFyRF8q3uD0czOkBzB-6nNyeSvUznazZ7B-uQ7QSYnFcXnS9Sll47fRN4dHwQeVktD8vF7BxeNUhzdrNuGK9ZvQU8QkeDWxFyT8apyxR6HZyPN2Gn4qy2gRvff337_sbxGzsvF2jVavir1kRWmSyzUiReeQ3V_5p6Mlpd9d6f3MQInw7v5FinjTniQuv322d2suYHNIjfx2vm0MjzjJdJXzXZitcMlgvWFqIpV0JIVkDLgGdF1giWaFGDdhXJN4TzAc7TTUWb5LtEVZxxznK2mjM2X5Rp3kpRzLMy520GosnJgsFRKJ0GHqmxXWKrSKkeO4dBrZx396BwTnUDQGyH9cWIf1CI6ONBSGLrKlL_BTTMepY">