aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2017-07-03 18:02:57 +0200
committerMichael Matz <matz@suse.de>2017-07-03 18:02:57 +0200
commitd4fe9aba3fc6f4b9cc97b100e86ffe7af5c29619 (patch)
treee2596c401bf3e8118b142a1c18fcfab282092350 /tccgen.c
parentb68df809eb8e927b7b4be790f4a3fe0dd2772dc8 (diff)
downloadtinycc-d4fe9aba3fc6f4b9cc97b100e86ffe7af5c29619.tar.gz
tinycc-d4fe9aba3fc6f4b9cc97b100e86ffe7af5c29619.tar.bz2
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.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tccgen.c b/tccgen.c
index 1a8ba3d..4e0a753 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -2829,7 +2829,8 @@ static void gen_assign_cast(CType *dt)
}
}
/* 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)))
tcc_warning("assignment discards qualifiers from pointer target type");
break;
@@ -4381,8 +4382,7 @@ ST_FUNC void unary(void)
/* string parsing */
t = VT_BYTE;
str_init:
- if (tcc_state->warn_write_strings)
- t |= VT_CONSTANT;
+ t |= VT_CONSTANT;
type.t = t;
mk_pointer(&type);
type.t |= VT_ARRAY;