1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 %s -fsyntax-only -fblocks -verify -Wno-unreachable-code 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc// rdar://6597252 4*f4a2713aSLionel SambucClass test1(Class X) { 5*f4a2713aSLionel Sambuc return 1 ? X : X; 6*f4a2713aSLionel Sambuc} 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc// rdar://6079877 10*f4a2713aSLionel Sambucvoid test2() { 11*f4a2713aSLionel Sambuc id str = @"foo" 12*f4a2713aSLionel Sambuc "bar\0" // no-warning 13*f4a2713aSLionel Sambuc @"baz" " blarg"; 14*f4a2713aSLionel Sambuc id str2 = @"foo" 15*f4a2713aSLionel Sambuc "bar" 16*f4a2713aSLionel Sambuc @"baz" 17*f4a2713aSLionel Sambuc " b\0larg"; // no-warning 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambuc 20*f4a2713aSLionel Sambuc if (@encode(int) == "foo") { } // expected-warning {{result of comparison against @encode is unspecified}} 21*f4a2713aSLionel Sambuc} 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc#define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) 24*f4a2713aSLionel Sambucvoid (^foo)(int, int) = ^(int x, int y) { int z = MAX(x, y); }; 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc// rdar://8445858 29*f4a2713aSLionel Sambuc@class Object; 30*f4a2713aSLionel Sambucstatic Object *g; 31*f4a2713aSLionel Sambucvoid test3(Object *o) { 32*f4a2713aSLionel Sambuc // this is ok. 33*f4a2713aSLionel Sambuc __sync_bool_compare_and_swap(&g, 0, o); 34*f4a2713aSLionel Sambuc} 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc@class Incomplete_ObjC_class; // expected-note{{forward declaration of class here}} 37*f4a2713aSLionel Sambucstruct Incomplete_struct; // expected-note {{forward declaration}} 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambucvoid test_encode() { 40*f4a2713aSLionel Sambuc (void)@encode(Incomplete_ObjC_class); // expected-error {{incomplete type}} 41*f4a2713aSLionel Sambuc (void)@encode(struct Incomplete_struct); // expected-error {{incomplete type}} 42*f4a2713aSLionel Sambuc (void)@encode(Incomplete_ObjC_class*); 43*f4a2713aSLionel Sambuc (void)@encode(id); 44*f4a2713aSLionel Sambuc} 45