[PATCH] MS extensions: Properly diagnose address of MS property decl

Richard Smith richard at metafoo.co.uk
Tue Feb 24 12:13:08 PST 2015


LGTM
On 24 Feb 2015 11:51, "Reid Kleckner" <rnk at google.com> wrote:

> Hi rsmith,
>
> Fixes PR22671.
>
> http://reviews.llvm.org/D7863
>
> Files:
>   lib/AST/ExprClassification.cpp
>   lib/Sema/SemaExpr.cpp
>   test/SemaCXX/MicrosoftExtensions.cpp
>
> Index: lib/AST/ExprClassification.cpp
> ===================================================================
> --- lib/AST/ExprClassification.cpp
> +++ lib/AST/ExprClassification.cpp
> @@ -418,9 +418,10 @@
>      islvalue = NTTParm->getType()->isReferenceType();
>    else
>      islvalue = isa<VarDecl>(D) || isa<FieldDecl>(D) ||
> -         isa<IndirectFieldDecl>(D) ||
> -      (Ctx.getLangOpts().CPlusPlus &&
> -        (isa<FunctionDecl>(D) || isa<FunctionTemplateDecl>(D)));
> +               isa<IndirectFieldDecl>(D) ||
> +               (Ctx.getLangOpts().CPlusPlus &&
> +                (isa<FunctionDecl>(D) || isa<MSPropertyDecl>(D) ||
> +                 isa<FunctionTemplateDecl>(D)));
>
>    return islvalue ? Cl::CL_LValue : Cl::CL_PRValue;
>  }
> Index: lib/Sema/SemaExpr.cpp
> ===================================================================
> --- lib/Sema/SemaExpr.cpp
> +++ lib/Sema/SemaExpr.cpp
> @@ -9352,6 +9352,8 @@
>            !getLangOpts().CPlusPlus) {
>          AddressOfError = AO_Register_Variable;
>        }
> +    } else if (isa<MSPropertyDecl>(dcl)) {
> +      AddressOfError = AO_Property_Expansion;
>      } else if (isa<FunctionTemplateDecl>(dcl)) {
>        return Context.OverloadTy;
>      } else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
> Index: test/SemaCXX/MicrosoftExtensions.cpp
> ===================================================================
> --- test/SemaCXX/MicrosoftExtensions.cpp
> +++ test/SemaCXX/MicrosoftExtensions.cpp
> @@ -344,6 +344,18 @@
>    __declspec(property(get=GetV)) int : 10; // expected-error {{anonymous
> property is not supported}}
>  };
>
> +struct MSPropertyClass {
> +  int get() { return 42; }
> +  int __declspec(property(get = get)) n;
> +};
> +
> +int *f(MSPropertyClass &x) {
> +  return &x.n; // expected-error {{address of property expression
> requested}}
> +}
> +int MSPropertyClass::*g() {
> +  return &MSPropertyClass::n; // expected-error {{address of property
> expression requested}}
> +}
> +
>  namespace rdar14250378 {
>    class Bar {};
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150224/eea5050d/attachment.html>


More information about the cfe-commits mailing list