Message ID | 91231fc7-4fe2-33d1-4fd1-a1b0ec3ff63a@ramsayjones.plus.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
Series | tests: add test to illustrate problem on git codebase | expand |
On 06/02/2019 01:14, Ramsay Jones wrote: > > Add a new test file which demonstrates some problems which can be > seen on the git codebase. gcc does not complain about this file: > > $ gcc -Wall -c validation/function-redecl2.c > $ > > ... but sparse does: > > $ sparse validation/function-redecl2.c > validation/function-redecl2.c:6:5: error: symbol 'func0' redeclared with different type (originally declared at validation/function-redecl2.c:3) - different modifiers > validation/function-redecl2.c:13:6: error: symbol 'func1' redeclared with different type (originally declared at validation/function-redecl2.c:11) - different modifiers > validation/function-redecl2.c:21:6: error: symbol 'func2' redeclared with different type (originally declared at validation/function-redecl2.c:18) - different modifiers > $ > > Note that func0 and func2 are essentially the same example, apart from > the attribute used, to demonstrate that the issue isn't caused by the > 'pure' attribute. Also, examples like func1 have occurred several times > in git and, although they can be worked around (eg. See [1]), it would > be preferable if this were not necessary. > > This test is marked 'check-know-to-fail'. Heh, of course, this should be 'check-known-to-fail'. sigh. ;-) ATB, Ramsay Jones > > [1] (git) commit 3d7dd2d3b6 ("usage: add NORETURN to BUG() function > definitions", 2017-05-21). > > Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> > --- > > Hi Luc, > > As promised, a 'known-to-fail' test case. > > Thanks! > > ATB, > Ramsay Jones > > validation/function-redecl2.c | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > create mode 100644 validation/function-redecl2.c > > diff --git a/validation/function-redecl2.c b/validation/function-redecl2.c > new file mode 100644 > index 0000000..c7bb93b > --- /dev/null > +++ b/validation/function-redecl2.c > @@ -0,0 +1,32 @@ > +extern void exit (int __status) __attribute__ ((__noreturn__)); > + > +int func0(int a) __attribute__ ((pure)); > + > +__attribute__ ((pure)) > +int func0(int a) > +{ > + return 0; > +} > + > +__attribute__ ((noreturn)) void func1(int a); > + > +void func1(int a) > +{ > + exit(0); > +} > + > +void func2(int a) __attribute__ ((noreturn)); > + > +__attribute__ ((noreturn)) > +void func2(int a) > +{ > + exit(0); > +} > + > +/* > + * check-name: function-redecl2 > + * > + * check-known-to-fail > + * > + */ > + >
On Wed, Feb 06, 2019 at 01:24:38AM +0000, Ramsay Jones wrote: > > > On 06/02/2019 01:14, Ramsay Jones wrote: > > > > Add a new test file which demonstrates some problems which can be > > seen on the git codebase. gcc does not complain about this file: > > > > $ gcc -Wall -c validation/function-redecl2.c > > $ > > > > ... but sparse does: > > > > $ sparse validation/function-redecl2.c > > validation/function-redecl2.c:6:5: error: symbol 'func0' redeclared with different type (originally declared at validation/function-redecl2.c:3) - different modifiers > > validation/function-redecl2.c:13:6: error: symbol 'func1' redeclared with different type (originally declared at validation/function-redecl2.c:11) - different modifiers > > validation/function-redecl2.c:21:6: error: symbol 'func2' redeclared with different type (originally declared at validation/function-redecl2.c:18) - different modifiers > > $ > > > > Note that func0 and func2 are essentially the same example, apart from > > the attribute used, to demonstrate that the issue isn't caused by the > > 'pure' attribute. Also, examples like func1 have occurred several times > > in git and, although they can be worked around (eg. See [1]), it would > > be preferable if this were not necessary. Yes, there are several related problems but this one is probably the most annoying. Thanks for the testcase. -- Luc
diff --git a/validation/function-redecl2.c b/validation/function-redecl2.c new file mode 100644 index 0000000..c7bb93b --- /dev/null +++ b/validation/function-redecl2.c @@ -0,0 +1,32 @@ +extern void exit (int __status) __attribute__ ((__noreturn__)); + +int func0(int a) __attribute__ ((pure)); + +__attribute__ ((pure)) +int func0(int a) +{ + return 0; +} + +__attribute__ ((noreturn)) void func1(int a); + +void func1(int a) +{ + exit(0); +} + +void func2(int a) __attribute__ ((noreturn)); + +__attribute__ ((noreturn)) +void func2(int a) +{ + exit(0); +} + +/* + * check-name: function-redecl2 + * + * check-known-to-fail + * + */ +
Add a new test file which demonstrates some problems which can be seen on the git codebase. gcc does not complain about this file: $ gcc -Wall -c validation/function-redecl2.c $ ... but sparse does: $ sparse validation/function-redecl2.c validation/function-redecl2.c:6:5: error: symbol 'func0' redeclared with different type (originally declared at validation/function-redecl2.c:3) - different modifiers validation/function-redecl2.c:13:6: error: symbol 'func1' redeclared with different type (originally declared at validation/function-redecl2.c:11) - different modifiers validation/function-redecl2.c:21:6: error: symbol 'func2' redeclared with different type (originally declared at validation/function-redecl2.c:18) - different modifiers $ Note that func0 and func2 are essentially the same example, apart from the attribute used, to demonstrate that the issue isn't caused by the 'pure' attribute. Also, examples like func1 have occurred several times in git and, although they can be worked around (eg. See [1]), it would be preferable if this were not necessary. This test is marked 'check-know-to-fail'. [1] (git) commit 3d7dd2d3b6 ("usage: add NORETURN to BUG() function definitions", 2017-05-21). Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> --- Hi Luc, As promised, a 'known-to-fail' test case. Thanks! ATB, Ramsay Jones validation/function-redecl2.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 validation/function-redecl2.c