summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog60
-rw-r--r--gcc/Makefile.in47
-rw-r--r--gcc/c-config-lang.in26
-rwxr-xr-xgcc/configure33
-rw-r--r--gcc/configure.in28
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/config-lang.in2
-rw-r--r--gcc/doc/gty.texi29
-rw-r--r--gcc/doc/sourcebuild.texi13
-rw-r--r--gcc/gengtype-lex.l2
-rw-r--r--gcc/gengtype.c168
-rw-r--r--gcc/gengtype.h2
-rw-r--r--gcc/objc/config-lang.in2
-rw-r--r--gcc/treelang/ChangeLog7
-rw-r--r--gcc/treelang/config-lang.in3
15 files changed, 341 insertions, 87 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8117485ac6f..7d40ca1b7e0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -95,6 +95,66 @@ Thu Jul 11 11:31:12 2002 J"orn Rennecke <joern.rennecke@superh.com>
(emit_move_sequence): Don't directly split DImode constants on 32-bit
targets.
+2002-07-11 Tim Josling <tej@melbpc.org.au>
+
+ Remove front end hard coding from gengtype.c.
+
+ * Makefile.in
+ (STAGESTUFF): add gtyp-gen.h
+ (GTFILES): Remove front end specific files.
+ (GTFILES_FILES_LANGS): New, from configure..
+ (GTFILES_FILES_FILES): Likewise.
+ (GTFILES_LANG_DIR_NAMES): Likewise.
+ (GTFILES_SRCDIR): Likewise.
+ (gtyp-gen.h): Build from configure information.
+ (s-gtype): Remove command line parameters from gengtype.
+ (gengtype.o): Remove dependency on GTFILES. Depend on gtyp-gen.h.
+ (mostlyclean): Delete files generated by and for gengtype.
+
+ * c-config-lang.in: New file.
+
+ * configure.in (all_gtfiles_files_langs): New. Accumulate files
+ for each language.
+ (all_gtfiles_files_files): New. Accumulate language for each file
+ accumulated.
+ (gtfiles): Pick up value for C.
+ (srcdir): AC-SUBST this variable.
+ (all_gtfiles_files_langs): AC-SUBST this variable.
+ (all_gtfiles_files_files): AC-SUBST this variable.
+
+ * configure: Regenerate.
+
+ * gengtype-lex.l (parse_file): Make parameter const.
+
+ * gengtype.c (toplevel): include gtyp-gen.h.
+ (BASE_FILE_<language> unnamed enum): Delete.
+ (lang_names): Delete (replaced by gtyp-gen.h)
+ (lang_dir_names): From gtyp-gen.h, replaces lang_names; changed
+ all references.
+ (NUM_GT_FILES): New.
+ (NUM_LANG_FILES): New.
+ (srcdir_len): New.
+ (NUM_BASE_FILES): Change calculation.
+ (open_base_files): Change prototype to avoid warning.
+ (startswith): Delete.
+ (get_file_basename): Iterate through generated language list not
+ hard coded list.
+ (get_base_file_bitmap): Use generated list of files and languages.
+ (close_output_files): Add prototype to rmove warning.
+ (main): Iterate through list of generated files from gtyp-gen.h
+ rather than command line paramaters. Ignore duplicated file
+ names.
+
+ * gengtype.h (parse_file): Amend prototype for const parameter.
+
+ * doc/sourcebuild.texi: Document gtfiles variable.
+
+ * doc/gty.texi: Document changes to gtfiles variable for front
+ ends.
+
+ * objc/config-lang.in (gtfiles): Add files needed for objc front
+ end.
+
2002-07-10 Roger Sayle <roger@eyesopen.com>
PR c/2454
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index e1e5a618735..d8315d44686 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -755,7 +755,7 @@ STAGESTUFF = *$(objext) insn-flags.h insn-config.h insn-codes.h \
insn-output.c insn-recog.c insn-emit.c insn-extract.c insn-peep.c \
insn-attr.h insn-attrtab.c insn-opinit.c insn-constants.h tm-preds.h \
tree-check.h \
- s-flags s-config s-codes s-mlib s-under s-genrtl s-gtype \
+ s-flags s-config s-codes s-mlib s-under s-genrtl s-gtype gtyp-gen.h \
s-output s-recog s-emit s-extract s-peep s-check \
s-attr s-attrtab s-opinit s-preds s-constants s-crt0 \
genemit$(build_exeext) genoutput$(build_exeext) genrecog$(build_exeext) \
@@ -1823,11 +1823,14 @@ GTFILES = $(GCONFIG_H) $(srcdir)/location.h \
$(srcdir)/profile.c $(srcdir)/regclass.c $(srcdir)/reg-stack.c \
$(srcdir)/sdbout.c $(srcdir)/stmt.c $(srcdir)/stor-layout.c \
$(srcdir)/tree.c $(srcdir)/varasm.c \
- $(srcdir)/c-objc-common.c $(srcdir)/c-common.c $(srcdir)/c-parse.in \
$(out_file) \
- $(srcdir)/c-decl.c $(srcdir)/c-pragma.c \
@all_gtfiles@
+GTFILES_FILES_LANGS = @all_gtfiles_files_langs@
+GTFILES_FILES_FILES = @all_gtfiles_files_files@
+GTFILES_LANG_DIR_NAMES = @subdirs@
+GTFILES_SRCDIR = @srcdir@
+
gtype-desc.h gtype-desc.c gt-except.h gt-function.h : s-gtype; @true
gt-integrate.h gt-stmt.h gt-tree.h gt-varasm.h gt-emit-rtl.h : s-gtype; @true
gt-explow.h gt-stor-layout.h gt-regclass.h gt-lists.h : s-gtype; @true
@@ -1837,8 +1840,35 @@ gt-reg-stack.h gt-dependence.h : s-gtype ; @true
gt-c-common.h gt-c-decl.h gt-c-parse.h gt-c-pragma.h : s-gtype; @true
gt-c-objc-common.h gtype-c.h gt-location.h : s-gtype ; @true
-s-gtype: gengtype$(build_exeext) $(GTFILES)
- ./gengtype $(GTFILES)
+gtyp-gen.h: Makefile
+ echo "/* This file is machine generated. Do not edit. */" > tmp-gtyp.h
+ echo "static const char *srcdir = " >> tmp-gtyp.h
+ echo "\"$(GTFILES_SRCDIR)\"" >> tmp-gtyp.h
+ echo ";" >> tmp-gtyp.h
+ echo "static const char *lang_files[] = {" >> tmp-gtyp.h
+ ll="$(GTFILES_FILES_FILES)"; \
+ for f in $$ll; do \
+ echo "\"$$f\", "; done >> tmp-gtyp.h
+ echo "NULL};" >> tmp-gtyp.h
+ echo "static const char *langs_for_lang_files[] = {" >> tmp-gtyp.h
+ ff="$(GTFILES_FILES_LANGS)"; \
+ for f in $$ff; do \
+ echo "\"$$f\", " ; done >> tmp-gtyp.h
+ echo "NULL};" >> tmp-gtyp.h
+ echo "static const char *all_files[] = {" >> tmp-gtyp.h
+ gf="$(GTFILES)"; \
+ for f in $$gf; do \
+ echo "\"$$f\", "; done >> tmp-gtyp.h
+ echo " NULL};" >> tmp-gtyp.h
+ echo "static const char *lang_dir_names[] = { \"c\", " >> tmp-gtyp.h
+ gf="$(GTFILES_LANG_DIR_NAMES)"; \
+ for l in $$gf; do \
+ echo "\"$$l\", "; done >> tmp-gtyp.h
+ echo "NULL};" >> tmp-gtyp.h
+ $(SHELL) $(srcdir)/move-if-change tmp-gtyp.h gtyp-gen.h
+
+s-gtype: gengtype$(build_exeext)
+ ./gengtype
$(STAMP) s-gtype
#
@@ -1977,7 +2007,7 @@ gengtype$(build_exeext) : gengtype.o gengtype-lex.o gengtype-yacc.o \
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
gengtype.o gengtype-lex.o gengtype-yacc.o $(HOST_LIBS)
-gengtype.o : gengtype.c gengtype.h $(HCONFIG_H) $(SYSTEM_H) real.h
+gengtype.o : gengtype.c gengtype.h $(HCONFIG_H) $(SYSTEM_H) real.h gtyp-gen.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) \
$(srcdir)/gengtype.c $(OUTPUT_OPTION)
@@ -2534,6 +2564,11 @@ mostlyclean: $(INTL_MOSTLYCLEAN) lang.mostlyclean
-rm -f gcc.vrs gcc.kys gcc.tps gcc.pgs gcc.fns
# Delete core dumps.
-rm -f core */core
+# Delete file generated for gengtype.c
+ -rm -f gtyp-gen.h
+# Delete files generated by gengtype.c
+ -rm -f gtype-*
+ -rm -f gt-*
# Delete all files made by compilation
# that don't exist in the distribution.
diff --git a/gcc/c-config-lang.in b/gcc/c-config-lang.in
new file mode 100644
index 00000000000..c0a786f53fd
--- /dev/null
+++ b/gcc/c-config-lang.in
@@ -0,0 +1,26 @@
+# Top level configure fragment for GNU C - C language.
+# Copyright (C) 1994, 1995, 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+#This file is part of GCC.
+
+#GCC is free software; you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation; either version 2, or (at your option)
+#any later version.
+
+#GCC is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU General Public License for more details.
+
+#You should have received a copy of the GNU General Public License
+#along with GCC; see the file COPYING. If not, write to
+#the Free Software Foundation, 59 Temple Place - Suite 330,
+#Boston, MA 02111-1307, USA.
+
+# This file c-config-lang.c is a special pseudo config-lang.in file
+# for the language C. It has limited use, specifically to record the
+# files used by C that have garbage collection GTY macros in them
+# which therefore need to be scanned by gengtype.c.
+
+gtfiles="\$(srcdir)/c-lang.c \$(srcdir)/c-parse.in \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-pragma.c \$(srcdir)/c-objc-common.c"
diff --git a/gcc/configure b/gcc/configure
index 1c95475aaba..cf0ea626af8 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -2244,7 +2244,7 @@ EOF
fi
# Find some useful tools
-for ac_prog in mawk gawk nawk awk
+for ac_prog in gawk mawk nawk awk
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
@@ -8168,6 +8168,9 @@ all_outputs='Makefile intl/Makefile fixinc/Makefile gccbug mklibgcc mkheaders'
all_lang_makefiles=
# Files for gengtype
all_gtfiles="$config_gtfiles"
+# Files for gengtype with language
+all_gtfiles_files_langs=
+all_gtfiles_files_files=
# Add the language fragments.
# Languages are added via two mechanisms. Some information must be
@@ -8208,9 +8211,31 @@ do
all_stagestuff="$all_stagestuff $stagestuff"
all_outputs="$all_outputs $outputs"
all_gtfiles="$all_gtfiles $gtfiles"
+ for f in .. $gtfiles
+ do
+ if test $f != ".."
+ then
+ all_gtfiles_files_langs="$all_gtfiles_files_langs ${s} "
+ all_gtfiles_files_files="$all_gtfiles_files_files ${f} "
+ fi
+ done
fi
done
+# Pick up gtfiles for c
+gtfiles=
+s="c"
+. ${srcdir}/c-config-lang.in
+all_gtfiles="$all_gtfiles $gtfiles"
+for f in .. $gtfiles
+do
+ if test $f != ".."
+ then
+ all_gtfiles_files_langs="$all_gtfiles_files_langs ${s} "
+ all_gtfiles_files_files="$all_gtfiles_files_files ${f} "
+ fi
+done
+
check_languages=
for language in .. $all_languages
do
@@ -8406,6 +8431,9 @@ ${CONFIG_SHELL-/bin/sh} $srcdir/configure.frag $srcdir "$subdirs" "$dep_host_xma
+
+
+
# Echo that links are built
if test x$host = x$target
then
@@ -8668,9 +8696,12 @@ s%@dollar@%$dollar%g
s%@slibdir@%$slibdir%g
s%@objdir@%$objdir%g
s%@subdirs@%$subdirs%g
+s%@srcdir@%$srcdir%g
s%@all_boot_languages@%$all_boot_languages%g
s%@all_compilers@%$all_compilers%g
s%@all_gtfiles@%$all_gtfiles%g
+s%@all_gtfiles_files_langs@%$all_gtfiles_files_langs%g
+s%@all_gtfiles_files_files@%$all_gtfiles_files_files%g
s%@all_lang_makefiles@%$all_lang_makefiles%g
s%@all_languages@%$all_languages%g
s%@all_stagestuff@%$all_stagestuff%g
diff --git a/gcc/configure.in b/gcc/configure.in
index 2b6de1780ad..da47e022cad 100644
--- a/gcc/configure.in
+++ b/gcc/configure.in
@@ -2408,6 +2408,9 @@ all_outputs='Makefile intl/Makefile fixinc/Makefile gccbug mklibgcc mkheaders'
all_lang_makefiles=
# Files for gengtype
all_gtfiles="$config_gtfiles"
+# Files for gengtype with language
+all_gtfiles_files_langs=
+all_gtfiles_files_files=
# Add the language fragments.
# Languages are added via two mechanisms. Some information must be
@@ -2448,9 +2451,31 @@ do
all_stagestuff="$all_stagestuff $stagestuff"
all_outputs="$all_outputs $outputs"
all_gtfiles="$all_gtfiles $gtfiles"
+ for f in .. $gtfiles
+ do
+ if test $f != ".."
+ then
+ all_gtfiles_files_langs="$all_gtfiles_files_langs ${s} "
+ all_gtfiles_files_files="$all_gtfiles_files_files ${f} "
+ fi
+ done
fi
done
+# Pick up gtfiles for c
+gtfiles=
+s="c"
+. ${srcdir}/c-config-lang.in
+all_gtfiles="$all_gtfiles $gtfiles"
+for f in .. $gtfiles
+do
+ if test $f != ".."
+ then
+ all_gtfiles_files_langs="$all_gtfiles_files_langs ${s} "
+ all_gtfiles_files_files="$all_gtfiles_files_files ${f} "
+ fi
+done
+
check_languages=
for language in .. $all_languages
do
@@ -2578,9 +2603,12 @@ ${CONFIG_SHELL-/bin/sh} $srcdir/configure.frag $srcdir "$subdirs" "$dep_host_xma
# Substitute configuration variables
AC_SUBST(subdirs)
+AC_SUBST(srcdir)
AC_SUBST(all_boot_languages)
AC_SUBST(all_compilers)
AC_SUBST(all_gtfiles)
+AC_SUBST(all_gtfiles_files_langs)
+AC_SUBST(all_gtfiles_files_files)
AC_SUBST(all_lang_makefiles)
AC_SUBST(all_languages)
AC_SUBST(all_stagestuff)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e2e1836a235..7042e77e153 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -18,6 +18,12 @@
* pt.c (template_parm_this_level_p, push_template_decl_real):
Pass depth as int pointer.
+2002-07-11 Tim Josling <tej@melbpc.org.au>
+
+ Remove front end hard coding from gengtype.c.
+
+ * config-lang.in (gtfiles): Add files needed for this front end.
+
2002-07-10 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (unqualified_name_lookup_error): Declare it.
diff --git a/gcc/cp/config-lang.in b/gcc/cp/config-lang.in
index ba3708bebb3..eeebb1aac57 100644
--- a/gcc/cp/config-lang.in
+++ b/gcc/cp/config-lang.in
@@ -34,4 +34,4 @@ stagestuff="g++\$(exeext) g++-cross\$(exeext) cc1plus\$(exeext)"
target_libs="${libstdcxx_version} target-gperf"
-gtfiles="\$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/lex.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/parse.y \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/spew.c \$(srcdir)/cp/tree.c"
+gtfiles="\$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/lex.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/parse.y \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/spew.c \$(srcdir)/cp/tree.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-pragma.c"
diff --git a/gcc/doc/gty.texi b/gcc/doc/gty.texi
index 02b1b3913f8..37e87c63e7a 100644
--- a/gcc/doc/gty.texi
+++ b/gcc/doc/gty.texi
@@ -228,14 +228,31 @@ things you need to do:
@enumerate
@item
-You need to add the file to the list of source files the type machinery
-scans. For a back-end file, this is usually done automatically; if not,
-you should add it to @code{config_gtfiles} in the appropriate port's
-entries in @file{config.gcc}. For a front-end file, this is done by
-adding the filename to the @code{gtfiles} variable defined in
-@file{config-lang.in}. For other files, this is done by adding the
+You need to add the file to the list of source files the type
+machinery scans. There are three cases:
+
+@enumerate a
+@item
+For a back-end file, this is usually done
+automatically; if not, you should add it to @code{config_gtfiles} in
+the appropriate port's entries in @file{config.gcc}.
+
+@item
+For files shared by all front ends, this is done by adding the
filename to the @code{GTFILES} variable in @file{Makefile.in}.
+@item
+For any other file used by a front end, this is done by adding the
+filename to the @code{gtfiles} variable defined in
+@file{config-lang.in}. For C, the file is @file{c-config-lang.in}.
+This list should include all files that have GTY macros in them that
+are used in that front end, other than those defined in the previous
+list items. For example, it is common for front end writers to use
+@file{c-common.c} and other files from the C front end, and these
+should be included in the @file{gtfiles} variable for such front ends.
+
+@end enumerate
+
@item
You need to include the file that the type machinery will generate in
the source file you just changed. The file will be called
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 24ed26be88d..9904b52fae9 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -610,9 +610,10 @@ codes.
@node Front End Config
@subsubsection The Front End @file{config-lang.in} File
-Each language subdirectory contains a @file{config-lang.in} file.
-This file is a shell script that may define some variables describing
-the language:
+Each language subdirectory contains a @file{config-lang.in} file. In
+addition the main directory contains @file{c-config-lang.in}, which
+contains limited information for the C language. This file is a shell
+script that may define some variables describing the language:
@table @code
@item language
@@ -655,6 +656,12 @@ by @file{configure} substituting values in them. This mechanism can
be used to create a file @file{@var{language}/Makefile} from
@file{@var{language}/Makefile.in}, but this is deprecated, building
everything from the single @file{gcc/Makefile} is preferred.
+@item gtfiles
+If defined, a space-separated list of files that should be scanned by
+gengtype.c to generate the garbage collection tables and routines for
+this language. This excludes the files that are common to all front
+ends. @xref{Type Information}.
+
@end table
@node Back End
diff --git a/gcc/gengtype-lex.l b/gcc/gengtype-lex.l
index 6a212627bc1..24e0ad47981 100644
--- a/gcc/gengtype-lex.l
+++ b/gcc/gengtype-lex.l
@@ -305,7 +305,7 @@ yyerror (s)
void
parse_file (fname)
- char *fname;
+ const char *fname;
{
yyin = fopen (fname, "r");
lexer_line.file = fname;
diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index b52d4a88d6a..d661e38440d 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -21,6 +21,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "hconfig.h"
#include "system.h"
#include "gengtype.h"
+#include "gtyp-gen.h"
/* Nonzero iff an error has occurred. */
static int hit_error = 0;
@@ -518,18 +519,16 @@ static outf_p output_files;
source file. */
outf_p header_file;
-enum {
- BASE_FILE_C,
- BASE_FILE_OBJC,
- BASE_FILE_CPLUSPLUS,
- BASE_FILE_TREELANG,
- BASE_FILE_COBOL
-};
+/* Number of files specified in gtfiles. */
+#define NUM_GT_FILES (ARRAY_SIZE (all_files) - 1)
-static const char *const lang_names[] = {
- "c", "objc", "cp", "treelang", "cobol", "f", "ada", "java"
-};
-#define NUM_BASE_FILES ARRAY_SIZE (lang_names)
+/* Number of files in the language files array. */
+#define NUM_LANG_FILES (ARRAY_SIZE (lang_files) - 1)
+
+/* Length of srcdir name. */
+static int srcdir_len = 0;
+
+#define NUM_BASE_FILES (ARRAY_SIZE (lang_dir_names) - 1)
outf_p base_files[NUM_BASE_FILES];
static outf_p create_file PARAMS ((const char *, const char *));
@@ -610,6 +609,8 @@ oprintf VPARAMS ((outf_p o, const char *format, ...))
/* Open the global header file and the language-specific header files. */
+static void open_base_files PARAMS((void));
+
static void
open_base_files ()
{
@@ -618,8 +619,8 @@ open_base_files ()
header_file = create_file ("GCC", "gtype-desc.h");
for (i = 0; i < NUM_BASE_FILES; i++)
- base_files[i] = create_file (lang_names[i],
- xasprintf ("gtype-%s.h", lang_names[i]));
+ base_files[i] = create_file (lang_dir_names[i],
+ xasprintf ("gtype-%s.h", lang_dir_names[i]));
/* gtype-desc.c is a little special, so we create it here. */
{
@@ -641,9 +642,6 @@ open_base_files ()
}
}
-#define startswith(len, c, s) \
- ((size_t)(len) >= strlen (s) && memcmp (c, s, strlen (s)) == 0)
-
/* Determine the pathname to F relative to $(srcdir). */
static const char *
@@ -652,29 +650,35 @@ get_file_basename (f)
{
size_t len;
const char *basename;
+ unsigned i;
- /* Determine the output file name. */
- len = strlen (f);
basename = strrchr (f, '/');
- if (basename == NULL)
- basename = f;
- else
- basename++;
- if (startswith (basename - f, basename-2, "f/"))
- basename -= 2;
- else if (startswith (basename - f, basename-3, "cp/"))
- basename -= 3;
- else if (startswith (basename - f, basename-4, "ada/"))
- basename -= 4;
- else if (startswith (basename - f, basename-5, "java/"))
- basename -= 5;
- else if (startswith (basename - f, basename-5, "objc/"))
- basename -= 5;
- else if (startswith (basename - f, basename-9, "treelang/"))
- basename -= 9;
- else if (startswith (basename - f, basename-6, "cobol/"))
- basename -= 6;
-
+
+ if (!basename)
+ return f;
+
+ len = strlen (f);
+ basename++;
+
+ for (i = 1; i < NUM_BASE_FILES; i++)
+ {
+ const char * s1;
+ const char * s2;
+ int l1;
+ int l2;
+ s1 = basename - strlen (lang_dir_names [i]) - 1;
+ s2 = lang_dir_names [i];
+ l1 = strlen (s1);
+ l2 = strlen (s2);
+ if (l1 >= l2 && !memcmp (s1, s2, l2))
+ {
+ basename -= l2 + 1;
+ if ((basename - f - 1) != srcdir_len)
+ abort (); /* Match is wrong - should be preceded by $srcdir. */
+ break;
+ }
+ }
+
return basename;
}
@@ -692,31 +696,47 @@ get_base_file_bitmap (input_file)
{
const char *basename = get_file_basename (input_file);
const char *slashpos = strchr (basename, '/');
- size_t len = strlen (basename);
+ unsigned j;
+ unsigned k;
+ unsigned bitmap;
- if (slashpos != NULL)
+ if (slashpos)
{
size_t i;
- for (i = 0; i < NUM_BASE_FILES; i++)
- if ((size_t)(slashpos - basename) == strlen (lang_names [i])
- && memcmp (basename, lang_names[i], strlen (lang_names[i])) == 0)
- return 1 << i;
+ for (i = 1; i < NUM_BASE_FILES; i++)
+ if ((size_t)(slashpos - basename) == strlen (lang_dir_names [i])
+ && memcmp (basename, lang_dir_names[i], strlen (lang_dir_names[i])) == 0)
+ {
+ /* It's in a language directory, set that language. */
+ bitmap = 1 << i;
+ return bitmap;
+ }
+
+ abort (); /* Should have found the language. */
}
- else if (strcmp (basename, "c-lang.c") == 0)
- return 1 << BASE_FILE_C;
- else if (strcmp (basename, "c-parse.in") == 0
- || strcmp (basename, "c-tree.h") == 0
- || strcmp (basename, "c-decl.c") == 0
- || strcmp (basename, "c-objc-common.c") == 0)
- return 1 << BASE_FILE_C | 1 << BASE_FILE_OBJC;
- else if (startswith (len, basename, "c-common.c"))
- return 1 << BASE_FILE_C | 1 << BASE_FILE_OBJC| 1 << BASE_FILE_CPLUSPLUS
- | 1 << BASE_FILE_TREELANG | 1 << BASE_FILE_COBOL;
- else if (startswith (len, basename, "c-"))
- return 1 << BASE_FILE_C | 1 << BASE_FILE_OBJC | 1 << BASE_FILE_CPLUSPLUS;
- else
- return (1 << NUM_BASE_FILES) - 1;
- abort ();
+
+ /* If it's in any config-lang.in, then set for the languages
+ specified. */
+
+ bitmap = 0;
+
+ for (j = 0; j < NUM_LANG_FILES; j++)
+ {
+ if (!strcmp(input_file, lang_files[j]))
+ {
+ for (k = 0; k < NUM_BASE_FILES; k++)
+ {
+ if (!strcmp(lang_dir_names[k], langs_for_lang_files[j]))
+ bitmap |= (1 << k);
+ }
+ }
+ }
+
+ /* Otherwise, set all languages. */
+ if (!bitmap)
+ bitmap = (1 << NUM_BASE_FILES) - 1;
+
+ return bitmap;
}
/* An output file, suitable for definitions, that can see declarations
@@ -765,8 +785,8 @@ get_output_file_with_visibility (input_file)
size_t i;
for (i = 0; i < NUM_BASE_FILES; i++)
- if (memcmp (basename, lang_names[i], strlen (lang_names[i])) == 0
- && basename[strlen(lang_names[i])] == '/')
+ if (memcmp (basename, lang_dir_names[i], strlen (lang_dir_names[i])) == 0
+ && basename[strlen(lang_dir_names[i])] == '/')
return base_files[i];
output_name = "gtype-desc.c";
@@ -798,6 +818,8 @@ get_output_file_name (input_file)
/* Copy the output to its final destination,
but don't unnecessarily change modification times. */
+static void close_output_files PARAMS ((void));
+
static void
close_output_files ()
{
@@ -1896,11 +1918,14 @@ write_gc_roots (variables)
extern int main PARAMS ((int argc, char **argv));
int
main(argc, argv)
- int argc;
- char **argv;
+ int argc ATTRIBUTE_UNUSED;
+ char **argv ATTRIBUTE_UNUSED;
{
- int i;
+ unsigned i;
static struct fileloc pos = { __FILE__, __LINE__ };
+ unsigned j;
+
+ srcdir_len = strlen (srcdir);
do_typedef ("CUMULATIVE_ARGS",
create_scalar_type ("CUMULATIVE_ARGS",
@@ -1914,8 +1939,21 @@ main(argc, argv)
strlen ("void"))),
&pos);
- for (i = 1; i < argc; i++)
- parse_file (argv[i]);
+ for (i = 0; i < NUM_GT_FILES; i++)
+ {
+ int dupflag = 0;
+ /* Omit if already seen. */
+ for (j = 0; j < i; j++)
+ {
+ if (!strcmp (all_files[i], all_files[j]))
+ {
+ dupflag = 1;
+ break;
+ }
+ }
+ if (!dupflag)
+ parse_file (all_files[i]);
+ }
if (hit_error != 0)
exit (1);
diff --git a/gcc/gengtype.h b/gcc/gengtype.h
index cd158ff26ba..20e496da05c 100644
--- a/gcc/gengtype.h
+++ b/gcc/gengtype.h
@@ -138,7 +138,7 @@ extern void note_yacc_type PARAMS ((options_p o, pair_p fields,
extern int yylex PARAMS((void));
extern void yyerror PARAMS ((const char *));
extern int yyparse PARAMS ((void));
-extern void parse_file PARAMS ((char *name));
+extern void parse_file PARAMS ((const char *name));
/* Output file handling. */
diff --git a/gcc/objc/config-lang.in b/gcc/objc/config-lang.in
index 62ff455f3d1..d79ac13e978 100644
--- a/gcc/objc/config-lang.in
+++ b/gcc/objc/config-lang.in
@@ -33,4 +33,4 @@ stagestuff=""
target_libs=target-libobjc
-gtfiles="\$(srcdir)/objc/objc-act.h"
+gtfiles="\$(srcdir)/objc/objc-act.h \$(srcdir)/c-parse.in \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-objc-common.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-pragma.c \$(srcdir)/c-parse.in"
diff --git a/gcc/treelang/ChangeLog b/gcc/treelang/ChangeLog
index 59e06b5a34e..685c258a4f3 100644
--- a/gcc/treelang/ChangeLog
+++ b/gcc/treelang/ChangeLog
@@ -1,3 +1,10 @@
+2002-07-11 Tim Josling <tej@melbpc.org.au>
+
+ Remove front end hard coding from gengtype.c.
+
+ * config-lang.in (gtfiles): Add files needed for this front
+ end.
+
2002-07-09 Tim Josling <tej@melbpc.org.au>
Support new attributes regime (Fix for PR c++/7099).
diff --git a/gcc/treelang/config-lang.in b/gcc/treelang/config-lang.in
index 6392b69bddf..4f5a82e1668 100644
--- a/gcc/treelang/config-lang.in
+++ b/gcc/treelang/config-lang.in
@@ -36,5 +36,4 @@ diff_excludes="-x lex.c -x parse.c -x parse.h"
headers=
build_by_default="no"
-gtfiles="\$(srcdir)/treelang/tree1.c \$(srcdir)/treelang/treelang.h"
-
+gtfiles="\$(srcdir)/c-decl.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/treelang/tree1.c \$(srcdir)/treelang/treelang.h"