/* Check for finding the prototype when there multiple identical available. */ /* Contributed by David Ayers and Alexander Malmberg */ /* { dg-do compile } */ #include struct _MyStruct { unsigned long a; unsigned long b; unsigned long c; }; typedef struct _MyStruct MyStruct; /* Protocol from Inherited class declares method. */ @protocol Proto1 - (MyStruct)getStruct; @end /* Class declares method directly. */ @interface Class1 - (MyStruct)getStruct; @end /* Protocol declares method. */ @protocol Proto2 - (MyStruct)getStruct; @end /* Superclass declares method. */ @interface Class2 : Class1 - (MyStruct)getStruct; + (Class2 *)class2; @end @interface Class2 (Category1) - (MyStruct)getStruct; @end /* Category is inherited. */ @interface Class1 (Category2) - (MyStruct)getStruct; @end /* Category's protocol declares method. */ @protocol Proto3 - (MyStruct)getStruct; @end @interface Class2 (Category3) @end /* Inherited category's protocol declares method. */ @protocol Proto4 - (MyStruct)getStruct; @end @interface Class1 (Category4) @end /* Implicit local declaraions in class. */ @implementation Class2 +(Class2 *)class2 { return nil; } -(MyStruct)getStruct { MyStruct strct = { 1UL, 1UL, 1UL }; return strct; } -(void)useInInstance { MyStruct strct; strct = [self getStruct]; } @end /* Implicit local declaraions in category. */ @implementation Class2 (Category5) -(MyStruct)getStruct { MyStruct strct = { 1UL, 1UL, 1UL }; return strct; } -(void)useInInstance2 { MyStruct strct; strct = [self getStruct]; } @end void foo1(void) { MyStruct strct; Class2 *varClass2; id varId; strct = [[Class2 class2] getStruct]; strct = [Class2 getStruct]; varClass2 = [Class2 class2]; strct = [varClass2 getStruct]; varId = [Class2 class2]; strct = [(Class2 *)varId getStruct]; }