[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-commits
Subject:    Re: r242973 - Downgrade error about adding 'dllimport' to used free function to warning (PR24215)
From:       Hans Wennborg <hans () chromium ! org>
Date:       2015-07-27 20:36:57
Message-ID: CAB8jPheiuPwAzSB_p_5ap1AeCGtFT5p_drPDh87Yube4md8Dfg () mail ! gmail ! com
[Download RAW message or body]

Thanks! Merged in r243320.

On Mon, Jul 27, 2015 at 1:23 PM, Richard Smith <richard@metafoo.co.uk> wrote:
> Approved.
> 
> On Mon, Jul 27, 2015 at 1:20 PM, Hans Wennborg <hans@chromium.org> wrote:
> > 
> > Ping?
> > 
> > On Thu, Jul 23, 2015 at 4:45 PM, Hans Wennborg <hans@chromium.org> wrote:
> > > This isn't fixing a regression, but would be nice to have in 3.7 I
> > > think.
> > > 
> > > Richard, is this OK for merging?
> > > 
> > > On Wed, Jul 22, 2015 at 4:54 PM, Hans Wennborg <hans@hanshq.net> wrote:
> > > > Author: hans
> > > > Date: Wed Jul 22 18:54:51 2015
> > > > New Revision: 242973
> > > > 
> > > > URL: http://llvm.org/viewvc/llvm-project?rev=242973&view=rev
> > > > Log:
> > > > Downgrade error about adding 'dllimport' to used free function to
> > > > warning (PR24215)
> > > > 
> > > > The code will still work as it can reference the function via its
> > > > thunk.
> > > > 
> > > > Modified:
> > > > cfe/trunk/lib/Sema/SemaDecl.cpp
> > > > cfe/trunk/test/Sema/dllimport.c
> > > > 
> > > > Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> > > > URL:
> > > > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=242973&r1=242972&r2=242973&view=diff
> > > >  
> > > > ==============================================================================
> > > >                 
> > > > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> > > > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jul 22 18:54:51 2015
> > > > @@ -5368,10 +5368,9 @@ static void checkDLLAttributeRedeclarati
> > > > bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
> > > > 
> > > > if (AddsAttr && !IsSpecialization && !OldDecl->isImplicit()) {
> > > > -    // If the declaration hasn't been used yet, allow with a warning
> > > > for
> > > > -    // free functions and global variables.
> > > > +    // Allow with a warning for free functions and global variables.
> > > > bool JustWarn = false;
> > > > -    if (!OldDecl->isUsed() && !OldDecl->isCXXClassMember()) {
> > > > +    if (!OldDecl->isCXXClassMember()) {
> > > > auto *VD = dyn_cast<VarDecl>(OldDecl);
> > > > if (VD && !VD->getDescribedVarTemplate())
> > > > JustWarn = true;
> > > > @@ -5380,6 +5379,13 @@ static void checkDLLAttributeRedeclarati
> > > > JustWarn = true;
> > > > }
> > > > 
> > > > +    // We cannot change a declaration that's been used because IR has
> > > > already
> > > > +    // been emitted. Dllimported functions will still work though
> > > > (modulo
> > > > +    // address equality) as they can use the thunk.
> > > > +    if (OldDecl->isUsed())
> > > > +      if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
> > > > +        JustWarn = false;
> > > > +
> > > > unsigned DiagID = JustWarn ?
> > > > diag::warn_attribute_dll_redeclaration
> > > > > 
> > > > diag::err_attribute_dll_redeclaration;
> > > > S.Diag(NewDecl->getLocation(), DiagID)
> > > > 
> > > > Modified: cfe/trunk/test/Sema/dllimport.c
> > > > URL:
> > > > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/dllimport.c?rev=242973&r1=242972&r2=242973&view=diff
> > > >  
> > > > ==============================================================================
> > > >                 
> > > > --- cfe/trunk/test/Sema/dllimport.c (original)
> > > > +++ cfe/trunk/test/Sema/dllimport.c Wed Jul 22 18:54:51 2015
> > > > @@ -143,7 +143,7 @@ __declspec(dllimport) void redecl3(); //
> > > > 
> > > > void redecl4(); // expected-note{{previous
> > > > declaration is here}}
> > > > void useRedecl4() { redecl4(); }
> > > > -__declspec(dllimport) void redecl4(); // expected-error{{redeclaration
> > > > of 'redecl4' cannot add 'dllimport' attribute}}
> > > > +__declspec(dllimport) void redecl4(); //
> > > > expected-warning{{redeclaration of 'redecl4' should not add 'dllimport'
> > > > attribute}}
> > > > 
> > > > // Allow with a warning if the decl hasn't been used yet.
> > > > void redecl5(); // expected-note{{previous
> > > > declaration is here}}
> > > > 
> > > > 
> > > > _______________________________________________
> > > > cfe-commits mailing list
> > > > cfe-commits@cs.uiuc.edu
> > > > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 
> 
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic