aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Elab.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bschommer@users.noreply.github.com>2018-05-27 09:05:47 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2018-05-27 09:05:47 +0200
commita5f96b68f8af673f7666658f796f2322b6b9da93 (patch)
tree10690b73f3029a0940c8c20352ec7886702801b2 /cparser/Elab.ml
parent9dc1505c01a5748cdd5cac9d978645e2fbc0773c (diff)
downloadcompcert-kvx-a5f96b68f8af673f7666658f796f2322b6b9da93.tar.gz
compcert-kvx-a5f96b68f8af673f7666658f796f2322b6b9da93.zip
String literals are l-values and have array types (#116)
* Allow strings literals as lvalues. Strings and WStrings literals are lvalues, thus it is allowed to take their addresses. Bug 23356. * String literals have types "array of (wide) char", not "pointer to (wide) char" The pointer types were a leftover from the early, CIL-based C frontend. * Remove special case for sizeof("string literal") during elaboration No longer needed now that literals have array types.
Diffstat (limited to 'cparser/Elab.ml')
-rw-r--r--cparser/Elab.ml13
1 files changed, 1 insertions, 12 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index 6923491a..0d9d9d09 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -1765,18 +1765,7 @@ let elab_expr vararg loc env a =
error "invalid application of 'sizeof' to an incomplete type %a" (print_typ env) b1.etyp;
if wrap is_bitfield loc env b1 then
error "invalid application of 'sizeof' to a bit-field";
- let bdesc =
- (* Catch special cases sizeof("string literal") *)
- match b1.edesc with
- | EConst(CStr s) ->
- let sz = String.length s + 1 in
- EConst(CInt(Int64.of_int sz, size_t_ikind(), ""))
- | EConst(CWStr s) ->
- let sz = (!config).sizeof_wchar * (List.length s + 1) in
- EConst(CInt(Int64.of_int sz, size_t_ikind(), ""))
- | _ ->
- ESizeof b1.etyp in
- { edesc = bdesc; etyp = TInt(size_t_ikind(), []) },env
+ { edesc = ESizeof b1.etyp; etyp = TInt(size_t_ikind(), []) },env
| TYPE_SIZEOF (spec, dcl) ->
let (ty, env') = elab_type loc env spec dcl in