Home | History | Annotate | Download | only in jni
      1 /* { dg-do run } */
      2 
      3 #include <stdarg.h>
      4 #include "check.h"
      5 
      6 #ifndef ALIGNMENT
      7 #define ALIGNMENT	64
      8 #endif
      9 
     10 typedef int aligned __attribute__((aligned(ALIGNMENT)));
     11 
     12 int global;
     13 
     14 void
     15 bar (char *p, int size)
     16 {
     17   __builtin_strncpy (p, "good", size);
     18 }
     19 
     20 class Base {};
     21 
     22 struct A : virtual public Base
     23 {
     24   A() {}
     25 };
     26 
     27 struct B {};
     28 
     29 void
     30 foo (const char *fmt, ...) throw (B,A)
     31 {
     32   va_list arg;
     33   char *p;
     34   aligned i;
     35   int size;
     36   double x;
     37 
     38   va_start (arg, fmt);
     39   size = va_arg (arg, int);
     40   if (size != 5)
     41     abort ();
     42   p = (char *) __builtin_alloca (size + 1);
     43 
     44   x = va_arg (arg, double);
     45   if (x != 5.0)
     46     abort ();
     47 
     48   bar (p, size);
     49   if (__builtin_strncmp (p, "good", size) != 0)
     50     {
     51 #ifdef DEBUG
     52       p[size] = '\0';
     53       printf ("Failed: %s != good\n", p);
     54 #endif
     55       abort ();
     56     }
     57 
     58   if (check_int (&i,  __alignof__(i)) != i)
     59     abort ();
     60 
     61   throw A();
     62 
     63   va_end (arg);
     64 }
     65 
     66 int
     67 main()
     68 {
     69   try {	foo ("foo", 5, 5.0); }
     70   catch (A& a) { }
     71   return 0;
     72 }
     73