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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [warn-addr-cmp.c] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* { dg-do compile } */
2
/* { dg-require-weak "" } */
3
/* { dg-options "-Waddress" } */
4
/* Warning when addr convert to bool always gives known result.
5
   Ada/Pascal programmers sometimes write 0-param functions without
6
   (), and might as well warn on variables, too.  */
7
 
8
int func (void);
9
extern int var;
10
int weak_func (void) __attribute__ ((weak));
11
extern int weak_var __attribute__ ((weak));
12
 
13
int
14
test_func_cmp (void)
15
{
16
  if (func)      /* { dg-warning "the address of 'func'" } */
17
    return 1;
18
  if (!func)     /* { dg-warning "the address of 'func'" } */
19
    return 1;
20
  if (&var)     /* { dg-warning "the address of 'var'" } */
21
    return 1;
22
  if (!&var)     /* { dg-warning "the address of 'var'" } */
23
    return 1;
24
  if (weak_func)
25
    return 1;
26
  if (!weak_func)
27
    return 1;
28
  if (&weak_var)
29
    return 1;
30
  if (!&weak_var)
31
    return 1;
32
  return 0;
33
}
34
 
35
/* Test equality with 0 on the right hand side.  */
36
int
37
test_func_cmp_rhs_zero (void)
38
{
39
  if (func == 0)     /* { dg-warning "the address of 'func'" } */
40
    return 1;
41
  if (func != 0)     /* { dg-warning "the address of 'func'" } */
42
    return 1;
43
  if (&var == 0)     /* { dg-warning "the address of 'var'" } */
44
    return 1;
45
  if (&var != 0)     /* { dg-warning "the address of 'var'" } */
46
    return 1;
47
  if (weak_func == 0)
48
    return 1;
49
  if (weak_func != 0)
50
    return 1;
51
  if (&weak_var == 0)
52
    return 1;
53
  if (&weak_var != 0)
54
    return 1;
55
  return 0;
56
}
57
 
58
/* Test equality with 0 on the left hand side.  */
59
int
60
test_func_cmp_lhs_zero (void)
61
{
62
  if (0 == func)     /* { dg-warning "the address of 'func'" } */
63
    return 1;
64
  if (0 != func)     /* { dg-warning "the address of 'func'" } */
65
    return 1;
66
  if (0 == &var)     /* { dg-warning "the address of 'var'" } */
67
    return 1;
68
  if (0 != &var)     /* { dg-warning "the address of 'var'" } */
69
    return 1;
70
  if (0 == weak_func)
71
    return 1;
72
  if (0 != weak_func)
73
    return 1;
74
  if (0 == &weak_var)
75
    return 1;
76
  if (0 != &weak_var)
77
    return 1;
78
  return 0;
79
}

powered by: WebSVN 2.1.0

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