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