OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc/] [execute/] [exceptions/] [local-variables-1.m] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 307 jeremybenn
/* 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
#include <stdlib.h>
6
#include <stdio.h>
7
#import "../../../objc-obj-c++-shared/Object1.h"
8
 
9
int gi1 = 9, gi2 = 19;
10
float gf1 = 9.0, gf2 = 19.0;
11
id obj2 = nil;
12
 
13
void foo (int arg1, float *arg2)
14
{
15
  int *pi = &gi1;
16
  float *pf = &gf1;
17
  id obj1 = nil;
18
  int local1 = 45, local2 = 47;
19
  float local3 = 3.0, local4 = 4.0;
20
  register int local5 = 15;
21
  static float local6 = 16.0;
22
 
23
  @try {
24
    local1 = 123;
25
    local2 = 345;
26
    local3 = 5.0;
27
    local4 = 6.0;
28
    local5 = 17;
29
    local6 = 18.0;
30
    pi = &gi2;
31
    pf = &gf2;
32
    obj2 = obj1 = [Object new];
33
    arg1 = 17;
34
    arg2 = &gf2;
35
 
36
    @throw [Object new];
37
  }
38
  @catch (Object *obj) {
39
    if (local1 != 123 || local2 != 345 || local3 != 5.0 || local4 != 6.0
40
       || local5 != 17 || local6 != 18.0) {
41
      printf("Abort 1\n");
42
      abort();
43
    }
44
    if(pi != &gi2 || pf != &gf2) {
45
      printf("Abort 2\n");
46
      abort();
47
    }
48
    if(!obj1 || obj1 != obj2) {
49
      printf("Abort 3\n");
50
      abort();
51
    }
52
    if(arg1 != 17 || arg2 != &gf2) {
53
      printf("Abort 4\n");
54
      abort();
55
    }
56
  }
57
}
58
 
59
int main(void) {
60
  foo(15, &gf1);
61
  return 0;
62
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.