X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/edbed51570922b674286769255e3ac2b949e1ba7..998925c8d088559a780a9f4fa63f66bad3e3321e:/tests/general.at diff --git a/tests/general.at b/tests/general.at index 49fd6a2..a9d2def 100644 --- a/tests/general.at +++ b/tests/general.at @@ -1,4 +1,4 @@ -dnl Copyright © 2019-2022 Nick Bowler +dnl Copyright © 2019-2023 Nick Bowler dnl License GPLv2+: GNU General Public License version 2 or any later version. dnl This is free software: you are free to change and redistribute it. dnl There is NO WARRANTY, to the extent permitted by law. @@ -21,6 +21,30 @@ AT_CLEANUP AT_SETUP([str.gob]) +# check if compiler supports format warnings +AT_DATA([fmt.c], +[[#include +#include + +void foo(const char *, ...) G_GNUC_PRINTF(1, 2); +void bar(void) { +#line 99 "VERIFY" +foo("%s", 0); +} +]]) +AT_DATA([fmt.awk], +[[BEGIN { pass=0; FS=":"; } +/%s/ && $1 == "VERIFY" && $2 == 99 { pass=1; } +END { exit(!pass); } +]]) + +fmt_warnings=false +set x $CPPFLAGS $CFLAGS $LIBGOBJECT_CFLAGS; shift +AS_IF([$CC "$@" -c fmt.c 1>/dev/null 2>out && $AWK -f fmt.awk out], + [fmt_warnings=:], + [AS_IF([$CC "$@" -Wformat -c fmt.c 1>/dev/null 2>out && $AWK -f fmt.awk out], + [CFLAGS="$CFLAGS -Wformat" fmt_warnings=:])]) + AT_DATA([main.c], [[#include #include "str.h" @@ -48,25 +72,45 @@ int main(void) str_gob=$abs_top_srcdir/t/str.gob AT_CHECK([gob2 "$str_gob"]) AT_CHECK([$HAVE_GOBJECT_PRIVATES || exit 77]) + TEST_COMPILE_GOBJECT([str.c], [0], [], [stderr]) mv stderr str_stderr +TEST_COMPILE_GOBJECT([main.c], [0], [], [stderr]) +mv stderr main_stderr +TEST_LINK_GOBJECT([main], [str.o main.o]) + +AT_DATA([str.awk], +[[/want a string/ { lines[NR] = 1; } +END { + FS=":"; + while ((rc = getline < "str_stderr") > 0) { + sub(/.*[\/]/, "", $1); + if (/%s/ && $1 == "str.gob" && $2 in lines) + lines[$2]--; + } -# Check for correct diagnostic messages on the target lines... -AT_CHECK([$AWK '/want a string/ { print NR }' "$str_gob" >str_lines]) -total=0 -exec 3