You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/frontc/cabs2cil.ml
+99-68Lines changed: 99 additions & 68 deletions
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,8 @@ open Cil
53
53
openCilint
54
54
openTrace
55
55
56
+
(* This exception is thrown if there is an attempt to transform Tauto into a CIL type *)
57
+
exceptionTautoEncountered
56
58
57
59
letmydebugfunction()=
58
60
E.s (error "mydebugfunction")
@@ -2327,9 +2329,7 @@ let rec doSpecList (suggestedAnonName: string) (* This string will be part of
2327
2329
letattrs : A.attribute list ref =ref[]in(* __attribute__, etc. *)
2328
2330
letcvattrs : A.cvspec list ref =ref[]in(* const/volatile *)
2329
2331
2330
-
letdoSpecElem (se: A.spec_elem)
2331
-
(acc: A.typeSpecifier list)
2332
-
: A.typeSpecifier list =
2332
+
letdoSpecElem (se: A.spec_elem) (acc: A.typeSpecifier list): A.typeSpecifier list =
2333
2333
match se with
2334
2334
A.SpecTypedef -> acc
2335
2335
|A.SpecInline -> isinline :=true; acc
@@ -2360,14 +2360,12 @@ let rec doSpecList (suggestedAnonName: string) (* This string will be part of
2360
2360
(* GCC allows a named type that appears first to be followed by things
2361
2361
* like "short", "signed", "unsigned" or "long". *)
2362
2362
match tspecs with
2363
-
A.Tnamedn :: (_ :: _asrest) ->
2364
-
(* If rest contains "short" or "long" then drop the Tnamed *)
2365
-
ifList.exists (functionA.Tshort ->true
2366
-
|A.Tlong -> true|_ -> false) rest then
2367
-
rest
2368
-
else
2369
-
tspecs
2370
-
2363
+
|A.Tnamedn :: (_ :: _asrest) ->
2364
+
(* If rest contains "short" or "long" then drop the Tnamed *)
2365
+
ifList.exists (functionA.Tshort ->true|A.Tlong -> true|_ ->false) rest then
2366
+
rest
2367
+
else
2368
+
tspecs
2371
2369
|_ -> tspecs
2372
2370
in
2373
2371
(* Sort the type specifiers *)
@@ -2574,37 +2572,37 @@ let rec doSpecList (suggestedAnonName: string) (* This string will be part of
2574
2572
let a = extraAttrs @ (getTypeAttrs ()) in
2575
2573
enum.eattr <- doAttributes a;
2576
2574
let res =TEnum (enum, []) in
2577
-
let smallest =ref zero_cilint in
2578
-
let largest =ref zero_cilint in
2579
-
2580
-
(* Life is fun here. ANSI says: enum constants are ints,
2581
-
and there's an implementation-dependent underlying integer
2582
-
type for the enum, which must be capable of holding all the
2583
-
enum's values.
2584
-
GCC allows enum constants that don't fit in int: the enum
2585
-
constant's type is the smallest type (but at least int) that
2586
-
will hold the value, with a preference for signed types.
2587
-
The underlying type EI of the enum is picked as follows:
2588
-
- let T be the smallest integer type that holds all the enum's
2589
-
values; T is signed if any enum value is negative, unsigned otherwise
2590
-
- if the enum is packed or sizeof(T) >= sizeof(int), then EI = T
2591
-
- otherwise EI = int if T is signed and unsigned int otherwise
2592
-
Note that these rules make the enum unsigned if possible (as
2593
-
opposed the enum constants which tend towards being signed...) *)
2594
-
2595
-
letupdateEnum (i:cilint) : ikind =
2596
-
if compare_cilint i !smallest <0then
2597
-
smallest := i;
2598
-
if compare_cilint i !largest >0then
2599
-
largest := i;
2600
-
(* This matches gcc's behaviour *)
2601
-
if fitsInInt IInt i thenIInt
2602
-
elseif fitsInInt IUInt i thenIUInt
2603
-
elseif fitsInInt ILong i thenILong
2604
-
elseif fitsInInt IULong i thenIULong
2605
-
elseif fitsInInt ILongLong i thenILongLong
2606
-
elseIULongLong(* assume there can be not enum constants that don't fit in long long since there can only be 128bit constants if long long is also 128bit *)
2607
-
in
2575
+
let smallest =ref zero_cilint in
2576
+
let largest =ref zero_cilint in
2577
+
2578
+
(* Life is fun here. ANSI says: enum constants are ints,
2579
+
and there's an implementation-dependent underlying integer
2580
+
type for the enum, which must be capable of holding all the
2581
+
enum's values.
2582
+
GCC allows enum constants that don't fit in int: the enum
2583
+
constant's type is the smallest type (but at least int) that
2584
+
will hold the value, with a preference for signed types.
2585
+
The underlying type EI of the enum is picked as follows:
2586
+
- let T be the smallest integer type that holds all the enum's
2587
+
values; T is signed if any enum value is negative, unsigned otherwise
2588
+
- if the enum is packed or sizeof(T) >= sizeof(int), then EI = T
2589
+
- otherwise EI = int if T is signed and unsigned int otherwise
2590
+
Note that these rules make the enum unsigned if possible (as
2591
+
opposed the enum constants which tend towards being signed...) *)
2592
+
2593
+
letupdateEnum (i:cilint) : ikind =
2594
+
if compare_cilint i !smallest <0then
2595
+
smallest := i;
2596
+
if compare_cilint i !largest >0then
2597
+
largest := i;
2598
+
(* This matches gcc's behaviour *)
2599
+
if fitsInInt IInt i thenIInt
2600
+
elseif fitsInInt IUInt i thenIUInt
2601
+
elseif fitsInInt ILong i thenILong
2602
+
elseif fitsInInt IULong i thenIULong
2603
+
elseif fitsInInt ILongLong i thenILongLong
2604
+
elseIULongLong(* assume there can be not enum constants that don't fit in long long since there can only be 128bit constants if long long is also 128bit *)
2605
+
in
2608
2606
(* as each name,value pair is determined, this is called *)
2609
2607
letrec processNamekname (i: exp) locrest=begin
2610
2608
(* add the name to the environment, but with a faked 'typ' field;
@@ -2641,25 +2639,24 @@ let rec doSpecList (suggestedAnonName: string) (* This string will be part of
0 commit comments