diff options
author | Hans Wennborg <hans@hanshq.net> | 2014-10-29 21:20:57 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2014-10-29 21:20:57 +0000 |
commit | ac6073bb1f01e67c47e004c5f3adb2bd6c1230cb (patch) | |
tree | f400977223331e4e09ab234fe852e0ead32faff4 | |
parent | 323d57336c74715ebf79b597dd0a239849e8456e (diff) | |
download | bcm5719-llvm-ac6073bb1f01e67c47e004c5f3adb2bd6c1230cb.tar.gz bcm5719-llvm-ac6073bb1f01e67c47e004c5f3adb2bd6c1230cb.zip |
Follow-up to r216619: use isCXXCLassMember() instead of trying to
check the context ourselves when selectively allowing late-added
dll attributes on unused free functions and variables (PR20746)
llvm-svn: 220874
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/dllexport.cpp | 12 | ||||
-rw-r--r-- | clang/test/SemaCXX/dllimport.cpp | 12 |
3 files changed, 23 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 16a84ffd30f..deac7c7d33b 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5140,7 +5140,7 @@ static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, // If the declaration hasn't been used yet, allow with a warning for // free functions and global variables. bool JustWarn = false; - if (!OldDecl->isUsed() && OldDecl->getDeclContext()->isFileContext()) { + if (!OldDecl->isUsed() && !OldDecl->isCXXClassMember()) { auto *VD = dyn_cast<VarDecl>(OldDecl); if (VD && !VD->getDescribedVarTemplate()) JustWarn = true; diff --git a/clang/test/SemaCXX/dllexport.cpp b/clang/test/SemaCXX/dllexport.cpp index 5d688944095..e6fc91d6b94 100644 --- a/clang/test/SemaCXX/dllexport.cpp +++ b/clang/test/SemaCXX/dllexport.cpp @@ -55,6 +55,11 @@ __declspec(dllexport) extern int GlobalRedecl2; extern int GlobalRedecl3; // expected-note{{previous declaration is here}} __declspec(dllexport) extern int GlobalRedecl3; // expected-warning{{redeclaration of 'GlobalRedecl3' should not add 'dllexport' attribute}} +extern "C" { + extern int GlobalRedecl4; // expected-note{{previous declaration is here}} +__declspec(dllexport) extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllexport' attribute}} +} + // External linkage is required. __declspec(dllexport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllexport'}} __declspec(dllexport) Internal InternalTypeGlobal; // expected-error{{'InternalTypeGlobal' must have external linkage when declared 'dllexport'}} @@ -191,8 +196,13 @@ __declspec(dllexport) void redecl2(); void redecl3(); // expected-note{{previous declaration is here}} __declspec(dllexport) void redecl3(); // expected-warning{{redeclaration of 'redecl3' should not add 'dllexport' attribute}} +extern "C" { void redecl4(); // expected-note{{previous declaration is here}} -__declspec(dllexport) inline void redecl4() {} // expected-warning{{redeclaration of 'redecl4' should not add 'dllexport' attribute}} +__declspec(dllexport) void redecl4(); // expected-warning{{redeclaration of 'redecl4' should not add 'dllexport' attribute}} +} + + void redecl5(); // expected-note{{previous declaration is here}} +__declspec(dllexport) inline void redecl5() {} // expected-warning{{redeclaration of 'redecl5' should not add 'dllexport' attribute}} // Friend functions struct FuncFriend { diff --git a/clang/test/SemaCXX/dllimport.cpp b/clang/test/SemaCXX/dllimport.cpp index 27378256f4f..844fe4fe0b4 100644 --- a/clang/test/SemaCXX/dllimport.cpp +++ b/clang/test/SemaCXX/dllimport.cpp @@ -77,6 +77,11 @@ __declspec(dllimport) extern int GlobalRedecl3; // expected-note{{previous decla extern int GlobalRedecl4; // expected-note{{previous declaration is here}} __declspec(dllimport) extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllimport' attribute}} +extern "C" { + extern int GlobalRedecl5; // expected-note{{previous declaration is here}} +__declspec(dllimport) extern int GlobalRedecl5; // expected-warning{{redeclaration of 'GlobalRedecl5' should not add 'dllimport' attribute}} +} + // External linkage is required. __declspec(dllimport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllimport'}} __declspec(dllimport) Internal InternalTypeGlobal; // expected-error{{'InternalTypeGlobal' must have external linkage when declared 'dllimport'}} @@ -229,8 +234,13 @@ __declspec(dllimport) void redecl3(); // expected-note{{previous declaration is void redecl4(); // expected-note{{previous declaration is here}} __declspec(dllimport) void redecl4(); // expected-warning{{redeclaration of 'redecl4' should not add 'dllimport' attribute}} +extern "C" { void redecl5(); // expected-note{{previous declaration is here}} -__declspec(dllimport) inline void redecl5() {} // expected-warning{{redeclaration of 'redecl5' should not add 'dllimport' attribute}} +__declspec(dllimport) void redecl5(); // expected-warning{{redeclaration of 'redecl5' should not add 'dllimport' attribute}} +} + + void redecl6(); // expected-note{{previous declaration is here}} +__declspec(dllimport) inline void redecl6() {} // expected-warning{{redeclaration of 'redecl6' should not add 'dllimport' attribute}} // Friend functions struct FuncFriend { |