diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2016-09-23 08:48:48 +0200 |
---|---|---|
committer | Bernhard Schommer <bernhardschommer@gmail.com> | 2016-09-23 08:48:48 +0200 |
commit | 905012098014efe6ac661ca5fdaa30ba80480296 (patch) | |
tree | 175ef31b14aae8ed083920ac42402d1846a476a8 /cfrontend | |
parent | 8fcdd1d52fcaec72edbe2bb93054f007392065f6 (diff) | |
download | compcert-905012098014efe6ac661ca5fdaa30ba80480296.tar.gz compcert-905012098014efe6ac661ca5fdaa30ba80480296.zip |
Improved error messages for wrong vararg calls.
Now "expected at least %d" instead of "expected %d". Also improved
error message for __builtin_debug.
Bug 19872
Diffstat (limited to 'cfrontend')
-rw-r--r-- | cfrontend/C2C.ml | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml index 92abac68..14976d01 100644 --- a/cfrontend/C2C.ml +++ b/cfrontend/C2C.ml @@ -755,15 +755,20 @@ let rec convertExpr env e = unsupported "compound literals"; ezero | C.ECall({edesc = C.EVar {name = "__builtin_debug"}}, args) -> + let len = List.length args in + if len < 2 then + error "too few arguments to function call, expected at least 2, have 0"; let (kind, args1) = match args with | {edesc = C.EConst(CInt(n,_,_))} :: args1 when n <> 0L-> (n, args1) - | _ -> error "argument 1 of '__builtin_debug' must be a non-zero constant"; (1L, args) in + | _::args -> error "argument 1 of '__builtin_debug' must be a non-zero constant"; (1L, args) + | [] -> assert false (* catched earlier *) in let (text, args2) = match args1 with | {edesc = C.EConst(CStr(txt))} :: args2 -> (txt, args2) | {edesc = C.EVar id} :: args2 -> (id.name, args2) - | _ -> error "argument 2 of '__builtin_debug' must be either a string literal or a variable"; ("", args1) in + | _::args2 -> error "argument 2 of '__builtin_debug' must be either a string literal or a variable"; ("", args2) + | [] -> assert false (* catched earlier *) in let targs2 = convertTypArgs env [] args2 in Ebuiltin( EF_debug(P.of_int64 kind, intern_string text, |