[Objective-C]. Modern property getters have side-effects.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 18 Dec 2014 00:30:54 +0000 (00:30 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 18 Dec 2014 00:30:54 +0000 (00:30 +0000)
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

llvm-svn: 224479

clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/Parser/MicrosoftExtensions.cpp
clang/test/SemaObjC/access-property-getter.m

index 65ff044..81efb8e 100644 (file)
@@ -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">;
index 99049c8..66306ec 100644 (file)
@@ -6100,7 +6100,7 @@ def warn_unused_voidptr : Warning<
   InGroup<UnusedValue>;
 def warn_unused_property_expr : Warning<
  "property access result unused - getters should not be used for side effects">,
-  InGroup<UnusedValue>;
+  InGroup<UnusedGetterReturnValue>;
 def warn_unused_container_subscript_expr : Warning<
  "container access result unused - container access should not be used for side effects">,
   InGroup<UnusedValue>;
index 7637777..73a1bb5 100644 (file)
@@ -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 )]
index afaf82e..41827bb 100644 (file)
      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
+