summaryrefslogtreecommitdiff
path: root/cparser/Elab.ml
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2014-05-15 07:27:56 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2014-05-15 07:27:56 +0000
commitb30f9ce6a87e94b34c1420323e445c07eee8305e (patch)
treeda5f7a1b52ed61b4dda6d01b8c1a71193279601e /cparser/Elab.ml
parentedc00e0c90a5598f653add89f42a095d8ee1b629 (diff)
- Re-added support for "__func__" identifier as per ISO C99.
- Support for empty structs and unions - Better handling of "extern" and "extern inline" function definitions. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2493 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cparser/Elab.ml')
-rw-r--r--cparser/Elab.ml13
1 files changed, 12 insertions, 1 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index c4331cf..34c545f 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -1699,6 +1699,12 @@ let elab_initializer loc env root ty ie =
| Some init ->
(fixup_typ loc env ty init, Some init)
+(* Handling of __func__ (section 6.4.2.2) *)
+
+let __func__type_and_init s =
+ (TArray(TInt(IChar, [AConst]), Some(Int64.of_int (String.length s + 1)), []),
+ init_char_array_string None s)
+
(* Elaboration of top-level and local definitions *)
@@ -1797,8 +1803,13 @@ let elab_fundef env spec name body loc =
let env2 =
List.fold_left (fun e (id, ty) -> Env.add_ident e id Storage_default ty)
(Env.new_scope env1) params in
+ (* Define "__func__" and enter it in the environment *)
+ let (func_ty, func_init) = __func__type_and_init s in
+ let (func_id, env3) =
+ enter_or_refine_ident true loc env2 "__func__" Storage_static func_ty in
+ emit_elab loc (Gdecl(Storage_static, func_id, func_ty, Some func_init));
(* Elaborate function body *)
- let body' = !elab_funbody_f ty_ret env2 body in
+ let body' = !elab_funbody_f ty_ret env3 body in
(* Build and emit function definition *)
let fn =
{ fd_storage = sto;