[cfe-commits] r65004 - /cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
Ted Kremenek
kremenek at apple.com
Wed Feb 18 20:07:38 PST 2009
Author: kremenek
Date: Wed Feb 18 22:07:38 2009
New Revision: 65004
URL: http://llvm.org/viewvc/llvm-project?rev=65004&view=rev
Log:
Add test case for 'nil receiver returns undefined struct value' check.
Added:
cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
Added: cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m?rev=65004&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m (added)
+++ cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m Wed Feb 18 22:07:38 2009
@@ -0,0 +1,19 @@
+// RUN: clang -analyze -checker-cfref -analyzer-constraints=basic -analyzer-store=basic %s -verify
+
+typedef struct Foo { int x; } Bar;
+
+ at interface MyClass {}
+- (Bar)foo;
+ at end
+ at implementation MyClass
+- (Bar)foo {
+ struct Foo f = { 0 };
+ return f;
+}
+ at end
+
+void createFoo() {
+ MyClass *obj = 0;
+ Bar f = [obj foo]; // expected-warning{{The receiver in the message expression is 'nil' and results in the returned value (of type 'Bar') to be garbage or otherwise undefined.}}
+}
+
More information about the cfe-commits
mailing list