r220874 - Follow-up to r216619: use isCXXCLassMember() instead of trying to

Richard Smith richard at metafoo.co.uk
Thu Oct 30 11:01:24 PDT 2014


Approved for branch.
On 29 Oct 2014 16:32, "Hans Wennborg" <hans at chromium.org> wrote:

> Tom, I'd like to merge this to the 3.5 branch.
> Richard, I guess you're the code owner.
>
> On Wed, Oct 29, 2014 at 2:20 PM, Hans Wennborg <hans at hanshq.net> wrote:
> > Author: hans
> > Date: Wed Oct 29 16:20:57 2014
> > New Revision: 220874
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=220874&view=rev
> > Log:
> > 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)
> >
> > Modified:
> >     cfe/trunk/lib/Sema/SemaDecl.cpp
> >     cfe/trunk/test/SemaCXX/dllexport.cpp
> >     cfe/trunk/test/SemaCXX/dllimport.cpp
> >
> > Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=220874&r1=220873&r2=220874&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Oct 29 16:20:57 2014
> > @@ -5140,7 +5140,7 @@ static void checkDLLAttributeRedeclarati
> >      // 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;
> >
> > Modified: cfe/trunk/test/SemaCXX/dllexport.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/dllexport.cpp?rev=220874&r1=220873&r2=220874&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/test/SemaCXX/dllexport.cpp (original)
> > +++ cfe/trunk/test/SemaCXX/dllexport.cpp Wed Oct 29 16:20:57 2014
> > @@ -55,6 +55,11 @@ __declspec(dllexport) extern int GlobalR
> >                        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 {
> >
> > Modified: cfe/trunk/test/SemaCXX/dllimport.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/dllimport.cpp?rev=220874&r1=220873&r2=220874&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/test/SemaCXX/dllimport.cpp (original)
> > +++ cfe/trunk/test/SemaCXX/dllimport.cpp Wed Oct 29 16:20:57 2014
> > @@ -77,6 +77,11 @@ __declspec(dllimport) extern int GlobalR
> >                        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(); //
> >                        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 {
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141030/a5f46ada/attachment.html>


More information about the cfe-commits mailing list