On my machine (Ubuntu Linux), all of the objc tests cause an error
like the following:

Command:
 clang -rewrite-test Sema/rewrite-foreach-4.m | clang
Output:
In file included from <stdin>:23:
/usr/lib/gcc/i486-linux-gnu/4.1.3/include/objc/objc.h:145:3: error:
redefinition of 'Protocol'
} Protocol;
  ^
<stdin>:7:28: error: previous definition is here
typedef struct objc_object Protocol;
                           ^
2 diagnostics generated.

It's a lot of noise, so a fix would be nice...

I've attached the output of "clang -rewrite-test
Sema/rewrite-foreach-4.m", in case it helps.  Please ask if a copy of
my objc.h would be helpful.

-Eli
struct objc_selector; struct objc_class;
#ifndef OBJC_SUPER
struct objc_super { struct objc_object *o; struct objc_object *superClass; };
#define OBJC_SUPER
#endif
#ifndef _REWRITER_typedef_Protocol
typedef struct objc_object Protocol;
#define _REWRITER_typedef_Protocol
#endif
extern struct objc_object *objc_msgSend(struct objc_object *, struct 
objc_selector *, ...);
extern struct objc_object *objc_msgSendSuper(struct objc_super *, struct 
objc_selector *, ...);
extern struct objc_object *objc_msgSend_stret(struct objc_object *, struct 
objc_selector *, ...);
extern struct objc_object *objc_msgSendSuper_stret(struct objc_super *, struct 
objc_selector *, ...);
extern struct objc_object *objc_msgSend_fpret(struct objc_object *, struct 
objc_selector *, ...);
extern struct objc_object *objc_getClass(const char *);
extern struct objc_object *objc_getMetaClass(const char *);
extern void objc_exception_throw(struct objc_object *);
extern void objc_exception_try_enter(void *);
extern void objc_exception_try_exit(void *);
extern struct objc_object *objc_exception_extract(void *);
extern int objc_exception_match(struct objc_class *, struct objc_object *, ...);
extern Protocol *objc_getProtocol(const char *);
#include <objc/objc.h>
#ifndef __FASTENUMERATIONSTATE
struct __objcFastEnumerationState {
        unsigned long state;
        id *itemsPtr;
        unsigned long *mutationsPtr;
        unsigned long extra[5];
};
#define __FASTENUMERATIONSTATE
#endif
// RUN: clang -rewrite-test %s | clang

#ifndef _REWRITER_typedef_MyList
#define _REWRITER_typedef_MyList
typedef struct MyList MyList;
#endif

// - (id) allKeys;
// @end
    
// @implementation MyList

static unsigned int _I_MyList_countByEnumeratingWithState_objects_count_(MyList 
* self, SEL _cmd, struct __objcFastEnumerationState * state, id * items, 
unsigned int stackcount) {
        return 0;
}

static id _I_MyList_allKeys(MyList * self, SEL _cmd) {}
// @end

// @interface MyList (BasicTest)
// - (void)compilerTestAgainst;
// @end

int LOOP();
// @implementation MyList (BasicTest)

static void _I_MyList_BasicTest_compilerTestAgainst(MyList * self, SEL _cmd) {
  MyList * el;
        
{
        struct __objcFastEnumerationState enumState = { 0 };
        id items[16];
        id l_collection = (id) ((id (*)(id, SEL))(void *)objc_msgSend)((id)el, 
sel_registerName("allKeys"));
        unsigned long limit =
                ((unsigned int (*) (id, SEL, struct __objcFastEnumerationState 
*, id *, unsigned int))(void *)objc_msgSend)
                ((id)l_collection,
                sel_registerName("countByEnumeratingWithState:objects:count:"),
                &enumState, (id *)items, (unsigned int)16);
        if (limit) {
        unsigned long startMutations = *enumState.mutationsPtr;
        do {
                unsigned long counter = 0;
                do {
                        if (startMutations != *enumState.mutationsPtr)
                                objc_enumerationMutation(l_collection);
                        el = (MyList *)enumState.itemsPtr[counter++]; { LOOP(); 
          };
        __continue_label_1: ;
                } while (counter < limit);
        } while (limit = ((unsigned int (*) (id, SEL, struct 
__objcFastEnumerationState *, id *, unsigned int))(void *)objc_msgSend)
                ((id)l_collection,
                sel_registerName("countByEnumeratingWithState:objects:count:"),
                &enumState, (id *)items, (unsigned int)16));
        el = nil;
        __break_label_1: ;
        }
        else
                el = nil;
}


        
{
        id el1;
        struct __objcFastEnumerationState enumState = { 0 };
        id items[16];
        id l_collection = (id)((id (*)(id, SEL))(void *)objc_msgSend)((id)el, 
sel_registerName("allKeys"));
        unsigned long limit =
                ((unsigned int (*) (id, SEL, struct __objcFastEnumerationState 
*, id *, unsigned int))(void *)objc_msgSend)
                ((id)l_collection,
                sel_registerName("countByEnumeratingWithState:objects:count:"),
                &enumState, (id *)items, (unsigned int)16);
        if (limit) {
        unsigned long startMutations = *enumState.mutationsPtr;
        do {
                unsigned long counter = 0;
                do {
                        if (startMutations != *enumState.mutationsPtr)
                                objc_enumerationMutation(l_collection);
                        el1 = (id)enumState.itemsPtr[counter++]; { LOOP(); 
          };
        __continue_label_2: ;
                } while (counter < limit);
        } while (limit = ((unsigned int (*) (id, SEL, struct 
__objcFastEnumerationState *, id *, unsigned int))(void *)objc_msgSend)
                ((id)l_collection,
                sel_registerName("countByEnumeratingWithState:objects:count:"),
                &enumState, (id *)items, (unsigned int)16));
        el1 = nil;
        __break_label_2: ;
        }
        else
                el1 = nil;
}

        
{
        struct __objcFastEnumerationState enumState = { 0 };
        id items[16];
        id l_collection = (id)(((id (*)(id, SEL))(void *)objc_msgSend)((id)el, 
sel_registerName("allKeys")));
        unsigned long limit =
                ((unsigned int (*) (id, SEL, struct __objcFastEnumerationState 
*, id *, unsigned int))(void *)objc_msgSend)
                ((id)l_collection,
                sel_registerName("countByEnumeratingWithState:objects:count:"),
                &enumState, (id *)items, (unsigned int)16);
        if (limit) {
        unsigned long startMutations = *enumState.mutationsPtr;
        do {
                unsigned long counter = 0;
                do {
                        if (startMutations != *enumState.mutationsPtr)
                                objc_enumerationMutation(l_collection);
                        el = (MyList *)enumState.itemsPtr[counter++]; { LOOP(); 
          };
        __continue_label_3: ;
                } while (counter < limit);
        } while (limit = ((unsigned int (*) (id, SEL, struct 
__objcFastEnumerationState *, id *, unsigned int))(void *)objc_msgSend)
                ((id)l_collection,
                sel_registerName("countByEnumeratingWithState:objects:count:"),
                &enumState, (id *)items, (unsigned int)16));
        el = nil;
        __break_label_3: ;
        }
        else
                el = nil;
}

}
// @end


#include <stddef.h>

struct _objc_method {
        SEL _cmd;
        char *method_types;
        void *_imp;
};

struct _objc_method_list {
        struct _objc_method_list *next_method;
        int method_count;
        struct _objc_method method_list[];
};

static struct _objc_method_list _OBJC_INSTANCE_METHODS_MyList __attribute__ 
((section ("__OBJC, __inst_meth")))= {
        0, 2
        ,{{(SEL)"countByEnumeratingWithState:objects:count:", "[EMAIL 
PROTECTED]:[EMAIL PROTECTED]", 
_I_MyList_countByEnumeratingWithState_objects_count_}
          ,{(SEL)"allKeys", "@[EMAIL PROTECTED]:4", _I_MyList_allKeys}
         }
};

struct _objc_class {
        struct _objc_class *isa;
        const char *super_class_name;
        char *name;
        long version;
        long info;
        long instance_size;
        struct _objc_ivar_list *ivars;
        struct _objc_method_list *methods;
        struct objc_cache *cache;
        struct _objc_protocol_list *protocols;
        const char *ivar_layout;
        struct _objc_class_ext  *ext;
};

static struct _objc_class _OBJC_METACLASS_MyList __attribute__ ((section 
("__OBJC, __meta_class")))= {
        (struct _objc_class *)"MyList", 0, "MyList", 0,2, sizeof(struct 
_objc_class), 0, 0
        ,0,0,0,0
};

static struct _objc_class _OBJC_CLASS_MyList __attribute__ ((section ("__OBJC, 
__class")))= {
        &_OBJC_METACLASS_MyList, 0, "MyList", 0,1,0,0, 
&_OBJC_INSTANCE_METHODS_MyList, 0
        ,0,0,0
};

static struct _objc_method_list 
_OBJC_CATEGORY_INSTANCE_METHODS_MyList_BasicTest __attribute__ ((section 
("__OBJC, __inst_meth")))= {
        0, 1
        ,{{(SEL)"compilerTestAgainst", "[EMAIL PROTECTED]:4", 
_I_MyList_BasicTest_compilerTestAgainst}
         }
};

struct _objc_category {
        char *category_name;
        char *class_name;
        struct _objc_method_list *instance_methods;
        struct _objc_method_list *class_methods;
        struct _objc_protocol_list *protocols;
        unsigned int size;
        struct _objc_property_list *instance_properties;
};

static struct _objc_category _OBJC_CATEGORY_MyList_BasicTest __attribute__ 
((section ("__OBJC, __category")))= {
        "BasicTest"
        , "MyList"
        , (struct _objc_method_list 
*)&_OBJC_CATEGORY_INSTANCE_METHODS_MyList_BasicTest
        , 0
        , 0
        , sizeof(struct _objc_category), 0
};

struct _objc_symtab {
        long sel_ref_cnt;
        SEL *refs;
        short cls_def_cnt;
        short cat_def_cnt;
        void *defs[2];
};

static struct _objc_symtab _OBJC_SYMBOLS __attribute__((section ("__OBJC, 
__symbols")))= {
        0, 0, 1, 1
        ,&_OBJC_CLASS_MyList
        ,&_OBJC_CATEGORY_MyList_BasicTest
};


struct _objc_module {
        long version;
        long size;
        const char *name;
        struct _objc_symtab *symtab;
};

static struct _objc_module _OBJC_MODULES __attribute__ ((section ("__OBJC, 
__module_info")))= {
        7, sizeof(struct _objc_module), "", &_OBJC_SYMBOLS
};

_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

Reply via email to