--===============7161292725697064016== Content-Type: multipart/alternative; boundary=bcaec548a05f8a2898051be12111 --bcaec548a05f8a2898051be12111 Content-Type: text/plain; charset=UTF-8 Approved. On Mon, Jul 27, 2015 at 1:20 PM, Hans Wennborg wrote: > Ping? > > On Thu, Jul 23, 2015 at 4:45 PM, Hans Wennborg 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 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(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(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 > --bcaec548a05f8a2898051be12111 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: Quoted-printable
Approved.

On Mon, Jul 27, 2015 at 1:20 PM, Hans Wennborg <hans@ch= romium.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=3D242973&view=3Drev
>> Log:
>> Downgrade error about adding 'dllimport' to used free func= tion to warning (PR24215)
>>
>> The code will still work as it can reference the function via its = thunk.
>>
>> Modified:
>>=C2=A0 =C2=A0 =C2=A0cfe/trunk/lib/Sema/SemaDecl.cpp
>>=C2=A0 =C2=A0 =C2=A0cfe/trunk/test/Sema/dllimport.c
>>
>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>> URL: http://llvm.org/viewvc/llv= m-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=3D242973&r1=3D242972&= r2=3D242973&view=3Ddiff
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D
>> --- 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
>>=C2=A0 =C2=A0 bool AddsAttr =3D !(OldImportAttr || OldExportAttr) &= amp;& HasNewAttr;
>>
>>=C2=A0 =C2=A0 if (AddsAttr && !IsSpecialization && = !OldDecl->isImplicit()) {
>> -=C2=A0 =C2=A0 // If the declaration hasn't been used yet, all= ow with a warning for
>> -=C2=A0 =C2=A0 // free functions and global variables.
>> +=C2=A0 =C2=A0 // Allow with a warning for free functions and glob= al variables.
>>=C2=A0 =C2=A0 =C2=A0 bool JustWarn =3D false;
>> -=C2=A0 =C2=A0 if (!OldDecl->isUsed() && !OldDecl->i= sCXXClassMember()) {
>> +=C2=A0 =C2=A0 if (!OldDecl->isCXXClassMember()) {
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 auto *VD =3D dyn_cast<VarDecl>(Ol= dDecl);
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (VD && !VD->getDescribedV= arTemplate())
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 JustWarn =3D true;
>> @@ -5380,6 +5379,13 @@ static void checkDLLAttributeRedeclarati
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 JustWarn =3D true;
>>=C2=A0 =C2=A0 =C2=A0 }
>>
>> +=C2=A0 =C2=A0 // We cannot change a declaration that's been u= sed because IR has already
>> +=C2=A0 =C2=A0 // been emitted. Dllimported functions will still w= ork though (modulo
>> +=C2=A0 =C2=A0 // address equality) as they can use the thunk.
>> +=C2=A0 =C2=A0 if (OldDecl->isUsed())
>> +=C2=A0 =C2=A0 =C2=A0 if (!isa<FunctionDecl>(OldDecl) || !Ne= wImportAttr)
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 JustWarn =3D false;
>> +
>>=C2=A0 =C2=A0 =C2=A0 unsigned DiagID =3D JustWarn ? diag::warn_attr= ibute_dll_redeclaration
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0: diag::err_attribute_d= ll_redeclaration;
>>=C2=A0 =C2=A0 =C2=A0 S.Diag(NewDecl->getLocation(), DiagID)
>>
>> Modified: cfe/trunk/test/Sema/dllimport.c
>> URL: http://llvm.org/viewvc/llv= m-project/cfe/trunk/test/Sema/dllimport.c?rev=3D242973&r1=3D242972&= r2=3D242973&view=3Ddiff
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D
>> --- 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(); //
>>
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 void redecl4(); // expected-note{{previous declaration is= here}}
>>=C2=A0 void useRedecl4() { redecl4(); }
>> -__declspec(dllimport) void redecl4(); // expected-error{{redeclar= ation of 'redecl4' cannot add 'dllimport' attribute}}
>> +__declspec(dllimport) void redecl4(); // expected-warning{{redecl= aration of 'redecl4' should not add 'dllimport' attribute}}=
>>
>>=C2=A0 // Allow with a warning if the decl hasn't been used yet= .
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 void redecl5(); // expected-note{{previous declaration is= here}}
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits@cs.uiuc.edu=
>> http://lists.cs.uiuc.edu/mailman/listi= nfo/cfe-commits

--bcaec548a05f8a2898051be12111-- --===============7161292725697064016== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits --===============7161292725697064016==--