]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gencheck.c
backport: As described in http://gcc.gnu.org/ml/gcc/2012-08/msg00015.html...
[thirdparty/gcc.git] / gcc / gencheck.c
CommitLineData
12b195d9 1/* Generate check macros for tree codes.
66647d44 2 Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2007, 2008
3d7aafde 3 Free Software Foundation, Inc.
12b195d9 4
1322177d 5This file is part of GCC.
12b195d9 6
1322177d
LB
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9dcd6f09 9Software Foundation; either version 3, or (at your option) any later
1322177d 10version.
12b195d9 11
1322177d
LB
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
12b195d9
ML
16
17You should have received a copy of the GNU General Public License
9dcd6f09
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
12b195d9 20
4977bab6 21#include "bconfig.h"
12b195d9 22#include "system.h"
4977bab6
ZW
23#include "coretypes.h"
24#include "tm.h"
12b195d9 25
9a238586 26#define DEFTREECODE(SYM, NAME, TYPE, LEN) #SYM,
c0ed0531 27#define END_OF_BASE_TREE_CODES
12b195d9 28
27c38fbe 29static const char *const tree_codes[] = {
c0ed0531 30#include "all-tree.def"
c4f2c499 31(char*) 0
12b195d9
ML
32};
33
c0ed0531
ILT
34#undef DEFTREECODE
35#undef END_OF_BASE_TREE_CODES
36
3d7aafde 37static void usage (void);
c1b59dce
KG
38
39static void
3d7aafde 40usage (void)
12b195d9 41{
0313e85b 42 fputs ("Usage: gencheck\n", stderr);
12b195d9
ML
43}
44
c1b59dce 45int
e18476eb 46main (int argc, char ** ARG_UNUSED (argv))
12b195d9 47{
cbdb4ba2 48 int i, j;
9ec36da5 49
12b195d9
ML
50 switch (argc)
51 {
52 case 1:
53 break;
9ec36da5 54
12b195d9
ML
55 default:
56 usage ();
c1b59dce 57 return (1);
12b195d9
ML
58 }
59
0313e85b
ZW
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");
63
cbdb4ba2
RK
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. */
12b195d9
ML
67 for (i = 0; tree_codes[i]; i++)
68 {
cbdb4ba2
RK
69 for (j = 0; j < i; j++)
70 if (strcmp (tree_codes[i], tree_codes[j]) == 0)
71 break;
72
73 if (i == j)
74 printf ("#define %s_CHECK(t)\tTREE_CHECK (t, %s)\n",
75 tree_codes[i], tree_codes[i]);
12b195d9
ML
76 }
77
0313e85b 78 puts ("\n#endif /* GCC_TREE_CHECK_H */");
12b195d9
ML
79 return 0;
80}