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" } */
9 struct tree *car, *cdr, *wfl;
11 struct { int renp:1; int rtnp:1; int rpnp:1; } flags;
13 typedef struct tree *tree;
14 #define NULL_TREE ((tree)0)
19 CALL_EXPR, NEW_ARRAY_EXPR, NEW_CLASS_EXPR, CONVERT_EXPR,
20 ARRAY_REF, CONDITIONAL_EXPR, STRING_CST, EXPR_WITH_FILE_LOCATION
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)
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)
39 extern tree current_class, this_identifier_node;
40 extern tree super_identifier_node, length_identifier_node;
42 tree resolve_and_layout (tree, tree);
43 tree lookup_field_wrapper (tree, tree);
46 qualify_ambiguous_name (id)
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;
55 qual = EXPR_WFL_QUALIFICATION (id);
57 qual_wfl = QUAL_WFL (qual);
58 switch (TREE_CODE (qual_wfl))
61 qual_wfl = TREE_OPERAND (qual_wfl, 0);
62 if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
64 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
65 qual_wfl = QUAL_WFL (qual);
69 qual = TREE_CHAIN (qual);
70 new_array_found = again = 1;
74 qual_wfl = TREE_OPERAND (qual_wfl, 0);
77 while (TREE_CODE (qual_wfl) == ARRAY_REF)
78 qual_wfl = TREE_OPERAND (qual_wfl, 0);
84 name = EXPR_WFL_NODE (qual_wfl);
85 ptr_type = current_class;
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. */
94 if (!this_found && !super_found && (decl = IDENTIFIER_LOCAL_VALUE (name)))
96 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
97 QUAL_RESOLUTION (qual) = decl;
99 else if ((decl = lookup_field_wrapper (ptr_type, name))
100 || (new_array_found && name == length_identifier_node))
102 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
103 QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
105 else if ((decl = resolve_and_layout (name, NULL_TREE)))
107 RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
108 QUAL_RESOLUTION (qual) = decl;
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;
114 RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;