OSDN Git Service

PR c++/44157
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / uninit-pred-1_b.C
1 /* { dg-do compile } */
2 /* { dg-options "-Wuninitialized -O2" } */
3
4 typedef long long int64;
5 void incr ();
6 bool is_valid (int);
7 int  get_time ();
8
9 class A 
10 {
11 public:
12   A ();
13   ~A () {
14     if (I) delete I;
15   }
16
17 private:
18   int* I;
19 };
20
21 bool get_url (A *);
22
23 class M {
24
25  public:
26 __attribute__ ((always_inline))  int GetC (int *c)  {
27
28     A details_str;
29     if (!get_url (&details_str))
30       {
31         incr ();
32         return 1;
33       }
34
35     *c = get_time ();
36     return -1;
37   }
38
39   void do_sth();
40   void do_sth2();
41    
42   void P (int64 t)
43     {
44       int cc; /* { dg-message "note: 'cc' was declared here" } */
45       if (GetC (&cc) <= 0 ) /* return flag checked wrongly */
46         return;
47       
48       if (t && cc <= 0 )  /* { dg-warning "uninitialized" "uninitialized variable warning" } */
49         {
50           this->do_sth();
51           return;
52         }
53
54     do_sth2();
55   }
56 };
57
58 M* m; 
59 void foo(int x)
60 {
61   m = new M;
62   m->P(x);
63 }