2011-08-19 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / gencheck.c
blob0d1907c8125012350602206898dee60c99f92cf5
1 /* Generate check macros for tree codes.
2 Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2007, 2008
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "bconfig.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
26 #define DEFTREECODE(SYM, NAME, TYPE, LEN) #SYM,
27 #define END_OF_BASE_TREE_CODES
29 static const char *const tree_codes[] = {
30 #include "all-tree.def"
31 (char*) 0
34 #undef DEFTREECODE
35 #undef END_OF_BASE_TREE_CODES
37 static void usage (void);
39 static void
40 usage (void)
42 fputs ("Usage: gencheck\n", stderr);
45 int
46 main (int argc, char ** ARG_UNUSED (argv))
48 int i, j;
50 switch (argc)
52 case 1:
53 break;
55 default:
56 usage ();
57 return (1);
60 puts ("/* This file is generated using gencheck. Do not edit. */\n");
61 puts ("#ifndef GCC_TREE_CHECK_H");
62 puts ("#define GCC_TREE_CHECK_H\n");
64 /* Print macros for checks based on each of the tree code names. However,
65 since we include the tree nodes from all languages, we must check
66 for duplicate names to avoid defining the same macro twice. */
67 for (i = 0; tree_codes[i]; i++)
69 for (j = 0; j < i; j++)
70 if (strcmp (tree_codes[i], tree_codes[j]) == 0)
71 break;
73 if (i == j)
74 printf ("#define %s_CHECK(t)\tTREE_CHECK (t, %s)\n",
75 tree_codes[i], tree_codes[i]);
78 puts ("\n#endif /* GCC_TREE_CHECK_H */");
79 return 0;