From 635a55adc093aded50651b6e13cd48a5ecb932fc Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 18 Dec 2014 00:30:54 +0000 Subject: [PATCH] [Objective-C]. Modern property getters have side-effects. So, place warning about property getter should not be used for side-effect under its own group so warning can be turned off. rdar://19137815 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224479 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticGroups.td | 1 + include/clang/Basic/DiagnosticSemaKinds.td | 2 +- test/Parser/MicrosoftExtensions.cpp | 2 +- test/SemaObjC/access-property-getter.m | 17 +++++++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index 65ff0443c3..81efb8eac9 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -413,6 +413,7 @@ def UnusedVariable : DiagGroup<"unused-variable", [UnusedConstVariable]>; def UnusedLocalTypedef : DiagGroup<"unused-local-typedef">; def UnusedPropertyIvar : DiagGroup<"unused-property-ivar">; +def UnusedGetterReturnValue : DiagGroup<"unused-getter-return-value">; def UsedButMarkedUnused : DiagGroup<"used-but-marked-unused">; def UserDefinedLiterals : DiagGroup<"user-defined-literals">; def Reorder : DiagGroup<"reorder">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 99049c8ebd..66306ecae4 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -6100,7 +6100,7 @@ def warn_unused_voidptr : Warning< InGroup; def warn_unused_property_expr : Warning< "property access result unused - getters should not be used for side effects">, - InGroup; + InGroup; def warn_unused_container_subscript_expr : Warning< "container access result unused - container access should not be used for side effects">, InGroup; diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp index 7637777d29..73a1bb57af 100644 --- a/test/Parser/MicrosoftExtensions.cpp +++ b/test/Parser/MicrosoftExtensions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple i386-mingw32 -std=c++11 -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing +// RUN: %clang_cc1 %s -triple i386-mingw32 -std=c++11 -fsyntax-only -Wno-unused-getter-return-value -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing /* Microsoft attribute tests */ [repeatable][source_annotation_attribute( Parameter|ReturnValue )] diff --git a/test/SemaObjC/access-property-getter.m b/test/SemaObjC/access-property-getter.m index afaf82e731..41827bb3c8 100644 --- a/test/SemaObjC/access-property-getter.m +++ b/test/SemaObjC/access-property-getter.m @@ -34,3 +34,20 @@ return 0; } @end + +// rdar://19137815 +#pragma clang diagnostic ignored "-Wunused-getter-return-value" + +@interface NSObject @end + +@interface I : NSObject +@property (copy) id window; +@end + +@implementation I +- (void) Meth { + [self window]; + self.window; +} +@end + -- 2.40.0