OSDN Git Service

YA spurious-uninitialized-variable-warning test
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / uninit-A.c
1 /* Inspired by part of java/parse.y.
2    May be a real bug in CSE. */
3
4 /* { dg-do compile } */
5 /* { dg-options "-O2 -Wall" } */
6
7 struct tree
8 {
9     struct tree *car, *cdr, *wfl;
10     int code;
11     struct { int renp:1; int rtnp:1; int rpnp:1; } flags;
12 };
13 typedef struct tree *tree;
14 #define NULL_TREE ((tree)0)
15
16 /* Codes */
17 enum
18 {
19     CALL_EXPR, NEW_ARRAY_EXPR, NEW_CLASS_EXPR, CONVERT_EXPR,
20     ARRAY_REF, CONDITIONAL_EXPR, STRING_CST, EXPR_WITH_FILE_LOCATION
21 };
22
23 /* Flags */
24 #define RESOLVE_EXPRESSION_NAME_P(t) ((t)->flags.renp)
25 #define RESOLVE_TYPE_NAME_P(t) ((t)->flags.rtnp)
26 #define RESOLVE_PACKAGE_NAME_P(t) ((t)->flags.rpnp)
27
28 /* Macros */
29 #define EXPR_WFL_QUALIFICATION(t) ((t)->wfl)
30 #define QUAL_WFL(t) ((t)->wfl)
31 #define EXPR_WFL_NODE(t) ((t)->wfl)
32 #define TREE_CODE(t) ((t)->code)
33 #define TREE_OPERAND(t,x) ((t)->car)
34 #define CLASSTYPE_SUPER(t) ((t)->car)
35 #define IDENTIFIER_LOCAL_VALUE(t) ((t)->car)
36 #define TREE_CHAIN(t) ((t)->cdr)
37 #define QUAL_RESOLUTION(t) ((t)->cdr)
38
39 extern tree current_class, this_identifier_node;
40 extern tree super_identifier_node, length_identifier_node;
41
42 tree resolve_and_layout (tree, tree);
43 tree lookup_field_wrapper (tree, tree);
44
45 void
46 qualify_ambiguous_name (id)
47      tree id;
48 {
49   tree qual, qual_wfl, decl;
50   tree name;     /* { dg-bogus "name" "uninitialized variable warning" { xfail *-*-* } } */
51   tree ptr_type; /* { dg-bogus "ptr_type" "uninitialized variable warning" { xfail *-*-* } } */
52   int again, new_array_found = 0;
53   int super_found = 0, this_found = 0;
54
55   qual = EXPR_WFL_QUALIFICATION (id);
56   do {
57     qual_wfl = QUAL_WFL (qual);
58     switch (TREE_CODE (qual_wfl))
59       {
60       case CALL_EXPR:
61         qual_wfl = TREE_OPERAND (qual_wfl, 0);
62         if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
63           {
64             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
65             qual_wfl = QUAL_WFL (qual);
66           }
67         break;
68       case NEW_ARRAY_EXPR:
69         qual = TREE_CHAIN (qual);
70         new_array_found = again = 1;
71         continue;
72       case NEW_CLASS_EXPR:
73       case CONVERT_EXPR:
74         qual_wfl = TREE_OPERAND (qual_wfl, 0);
75         break;
76       case ARRAY_REF:
77         while (TREE_CODE (qual_wfl) == ARRAY_REF)
78           qual_wfl = TREE_OPERAND (qual_wfl, 0);
79         break;
80       default:
81         break;
82       }
83
84     name = EXPR_WFL_NODE (qual_wfl);
85     ptr_type = current_class;
86     again = 0;
87
88   } while (again);
89
90   /* If you put straightforward uses of name and ptr_type here
91      instead of the if-else sequence below, the warnings go away.
92      Therefore I suspect a real bug. */
93   
94   if (!this_found && !super_found && (decl = IDENTIFIER_LOCAL_VALUE (name)))
95     {
96       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
97       QUAL_RESOLUTION (qual) = decl;
98     }
99   else if ((decl = lookup_field_wrapper (ptr_type, name))
100            || (new_array_found && name == length_identifier_node))
101     {
102       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
103       QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
104     }
105   else if ((decl = resolve_and_layout (name, NULL_TREE)))
106     {
107       RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
108       QUAL_RESOLUTION (qual) = decl;
109     }
110   else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
111            || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF)
112     RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
113   else 
114     RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
115 }