| 1 |
// { dg-do assemble } |
| 2 |
// { dg-options "-Wall -Weffc++" } |
| 3 |
|
| 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 |
} |
| 11 |
|
| 12 |
catch( int) |
| 13 |
{ |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
// |
| 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(); |
| 23 |
}; |
| 24 |
|
| 25 |
void f (void){ |
| 26 |
C x __attribute__ ((__unused__)); |
| 27 |
int y __attribute__ ((__unused__)); |
| 28 |
} |
| 29 |
|
| 30 |
// |
| 31 |
//3 g++/12982 lock should not give error here, as above |
| 32 |
void setLock (); |
| 33 |
void clearLock (); |
| 34 |
|
| 35 |
template <class T> |
| 36 |
class test { |
| 37 |
public: |
| 38 |
class lock |
| 39 |
{ |
| 40 |
public: |
| 41 |
lock () { setLock(); } |
| 42 |
~lock () { clearLock(); } |
| 43 |
}; |
| 44 |
|
| 45 |
static void f (void) |
| 46 |
{ |
| 47 |
lock local __attribute__ ((__unused__)); |
| 48 |
} |
| 49 |
|
| 50 |
}; |
| 51 |
|
| 52 |
|
| 53 |
// |
| 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__)); |
| 64 |
|
| 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__)); |
| 73 |
|
| 74 |
|
| 75 |
template <class T> |
| 76 |
int foofunc(T x){ |
| 77 |
Mutex sm(2); |
| 78 |
AutoMutex m(&sm); |
| 79 |
return 0; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 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 "" } |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|