2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.benjamin / warn01.C
blob99b23967c84400085a8eb4af353c7cda90815b46
1 // { dg-do assemble  }
2 // { dg-options "-Wall -Weffc++" }
4 //1 g++/12952 un-named variables in a catch block
5 //Wall or Wunused should not give warnings here
6 template <class T>
7 void f (void) { 
8    try
9     {
10     }
12    catch( int)
13     {    
14     }
18 //2 g++/12923 __attribute__((__unused__)) not working for objects
19 //Weffc++ or Wunused should not report the object as an error
20 class C {
21   public:
22   C();
25 void f (void){
26   C x __attribute__ ((__unused__));
27   int y __attribute__ ((__unused__));
31 //3 g++/12982 lock should not give error here, as above
32 void setLock ();
33 void clearLock ();
35 template <class T>
36 class test {
37 public:
38    class lock
39    {
40    public:
41      lock () { setLock(); }
42      ~lock () { clearLock(); }
43    };
45   static void f (void)
46   {
47    lock local  __attribute__ ((__unused__));
48   } 
54 //4 g++/12988 neither Mutex nor AutoMutex varibles should give warnings here
55 //compile with -Weffc++ or -Wunused depending on post or pre 97r1
56 class Mutex {
57 private:
58   long counter;
59 public:
60   virtual long retcntr() {return counter;};
61   Mutex(int i = 0): counter(i) {};
62   virtual ~Mutex() {};
63 } __attribute__ ((__unused__));
65 class AutoMutex: public Mutex{
66 private:
67   long counter2;
68 public:
69   long retcntr() {return counter2;};
70   AutoMutex(int i = 0): counter2(i) {};
71   virtual ~AutoMutex() {};
72 } __attribute__ ((__unused__));
75 template <class T>
76 int foofunc(T x){
77   Mutex sm(2);
78   AutoMutex m(&sm);
79   return 0;
83 //5 sanity check to make sure other attributes cannot be used
84 class Mutex2 {
85 private:
86   long counter;
87 public:
88   virtual long retcntr() {return counter;};
89   Mutex2(int i = 0): counter(i) {};
90   virtual ~Mutex2() {};
91 } __attribute__ ((warn));  // { dg-warning "" }