# HG changeset patch # User Nobuyasu Oshiro # Date 1337909663 -32400 # Node ID b3cfc7733d3fd11a1e0f4a06bf084535f738849f # Parent 46ee985e4f0e0bb5e4488bfdc57d07e13accc0ec fix bug. implementation fo rectype. c-family/c-pretty-print.c diff -r 46ee985e4f0e -r b3cfc7733d3f CbC-examples/rectypeTest/rectypeTest1.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CbC-examples/rectypeTest/rectypeTest1.c Fri May 25 10:34:23 2012 +0900 @@ -0,0 +1,22 @@ +#include +__code print(__rectype *p, int num) { + printf("num = %d\n",num); +} + +__code csA(__rectype *p, int num) { + goto p(csA,3,4); + goto p(2,3); + goto p(csA,3); + return; +} + +void funcA(__code (*p)()){ + goto p(print, 3); + return; +} + +int main() { + funcA(csA); + + return 0; +} diff -r 46ee985e4f0e -r b3cfc7733d3f gcc/c-family/c-pretty-print.c --- a/gcc/c-family/c-pretty-print.c Mon Apr 09 19:01:21 2012 +0900 +++ b/gcc/c-family/c-pretty-print.c Fri May 25 10:34:23 2012 +0900 @@ -29,7 +29,9 @@ #include "tree-pretty-print.h" #include "tree-iterator.h" #include "diagnostic.h" - +#ifndef noCbC +#include "cbc-tree.h" +#endif /* Translate if being used for diagnostics, but not for dump files or __PRETTY_FUNCTION. */ #define M_(msgid) (pp_translate_identifiers (pp) ? _(msgid) : (msgid)) @@ -544,6 +546,9 @@ if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE) pp_c_right_paren (pp); +#ifndef noCbC + if(IS_RECTYPE(t)) return; +#endif t = TREE_TYPE (t); } diff -r 46ee985e4f0e -r b3cfc7733d3f gcc/c-parser.c --- a/gcc/c-parser.c Mon Apr 09 19:01:21 2012 +0900 +++ b/gcc/c-parser.c Fri May 25 10:34:23 2012 +0900 @@ -1638,7 +1638,7 @@ chainon (postfix_attrs, all_prefix_attrs)); #ifndef noCbC - if(specs->typespec_word == cts_CbC_code ) { + if (specs->typespec_word == cts_CbC_code) { /* * func_tree is TYPE_DECL or FUNCTION_DECL. * tmp is POINTER_TYPE or FUNCTION_TYPE. @@ -1655,12 +1655,21 @@ tree t = TREE_TYPE(tmptype); while (TREE_CODE(t) == POINTER_TYPE) { tmptype = t; - t= TREE_TYPE(tmptype); + t = TREE_TYPE(tmptype); } TREE_TYPE(tmptype) = func_tree; parm = TREE_CHAIN(parm); } } + if (specs->typespec_word == cts_CbC_rec) { + tree t = TREE_TYPE(d); + tree tmptype = t; + while (TREE_CODE(t) == POINTER_TYPE) { + tmptype = t; + t = TREE_TYPE(tmptype); + } + TREE_TYPE(tmptype) = TREE_TYPE(current_function_decl); + } #endif if (d) @@ -2146,9 +2155,9 @@ /*attrs = build_tree_list (get_identifier("noreturn"), attrs);*/ declspecs_add_attrs(specs, attrs); } - - c_parser_consume_token (parser); - break; + + c_parser_consume_token (parser); + break; case RID_CbC_SELFTYPE: if (!typespec_ok) goto out;