From 096a6e38665392d1de16a3059d73ed77e32045a5 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Fri, 24 Jun 2016 15:07:00 +0200 Subject: Revised handling of old-style, K&R function definitions This commits handles the case where the argument is passed with a type different from the actual type of the argument, as in float f (x) float x; { return x; } "x" is passed with type "double", and must be converted to "float" at the beginning of the function. --- test/regression/krfun.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/regression/krfun.c (limited to 'test/regression/krfun.c') diff --git a/test/regression/krfun.c b/test/regression/krfun.c new file mode 100644 index 00000000..e34098b5 --- /dev/null +++ b/test/regression/krfun.c @@ -0,0 +1,37 @@ +/* Old-style, K&R function definitions */ + +#include + +void f(a, b, c) + int c, a; + char * b; +{ + printf("f(%d, \"%s\", %d)\n", a, b, c); +} + +void g(a, b, c, d, e, x) + const unsigned char a; + char b[64]; + float c; + double d; + volatile int e; + long long x; +{ + printf("g(%d, \"%s\", %a, %a, %d, %lld)\n", a, b, c, d, e, x); +} + +void h(a, b, c) + char * b; +{ + printf("h(%d, \"%s\", %d)\n", a, b, c); +} + + +int main() +{ + f(1, "Hello", 2); + g(257, "World", 3.141592654, 3.141592654, -34, 12345678901234567LL); + h(6, "warning!", 7); + return 0; +} + -- cgit