Commit 9b8167f0 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

Merge branch 'fix/kernel/ghost-else-error-msg' into 'master'

[ghost] Fixes error msg for ignored ghost-else

See merge request frama-c/frama-c!2604
parents 62063942 fb42dae6
......@@ -923,7 +923,9 @@ else_part:
%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
{
Format.eprintf "Warning: %a: Invalid ghost else ignored@." Cil_datatype.Location.pretty $1 ;
let loc = Cil_datatype.Location.of_lexing_loc (Parsing.symbol_start_pos (), Parsing.symbol_end_pos ()) in
Kernel.warning ~wkey:Kernel.wkey_ghost_bad_use ~source:(fst loc)
"Invalid ghost else ignored@." ;
in_block $5
}
......
/* run.config
OPT: -no-autoload-plugins -cpp-extra-args="-DERROR_LOC_WITH_COMMENTS"
OPT: -no-autoload-plugins -cpp-extra-args="-DALREADY_HAS_ELSE" -print
OPT: -no-autoload-plugins -cpp-extra-args="-DALREADY_HAS_ELSE" -print -kernel-warn-key ghost:bad-use=feedback
OPT: -no-autoload-plugins -cpp-extra-args="-DBAD_ANNOT_POSITION"
*/
......@@ -22,7 +22,7 @@ void if_ghost_else_block_comments_then_error(int x, int y) {
#endif
#ifdef ALREADY_HAS_ELSE
#ifdef ALREADY_HAS_ELSE
// Must warn that the ghost else cannot appear since there is already a else
// Thus the ghost else is ignored and the resulting code does not comprise it
......
[kernel] Parsing tests/syntax/ghost_else_bad.c (with preprocessing)
[kernel:ghost:bad-use] tests/syntax/ghost_else_bad.c:32:
Invalid ghost else ignored
/* Generated by Frama-C */
void if_ghost_else_block_bad(int x, int y)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment