Don't make the standard mandated types of string literals depends on warning options. Instead make them always const, but limit the emission of the warning by that option.
Unified · Split
| @@ -2829,7 +2829,8 @@ static void gen_assign_cast(CType *dt) · 2828 unmodified lines | ||
| 2829 | 2829 | } |
| 2830 | 2830 | } |
| 2831 | 2831 | /* check const and volatile */ |
| 2832 | − if ((!(type1->t & VT_CONSTANT) && (type2->t & VT_CONSTANT)) || | |
| 2832 | + if ((!(type1->t & VT_CONSTANT) && (type2->t & VT_CONSTANT) && | |
| 2833 | + ((type2->t & VT_BTYPE) != VT_BYTE || tcc_state->warn_write_strings)) || | |
| 2833 | 2834 | (!(type1->t & VT_VOLATILE) && (type2->t & VT_VOLATILE))) |
| 2834 | 2835 | tcc_warning("assignment discards qualifiers from pointer target type"); |
| 2835 | 2836 | break; |
| @@ -4381,8 +4382,7 @@ ST_FUNC void unary(void) · 1545 unmodified lines | ||
| 4381 | 4382 | /* string parsing */ |
| 4382 | 4383 | t = VT_BYTE; |
| 4383 | 4384 | str_init: |
| 4384 | − if (tcc_state->warn_write_strings) | |
| 4385 | − t |= VT_CONSTANT; | |
| 4385 | + t |= VT_CONSTANT; | |
| 4386 | 4386 | type.t = t; |
| 4387 | 4387 | mk_pointer(&type); |
| 4388 | 4388 | type.t |= VT_ARRAY; |