[LLVMbugs] [Bug 24215] New: Downgrade "redeclaration cannot add dllimport" error to a warning

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jul 22 09:28:44 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24215

            Bug ID: 24215
           Summary: Downgrade "redeclaration cannot add dllimport" error
                    to a warning
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hans at chromium.org
                CC: eldlistmailingz at tropicsoft.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150722/7d14187a/attachment.html>


More information about the llvm-bugs mailing list