[cfe-commits] r141522 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprMember.cpp test/SemaObjCXX/propert-dot-error.mm
jahanian
fjahanian at apple.com
Mon Oct 10 09:05:43 PDT 2011
On Oct 9, 2011, at 4:22 PM, Douglas Gregor wrote:
> Author: dgregor
> Date: Sun Oct 9 18:22:49 2011
> New Revision: 141522
>
> URL: http://llvm.org/viewvc/llvm-project?rev=141522&view=rev
> Log:
> Diagnose attempts to qualify the name of an instance variable or
> property in an Objective-C++ member access expression. Fixes PR9759.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaExprMember.cpp
> cfe/trunk/test/SemaObjCXX/propert-dot-error.mm
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=141522&r1=141521&r2=141522&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Oct 9 18:22:49 2011
> @@ -3472,7 +3472,9 @@
> "setter method is needed to assign to object using property" " assignment syntax">;
> def error_no_subobject_property_setting : Error<
> "expression is not assignable">;
> -
> +def err_qualified_objc_access : Error<
> + "%select{property|ivar}0 access cannot be qualified with '%1'">;
> +
> def ext_freestanding_complex : Extension<
> "complex numbers are an extension in a freestanding C99 implementation">;
>
>
> Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=141522&r1=141521&r2=141522&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Sun Oct 9 18:22:49 2011
> @@ -1045,6 +1045,13 @@
>
> // Handle ivar access to Objective-C objects.
> if (const ObjCObjectType *OTy = BaseType->getAs<ObjCObjectType>()) {
> + if (!SS.isEmpty()) {
> + Diag(SS.getRange().getBegin(), diag::err_qualified_objc_access)
> + << 1 << SS.getScopeRep()
> + << FixItHint::CreateRemoval(SS.getRange());
> + SS.clear();
> + }
> +
> IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
>
> // There are three cases for the base type:
> @@ -1163,6 +1170,13 @@
> // Objective-C property access.
> const ObjCObjectPointerType *OPT;
> if (!IsArrow && (OPT = BaseType->getAs<ObjCObjectPointerType>())) {
> + if (!SS.isEmpty()) {
> + Diag(SS.getRange().getBegin(), diag::err_qualified_objc_access)
> + << 0 << SS.getScopeRep()
> + << FixItHint::CreateRemoval(SS.getRange());
> + SS.clear();
> + }
> +
> // This actually uses the base as an r-value.
> BaseExpr = DefaultLvalueConversion(BaseExpr.take());
> if (BaseExpr.isInvalid())
>
> Modified: cfe/trunk/test/SemaObjCXX/propert-dot-error.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/propert-dot-error.mm?rev=141522&r1=141521&r2=141522&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjCXX/propert-dot-error.mm (original)
> +++ cfe/trunk/test/SemaObjCXX/propert-dot-error.mm Sun Oct 9 18:22:49 2011
> @@ -50,3 +50,18 @@
> b->operator+ = 17; // expected-error{{'B' does not have a member named 'operator+'}}
> }
> @end
> +
> +// PR9759
> +class Forward;
> + at interface D {
> + at public
> + int ivar;
> +}
> +
> + at property int property;
> + at end
> +
> +void testD(D *d) {
> + d.Forward::property = 17; // expected-error{{property access cannot be qualified with 'Forward::'}}
> + d->Forward::ivar = 12; // expected-error{{ivar access cannot be qualified with 'Forward::'}}
> +}
This is the more interesting bug which currently crashes.
// PR9759
@interface D {
@public
int ivar;
}
@property int property;
@end
void testD(D *d) {
d.D::property = 17; // expected-error{{property access cannot be qualified with 'D::'}}
d->D::ivar = 12; // expected-error{{ivar access cannot be qualified with 'D::'}}
}
- Fariborz
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list