]> granicus.if.org Git - clang/commit
Drop 'dllimport' when redeclaring inline function template without the attribute...
authorHans Wennborg <hans@hanshq.net>
Wed, 1 Feb 2017 18:52:53 +0000 (18:52 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 1 Feb 2017 18:52:53 +0000 (18:52 +0000)
commit3286ac625a20c1d7bf5293c89acd986f4f277be6
treefd2980c18c2e737c7f9088189d51226407bcf31f
parentceed2a6d9e25814ac359400a81d77fa17f4b9e30
Drop 'dllimport' when redeclaring inline function template without the attribute (PR31695)

For non-template dllimport functions, MSVC allows providing an inline
definition without spelling out the attribute again. In the example below, f
remains a dllimport function.

  __declspec(dllimport) int f();
  inline int f() { return 42; }

  int useit() {
    return f();
  }

However, for a function template, not putting dllimport on the redeclaration
causes it to be dropped. In the example below, f is not dllimport.

  template <typename> __declspec(dllimport) int f();
  template <typename> inline int f() { return 42; }

  int useit() {
    return f<int>();
  }

This patch makes Clang match MSVC for the second example.

MSVC does not warn about the attribute being dropped in the example above, but
I think we should. (MSVC does warn if the inline keyword isn't used.)

Differential Revision: https://reviews.llvm.org/D29152

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293800 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaDecl.cpp
test/CodeGenCXX/dllimport.cpp
test/SemaCXX/dllimport.cpp