From f2382f756c711e3c4bba79e3d20fe7461c190e8d Mon Sep 17 00:00:00 2001 From: Allan Blanchard <allan.blanchard@cea.fr> Date: Tue, 3 Sep 2019 15:56:52 +0200 Subject: [PATCH] [Parsing] Makes ghost else blocks actually ghosts --- src/kernel_internals/parsing/cparser.mly | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/kernel_internals/parsing/cparser.mly b/src/kernel_internals/parsing/cparser.mly index afe88cf64d1..35209bebcab 100644 --- a/src/kernel_internals/parsing/cparser.mly +++ b/src/kernel_internals/parsing/cparser.mly @@ -289,6 +289,7 @@ let transformOffsetOf (speclist, dtype) member = { addrExpr with expr_node = CAST (sizeofType, SINGLE_INIT addrExpr)} let no_ghost_stmt s = {stmt_ghost = false ; stmt_node = s} +let ghost_stmt s = {stmt_ghost = true ; stmt_node = s} let no_ghost = List.map no_ghost_stmt @@ -301,6 +302,12 @@ let in_block l = get_statementloc (List.hd l), get_statementloc (Extlib.last l))) +let in_ghost_block ?(battrs=[]) l = + let l = in_ghost l in + ghost_stmt (BLOCK ({ blabels = []; battrs ; bstmts = l}, + get_statementloc (List.hd l), + get_statementloc (Extlib.last l))) + %} %token <Filepath.position * string> SPEC @@ -908,7 +915,7 @@ else_part: | ELSE annotated_statement { in_block $2 } | LGHOST_ELSE annotated_statement RGHOST - { in_block $2 } + { in_ghost_block ~battrs:[ ("ghost_else" , []) ] $2 } %prec GHOST_ELSE_NO_ELSE /* To force the non ghost else to be attached to the current if */ | LGHOST_ELSE annotated_statement RGHOST ELSE annotated_statement { -- GitLab