blob: 2b505e0eae332c88a0e05709e79cdeb97e7b2f0e [file] [log] [blame]
Douglas Gregordd8f5692010-03-10 04:54:39 +00001// RUN: %clang_cc1 %s -fsyntax-only -fblocks -verify -Wno-unreachable-code
Chris Lattnera119a3b2009-02-18 04:38:20 +00002
3// rdar://6597252
Chris Lattner60800082009-02-18 17:49:48 +00004Class test1(Class X) {
Chris Lattnera119a3b2009-02-18 04:38:20 +00005 return 1 ? X : X;
6}
7
Chris Lattner60800082009-02-18 17:49:48 +00008
9// rdar://6079877
10void test2() {
11 id str = @"foo"
Ted Kremenekdb9e9e62011-03-15 21:18:52 +000012 "bar\0" // no-warning
Chris Lattner60800082009-02-18 17:49:48 +000013 @"baz" " blarg";
14 id str2 = @"foo"
15 "bar"
16 @"baz"
Ted Kremenekdb9e9e62011-03-15 21:18:52 +000017 " b\0larg"; // no-warning
Chris Lattner95f49fb2009-04-03 21:11:28 +000018
Chris Lattner60800082009-02-18 17:49:48 +000019
Chris Lattner95f49fb2009-04-03 21:11:28 +000020 if (@encode(int) == "foo") { } // expected-warning {{result of comparison against @encode is unspecified}}
Daniel Dunbard7d5f022009-03-24 02:24:46 +000021}
Douglas Gregordd8f5692010-03-10 04:54:39 +000022
23#define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
24void (^foo)(int, int) = ^(int x, int y) { int z = MAX(x, y); };
Chris Lattnerdd5fa7a2010-09-17 21:12:38 +000025
26
27
28// rdar://8445858
29@class Object;
30static Object *g;
31void test3(Object *o) {
32 // this is ok.
33 __sync_bool_compare_and_swap(&g, 0, o);
34}
Argyrios Kyrtzidis3b5904b2011-05-14 20:32:39 +000035
36@class Incomplete_ObjC_class;
37struct Incomplete_struct; // expected-note {{forward declaration}}
38
39void test_encode() {
40 (void)@encode(Incomplete_ObjC_class); // expected-error {{incomplete type}}
41 (void)@encode(struct Incomplete_struct); // expected-error {{incomplete type}}
42 (void)@encode(Incomplete_ObjC_class*);
43 (void)@encode(id);
44}