summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.benjamin/warn01.C
blob: 99b23967c84400085a8eb4af353c7cda90815b46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// { dg-do assemble  }
// { dg-options "-Wall -Weffc++" }

//1 g++/12952 un-named variables in a catch block
//Wall or Wunused should not give warnings here
template <class T>
void f (void) { 
   try
    {
    }
 
   catch( int)
    {    
    }
}

//
//2 g++/12923 __attribute__((__unused__)) not working for objects
//Weffc++ or Wunused should not report the object as an error
class C {
  public:
  C();
};

void f (void){
  C x __attribute__ ((__unused__));
  int y __attribute__ ((__unused__));
}

//
//3 g++/12982 lock should not give error here, as above
void setLock ();
void clearLock ();

template <class T>
class test {
public:
   class lock
   {
   public:
     lock () { setLock(); }
     ~lock () { clearLock(); }
   };

  static void f (void)
  {
   lock local  __attribute__ ((__unused__));
  } 

};


//
//4 g++/12988 neither Mutex nor AutoMutex varibles should give warnings here
//compile with -Weffc++ or -Wunused depending on post or pre 97r1
class Mutex {
private:
  long counter;
public:
  virtual long retcntr() {return counter;};
  Mutex(int i = 0): counter(i) {};
  virtual ~Mutex() {};
} __attribute__ ((__unused__));

class AutoMutex: public Mutex{
private:
  long counter2;
public:
  long retcntr() {return counter2;};
  AutoMutex(int i = 0): counter2(i) {};
  virtual ~AutoMutex() {};
} __attribute__ ((__unused__));


template <class T>
int foofunc(T x){
  Mutex sm(2);
  AutoMutex m(&sm);
  return 0;
}


//5 sanity check to make sure other attributes cannot be used
class Mutex2 {
private:
  long counter;
public:
  virtual long retcntr() {return counter;};
  Mutex2(int i = 0): counter(i) {};
  virtual ~Mutex2() {};
} __attribute__ ((warn));  // { dg-warning "" }