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: unassignedclangb...@nondot.org
          Reporter: h...@chromium.org
                CC: eldlistmaili...@tropicsoft.com, llvmbugs@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.
_______________________________________________
LLVMbugs mailing list
LLVMbugs@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to