summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2014-05-22 15:46:15 +0000
committerHans Wennborg <hans@hanshq.net>2014-05-22 15:46:15 +0000
commitf436b2837c3a5968aa757d6f2581d32940961ad8 (patch)
tree1bb5142d4a455939332c978d7bca108f4e895c3a /clang
parentd6ac15dd5fce595f876edf2d0c1e072f6556a233 (diff)
downloadbcm5719-llvm-f436b2837c3a5968aa757d6f2581d32940961ad8.tar.gz
bcm5719-llvm-f436b2837c3a5968aa757d6f2581d32940961ad8.zip
An inline function redeclaration does not drop the dllimport attribute
llvm-svn: 209449
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp6
-rw-r--r--clang/test/Rewriter/missing-dllimport.c17
-rw-r--r--clang/test/Sema/dllimport.c4
3 files changed, 11 insertions, 16 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d65ba117dc8..88f099f96d2 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4898,9 +4898,11 @@ static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl,
// A redeclaration is not allowed to drop a dllimport attribute, the only
// exception being inline function definitions.
- // FIXME: Handle inline functions.
// NB: MSVC converts such a declaration to dllexport.
- if (OldImportAttr && !HasNewAttr) {
+ bool IsInline =
+ isa<FunctionDecl>(NewDecl) && cast<FunctionDecl>(NewDecl)->isInlined();
+
+ if (OldImportAttr && !HasNewAttr && !IsInline) {
S.Diag(NewDecl->getLocation(),
diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
<< NewDecl << OldImportAttr;
diff --git a/clang/test/Rewriter/missing-dllimport.c b/clang/test/Rewriter/missing-dllimport.c
index 1e4689fba0d..a09ebff44db 100644
--- a/clang/test/Rewriter/missing-dllimport.c
+++ b/clang/test/Rewriter/missing-dllimport.c
@@ -1,19 +1,8 @@
-// RUN: not %clang_cc1 -triple i686-pc-win32 -fms-extensions -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-NEG %s
-// RUN: not %clang_cc1 -triple i686-pc-win32 -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-POS %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -verify %s
-// Do not report that 'foo()' is redeclared without dllimport attribute with -fms-extensions
+// Do not report that 'foo()' is redeclared without dllimport attribute.
// specified. Addresses <rdar://problem/7653912>.
+// expected-no-diagnostics
__declspec(dllimport) int __cdecl foo(void);
inline int __cdecl foo() { return 0; }
-
-// This function is added just to trigger a diagnostic. This way we can test how many
-// diagnostics we expect.
-void bar() { return 1; }
-
-// CHECK-NEG: error: void function 'bar' should not return a value
-// CHECK-NEG: 1 error generated
-// CHECK-POS: warning: 'foo' redeclared without 'dllimport' attribute: previous 'dllimport' ignored
-// CHECK-POS: error: void function 'bar' should not return a value
-// CHECK-POS: 1 warning and 1 error generated
-
diff --git a/clang/test/Sema/dllimport.c b/clang/test/Sema/dllimport.c
index fa3e2b385a4..2c504d1f77b 100644
--- a/clang/test/Sema/dllimport.c
+++ b/clang/test/Sema/dllimport.c
@@ -118,5 +118,9 @@ __declspec(dllimport) void redecl3(); // expected-note{{previous declaration is
void redecl4(); // expected-note{{previous declaration is here}}
__declspec(dllimport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllimport' attribute}}
+// Inline redeclarations are fine.
+__declspec(dllimport) void redecl5();
+inline void redecl5() {}
+
// External linkage is required.
__declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}}
OpenPOWER on IntegriCloud