Debian Codegraph @

gcc/testsuite/g++.dg/uninit-pred-5.C

raw
1 // { dg-do compile }
2 // { dg-options "-O2 -Wuninitialized" }
3
4 typedef int size_t;
5 typedef struct {
6 } max_align_t;
7 typedef struct tree_node *tree;
8 struct ht_identifier {
9 char str;
10 int len;
11 };
12 struct cpp_hashnode {
13 ht_identifier ident;
14 };
15 tree get_identifier_with_length(char *, size_t);
16 struct cpp_reader *parse_in;
17 typedef int edit_distance_t;
18 edit_distance_t get_edit_distance(char *);
19 template < typename > struct edit_distance_traits;
20 edit_distance_t get_edit_distance_cutoff(size_t);
21 template < typename GOAL_TYPE, typename CANDIDATE_TYPE > class best_match {
22 public:
23 typedef CANDIDATE_TYPE candidate_t;
24 typedef edit_distance_traits< candidate_t > candidate_traits;
25 best_match(GOAL_TYPE)
26 : m_goal(), m_goal_len(), m_best_candidate(), m_best_distance() {}
27 void consider(candidate_t candidate) {
28 size_t candidate_len = candidate_traits::get_length(candidate);
29 char candidate_str;
30 edit_distance_t dist = get_edit_distance(&candidate_str);
31 bool is_better = false;
32 if (dist)
33 is_better = true;
34 if (is_better) {
35 m_best_candidate = candidate;
36 m_best_candidate_len = candidate_len;
37 }
38 }
39 void set_best_so_far(CANDIDATE_TYPE) {}
40 candidate_t get_best_meaningful_candidate() {
41 edit_distance_t __trans_tmp_1;
42 if (m_best_candidate) {
43 size_t candidate_len = m_best_candidate_len;
44 __trans_tmp_1 = get_edit_distance_cutoff(candidate_len); // { dg-warning "may be used uninitialized" }
45 }
46 edit_distance_t cutoff = __trans_tmp_1;
47 if (cutoff)
48 ;
49 return m_best_candidate;
50 }
51 char m_goal;
52 size_t m_goal_len;
53 candidate_t m_best_candidate;
54 edit_distance_t m_best_distance;
55 size_t m_best_candidate_len;
56 };
57 template <> struct edit_distance_traits< tree > {
58 static size_t get_length(tree);
59 };
60 class name_hint {};
61 class best_macro_match : public best_match< tree, cpp_hashnode * > {
62 public:
63 best_macro_match(cpp_reader *);
64 };
65 struct c_binding {
66 tree id;
67 c_binding *prev;
68 };
69 struct c_scope {
70 c_scope *outer;
71 c_binding bindings;
72 } * current_scope;
73 tree lookup_name_fuzzy_name;
74 void lookup_name_fuzzy() {
75 bool consider_implementation_names = 0;
76 best_match< tree, tree > bm(lookup_name_fuzzy_name);
77 for (c_scope *scope = current_scope; current_scope;
78 scope = scope->outer)
79 for (c_binding *binding = &scope->bindings; binding;
80 binding = binding->prev)
81 if (!consider_implementation_names)
82 bm.consider(binding->id);
83 best_macro_match bmm(parse_in);
84 cpp_hashnode *best_macro = bmm.get_best_meaningful_candidate();
85 if (best_macro) {
86 char id = best_macro->ident.str;
87 tree macro_as_identifier =
88 get_identifier_with_length(&id, best_macro->ident.len);
89 bm.set_best_so_far(macro_as_identifier);
90 }
91 tree best = bm.get_best_meaningful_candidate();
92 if (best)
93 name_hint();
94 }