# HG changeset patch # User Nobuyasu Oshiro # Date 1327396275 -32400 # Node ID 98e1e78a6b5a97dd5f293be367259056e768b2eb # Parent 5211b774b8b522a01a5f11e802482a389c7dc860 modify implementation of selftype diff -r 5211b774b8b5 -r 98e1e78a6b5a gcc/c-parser.c --- a/gcc/c-parser.c Tue Jan 24 03:25:13 2012 +0900 +++ b/gcc/c-parser.c Tue Jan 24 18:11:15 2012 +0900 @@ -2134,12 +2134,11 @@ c_parser_set_source_position_from_token (c_parser_peek_token (parser)); tree value; struct c_typespec ret; - // ret = parser_xref_tag (ident_loc, code, ident); value = make_node (IDENTIFIER_NODE); ret = parser_xref_tag (loc, code, value); - // IS_SELFTYPE (ret.spec) = 1; - ret.spec->base.lang_flag_3 = 1; - // ret = lookup_tag (code, value, 0, &loc); + + // ret.spec->base.lang_flag_3 = 1; + IS_SELFTYPE (ret.spec) = 1; declspecs_add_type (loc, specs, ret); c_parser_consume_token (parser); break; @@ -2483,19 +2482,12 @@ #ifndef noCbC /* If tree type of d_type is selftype, d_type modify to RECORD_TYPE: (d_type = type). */ if(TREE_CODE(decls) == FIELD_DECL && TREE_CODE(type) == RECORD_TYPE) { - // tree d_type = TREE_TYPE(decls); - tree tmptype = decls; - while(TREE_TYPE (tmptype)) { - // if(IS_SELFTYPE (TREE_TYPE (d_type))) { - if(tmptype->common.type->base.lang_flag_3) { - TREE_TYPE (tmptype) = type; - break; - } else if(TREE_CODE (TREE_TYPE((tmptype))) != POINTER_TYPE) { - break; - } - tmptype = TREE_TYPE(decls); - } + tree tmptype = decls; + while(TREE_CODE (TREE_TYPE (tmptype)) == POINTER_TYPE) + tmptype = TREE_TYPE(tmptype); + if(IS_SELFTYPE ( TREE_TYPE (tmptype))) TREE_TYPE(tmptype) = type; } + #endif contents = chainon (decls, contents); diff -r 5211b774b8b5 -r 98e1e78a6b5a gcc/cbc-tree.h --- a/gcc/cbc-tree.h Tue Jan 24 03:25:13 2012 +0900 +++ b/gcc/cbc-tree.h Tue Jan 24 18:11:15 2012 +0900 @@ -14,5 +14,9 @@ extern location_t cbc_return; /* flag of selftype is lang_flag_3. */ -#define IS_SELFTYPE(NODE) TYPE_LANG_FLAG_3 (RECORD_OR_UNION_CHECK (NODE)) +#define IS_SELFTYPE(NODE) ((NODE)->type.lang_flag_3) +//#define CbC_TYPE_LANG_FLAG_3(NODE) (RECORD_OR_POINTER_CHECK (NODE)->type.lang_flag_3) +//#define RECORD_OR_POINTER_CHECK(NODE) TYPE_CHECK2 (T, POINTER_TYPE, RECORD_TYPE) + +//#define TYPE_LANG_FLAG_3(NODE) (TYPE_CHECK (NODE)->type.lang_flag_3)