History

Revert "String literals are always const"

This reverts commit d4fe9aba3fc6f4b9cc97b100e86ffe7af5c29619. 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.

Michael Matz committed 9 years ago

Commit 9ed8b541 parent 580ad5f1 file · +3 −3Browse files

Unified · Split

tccgen.c+3−3
@@ -2829,8 +2829,7 @@ static void gen_assign_cast(CType *dt) · 2828 unmodified lines
2829 }2829 }
2830 }2830 }
2831 /* check const and volatile */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)) ||
2834 (!(type1->t & VT_VOLATILE) && (type2->t & VT_VOLATILE)))2833 (!(type1->t & VT_VOLATILE) && (type2->t & VT_VOLATILE)))
2835 tcc_warning("assignment discards qualifiers from pointer target type");2834 tcc_warning("assignment discards qualifiers from pointer target type");
2836 break;2835 break;
@@ -4382,7 +4381,8 @@ ST_FUNC void unary(void) · 1545 unmodified lines
4382 /* string parsing */4381 /* string parsing */
4383 t = VT_BYTE;4382 t = VT_BYTE;
4384 str_init:4383 str_init:
4385 t |= VT_CONSTANT;4384 if (tcc_state->warn_write_strings)
4385 t |= VT_CONSTANT;
4386 type.t = t;4386 type.t = t;
4387 mk_pointer(&type);4387 mk_pointer(&type);
4388 type.t |= VT_ARRAY;4388 type.t |= VT_ARRAY;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t