Skip to content
Snippets Groups Projects
Commit 159736b1 authored by Andre Maroneze's avatar Andre Maroneze Committed by Thibault Martin
Browse files

[Kernel] improve mergecil warning about conflicting types

parent 10fbb281
No related branches found
No related tags found
No related merge requests found
...@@ -1237,27 +1237,31 @@ let matchTypeInfoGen (combineF : combineFunction) ...@@ -1237,27 +1237,31 @@ let matchTypeInfoGen (combineF : combineFunction)
let conflict_detected = ref false let conflict_detected = ref false
let combines = { let combines = {
typ_combine = (fun combF -> typ_combine = (fun combF ~strictInteger ~strictReturnTypes what t1 t2 ->
let find_names_file = H.find fileNames in let find_names_file = H.find fileNames in
let oldfidx = Fidx.get_oldfidx () in let oldfidx = Fidx.get_oldfidx () in
let fidx = Fidx.get_fidx () in let fidx = Fidx.get_fidx () in
let old_file = find_names_file oldfidx in let old_file = find_names_file oldfidx in
let new_file = find_names_file fidx in let pre_msg =
let old_name_file = Filepath.Normalized.to_pretty_string old_file in Format.asprintf
let new_name_file = Filepath.Normalized.to_pretty_string new_file in "Conflicting definitions for types '%a' and '%a' \
let pre_msg = "Conflicting definitions are between files "^ (previous definition was in file %s)."
old_name_file^" and "^new_name_file in Cil_printer.pp_typ t1
Cil_printer.pp_typ t2
(Filepath.Normalized.to_pretty_string old_file)
in
let emitwith _ = let emitwith _ =
if (not !conflict_detected) && oldfidx <> fidx if (not !conflict_detected) && oldfidx <> fidx
then then
begin begin
conflict_detected := true; conflict_detected := true;
Kernel.warning Kernel.warning ~current:true
~wkey:Kernel.wkey_merge_conversion ~wkey:Kernel.wkey_merge_conversion
"%s" pre_msg "%s" pre_msg
end end
in in
combineTypesGen ~emitwith combF); combineTypesGen
~emitwith combF ~strictInteger ~strictReturnTypes what t1 t2);
enum_combine = (fun _ oldei ei -> enum_combine = (fun _ oldei ei ->
matchEnumInfoGen oldei ei; matchEnumInfoGen oldei ei;
oldei); oldei);
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
[kernel] Parsing cpu_b.c (with preprocessing) [kernel] Parsing cpu_b.c (with preprocessing)
[kernel:typing:int-conversion] cpu_b.c:7: Warning: [kernel:typing:int-conversion] cpu_b.c:7: Warning:
Integer compatibility is machine-dependent: unsigned short and unsigned int Integer compatibility is machine-dependent: unsigned short and unsigned int
[kernel:typing:merge-conversion] Warning: [kernel:typing:merge-conversion] cpu_b.c:7: Warning:
Conflicting definitions are between files cpu_a.c and cpu_b.c Conflicting definitions for types 'unsigned short' and 'unsigned int' (previous definition was in file cpu_a.c).
/* Generated by Frama-C */ /* Generated by Frama-C */
typedef unsigned short DWORD; typedef unsigned short DWORD;
DWORD f(void) DWORD f(void)
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
[kernel] Parsing cpu_a.c (with preprocessing) [kernel] Parsing cpu_a.c (with preprocessing)
[kernel:typing:int-conversion] cpu_a.c:6: Warning: [kernel:typing:int-conversion] cpu_a.c:6: Warning:
Integer compatibility is machine-dependent: unsigned int and unsigned short Integer compatibility is machine-dependent: unsigned int and unsigned short
[kernel:typing:merge-conversion] Warning: [kernel:typing:merge-conversion] cpu_a.c:6: Warning:
Conflicting definitions are between files cpu_b.c and cpu_a.c Conflicting definitions for types 'unsigned int' and 'unsigned short' (previous definition was in file cpu_b.c).
/* Generated by Frama-C */ /* Generated by Frama-C */
typedef unsigned int DWORD; typedef unsigned int DWORD;
DWORD f(void); DWORD f(void);
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
[kernel] Parsing multiple_file_2.c (with preprocessing) [kernel] Parsing multiple_file_2.c (with preprocessing)
[kernel:typing:int-conversion] multiple_file_2.c:28: Warning: [kernel:typing:int-conversion] multiple_file_2.c:28: Warning:
Array type comparison succeeds only based on machine-dependent constant evaluation: int [sizeof(struct i_s2)] and int [sizeof(struct i_s2)] Array type comparison succeeds only based on machine-dependent constant evaluation: int [sizeof(struct i_s2)] and int [sizeof(struct i_s2)]
[kernel:typing:merge-conversion] Warning: [kernel:typing:merge-conversion] multiple_file_2.c:28: Warning:
Conflicting definitions are between files multiple_file_1.c and multiple_file_2.c Conflicting definitions for types 'int [sizeof(struct i_s2)]' and 'int [sizeof(struct i_s2)]' (previous definition was in file multiple_file_1.c).
[kernel:typing:int-conversion] multiple_file_2.c:36: Warning: [kernel:typing:int-conversion] multiple_file_2.c:36: Warning:
Array type comparison succeeds only based on machine-dependent constant evaluation: int [sizeof(void *)] and int [sizeof(struct i_s2)] Array type comparison succeeds only based on machine-dependent constant evaluation: int [sizeof(void *)] and int [sizeof(struct i_s2)]
[kernel:typing:int-conversion] multiple_file_2.c:38: Warning: [kernel:typing:int-conversion] multiple_file_2.c:38: Warning:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment