From f8e82448be26fbbfae3d817310befe335fb2bcf7 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 25 Jan 2021 21:48:00 -0800 Subject: [PATCH] Add a warning when a single % is at the end of the format string --- vpi/sys_display.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vpi/sys_display.c b/vpi/sys_display.c index 94a3fc9e1..ed8be0ec2 100644 --- a/vpi/sys_display.c +++ b/vpi/sys_display.c @@ -312,8 +312,11 @@ static unsigned int get_format_char(char **rtn, int ljust, int plus, size = strlen(result) + 1; /* fallback value if errors */ switch (fmt) { - case '%': case '\0': + vpi_printf("WARNING: %s:%d: a single %% at the end of format string " + "%s%s will be displayed as '%%'.\n", + info->filename, info->lineno, info->name, fmtb); + case '%': if (ljust != 0 || plus != 0 || ld_zero != 0 || width != -1 || prec != -1) { vpi_printf("WARNING: %s:%d: invalid format %s%s.\n",