summaryrefslogtreecommitdiffstats
path: root/src/util/gccw.c
blob: d3421fe592f7eca7c17a63e9facf0872380ba70a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 /*
  * This is is a regression test for all the things that gcc is meant to warn
  * about.
  * 
  * gcc version 3 breaks several tests:
  * 
  * -W does not report missing return value
  * 
  * -Wunused does not report unused parameter
  */

#include <stdio.h>
#include <setjmp.h>

jmp_buf jbuf;

 /* -Wmissing-prototypes: no previous prototype for 'test1' */
 /* -Wimplicit: return type defaults to `int' */
test1(void)
{
    /* -Wunused: unused variable `foo' */
    int     foo;

    /* -Wparentheses: suggest parentheses around && within || */
    printf("%d\n", 1 && 2 || 3 && 4);
    /* -W: statement with no effect */
    0;
    /* BROKEN in gcc 3 */
    /* -W: control reaches end of non-void function */
}


 /* -W??????: unused parameter `foo' */
void    test2(int foo)
{
    enum {
    a = 10, b = 15} moe;
    int     bar;

    /* -Wuninitialized: 'bar' might be used uninitialized in this function */
    /* -Wformat: format argument is not a pointer (arg 2) */
    printf("%s\n", bar);
    /* -Wformat: too few arguments for format */
    printf("%s%s\n", "bar");
    /* -Wformat: too many arguments for format */
    printf("%s\n", "bar", "bar");

    /* -Wswitch: enumeration value `b' not handled in switch */
    switch (moe) {
    case a:
	return;
    }
}

 /* -Wstrict-prototypes: function declaration isn't a prototype */
void    test3()
{
}