]> granicus.if.org Git - clang/commitdiff
Don't warn about undefined inline functions if they're dllexport/import
authorHans Wennborg <hans@hanshq.net>
Thu, 22 May 2014 20:45:53 +0000 (20:45 +0000)
committerHans Wennborg <hans@hanshq.net>
Thu, 22 May 2014 20:45:53 +0000 (20:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209471 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.cpp
test/SemaCXX/undefined-inline.cpp

index b0d1023b0119f5ca16b35009023d16aa79b43f39..6a7ba5a610c8d80ebf29b95b8b40543576daef3a 100644 (file)
@@ -478,6 +478,13 @@ static void checkUndefinedButUsed(Sema &S) {
          I = Undefined.begin(), E = Undefined.end(); I != E; ++I) {
     NamedDecl *ND = I->first;
 
+    if (ND->hasAttr<DLLImportAttr>() || ND->hasAttr<DLLExportAttr>()) {
+      // An exported function will always be emitted when defined, so even if
+      // the function is inline, it doesn't have to be emitted in this TU. An
+      // imported function implies that it has been exported somewhere else.
+      continue;
+    }
+
     if (!ND->isExternallyVisible()) {
       S.Diag(ND->getLocation(), diag::warn_undefined_internal)
         << isa<VarDecl>(ND) << ND;
index ad719ae03abb64d8c6d8ace647b2340702acbc46..18973ef8b79c8e2432fbe667323e7c4a10ee0ffd 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple i686-pc-win32 -verify %s
 // PR14993
 
 namespace test1 {
@@ -55,3 +55,9 @@ namespace test10 {
   void test() { foo(); }
   inline void foo() __attribute__((gnu_inline));
 }
+
+namespace test11 {
+  inline void foo() __attribute__((dllexport));
+  inline void bar() __attribute__((dllimport));
+  void test() { foo(); bar(); }
+}