aboutsummaryrefslogtreecommitdiffstats
path: root/cparser
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-06-17 18:53:39 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2015-06-17 18:53:39 +0200
commitb51cc596555dae929e75e4a02520f01d6f53978d (patch)
tree7a43ce306cb641b85dab43e88ed757edb873eed2 /cparser
parente503983cdc99c6038ada0d0b94f32f02d13210c8 (diff)
parent0e9ededa8c1d194453f5113bf57c93d0803f03b1 (diff)
downloadcompcert-b51cc596555dae929e75e4a02520f01d6f53978d.tar.gz
compcert-b51cc596555dae929e75e4a02520f01d6f53978d.zip
Merge branch 'master' into json_export
Diffstat (limited to 'cparser')
-rw-r--r--cparser/Elab.ml12
1 files changed, 9 insertions, 3 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index fe74a786..aa015b83 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -640,7 +640,7 @@ and elab_field_group env (Field_group (spec, fieldlist, loc)) =
error loc "non-default storage in struct or union";
if fieldlist = [] then
if is_anonymous_composite spec then
- error loc "ISO C99 does not support anonymous structs/unions"
+ warning loc "ISO C99 does not support anonymous structs/unions"
else
warning loc "declaration does not declare any members";
@@ -778,7 +778,9 @@ and elab_enum_item env ((s, exp), loc) nextval =
"value of enumerator '%s' is not a compile-time constant" s;
(nextval, Some exp') in
if redef Env.lookup_ident env s then
- error loc "redefinition of enumerator '%s'" s;
+ error loc "redefinition of identifier '%s'" s;
+ if redef Env.lookup_typedef env s then
+ error loc "redefinition of typedef '%s' as different kind of symbol" s;
if not (int_representable v (8 * sizeof_ikind enum_ikind) (is_signed_ikind enum_ikind)) then
warning loc "the value of '%s' is not representable with type %a"
s Cprint.typ (TInt(enum_ikind, []));
@@ -1784,11 +1786,15 @@ let enter_typedefs loc env sto dl =
error loc "initializer in typedef";
if redef Env.lookup_typedef env s then
error loc "redefinition of typedef '%s'" s;
+ if redef Env.lookup_ident env s then
+ error loc "redefinition of identifier '%s' as different kind of symbol" s;
let (id, env') = Env.enter_typedef env s ty in
emit_elab loc (Gtypedef(id, ty));
env') env dl
let enter_or_refine_ident local loc env s sto ty =
+ if redef Env.lookup_typedef env s then
+ error loc "redefinition of typedef '%s' as different kind of symbol" s;
match previous_def Env.lookup_ident env s with
| Some(id, II_ident(old_sto, old_ty))
when sto = Storage_extern || Env.in_current_scope env id ->
@@ -1817,7 +1823,7 @@ let enter_or_refine_ident local loc env s sto ty =
in
(id, new_sto, Env.add_ident env id new_sto new_ty)
| Some(id, II_enum v) when Env.in_current_scope env id ->
- error loc "illegal redefinition of enumerator '%s'" s;
+ error loc "redefinition of enumerator '%s'" s;
(id, sto, Env.add_ident env id sto ty)
| _ ->
let (id, env') = Env.enter_ident env s sto ty in (id, sto, env')