[PATCH] PR16395 Crash using Microsoft property declaration without a name
Aaron Ballman
aaron at aaronballman.com
Mon Jun 24 13:02:25 PDT 2013
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