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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [builtins-13.c] - Blame information for rev 867

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

Line No. Rev Author Line
1 149 jeremybenn
/* Copyright (C) 2003  Free Software Foundation.
2
 
3
   Verify that the malloc-like __builtin_ allocation functions are
4
   correctly aliased by the compiler.
5
 
6
   Written by Roger Sayle, 12th April 2003.  */
7
 
8
/* { dg-do link } */
9
 
10
typedef __SIZE_TYPE__ size_t;
11
 
12
extern void abort (void);
13
extern void *malloc (size_t);
14
extern void *calloc (size_t,size_t);
15
 
16
extern void link_error (void);
17
 
18
static int x;
19
 
20
void test1(void)
21
{
22
  int *ptr1, *ptr2;
23
 
24
  ptr1 = &x;
25
  ptr2 = (int*) malloc (sizeof (int));
26
 
27
  *ptr1 = 12;
28
  *ptr2 = 8;
29
 
30
  if (*ptr1 != 12)
31
    link_error();
32
}
33
 
34
void test2(void)
35
{
36
  int *ptr1, *ptr2;
37
 
38
  ptr1 = &x;
39
  ptr2 = (int*) calloc (1, sizeof (int));
40
 
41
  *ptr1 = 12;
42
  *ptr2 = 8;
43
 
44
  if (*ptr1 != 12)
45
    link_error ();
46
}
47
 
48
int main()
49
{
50
  test1 ();
51
  test2 ();
52
  return 0;
53
}
54
 
55
#ifndef __OPTIMIZE__
56
void link_error (void)
57
{
58
  abort ();
59
}
60
#endif
61
 

powered by: WebSVN 2.1.0

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