From a56a81abb0079b91f8908b46c784f870f562c73f Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 24 Feb 2015 20:29:40 +0000 Subject: [PATCH] MS extensions: Properly diagnose address of MS property decl Summary: Fixes PR22671. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D7863 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230362 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ExprClassification.cpp | 7 ++++--- lib/Sema/SemaExpr.cpp | 2 ++ test/SemaCXX/MicrosoftExtensions.cpp | 12 ++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp index 933ea97fa2..124b4675ca 100644 --- a/lib/AST/ExprClassification.cpp +++ b/lib/AST/ExprClassification.cpp @@ -418,9 +418,10 @@ static Cl::Kinds ClassifyDecl(ASTContext &Ctx, const Decl *D) { islvalue = NTTParm->getType()->isReferenceType(); else islvalue = isa(D) || isa(D) || - isa(D) || - (Ctx.getLangOpts().CPlusPlus && - (isa(D) || isa(D))); + isa(D) || + (Ctx.getLangOpts().CPlusPlus && + (isa(D) || isa(D) || + isa(D))); return islvalue ? Cl::CL_LValue : Cl::CL_PRValue; } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 4b807c1058..90f5046582 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -9352,6 +9352,8 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) { !getLangOpts().CPlusPlus) { AddressOfError = AO_Register_Variable; } + } else if (isa(dcl)) { + AddressOfError = AO_Property_Expansion; } else if (isa(dcl)) { return Context.OverloadTy; } else if (isa(dcl) || isa(dcl)) { diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp index 57d6f0d6be..db5e4586da 100644 --- a/test/SemaCXX/MicrosoftExtensions.cpp +++ b/test/SemaCXX/MicrosoftExtensions.cpp @@ -344,6 +344,18 @@ struct StructWithUnnamedMember { __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 {}; -- 2.40.0