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
28292829 }
28302830 }
28312831 /* check const and volatile */
2832− if ((!(type1->t & VT_CONSTANT) && (type2->t & VT_CONSTANT) &&
2833− ((type2->t & VT_BTYPE) != VT_BYTE || tcc_state->warn_write_strings)) ||
2832+ if ((!(type1->t & VT_CONSTANT) && (type2->t & VT_CONSTANT)) ||
28342833 (!(type1->t & VT_VOLATILE) && (type2->t & VT_VOLATILE)))
28352834 tcc_warning("assignment discards qualifiers from pointer target type");
28362835 break;
@@ -4382,7 +4381,8 @@ ST_FUNC void unary(void) · 1545 unmodified lines
43824381 /* string parsing */
43834382 t = VT_BYTE;
43844383 str_init:
4385− t |= VT_CONSTANT;
4384+ if (tcc_state->warn_write_strings)
4385+ t |= VT_CONSTANT;
43864386 type.t = t;
43874387 mk_pointer(&type);
43884388 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