blob: ced406ebd29b83f65d088df1f5985a8fd27cd093 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Fariborz Jahanianc55a2402009-01-16 19:58:32 +00002
Chris Lattner2c4463f2009-04-12 09:02:39 +00003@protocol Foo;
4
5Class T;
6id<Foo> S;
7id R;
8void foo() {
9 // Test assignment compatibility of Class and id. No warning should be
10 // produced.
11 // rdar://6770142 - Class and id<foo> are compatible.
Douglas Gregord4eea832010-04-09 00:35:39 +000012 S = T; // expected-warning {{incompatible pointer types assigning to 'id<Foo>' from 'Class'}}
13 T = S; // expected-warning {{incompatible pointer types assigning to 'Class' from 'id<Foo>'}}
Chris Lattner2c4463f2009-04-12 09:02:39 +000014 R = T; T = R;
15 R = S; S = R;
16}
17
18// Test attempt to redefine 'id' in an incompatible fashion.
Fariborz Jahanian0cd00be2012-05-14 22:48:56 +000019// rdar://11356439
20typedef int id; // expected-error {{typedef redefinition with different types ('int' vs 'id')}}
Fariborz Jahanianc55a2402009-01-16 19:58:32 +000021id b;
Chris Lattner2c4463f2009-04-12 09:02:39 +000022
Fariborz Jahanian0cd00be2012-05-14 22:48:56 +000023typedef double id; // expected-error {{typedef redefinition with different types ('double' vs 'id')}}
24
25typedef char *id; // expected-error {{typedef redefinition with different types ('char *' vs 'id')}}
26
27typedef union U{ int iu; } *id; // expected-error {{typedef redefinition with different types ('union U *' vs 'id')}}
28
29void test11356439(id o) {
30 o->x; // expected-error {{member reference base type 'id' is not a structure or union}}
31}