2008-05-13 Diego Novillo <dnovillo@google.com>
[official-gcc.git] / gcc / gencheck.c
blobf8b591e875db7b64517bc4b303badbb3117979c7
1 /* Generate check macros for tree codes.
2 Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2007
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,
28 static const char *const tree_codes[] = {
29 #include "tree.def"
30 #include "c-common.def"
31 #include "gencheck.h"
32 (char*) 0
35 static void usage (void);
37 static void
38 usage (void)
40 fputs ("Usage: gencheck\n", stderr);
43 int
44 main (int argc, char ** ARG_UNUSED (argv))
46 int i, j;
48 switch (argc)
50 case 1:
51 break;
53 default:
54 usage ();
55 return (1);
58 puts ("/* This file is generated using gencheck. Do not edit. */\n");
59 puts ("#ifndef GCC_TREE_CHECK_H");
60 puts ("#define GCC_TREE_CHECK_H\n");
62 /* Print macros for checks based on each of the tree code names. However,
63 since we include the tree nodes from all languages, we must check
64 for duplicate names to avoid defining the same macro twice. */
65 for (i = 0; tree_codes[i]; i++)
67 for (j = 0; j < i; j++)
68 if (strcmp (tree_codes[i], tree_codes[j]) == 0)
69 break;
71 if (i == j)
72 printf ("#define %s_CHECK(t)\tTREE_CHECK (t, %s)\n",
73 tree_codes[i], tree_codes[i]);
76 puts ("\n#endif /* GCC_TREE_CHECK_H */");
77 return 0;