xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/id.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc@protocol Foo;
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel SambucClass T;
6*f4a2713aSLionel Sambucid<Foo> S;
7*f4a2713aSLionel Sambucid R;
8*f4a2713aSLionel Sambucvoid foo() {
9*f4a2713aSLionel Sambuc  // Test assignment compatibility of Class and id.  No warning should be
10*f4a2713aSLionel Sambuc  // produced.
11*f4a2713aSLionel Sambuc  // rdar://6770142 - Class and id<foo> are compatible.
12*f4a2713aSLionel Sambuc  S = T; // expected-warning {{incompatible pointer types assigning to 'id<Foo>' from 'Class'}}
13*f4a2713aSLionel Sambuc  T = S; // expected-warning {{incompatible pointer types assigning to 'Class' from 'id<Foo>'}}
14*f4a2713aSLionel Sambuc  R = T; T = R;
15*f4a2713aSLionel Sambuc  R = S; S = R;
16*f4a2713aSLionel Sambuc}
17*f4a2713aSLionel Sambuc
18*f4a2713aSLionel Sambuc// Test attempt to redefine 'id' in an incompatible fashion.
19*f4a2713aSLionel Sambuc// rdar://11356439
20*f4a2713aSLionel Sambuctypedef int id;  // expected-error {{typedef redefinition with different types ('int' vs 'id')}}
21*f4a2713aSLionel Sambucid b;
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambuctypedef double id;  // expected-error {{typedef redefinition with different types ('double' vs 'id')}}
24*f4a2713aSLionel Sambuc
25*f4a2713aSLionel Sambuctypedef char *id; // expected-error {{typedef redefinition with different types ('char *' vs 'id')}}
26*f4a2713aSLionel Sambuc
27*f4a2713aSLionel Sambuctypedef union U{ int iu; } *id; // expected-error {{typedef redefinition with different types ('union U *' vs 'id')}}
28*f4a2713aSLionel Sambuc
29*f4a2713aSLionel Sambucvoid test11356439(id o) {
30*f4a2713aSLionel Sambuc  o->x; // expected-error {{member reference base type 'id' is not a structure or union}}
31*f4a2713aSLionel Sambuc}
32