1 |
305 |
jeremybenn |
// { dg-do assemble }
|
2 |
|
|
|
3 |
|
|
// Copyright (C) 1999 Free Software Foundation, Inc.
|
4 |
|
|
// Contributed by Nathan Sidwell 19 Jan 1999
|
5 |
|
|
|
6 |
|
|
// Determine that throw specifiers are checked correctly.
|
7 |
|
|
|
8 |
|
|
// [except.spec] 1, a type in an exception specifier shall not be incomplete,
|
9 |
|
|
// or pointer or ref to incomplete
|
10 |
|
|
struct X; // { dg-error "" } forward declaration.*
|
11 |
|
|
void fn1() throw(X); // { dg-error "" } invalid use of undefined type
|
12 |
|
|
void fn2() throw(X *); // { dg-error "" } invalid use of undefined type
|
13 |
|
|
void fn3() throw(X &); // { dg-error "" } invalid use of undefined tyoe
|
14 |
|
|
void fn4() throw(void); // { dg-error "" } invalid use of void expression
|
15 |
|
|
void fn5() throw(void &); // { dg-error "" } invalid type // ERROR - invalid use of void
|
16 |
|
|
// except for cv pointer to void
|
17 |
|
|
void fn6() throw(void *); // ok -- pointer to void
|
18 |
|
|
void fn7() throw(void const *); // ok -- pointer to cv void
|
19 |
|
|
|
20 |
|
|
template void fny() throw(T); // ok (so far)
|
21 |
|
|
template<> void fny() throw(int); // ok
|
22 |
|
|
template<> void fny() throw(void); // { dg-error "" } invalid use of void
|
23 |
|
|
|
24 |
|
|
template void fnx(T *) throw(T){} // { dg-error "" } invalid use of void expression
|
25 |
|
|
void fx()
|
26 |
|
|
{
|
27 |
|
|
fnx((int *)0);
|
28 |
|
|
fnx((void *)0); // { dg-message "instantiated from here" }
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
// [except.spec] 2, exception specifiers must be the same set of types (but
|
32 |
|
|
// can be reordered)
|
33 |
|
|
void baz1() throw(int, char);
|
34 |
|
|
void baz1() throw(char, int){} // reordering is ok
|
35 |
|
|
|
36 |
|
|
void baz2() throw(int, char);
|
37 |
|
|
void baz2() throw(int, char, int){} // duplicates are ignored
|
38 |
|
|
|
39 |
|
|
typedef int Int;
|
40 |
|
|
void baz3() throw(int, char);
|
41 |
|
|
void baz3() throw(Int, char){} // typedefs are the same type ...
|
42 |
|
|
|
43 |
|
|
void baz4() throw(int, Int, char); // ... so this is a duplicate
|
44 |
|
|
void baz4() throw(Int, char){}
|
45 |
|
|
|
46 |
|
|
void fna() throw(int, char); // { dg-error "" } to previous declaration
|
47 |
|
|
void fna() throw(int const, char); // { dg-error "" } declaration different exceptions // ERROR - to previous declaration
|
48 |
|
|
void fna() throw(int){} // { dg-error "" } declaration different exceptions
|
49 |
|
|
|
50 |
|
|
void fnb() throw(int, char); // { dg-error "" } to previous declaration
|
51 |
|
|
void fnb() throw(char){} // { dg-error "" } declaration different exceptions
|
52 |
|
|
|
53 |
|
|
void fnc() throw(int, char); // { dg-error "" } to previous declaration
|
54 |
|
|
void fnc() throw(char, int, float){} // { dg-error "" } declaration different exceptions
|
55 |
|
|
|
56 |
|
|
void fnd() throw(); // { dg-error "" } to previous declaration
|
57 |
|
|
void fnd() throw(char){} // { dg-error "" } declaration different exceptions
|
58 |
|
|
|
59 |
|
|
void fne() throw(char); // { dg-error "" } to previous declaration
|
60 |
|
|
void fne() throw(){} // { dg-error "" } declaration different exceptions
|
61 |
|
|
|
62 |
|
|
void fnf(); // { dg-error "" } to previous declaration
|
63 |
|
|
void fnf() throw(char){} // { dg-error "" } declaration different exceptions
|
64 |
|
|
|
65 |
|
|
void fng() throw(char); // { dg-error "" } to previous declaration
|
66 |
|
|
void fng(){} // { dg-error "" } declaration different exceptions
|
67 |
|
|
|
68 |
|
|
void fnh() throw(int, char); // { dg-error "" } to previous declaration
|
69 |
|
|
void fnh() throw(int, float){} // { dg-error "" } declaration different exceptions
|
70 |
|
|
|
71 |
|
|
void fni() throw(int, char); // { dg-error "" } to previous declaration
|
72 |
|
|
void fni() throw(float, char){} // { dg-error "" } declaration different exceptions
|
73 |
|
|
|
74 |
|
|
// [except.spec] 3, virtual function overriders shall throw a subset of the
|
75 |
|
|
// overridden function
|
76 |
|
|
struct E {};
|
77 |
|
|
struct F : public E {};
|
78 |
|
|
struct F1 : public E {};
|
79 |
|
|
struct G : public F, F1 {};
|
80 |
|
|
struct H : private E {};
|
81 |
|
|
struct A
|
82 |
|
|
{
|
83 |
|
|
virtual void foo() throw(); // { dg-error "" } overriding
|
84 |
|
|
virtual void baz() throw(double, int);
|
85 |
|
|
virtual void bar();
|
86 |
|
|
virtual void qux() throw(E);
|
87 |
|
|
virtual void qux(int) throw(E const *); // { dg-error "" } overriding (pedantically)
|
88 |
|
|
virtual void quux() throw(F); // { dg-error "" } overriding
|
89 |
|
|
virtual void quux(int) throw(F *); // { dg-error "" } overriding
|
90 |
|
|
virtual void wibble() throw(E); // { dg-error "" } overriding
|
91 |
|
|
virtual void wobble() throw(E *); // { dg-error "" } overriding
|
92 |
|
|
virtual void wobble(int) throw(E *); // { dg-error "" } overriding
|
93 |
|
|
virtual void wabble(int) throw(E *);
|
94 |
|
|
virtual void wubble(int) throw(E *, H *);
|
95 |
|
|
virtual ~A() throw(); // { dg-error "" } overriding
|
96 |
|
|
};
|
97 |
|
|
|
98 |
|
|
struct B : A
|
99 |
|
|
{
|
100 |
|
|
virtual void foo() throw(int); // { dg-error "" } looser throw - A::foo
|
101 |
|
|
virtual void baz() throw(double); // ok subset
|
102 |
|
|
virtual void bar(int) throw(int); // ok not overriding
|
103 |
|
|
virtual void qux() throw(F); // ok subset
|
104 |
|
|
virtual void qux(int) throw(F *); // { dg-error "" } looser (pedantically)
|
105 |
|
|
virtual void quux() throw(E); // { dg-error "" } looser throw - A::quux()
|
106 |
|
|
virtual void quux(int) throw(E *); // { dg-error "" } looser throw - A::quux(int)
|
107 |
|
|
virtual void wibble() throw(E *); // { dg-error "" } looser throw - A::wibble
|
108 |
|
|
virtual void wobble() throw(G *); // { dg-error "" } looser throw - A::wobble()
|
109 |
|
|
virtual void wobble(int) throw(H *); // { dg-error "" } looser throw - A::wobble(int)
|
110 |
|
|
virtual void wubble(int) throw(H *); // ok
|
111 |
|
|
virtual void wabble(int) throw(F1 *, F *); // ok
|
112 |
|
|
};
|
113 |
|
|
|
114 |
|
|
struct A1
|
115 |
|
|
{
|
116 |
|
|
virtual void foo() throw(int);
|
117 |
|
|
virtual void bar() throw(); // { dg-error "" } overriding
|
118 |
|
|
virtual ~A1() throw(int);
|
119 |
|
|
};
|
120 |
|
|
|
121 |
|
|
struct B1 : A
|
122 |
|
|
{
|
123 |
|
|
};
|
124 |
|
|
|
125 |
|
|
struct C : A, A1
|
126 |
|
|
{ // { dg-error "" } looser throw - A::~A()
|
127 |
|
|
virtual void foo() throw(int); // { dg-error "" } looser throw - A::foo
|
128 |
|
|
virtual void bar() throw(int); // { dg-error "" } looser throw - A1::bar
|
129 |
|
|
};
|
130 |
|
|
|
131 |
|
|
struct D : A, A1
|
132 |
|
|
{
|
133 |
|
|
virtual ~D() throw(int); // { dg-error "" } looser throw - A::~A()
|
134 |
|
|
};
|
135 |
|
|
|
136 |
|
|
// [except.spec] 5, types shall not be defined in exception specifiers
|
137 |
|
|
void fn8() throw(struct Z {}); // { dg-error "" } ANSI C++ forbids
|