History

String literals are always const

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.

Michael Matz committed 9 years ago

Commit d4fe9ab1 parent b68df801 file · +3 −3Browse files

Unified · Split

tccgen.c+3−3
@@ -2829,7 +2829,8 @@ 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)) ||
2832+ if ((!(type1->t & VT_CONSTANT) && (type2->t & VT_CONSTANT) &&
2833+ ((type2->t & VT_BTYPE) != VT_BYTE || tcc_state->warn_write_strings)) ||
28332834 (!(type1->t & VT_VOLATILE) && (type2->t & VT_VOLATILE)))
28342835 tcc_warning("assignment discards qualifiers from pointer target type");
28352836 break;
@@ -4381,8 +4382,7 @@ ST_FUNC void unary(void) · 1545 unmodified lines
43814382 /* string parsing */
43824383 t = VT_BYTE;
43834384 str_init:
4384− if (tcc_state->warn_write_strings)
4385− t |= VT_CONSTANT;
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