aboutsummaryrefslogtreecommitdiffstats
path: root/cfrontend
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2017-04-07 14:02:15 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2017-04-07 14:08:33 +0200
commit6cfc4dac7a8962bc49b88c9cb75156c7b6abd5c1 (patch)
tree2e722cdf3c3153f1a22297c429a91c887bd63a6a /cfrontend
parent2086ba4770d435a084c65410ab061591e1a36c33 (diff)
downloadcompcert-kvx-6cfc4dac7a8962bc49b88c9cb75156c7b6abd5c1.tar.gz
compcert-kvx-6cfc4dac7a8962bc49b88c9cb75156c7b6abd5c1.zip
Do not generate code for "inline definitions"
ISO C99 states that "inline defintions", functions with inline specifier that are not extern, does not provide an external definition and another compilation unit can contain an external definition. Thus in the case of non-static inline functions no code should be generated. Bug 21343
Diffstat (limited to 'cfrontend')
-rw-r--r--cfrontend/C2C.ml23
1 files changed, 15 insertions, 8 deletions
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml
index 3bd1eea0..84e24640 100644
--- a/cfrontend/C2C.ml
+++ b/cfrontend/C2C.ml
@@ -40,14 +40,7 @@ let decl_atom : (AST.ident, atom_info) Hashtbl.t = Hashtbl.create 103
let atom_is_static a =
try
- let i = Hashtbl.find decl_atom a in
- (* inline functions can remain in generated code, but should not
- be global, unless explicitly marked "extern" *)
- match i.a_storage with
- | C.Storage_default -> i.a_inline
- | C.Storage_extern -> false
- | C.Storage_static -> true
- | C.Storage_register -> false (* should not happen *)
+ (Hashtbl.find decl_atom a).a_storage = C.Storage_static
with Not_found ->
false
@@ -87,6 +80,20 @@ let atom_is_inline a =
with Not_found ->
false
+(** Iso C99 defines inline definitions of functions as functions
+ with inline specifier and without extern. These functions do
+ not provide an external definition. In the case of non static
+ functions this means that no code should be generated for these
+ functions. *)
+let atom_is_iso_inline_definition a =
+ try
+ let i = Hashtbl.find decl_atom a in
+ match i.a_storage with
+ | C.Storage_default -> i.a_inline
+ | _ -> false
+ with Not_found ->
+ false
+
let atom_location a =
try
(Hashtbl.find decl_atom a).a_loc