1/* Check that local variables that get modified inside the @try
2   block survive until the @catch block is reached.  */
3/* Developed by Ziemowit Laski <zlaski@apple.com>.  */
4
5/* { dg-do run } */
6/* { dg-xfail-run-if "PR23616" { *-*-* } { "-fgnu-runtime" } { "-fnext-runtime" } } */
7/* { dg-xfail-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" "-fgnu-runtime" } { "" } }
8/* { dg-prune-output ".*internal compiler error.*" } */
9/* { dg-options "-fobjc-exceptions -O2 -Wno-register" } */
10
11#include "../objc-obj-c++-shared/TestsuiteObject.m"
12#include <stdlib.h>
13#include <stdio.h>
14
15int gi1 = 9, gi2 = 19;
16float gf1 = 9.0, gf2 = 19.0;
17id obj2 = nil;
18
19void foo (int arg1, float *arg2)
20{
21  int *pi = &gi1;
22  float *pf = &gf1;
23  id obj1 = nil;
24  int local1 = 45, local2 = 47;
25  float local3 = 3.0, local4 = 4.0;
26  register int local5 = 15;
27  static float local6 = 16.0;
28
29  @try {
30    local1 = 123;
31    local2 = 345;
32    local3 = 5.0;
33    local4 = 6.0;
34    local5 = 17;
35    local6 = 18.0;
36    pi = &gi2;
37    pf = &gf2;
38    obj2 = obj1 = [TestsuiteObject new];
39    arg1 = 17;
40    arg2 = &gf2;
41
42    @throw [TestsuiteObject new];
43  }
44  @catch (TestsuiteObject *obj) {
45   if (local1 != 123 || local2 != 345 || local3 != 5.0
46       || local4 != 6.0 || local5 != 17 || local6 != 18.0) {
47     printf("Abort 1\n");
48     abort();
49   }
50   if (pi != &gi2 || pf != &gf2) {
51     printf("Abort 2\n");
52     abort();
53   }
54   if (!obj1 || obj1 != obj2) {
55     printf("Abort 3\n");
56     abort();
57   }
58   if (arg1 != 17 || arg2 != &gf2) {
59     printf("Abort 4\n");
60     abort();
61   }
62  }
63}
64
65int main(void) {
66  foo(15, &gf1);
67  return 0;
68}
69
70