aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cparser/Cerrors.ml10
-rw-r--r--cparser/Cutil.ml5
-rw-r--r--cparser/Cutil.mli2
-rw-r--r--cparser/Elab.ml4
4 files changed, 15 insertions, 6 deletions
diff --git a/cparser/Cerrors.ml b/cparser/Cerrors.ml
index a38cceee..6bbe4b5b 100644
--- a/cparser/Cerrors.ml
+++ b/cparser/Cerrors.ml
@@ -224,19 +224,19 @@ let pp_key key fmt =
fprintf fmt "%s%t@." key rsc
let pp_loc fmt (filename,lineno) =
- if filename <> "" then
- fprintf fmt "%t%s:%d:%t" bc filename lineno rsc
+ if filename <> "" && lineno <> -10 && filename <> "cabs loc unknown" then
+ fprintf fmt "%t%s:%d:%t " bc filename lineno rsc
let error key loc fmt =
incr num_errors;
kfprintf (pp_key key)
- err_formatter ("%a %terror:%t %t" ^^ fmt) pp_loc loc rc rsc bc
+ err_formatter ("%a%terror:%t %t" ^^ fmt) pp_loc loc rc rsc bc
let fatal_error key loc fmt =
incr num_errors;
kfprintf
(fun fmt -> pp_key key fmt;raise Abort)
- err_formatter ("%a %terror:%t %t" ^^ fmt) pp_loc loc rc rsc bc
+ err_formatter ("%a%terror:%t %t" ^^ fmt) pp_loc loc rc rsc bc
let warning loc ty fmt =
let kind,key = classify_warning ty in
@@ -248,7 +248,7 @@ let warning loc ty fmt =
| WarningMsg ->
incr num_warnings;
kfprintf (pp_key key)
- err_formatter ("%a %twarning:%t %t" ^^ fmt) pp_loc loc mc rsc bc
+ err_formatter ("%a%twarning:%t %t" ^^ fmt) pp_loc loc mc rsc bc
| SuppressedMsg -> ifprintf err_formatter fmt
let error loc fmt =
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml
index 19a32a7e..4d0cd735 100644
--- a/cparser/Cutil.ml
+++ b/cparser/Cutil.ml
@@ -683,6 +683,11 @@ let is_function_type env t =
| TFun _ -> true
| _ -> false
+let is_anonymous_composite = function
+ | TStruct (id,_)
+ | TUnion (id,_) -> id.C.name = ""
+ | _ -> false
+
(* Find the info for a field access *)
let field_of_dot_access env t m =
diff --git a/cparser/Cutil.mli b/cparser/Cutil.mli
index 3f988f7c..edff9ee1 100644
--- a/cparser/Cutil.mli
+++ b/cparser/Cutil.mli
@@ -128,6 +128,8 @@ val is_composite_type : Env.t -> typ -> bool
(* Is type a struct or union? *)
val is_function_type : Env.t -> typ -> bool
(* Is type a function type? (not pointer to function) *)
+val is_anonymous_composite : typ -> bool
+ (* Is type an anonymous composite? *)
val pointer_arithmetic_ok : Env.t -> typ -> bool
(* Is the type [*ty] appropriate for pointer arithmetic?
[ty] must not be void, nor a function type, nor an incomplete type. *)
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index 38ef7617..6188b482 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -759,7 +759,7 @@ and elab_field_group keep_ty env (Field_group (spec, fieldlist, loc)) =
let fieldlist = List.map (
function
- | (None, x) -> (Name ("", JUSTBASE, [], cabslu), x)
+ | (None, x) -> (Name ("", JUSTBASE, [], loc), x)
| (Some n, x) -> (n, x))
fieldlist
in
@@ -812,6 +812,8 @@ and elab_field_group keep_ty env (Field_group (spec, fieldlist, loc)) =
error loc "bit-field '%s' width not an integer constant" id;
None
end in
+ if id = "" && not (Cutil.is_anonymous_composite ty) && optbitsize = None then
+ warning loc Missing_declarations "declaration does not declare anything";
{ fld_name = id; fld_typ = ty; fld_bitfield = optbitsize' }
in
(List.map2 elab_bitfield fieldlist names, env')