This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

throw specifiers


Hi,
I attach a file, suitable for insertion in the test suite, which checks that
bad throw specifiers are suitably diagnosed. The 19990117 snapshot fails in
several ways. I'm working from the CD2, so if something relevant has changed
between that and the standard, I'd appreciate enlightenment. If someone can
confirm the testcase as OK, then I'll set to work fixing the compiler.

All the issues are in [except.spec] (15.4)

Here I the non-compliance issues,
1) A type in an exception specifier shall not be an incomplete type or pointer
or reference to an incomplete type, other than pointer to cv void.

2) all declarations and the definition of a function shall have the same set of
type-ids in the exception specifier. egcs requires the type-id's in the same
order, and so considers throw(int, char) to be different to throw(char, int).

3) If a virtual function is overridden, the overrider shall have an exception
specifier which only throws those allowed by the overridden function (i.e. is a
subset).

4) types shall not be defined in a throw specifier. Is a throw specifier a
scope?

The 19990117 snapshot produces the following output for the test case,
nathan@manao:671>ss-g++ -c throwspec.C    
throwspec.C: In function `void fn()':
throwspec.C:21: declaration of `fn()' throws different exceptions
throwspec.C:20: previous declaration here

Fails on all four counts :-(

Can someone confirm whether my understanding is correct?

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light      
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
// Build don't link:

// Copyright (C) 1999 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 19 Jan 1999 <nathan@acm.org>

// Determine that throw specifiers are checked correctly.

// [except.spec] 1, a type in an exception specifier shall not be incomplete,
// or pointer or ref to incomplete
struct X; // ERROR - forward declaration
void fn1() throw(X);  // ERROR - incomplete type
void fn2() throw(X *); // ERROR - incomplete type
void fn3() throw(X &); // ERROR - incomplete type
void fn4() throw(void); // ERROR - incomplete type
// except for cv pointer to void
void fn5() throw(void *);

// [except.spec] 2, exception specifiers must be the same set of types (but
// can be reordered)
void fn() throw(int, char);
void fn() throw(char, int){}

// [except.spec] 3, virtual function overriders shall throw a subset of the
// overridden function
struct E {};
struct F : public E {};
struct A
{
  virtual void foo() throw();
  virtual void baz() throw(double, int);
  virtual void bar();
  virtual void qux() throw(E);
  virtual void quux() throw(F);
};

struct B : A
{
  virtual void foo() throw(int);  // ERROR - not in base function
  virtual void baz() throw(double);
  virtual void bar(int) throw(int);
  virtual void qux() throw(F);
  virtual void quux() throw(E);   // ERROR - not in base function
};

// [except.spec] 5, types shall not be defined in exception specifiers
void fn6() throw(struct Z {}); // ERROR - types shall not be defined



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]