~ubuntu-branches/ubuntu/natty/diffutils/natty

« back to all changes in this revision

Viewing changes to gnulib-tests/test-stdbool.c

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2010-05-04 20:38:00 UTC
  • mfrom: (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100504203800-f67xd9rsa9xl9qqj
Tags: 1:3.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- buffer-read-only: t -*- vi: set ro: */
 
2
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
 
3
/* Test of <stdbool.h> substitute.
 
4
   Copyright (C) 2002-2007, 2009-2010 Free Software Foundation, Inc.
 
5
 
 
6
   This program is free software: you can redistribute it and/or modify
 
7
   it under the terms of the GNU General Public License as published by
 
8
   the Free Software Foundation; either version 3 of the License, or
 
9
   (at your option) any later version.
 
10
 
 
11
   This program is distributed in the hope that it will be useful,
 
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
   GNU General Public License for more details.
 
15
 
 
16
   You should have received a copy of the GNU General Public License
 
17
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
18
 
 
19
/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 
20
 
 
21
#include <config.h>
 
22
 
 
23
#include <stdbool.h>
 
24
 
 
25
#ifndef bool
 
26
 "error: bool is not defined"
 
27
#endif
 
28
#ifndef false
 
29
 "error: false is not defined"
 
30
#endif
 
31
#if false
 
32
 "error: false is not 0"
 
33
#endif
 
34
#ifndef true
 
35
 "error: true is not defined"
 
36
#endif
 
37
#if true != 1
 
38
 "error: true is not 1"
 
39
#endif
 
40
#ifndef __bool_true_false_are_defined
 
41
 "error: __bool_true_false_are_defined is not defined"
 
42
#endif
 
43
 
 
44
#if 0 /* Cannot be guaranteed with gnulib's <stdbool.h>.  */
 
45
struct s { _Bool s: 1; _Bool t; } s;
 
46
#endif
 
47
 
 
48
char a[true == 1 ? 1 : -1];
 
49
char b[false == 0 ? 1 : -1];
 
50
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
 
51
#if 0 /* Cannot be guaranteed with gnulib's <stdbool.h>, at least,
 
52
not for all compilers.  */
 
53
char d[(bool) 0.5 == true ? 1 : -1];
 
54
bool e = &s;
 
55
char f[(_Bool) 0.0 == false ? 1 : -1];
 
56
#endif
 
57
char g[true];
 
58
char h[sizeof (_Bool)];
 
59
#if 0 /* See above.  */
 
60
char i[sizeof s.t];
 
61
#endif
 
62
enum { j = false, k = true, l = false * true, m = true * 256 };
 
63
_Bool n[m];
 
64
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
 
65
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
 
66
#if 0 /* Cannot be guaranteed with gnulib's <stdbool.h>.  */
 
67
#if defined __xlc__ || defined __GNUC__
 
68
 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
 
69
    reported by James Lemley on 2005-10-05; see
 
70
    http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
 
71
    This test is not quite right, since xlc is allowed to
 
72
    reject this program, as the initializer for xlcbug is
 
73
    not one of the forms that C requires support for.
 
74
    However, doing the test right would require a run-time
 
75
    test, and that would make cross-compilation harder.
 
76
    Let us hope that IBM fixes the xlc bug, and also adds
 
77
    support for this kind of constant expression.  In the
 
78
    meantime, this test will reject xlc, which is OK, since
 
79
    our stdbool.h substitute should suffice.  We also test
 
80
    this with GCC, where it should work, to detect more
 
81
    quickly whether someone messes up the test in the
 
82
    future.  */
 
83
 char digs[] = "0123456789";
 
84
 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
 
85
#endif
 
86
#endif
 
87
/* Catch a bug in an HP-UX C compiler.  See
 
88
   http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
 
89
   http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
 
90
 */
 
91
_Bool q = true;
 
92
_Bool *pq = &q;
 
93
 
 
94
int
 
95
main ()
 
96
{
 
97
  return 0;
 
98
}