Revert "String literals are always const"
This reverts commit d4fe9aba3f
.
I was confused by the fact that string literals aren't writable.
Nevertheless the type isn't const. As extension in GCC it's const
with -Wwrite-string, which is exactly what we had before.
GCC also wonders in a comment if it's really a good idea to change
expression types based on warning flags (IMHO it's not), but let's
be compatible. So restore the state from before.
This commit is contained in:
parent
580ad5f24c
commit
9ed8b54f6c
1 changed files with 3 additions and 3 deletions
6
tccgen.c
6
tccgen.c
|
@ -2829,8 +2829,7 @@ static void gen_assign_cast(CType *dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* check const and volatile */
|
/* check const and volatile */
|
||||||
if ((!(type1->t & VT_CONSTANT) && (type2->t & VT_CONSTANT) &&
|
if ((!(type1->t & VT_CONSTANT) && (type2->t & VT_CONSTANT)) ||
|
||||||
((type2->t & VT_BTYPE) != VT_BYTE || tcc_state->warn_write_strings)) ||
|
|
||||||
(!(type1->t & VT_VOLATILE) && (type2->t & VT_VOLATILE)))
|
(!(type1->t & VT_VOLATILE) && (type2->t & VT_VOLATILE)))
|
||||||
tcc_warning("assignment discards qualifiers from pointer target type");
|
tcc_warning("assignment discards qualifiers from pointer target type");
|
||||||
break;
|
break;
|
||||||
|
@ -4382,7 +4381,8 @@ ST_FUNC void unary(void)
|
||||||
/* string parsing */
|
/* string parsing */
|
||||||
t = VT_BYTE;
|
t = VT_BYTE;
|
||||||
str_init:
|
str_init:
|
||||||
t |= VT_CONSTANT;
|
if (tcc_state->warn_write_strings)
|
||||||
|
t |= VT_CONSTANT;
|
||||||
type.t = t;
|
type.t = t;
|
||||||
mk_pointer(&type);
|
mk_pointer(&type);
|
||||||
type.t |= VT_ARRAY;
|
type.t |= VT_ARRAY;
|
||||||
|
|
Loading…
Reference in a new issue