Mercurial > hg > CbC > CbC_gcc
changeset 104:46ee985e4f0e
fix implementation of rectype in c-decl.c
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 09 Apr 2012 19:01:21 +0900 |
parents | edcadcec937d |
children | b3cfc7733d3f |
files | gcc/c-decl.c gcc/c-parser.c |
diffstat | 2 files changed, 29 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/gcc/c-decl.c Fri Mar 23 17:11:33 2012 +0900 +++ b/gcc/c-decl.c Mon Apr 09 19:01:21 2012 +0900 @@ -5159,7 +5159,7 @@ #ifndef noCbC if ( declspecs->typespec_word == cts_CbC_rec ) { - type = build_code_segment_type (type, NULL_TREE); + // type = build_code_segment_type (type, NULL_TREE); IS_RECTYPE(type) = 1; } #endif @@ -7700,7 +7700,29 @@ { cbc_set_codesegment(decl1); //CbC_IS_CODE_SEGMENT(TREE_TYPE(decl1)) = 1; - } + + + /* implementation of rectype */ + tree func_tree = TREE_TYPE(decl1); + // parm is PARM_DECL + tree parm = declarator->u.arg_info->parms; + while (parm) { + tree tmptype = parm; + if (!IS_RECTYPE(TREE_TYPE(tmptype))) { + parm = TREE_CHAIN(parm); + continue; + } + tree t = TREE_TYPE(tmptype); + while (TREE_CODE(t) == POINTER_TYPE) { + tmptype = t; + t= TREE_TYPE(tmptype); + } + TREE_TYPE(tmptype) = func_tree; + parm = TREE_CHAIN(parm); + } + + } + #endif /* If the declarator is not suitable for a function definition,
--- a/gcc/c-parser.c Fri Mar 23 17:11:33 2012 +0900 +++ b/gcc/c-parser.c Mon Apr 09 19:01:21 2012 +0900 @@ -1638,46 +1638,22 @@ chainon (postfix_attrs, all_prefix_attrs)); #ifndef noCbC - /* - if(specs->storage_class == csc_typedef) { - tree tmp = TREE_TYPE(d); - while(TREE_CODE(tmp) == POINTER_TYPE) tmp = TREE_TYPE(tmp); - if(TREE_CODE(tmp) == FUNCTION_TYPE) { - tree t = declarator->u.arg_info->parms; - while(t) { - if( !IS_RECTYPE(t)) { - t = TREE_CHAIN(t); - continue; - } - tree tmptype = t; - while(TREE_CODE(TREE_TYPE(tmptype)) == POINTER_TYPE) { - t = TREE_TYPE(tmptype); - tmptype = TREE_TYPE(t); - } - TREE_TYPE(t) = tmp; - break; - t = TREE_CHAIN(t); - } - } - } - */ if(specs->typespec_word == cts_CbC_code ) { - /* - * func_tree is TYPE_DECL or FUNCTION_DECL - * tmp is POINTER_TYPE or FUNCTION_TYPE + * func_tree is TYPE_DECL or FUNCTION_DECL. + * tmp is POINTER_TYPE or FUNCTION_TYPE. */ tree func_tree = TREE_TYPE(d); // parm is PARM_DECL tree parm = declarator->u.arg_info->parms; - while(parm) { + while (parm) { tree tmptype = parm; - if( !IS_RECTYPE(TREE_TYPE(tmptype))) { + if (!IS_RECTYPE(TREE_TYPE(tmptype))) { parm = TREE_CHAIN(parm); continue; } tree t = TREE_TYPE(tmptype); - while(TREE_CODE(t) == POINTER_TYPE) { + while (TREE_CODE(t) == POINTER_TYPE) { tmptype = t; t= TREE_TYPE(tmptype); }