// ----------------------------------------------------------------------
//
// except.cc - Do we support exceptions (try/throw/catch)?
//
// History:
//   13-Aug-1999  WEB  Initial draft, adapted from Blitz++
//   19-Aug-1999  WEB  Remove unused identifier from catch clause;
//     use macros in lieu of assorted #ifdef's
//   20-Aug-1999  WEB  Fix results for defective environment; add throw-
//     specification to the test function
//   11-Aug-2000  WEB  THROW_SPEC -> THROWS
//   25-Apr-2001  WEB  s/<ISOcxxSyntax.hh>/"ISOcxx\/ISOcxxSyntax.hh"/
//
// ----------------------------------------------------------------------


#include "ISOcxx/ISOcxxSyntax.hh"


// ----------------------------------------------------------------------
// local exception class:
// ----------------------------------------------------------------------

struct oops  { };


// ----------------------------------------------------------------------
// throwable function:
// ----------------------------------------------------------------------

int  f( int a, int b )  THROWS( (oops) )  {

  if ( b == 0 )
    THROW( oops() );
  return  a;

}  // f()


// ----------------------------------------------------------------------
// test driver:
// ----------------------------------------------------------------------

int  main()  {

  int  result( 2 );

  TRY {
    result = f( 1, 0 );
#   if defined DEFECT_NO_EXCEPTIONS
    if ( result == 1 )
      result = 0;
#   endif
  }
  CATCH( oops const )  {
    result = 0;  // exceptions working as expected
  }

  return  result;

}  // main()
