r230362 - MS extensions: Properly diagnose address of MS property decl
Reid Kleckner
reid at kleckner.net
Tue Feb 24 12:29:40 PST 2015
Author: rnk
Date: Tue Feb 24 14:29:40 2015
New Revision: 230362
URL: http://llvm.org/viewvc/llvm-project?rev=230362&view=rev
Log:
MS extensions: Properly diagnose address of MS property decl
Summary: Fixes PR22671.
Reviewers: rsmith
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D7863
Modified:
cfe/trunk/lib/AST/ExprClassification.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
Modified: cfe/trunk/lib/AST/ExprClassification.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprClassification.cpp?rev=230362&r1=230361&r2=230362&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprClassification.cpp (original)
+++ cfe/trunk/lib/AST/ExprClassification.cpp Tue Feb 24 14:29:40 2015
@@ -418,9 +418,10 @@ static Cl::Kinds ClassifyDecl(ASTContext
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;
}
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=230362&r1=230361&r2=230362&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Feb 24 14:29:40 2015
@@ -9352,6 +9352,8 @@ QualType Sema::CheckAddressOfOperand(Exp
!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)) {
Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=230362&r1=230361&r2=230362&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Tue Feb 24 14:29:40 2015
@@ -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 {};
More information about the cfe-commits
mailing list