comparison gcc/c/c-parser.c @ 113:bdf41c9fa0b7

remove RECTYPE
author mir3636
date Fri, 17 Nov 2017 06:33:55 +0900
parents ab0bcb71f44d
children e234ee7b7292
comparison
equal deleted inserted replaced
112:ab0bcb71f44d 113:bdf41c9fa0b7
510 case RID_ACCUM: 510 case RID_ACCUM:
511 case RID_SAT: 511 case RID_SAT:
512 case RID_AUTO_TYPE: 512 case RID_AUTO_TYPE:
513 #ifndef noCbC 513 #ifndef noCbC
514 case RID_CbC_CODE: 514 case RID_CbC_CODE:
515 case RID_CbC_REC:
516 #endif 515 #endif
517 return true; 516 return true;
518 default: 517 default:
519 if (keyword >= RID_FIRST_INT_N 518 if (keyword >= RID_FIRST_INT_N
520 && keyword < RID_FIRST_INT_N + NUM_INT_N_ENTS 519 && keyword < RID_FIRST_INT_N + NUM_INT_N_ENTS
2104 { 2103 {
2105 /* The declaration of the variable is in effect while 2104 /* The declaration of the variable is in effect while
2106 its initializer is parsed. */ 2105 its initializer is parsed. */
2107 d = start_decl (declarator, specs, true, 2106 d = start_decl (declarator, specs, true,
2108 chainon (postfix_attrs, all_prefix_attrs)); 2107 chainon (postfix_attrs, all_prefix_attrs));
2109 #ifndef noCbC
2110 if (specs->typespec_word == cts_CbC_code) {
2111 /*
2112 * func_tree is TYPE_DECL or FUNCTION_DECL.
2113 * tmp is POINTER_TYPE or FUNCTION_TYPE.
2114 */
2115 tree func_tree = TREE_TYPE(d);
2116 // parm is PARM_DECL
2117 tree parm = declarator->u.arg_info->parms;
2118 while (parm) {
2119 tree tmptype = parm;
2120 if (!IS_RECTYPE(TREE_TYPE(tmptype))) {
2121 parm = TREE_CHAIN(parm);
2122 continue;
2123 }
2124 tree t = TREE_TYPE(tmptype);
2125 while (TREE_CODE(t) == POINTER_TYPE) {
2126 tmptype = t;
2127 t = TREE_TYPE(tmptype);
2128 }
2129 TREE_TYPE(tmptype) = func_tree;
2130 parm = TREE_CHAIN(parm);
2131 }
2132 }
2133 if (specs->typespec_word == cts_CbC_rec) {
2134 tree t = TREE_TYPE(d);
2135 tree tmptype = t;
2136 while (TREE_CODE(t) == POINTER_TYPE) {
2137 tmptype = t;
2138 t = TREE_TYPE(tmptype);
2139 }
2140 TREE_TYPE(tmptype) = TREE_TYPE(current_function_decl);
2141 }
2142
2143 #endif
2144 if (!d) 2108 if (!d)
2145 d = error_mark_node; 2109 d = error_mark_node;
2146 if (omp_declare_simd_clauses.exists () 2110 if (omp_declare_simd_clauses.exists ()
2147 || !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) 2111 || !vec_safe_is_empty (parser->cilk_simd_fn_tokens))
2148 c_finish_omp_declare_simd (parser, d, NULL_TREE, 2112 c_finish_omp_declare_simd (parser, d, NULL_TREE,
2793 declspecs_add_type (loc, specs, t); 2757 declspecs_add_type (loc, specs, t);
2794 c_parser_consume_token (parser); 2758 c_parser_consume_token (parser);
2795 break; 2759 break;
2796 #ifndef noCbC 2760 #ifndef noCbC
2797 case RID_CbC_CODE: 2761 case RID_CbC_CODE:
2798 case RID_CbC_REC:
2799 if (!typespec_ok) 2762 if (!typespec_ok)
2800 goto out; 2763 goto out;
2801 attrs_ok = true; 2764 attrs_ok = true;
2802 seen_type = true; 2765 seen_type = true;
2803 if (c_dialect_objc ()) 2766 if (c_dialect_objc ())
2804 parser->objc_need_raw_identifier = true; 2767 parser->objc_need_raw_identifier = true;
2805 t.kind = ctsk_resword; 2768 t.kind = ctsk_resword;
2806 t.spec = c_parser_peek_token (parser)->value; 2769 t.spec = c_parser_peek_token (parser)->value;
2807 declspecs_add_type (loc, specs, t); 2770 declspecs_add_type (loc, specs, t);
2808 2771
2809 IS_RECTYPE(t.spec) = 1;
2810 /*
2811 attrs = get_identifier("fastcall");
2812 attrs = build_tree_list(attrs, NULL_TREE);
2813 declspecs_add_attrs(specs, attrs);
2814 */
2815 if(!TARGET_64BIT) { 2772 if(!TARGET_64BIT) {
2816 attrs = build_tree_list (get_identifier("fastcall"), NULL_TREE); 2773 attrs = build_tree_list (get_identifier("fastcall"), NULL_TREE);
2817 /*attrs = build_tree_list (get_identifier("noreturn"), attrs);*/
2818 declspecs_add_attrs(specs, attrs); 2774 declspecs_add_attrs(specs, attrs);
2819 } 2775 }
2820 2776
2821 c_parser_consume_token (parser);
2822 break;
2823 case RID_CbC_SELFTYPE:
2824 if (!typespec_ok)
2825 goto out;
2826 attrs_ok = true;
2827 seen_type = true;
2828 enum tree_code code = RECORD_TYPE;
2829 location_t loc = c_parser_peek_token (parser)->location;
2830
2831 c_parser_set_source_position_from_token (c_parser_peek_token (parser));
2832 tree value;
2833 struct c_typespec ret;
2834 value = make_node (IDENTIFIER_NODE);
2835 ret = parser_xref_tag (loc, code, value);
2836
2837 IS_SELFTYPE (ret.spec) = 1;
2838 declspecs_add_type (loc, specs, ret);
2839 c_parser_consume_token (parser); 2777 c_parser_consume_token (parser);
2840 break; 2778 break;
2841 #endif 2779 #endif
2842 case RID_ENUM: 2780 case RID_ENUM:
2843 if (!typespec_ok) 2781 if (!typespec_ok)
3275 continue; 3213 continue;
3276 } 3214 }
3277 /* Parse some comma-separated declarations, but not the 3215 /* Parse some comma-separated declarations, but not the
3278 trailing semicolon if any. */ 3216 trailing semicolon if any. */
3279 decls = c_parser_struct_declaration (parser); 3217 decls = c_parser_struct_declaration (parser);
3280 #ifndef noCbC
3281 /* If tree type of tmptype is selftype, tmptype modify to RECORD_TYPE of struct [CPP_NAME]. */
3282 if(TREE_CODE(decls) == FIELD_DECL && TREE_CODE(type) == RECORD_TYPE) {
3283 tree tmptype = decls;
3284 while(TREE_CODE (TREE_TYPE (tmptype)) == POINTER_TYPE)
3285 tmptype = TREE_TYPE(tmptype);
3286 if(IS_SELFTYPE ( TREE_TYPE (tmptype))) TREE_TYPE(tmptype) = type;
3287 // if(IS_RECTYPE ( TREE_TYPE (tmptype)))
3288 if(IS_RECTYPE (tmptype))
3289 TREE_TYPE(tmptype) = type;
3290 }
3291
3292 #endif
3293 contents = chainon (decls, contents); 3218 contents = chainon (decls, contents);
3294 /* If no semicolon follows, either we have a parse error or 3219 /* If no semicolon follows, either we have a parse error or
3295 are at the end of the struct or union and should 3220 are at the end of the struct or union and should
3296 pedwarn. */ 3221 pedwarn. */
3297 if (c_parser_next_token_is (parser, CPP_SEMICOLON)) 3222 if (c_parser_next_token_is (parser, CPP_SEMICOLON))