[PATCH] PR16395 Crash using Microsoft property declaration without a name

Aaron Ballman aaron at aaronballman.com
Wed Jun 26 14:30:13 PDT 2013


Committed in r185022; thanks!

~Aaron

On Wed, Jun 26, 2013 at 5:11 PM, Robert Wilhelm <robert.wilhelm at gmx.net> wrote:
> Attached is new patch with the curly braces removed.
> I also removed the braces a few lines below in the snippet I used as
> boilerplate.
>
> Somebody please commit this for me.
>
> Thanks,
> Robert
>
>
> On Mon, 2013-06-24 at 16:02 -0400, Aaron Ballman wrote:
>> On Mon, Jun 24, 2013 at 3:51 PM, Robert Wilhelm <robert.wilhelm at gmx.net> wrote:
>> >
>> > I have attached patch for http://llvm.org/bugs/show_bug.cgi?id=16395.
>> >
>> > Bail out, if HandleMSProperty returns null.
>> > While HandleField never returns null, HandleMSProperty does on error.
>> >
>> > Testcase and bug report by Eli Friedman.
>> > Index: lib/Sema/SemaDeclCXX.cpp
>> > ===================================================================
>> > --- lib/Sema/SemaDeclCXX.cpp (revision 184670)
>> > +++ lib/Sema/SemaDeclCXX.cpp (working copy)
>> > @@ -1935,12 +1935,15 @@
>> >      if (MSPropertyAttr) {
>> >        Member = HandleMSProperty(S, cast<CXXRecordDecl>(CurContext), Loc, D,
>> >                                  BitWidth, InitStyle, AS, MSPropertyAttr);
>> > +      if (!Member) {
>> > +        return 0;
>> > +      }
>>
>> Remove curly braces (single-line if).
>>
>> >        isInstField = false;
>> >      } else {
>> >        Member = HandleField(S, cast<CXXRecordDecl>(CurContext), Loc, D,
>> >                                  BitWidth, InitStyle, AS);
>> > +      assert(Member && "HandleField never returns null");
>> >      }
>> > -    assert(Member && "HandleField never returns null");
>> >    } else {
>> >      assert(InitStyle == ICIS_NoInit || D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static);
>> >
>> > Index: test/SemaCXX/MicrosoftExtensions.cpp
>> > ===================================================================
>> > --- test/SemaCXX/MicrosoftExtensions.cpp (revision 184665)
>> > +++ test/SemaCXX/MicrosoftExtensions.cpp (working copy)
>> > @@ -361,3 +361,7 @@
>> >    TakeRef(V);
>> >    TakeVal(V);
>> >  }
>> > +
>> > +struct StructWithUnnamedMember {
>> > +  __declspec(property(get=GetV)) int : 10; // expected-error {{anonymous property is not supported}}
>> > +};
>>
>> Aside from that, the patch LGTM
>>
>> ~Aaron
>



More information about the cfe-commits mailing list