<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - Downgrade &quot;redeclaration cannot add dllimport&quot; error to a warning" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24215&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=8_Uf_miQcnFNL5EAF1CYXVmI-M1w9Vcav6eDzWNse1o&s=4hbIazCeBwCNfplnkGS8_qu12DyQo3F4g_23AjDYI4U&e=">24215</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Downgrade "redeclaration cannot add dllimport" error to a warning
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hans@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>eldlistmailingz@tropicsoft.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In the following code:

  extern "C" void sleep(unsigned ms);

  void f() {
    sleep(1000);
  }

  extern "C" __declspec(dllimport) void sleep(unsigned ms);

Clang will error:

/tmp/a.cc:7:39: error: redeclaration of 'sleep' cannot add 'dllimport'
attribute
extern "C" __declspec(dllimport) void sleep(unsigned ms);
                                      ^
/tmp/a.cc:1:17: note: previous declaration is here
extern "C" void sleep(unsigned ms);
                ^

The problem is that Clang will already have generated IR for the sleep()
declaration after emitting f().

Because the IR has already been generated, the 'dllimport' attribute won't be
added and the compiler errors.


In practice, this code would still work as it will link against the thunk for
sleep(). Pointer identity will be broken, but that is probably not serious
enough to error about.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>