summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/nested-func-1.m
blob: 7a182bd938e6872b964fd0646f392ab8095e6d9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Test basic nested C function functionality within ObjC
   methods.  */
/* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
/* { dg-options "-lobjc" } */
/* { dg-do run } */
#include <stdio.h>
#include <objc/objc.h>
#include <objc/Object.h>

int bappy (int (*blargh) (int a, int b, int c))
{
  return blargh (4, 7, 2) + 3;
}

@interface Foo: Object
+ (int)foo;
@end

@implementation Foo
+ (int)foo
{
  int blargh (int a, int b, int c)
  {
    return a * b + c;
  }
  return bappy (blargh);
}
@end

int main () 
{
  int f = [Foo foo];
  if (f != 33)
    abort ();

  return 0;
}