Home | History | Annotate | Download | only in jni
      1 // PR c++/7050
      2 // { dg-do run }
      3 
      4 extern "C" void abort(void);
      5 
      6 #define CI(stmt) try { stmt; abort(); } catch (int) { }
      7 
      8 struct has_destructor
      9 {
     10     ~has_destructor() { }
     11 };
     12 
     13 struct no_destructor
     14 {
     15 };
     16 
     17 int PI(int& i) { return i++; }
     18 
     19 int main(int argc, char *argv[])
     20 {
     21     (argc+1 ? has_destructor() : throw 0);
     22     CI((argc+1 ? throw 0 : has_destructor()));
     23     CI((0 ? has_destructor() : throw 0));
     24     CI((1 ? throw 0 : has_destructor()));
     25     (0 ? throw 0 : has_destructor());
     26     (1 ? has_destructor() : throw 0);
     27 
     28     (argc+1 ? no_destructor() : throw 0);
     29     CI((argc+1 ? throw 0 : no_destructor()));
     30     CI((0 ? no_destructor() : throw 0));
     31     CI((1 ? throw 0 : no_destructor()));
     32     (0 ? throw 0 : no_destructor());
     33     (1 ? no_destructor() : throw 0);
     34 
     35     int i = 1;
     36     CI(throw PI(i));
     37     if (i != 2) abort();
     38 
     39     (1 ? 0 : throw PI(i));
     40     if (i != 2) abort();
     41 
     42     CI(0 ? 0 : throw PI(i));
     43     if (i != 3) abort();
     44 
     45     CI(0 ? has_destructor() : throw PI(i));
     46     if (i != 4) abort();
     47     (argc+1 ? has_destructor() : throw PI(i));
     48     if (i != 4) abort();
     49 
     50     i = 1;
     51     CI(throw i++);
     52     if (i != 2) abort();
     53 
     54     (1 ? 0 : throw i++);
     55     if (i != 2) abort();
     56 
     57     CI(0 ? 0 : throw i++);
     58     if (i != 3) abort();
     59 
     60     CI(0 ? has_destructor() : throw i++);
     61     if (i != 4) abort();
     62     (argc+1 ? has_destructor() : throw i++);
     63     if (i != 4) abort();
     64 }
     65