daily update
[external/binutils.git] / gdb / testsuite / gdb.modula2 / unbounded1.c
1 /* This test script is part of GDB, the GNU debugger.
2
3    Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14  
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18    */
19
20
21 typedef struct {
22    char *_m2_contents;
23    int _m2_high;
24 } unbounded;
25
26
27 static int
28 foo (unbounded a)
29 {
30   if (a._m2_contents[3] == 'd')
31     return 0;
32   else
33     return 1;
34 }
35
36
37 main ()
38 {
39   unbounded t;
40   char data[6];
41   char *input = "abcde";
42   int i;
43
44   t._m2_contents = (char *)&data;
45   t._m2_high = 4;
46   /* include the <nul> in the string, even though high is set to 4.  */
47   
48   for (i=0; i<6; i++)
49     data[i] = input[i];
50   return foo (t);
51 }