diff --git a/src/plugins/variadic/standard.ml b/src/plugins/variadic/standard.ml index ecc9a7d96005b7c5bb8408a0243847f50b9006d2..4c5c16721c2e06d08fc97be1cee66daf5f7cd47c 100644 --- a/src/plugins/variadic/standard.ml +++ b/src/plugins/variadic/standard.ml @@ -701,11 +701,17 @@ let infer_format_from_args vf format_fun args = let t = Cil.typeOf arg in let t = match format_fun.f_kind with - | PrintfLike -> t - | ScanfLike -> - if not (Cil.isPointerType t) then - raise (Translate_call_exn vf.vf_decl); - Cil.typeOf_pointed t + | PrintfLike -> t + | ScanfLike -> + if not (Cil.isPointerType t) then begin + let source = fst arg.eloc in + Self.warning ~source + "Expecting pointer as parameter of scanf function. \ + Argument %a has type %a" + Printer.pp_exp arg Printer.pp_typ t; + raise (Translate_call_exn vf.vf_decl); + end; + Cil.typeOf_pointed t in format_of_type vf format_fun.f_kind t in @@ -722,8 +728,9 @@ let format_fun_call ~fundec env format_fun scope loc mk_call vf args = match static_string format_arg with | None -> Self.warning ~current:true - "Call to function %s with non-static format argument:@ \ - assuming that parameters are coherent with the format" + "Call to function %s with non-static format argument: \ + assuming that parameters are coherent with the format, and that \ + no %%n specifiers are present in the actual string." vf.vf_decl.vorig_name; infer_format_from_args vf format_fun args | Some s -> Format_parser.parse_format format_fun.f_kind s diff --git a/src/plugins/variadic/tests/known/oracle/stdio_print.res.oracle b/src/plugins/variadic/tests/known/oracle/stdio_print.res.oracle index e461895f7764ddd53e43de41a8c92d44fc5f79af..0a72e68f29843f25f4a08f83fdfb8f738707856b 100644 --- a/src/plugins/variadic/tests/known/oracle/stdio_print.res.oracle +++ b/src/plugins/variadic/tests/known/oracle/stdio_print.res.oracle @@ -17,28 +17,23 @@ [variadic] FRAMAC_SHARE/libc/stdio.h:590: Declaration of variadic function asprintf. [variadic] tests/known/stdio_print.c:9: Warning: - Call to function fprintf with non-static format argument: - assuming that parameters are coherent with the format + Call to function fprintf with non-static format argument: assuming that parameters are coherent with the format, and that no %n specifiers are present in the actual string. [variadic] tests/known/stdio_print.c:9: Translating call to fprintf to a call to the specialized version fprintf_va_1. [variadic] tests/known/stdio_print.c:10: Warning: - Call to function printf with non-static format argument: - assuming that parameters are coherent with the format + Call to function printf with non-static format argument: assuming that parameters are coherent with the format, and that no %n specifiers are present in the actual string. [variadic] tests/known/stdio_print.c:10: Translating call to printf to a call to the specialized version printf_va_1. [variadic] tests/known/stdio_print.c:11: Warning: - Call to function snprintf with non-static format argument: - assuming that parameters are coherent with the format + Call to function snprintf with non-static format argument: assuming that parameters are coherent with the format, and that no %n specifiers are present in the actual string. [variadic] tests/known/stdio_print.c:11: Translating call to snprintf to a call to the specialized version snprintf_va_1. [variadic] tests/known/stdio_print.c:12: Warning: - Call to function sprintf with non-static format argument: - assuming that parameters are coherent with the format + Call to function sprintf with non-static format argument: assuming that parameters are coherent with the format, and that no %n specifiers are present in the actual string. [variadic] tests/known/stdio_print.c:12: Translating call to sprintf to a call to the specialized version sprintf_va_1. [variadic] tests/known/stdio_print.c:13: Warning: - Call to function dprintf with non-static format argument: - assuming that parameters are coherent with the format + Call to function dprintf with non-static format argument: assuming that parameters are coherent with the format, and that no %n specifiers are present in the actual string. [variadic] tests/known/stdio_print.c:13: Translating call to dprintf to a call to the specialized version dprintf_va_1. [variadic] tests/known/stdio_print.c:15: diff --git a/src/plugins/variadic/tests/known/oracle/stdio_scan.res.oracle b/src/plugins/variadic/tests/known/oracle/stdio_scan.res.oracle index 66601b31517e782008505706ab0b03138c81d41e..83103e4ba9a423384d500ad5bdbac32a33889ec5 100644 --- a/src/plugins/variadic/tests/known/oracle/stdio_scan.res.oracle +++ b/src/plugins/variadic/tests/known/oracle/stdio_scan.res.oracle @@ -17,18 +17,15 @@ [variadic] FRAMAC_SHARE/libc/stdio.h:590: Declaration of variadic function asprintf. [variadic] tests/known/stdio_scan.c:10: Warning: - Call to function fscanf with non-static format argument: - assuming that parameters are coherent with the format + Call to function fscanf with non-static format argument: assuming that parameters are coherent with the format, and that no %n specifiers are present in the actual string. [variadic] tests/known/stdio_scan.c:10: Translating call to fscanf to a call to the specialized version fscanf_va_1. [variadic] tests/known/stdio_scan.c:11: Warning: - Call to function scanf with non-static format argument: - assuming that parameters are coherent with the format + Call to function scanf with non-static format argument: assuming that parameters are coherent with the format, and that no %n specifiers are present in the actual string. [variadic] tests/known/stdio_scan.c:11: Translating call to scanf to a call to the specialized version scanf_va_1. [variadic] tests/known/stdio_scan.c:12: Warning: - Call to function sscanf with non-static format argument: - assuming that parameters are coherent with the format + Call to function sscanf with non-static format argument: assuming that parameters are coherent with the format, and that no %n specifiers are present in the actual string. [variadic] tests/known/stdio_scan.c:12: Translating call to sscanf to a call to the specialized version sscanf_va_1. [variadic] tests/known/stdio_scan.c:14: