@@ -137,9 +137,6 @@ static void gen_cast(CType *type);
137137static void gen_cast_s (int t );
138138static inline CType * pointed_type (CType * type );
139139static void check_restrict_type (CType * type );
140- static void unqualify_optional (CType * type );
141- static void unqualify_optional_target (CType * type );
142- static int is_optional_type (CType * type );
143140static int type_qualifiers (CType * type );
144141static void parse_btype_qualify (CType * type , int qualifiers );
145142static int is_compatible_types (CType * type1 , CType * type2 );
@@ -899,7 +896,6 @@ static void vsetc(CType *type, int r, CValue *vc)
899896 vtop -> r2 = VT_CONST ;
900897 vtop -> c = * vc ;
901898 vtop -> sym = NULL ;
902- vtop -> nulls = 0 ;
903899}
904900
905901ST_FUNC void vswap (void )
@@ -2684,8 +2680,6 @@ static void type_to_str(char *buf, int buf_size,
26842680 if (bt != VT_PTR ) {
26852681 if (t & VT_RESTRICT )
26862682 pstrcat (buf , buf_size , "restrict " );
2687- if (t & VT_OPTIONAL )
2688- pstrcat (buf , buf_size , "_Optional " );
26892683 if (t & VT_VOLATILE )
26902684 pstrcat (buf , buf_size , "volatile " );
26912685 if (t & VT_CONSTANT )
@@ -2790,8 +2784,6 @@ static void type_to_str(char *buf, int buf_size,
27902784 pstrcat (buf1 , sizeof (buf1 ), "const " );
27912785 if (t & VT_VOLATILE )
27922786 pstrcat (buf1 , sizeof (buf1 ), "volatile " );
2793- if (t & VT_OPTIONAL )
2794- pstrcat (buf1 , sizeof (buf1 ), "_Optional " );
27952787 if (varstr )
27962788 pstrcat (buf1 , sizeof (buf1 ), varstr );
27972789 type_to_str (buf , buf_size , & s -> type , buf1 );
@@ -2839,11 +2831,6 @@ static inline int is_null_pointer(SValue *p)
28392831 );
28402832}
28412833
2842- static int has_implicit_null (SValue * sv )
2843- {
2844- return sv -> nulls > 0 || (sv -> nulls == 0 && is_null_pointer (sv ));
2845- }
2846-
28472834/* compare function types. OLD functions match any new functions */
28482835static int is_compatible_func (CType * type1 , CType * type2 )
28492836{
@@ -3079,8 +3066,6 @@ ST_FUNC void gen_op(int op)
30793066 CType type1 , combtype ;
30803067 int op_class = op ;
30813068
3082- vtop [-1 ].nulls = vtop -> nulls = 0 ;
3083-
30843069 if (op == TOK_SHR || op == TOK_SAR || op == TOK_SHL )
30853070 op_class = SHIFT_OP ;
30863071 else if (TOK_ISCOND (op )) /* == != > ... */
@@ -3095,13 +3080,11 @@ ST_FUNC void gen_op(int op)
30953080 if (bt1 == VT_FUNC || bt2 == VT_FUNC ) {
30963081 if (bt2 == VT_FUNC ) {
30973082 mk_pointer (& vtop -> type );
3098- unqualify_optional_target (& vtop -> type );
30993083 gaddrof ();
31003084 }
31013085 if (bt1 == VT_FUNC ) {
31023086 vswap ();
31033087 mk_pointer (& vtop -> type );
3104- unqualify_optional_target (& vtop -> type );
31053088 gaddrof ();
31063089 vswap ();
31073090 }
@@ -3161,7 +3144,6 @@ ST_FUNC void gen_op(int op)
31613144 gen_opic (op );
31623145 }
31633146 type1 .t &= ~(VT_ARRAY |VT_VLA );
3164- unqualify_optional_target (& type1 );
31653147 /* put again type if gen_opic() swaped operands */
31663148 vtop -> type = type1 ;
31673149 }
@@ -3628,26 +3610,6 @@ static CType *qualifier_type(CType *type)
36283610 return type ;
36293611}
36303612
3631- static void unqualify_optional (CType * type )
3632- {
3633- if (is_optional_type (type ))
3634- qualifier_type (type )-> t &= ~VT_OPTIONAL ;
3635- }
3636-
3637- static void unqualify_optional_target (CType * type )
3638- {
3639- if (!is_optional_type (pointed_type (type )))
3640- return ;
3641- /* The target symbol may be shared with another type. */
3642- type -> ref = sym_push (SYM_FIELD , & type -> ref -> type , 0 , type -> ref -> c );
3643- unqualify_optional (pointed_type (type ));
3644- }
3645-
3646- static int is_optional_type (CType * type )
3647- {
3648- return !!(type_qualifiers (type ) & VT_OPTIONAL );
3649- }
3650-
36513613/* Array qualifiers are represented on the element type. */
36523614static int type_qualifiers (CType * type )
36533615{
@@ -3688,17 +3650,12 @@ static void cast_error(CType *st, CType *dt)
36883650/* verify type compatibility to store vtop in 'dt' type */
36893651static void verify_assign_cast (CType * dt )
36903652{
3691- CType * st , * type1 , * type2 , ct ;
3653+ CType * st , * type1 , * type2 ;
36923654 int dbt , sbt , qualwarn , lvl ;
36933655
36943656 st = & vtop -> type ; /* source type */
36953657 dbt = dt -> t & VT_BTYPE ;
36963658 sbt = st -> t & VT_BTYPE ;
3697- if (dbt == VT_PTR && !(dt -> t & VT_ARRAY )
3698- && !is_optional_type (pointed_type (dt )) && has_implicit_null (vtop ))
3699- tcc_warning_c (warn_null_to_nonoptional )(
3700- "null pointer constant converted to pointer with non-optional target type" );
3701- vtop -> nulls = 0 ;
37023659 if (dt -> t & VT_CONSTANT )
37033660 tcc_warning ("assignment of read-only location" );
37043661 switch (dbt ) {
@@ -3720,14 +3677,9 @@ static void verify_assign_cast(CType *dt)
37203677 if (sbt == VT_PTR )
37213678 type2 = pointed_type (st );
37223679 else if (sbt == VT_FUNC )
3723- type2 = st ;
3680+ type2 = st ; /* a function is implicitly a function pointer */
37243681 else
37253682 goto error ;
3726- if ((st -> t & VT_ARRAY_MASK ) || sbt == VT_FUNC ) {
3727- ct = * type2 ;
3728- unqualify_optional (& ct );
3729- type2 = & ct ;
3730- }
37313683 if (is_compatible_types (type1 , type2 ))
37323684 break ;
37333685 for (qualwarn = lvl = 0 ;; ++ lvl ) {
@@ -4718,9 +4670,6 @@ static void struct_decl(CType *type, int u)
47184670 }
47194671 }
47204672 }
4721- if (is_optional_type (& type1 ))
4722- tcc_error ("field '%s' has optional-qualified type" ,
4723- get_tok_str (v , NULL ));
47244673 if (type_size (& type1 , & align ) < 0 ) {
47254674 if ((u == VT_STRUCT ) && (type1 .t & VT_ARRAY ) && c )
47264675 flexible = 1 ;
@@ -4956,12 +4905,6 @@ static int parse_btype(CType *type, AttributeDef *ad, int ignore_label)
49564905 goto basic_type2 ;
49574906 }
49584907 break ;
4959- case TOK_OPTIONAL :
4960- type -> t = t ;
4961- parse_btype_qualify (type , VT_OPTIONAL );
4962- t = type -> t ;
4963- next ();
4964- break ;
49654908 case TOK_CONST1 :
49664909 case TOK_CONST2 :
49674910 case TOK_CONST3 :
@@ -5131,12 +5074,8 @@ static inline void convert_parameter_type(CType *pt)
51315074/* apply the conversions required for an expression value */
51325075static inline void convert_expression_type (CType * pt )
51335076{
5134- int converts = (pt -> t & VT_BTYPE ) == VT_FUNC || (pt -> t & VT_ARRAY_MASK );
5135-
51365077 pt -> t &= ~VT_QUAL ;
51375078 convert_parameter_type (pt );
5138- if (converts )
5139- unqualify_optional_target (pt );
51405079}
51415080
51425081ST_FUNC CString * parse_asm_str (void )
@@ -5217,9 +5156,6 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
52175156 if (n < TOK_UIDENT )
52185157 expect ("identifier" );
52195158 convert_parameter_type (& pt );
5220- if (is_optional_type (& pt ))
5221- tcc_error ("parameter '%s' has optional-qualified type" ,
5222- get_tok_str (n & ~SYM_FIELD , NULL ));
52235159 arg_size += (type_size (& pt , & align ) + PTR_SIZE - 1 ) / PTR_SIZE ;
52245160 /* these symbols may be evaluated for VLArrays (see below, under
52255161 nocode_wanted) Example: int func(int a, int b[++a]); */
@@ -5276,10 +5212,6 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
52765212 in parameter decls. The '*' as well, and then even only
52775213 in prototypes (not function defs). */
52785214 switch (tok ) {
5279- case TOK_OPTIONAL :
5280- array_qualifiers |= VT_OPTIONAL ;
5281- next ();
5282- continue ;
52835215 case TOK_CONST1 : case TOK_CONST2 : case TOK_CONST3 :
52845216 array_qualifiers |= VT_CONSTANT ;
52855217 next ();
@@ -5414,9 +5346,6 @@ static CType *type_decl(CType *type, AttributeDef *ad, int *v, int td)
54145346 case TOK__Atomic :
54155347 qualifiers |= VT_ATOMIC ;
54165348 goto redo ;
5417- case TOK_OPTIONAL :
5418- qualifiers |= VT_OPTIONAL ;
5419- goto redo ;
54205349 case TOK_CONST1 :
54215350 case TOK_CONST2 :
54225351 case TOK_CONST3 :
@@ -5855,9 +5784,7 @@ ST_FUNC void unary(void)
58555784 skip (')' );
58565785 /* check ISOC99 compound literal */
58575786 if (tok == '{' ) {
5858- if (is_optional_type (& type ))
5859- tcc_error ("compound literal has optional-qualified type" );
5860- /* data is allocated locally by default */
5787+ /* data is allocated locally by default */
58615788 if (global_expr )
58625789 r = VT_CONST ;
58635790 else
@@ -5872,10 +5799,7 @@ ST_FUNC void unary(void)
58725799 return ;
58735800 } else {
58745801 unary ();
5875- /* Remember a pointer operand even if the cast folds to 0. */
5876- r = vtop -> nulls < 0 || (vtop -> type .t & VT_BTYPE ) == VT_PTR ;
58775802 gen_cast (& type );
5878- vtop -> nulls = r ? -1 : 0 ;
58795803 }
58805804 } else if (tok == '{' ) {
58815805 int saved_nocode_wanted = nocode_wanted ;
@@ -5909,7 +5833,6 @@ ST_FUNC void unary(void)
59095833 next ();
59105834 unary ();
59115835 indir ();
5912- vtop -> nulls = 0 ;
59135836 break ;
59145837 case '&' :
59155838 next ();
@@ -5924,7 +5847,6 @@ ST_FUNC void unary(void)
59245847 test_lvalue ();
59255848 if (vtop -> sym )
59265849 vtop -> sym -> a .addrtaken = 1 ;
5927- unqualify_optional (& vtop -> type );
59285850 mk_pointer (& vtop -> type );
59295851 gaddrof ();
59305852 break ;
@@ -6773,7 +6695,6 @@ static int is_cond_bool(SValue *sv)
67736695static void expr_cond (void )
67746696{
67756697 int tt , u , r1 , r2 , rc , t1 , t2 , islv , c , g ;
6776- int nulls ;
67776698 SValue sv ;
67786699 CType type ;
67796700
@@ -6826,9 +6747,6 @@ static void expr_cond(void)
68266747 if ((vtop -> type .t & VT_BTYPE ) == VT_FUNC )
68276748 mk_pointer (& vtop -> type );
68286749
6829- /* Defer null-arm warnings until the destination type is known. */
6830- nulls = has_implicit_null (& sv ) || has_implicit_null (vtop );
6831-
68326750 /* cast operands to correct type according to ISOC rules */
68336751 if (!combine_types (& type , & sv , vtop , '?' ))
68346752 type_incompatibility_error (& sv .type , & vtop -> type ,
@@ -6901,7 +6819,6 @@ static void expr_cond(void)
69016819
69026820 if (islv )
69036821 indir ();
6904- vtop -> nulls = (type .t & VT_BTYPE ) == VT_PTR ? nulls : 0 ;
69056822 }
69066823}
69076824
@@ -8443,11 +8360,9 @@ static void decl_initializer(init_params *p, CType *type, unsigned long c, int f
84438360 && (vtop -> r & (VT_VALMASK | VT_LVAL | VT_SYM )) == VT_CONST
84448361 && vtop -> c .i == 0
84458362 && btype_size (type -> t & VT_BTYPE ) /* not for fp constants */
8446- ) {
8447- if ((type -> t & VT_BTYPE ) == VT_PTR )
8448- verify_assign_cast (type );
8363+ )
84498364 vpop ();
8450- } else
8365+ else
84518366 init_putv (p , type , c );
84528367 }
84538368}
@@ -9023,9 +8938,6 @@ static int decl(int l)
90238938 type = btype ;
90248939 ad = adbase ;
90258940 type_decl (& type , & ad , & v , l == VT_CMP ? TYPE_DIRECT | TYPE_PARAM : TYPE_DIRECT );
9026- if (!(type .t & VT_TYPEDEF ) && is_optional_type (& type ))
9027- tcc_error ("'%s' has optional-qualified type" ,
9028- get_tok_str (v , NULL ));
90298941 /*ptype("decl", &type, v);*/
90308942 if ((type .t & VT_BTYPE ) == VT_FUNC ) {
90318943 if ((type .t & VT_STATIC ) && (l != VT_CONST ))
0 commit comments