configure.in (--enable-c-cpplib): Uncomment.

* configure.in (--enable-c-cpplib): Uncomment.  Use AC_DEFINE
	instead of extra_c_flags.
	(--enable-c-mbchar): Use AC_DEFINE instead of extra_c_flags.
	* configure: Regenerate.
	* config.in: Regenerate.

	* cpperror.c (cpp_type2name): New function.
	* cpplex.c (lex_line): If we issued an error for an invalid
	preprocessing directive, discard that logical line.
	* cpplib.c (do_line): Call a hook function if the current file
	is renamed by #line.
	(do_ident): Pass the contents of the string, not the entire
	token, to the callback function.
	* cpplib.h (CPP_LAST_PUNCTUATOR): New #define.
	(cb.rename_file): New hook function.
	(cb.ident): Adjust prototype.
	(cpp_type2name): Prototype.
	* cppmacro.c (dump_macro_args): Correct precedence lossage.

	* cppmain.c (cb_ident): Update for changed interface.
	(cb_rename_file): New function.
	(main): Set rename callback.

From-SVN: r35593
This commit is contained in:
Zack Weinberg 2000-08-09 19:41:12 +00:00 committed by Zack Weinberg
parent 9cc82a0198
commit 9ec7291f1f
10 changed files with 356 additions and 264 deletions

View file

@ -1,3 +1,28 @@
2000-08-09 Zack Weinberg <zack@wolery.cumb.org>
* configure.in (--enable-c-cpplib): Uncomment. Use AC_DEFINE
instead of extra_c_flags.
(--enable-c-mbchar): Use AC_DEFINE instead of extra_c_flags.
* configure: Regenerate.
* config.in: Regenerate.
* cpperror.c (cpp_type2name): New function.
* cpplex.c (lex_line): If we issued an error for an invalid
preprocessing directive, discard that logical line.
* cpplib.c (do_line): Call a hook function if the current file
is renamed by #line.
(do_ident): Pass the contents of the string, not the entire
token, to the callback function.
* cpplib.h (CPP_LAST_PUNCTUATOR): New #define.
(cb.rename_file): New hook function.
(cb.ident): Adjust prototype.
(cpp_type2name): Prototype.
* cppmacro.c (dump_macro_args): Correct precedence lossage.
* cppmain.c (cb_ident): Update for changed interface.
(cb_rename_file): New function.
(main): Set rename callback.
2000-08-09 Alexandre Oliva <aoliva@redhat.com>
* caller-save.c (mark_referenced_regs): Mark partially-overwritten

View file

@ -308,6 +308,14 @@
every opportunity. This is extremely expensive. */
#undef ENABLE_GC_ALWAYS_COLLECT
/* Define if you want the preprocessor merged into the C and C++ compilers.
This mode is not ready for production use. */
#undef USE_CPPLIB
/* Define if you want the C and C++ compilers to support multibyte
character sets for source code. */
#undef MULTIBYTE_CHARS
/* Define if your compiler understands volatile. */
#undef HAVE_VOLATILE

495
gcc/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -254,22 +254,26 @@ elif test x$withval != xno; then
cpp_install_dir=$withval
fi])
dnl Disable this for the moment; the library interface is changing.
dnl # Link cpplib into the compiler proper, for C/C++/ObjC.
dnl AC_ARG_ENABLE(c-cpplib,
dnl [ --enable-c-cpplib link cpplib directly into C and C++ compilers
dnl (EXPERIMENTAL) (implies --enable-cpplib).],
dnl if test x$enable_c_cpplib != xno; then
dnl extra_c_objs="${extra_c_objs} libcpp.a"
dnl extra_cxx_objs="${extra_cxx_objs} ../libcpp.a"
dnl extra_c_flags="${extra_c_flags} -DUSE_CPPLIB=1"
dnl fi)
# Link cpplib into the compiler proper, for C/C++/ObjC.
AC_ARG_ENABLE(c-cpplib,
[ --enable-c-cpplib link cpplib directly into C and C++ compilers
(HIGHLY EXPERIMENTAL).],
if test x$enable_c_cpplib != xno; then
extra_c_objs="${extra_c_objs} libcpp.a"
extra_cxx_objs="${extra_cxx_objs} ../libcpp.a"
AC_DEFINE(USE_CPPLIB, 1,
[Define if you want the preprocessor merged into the C and C++ compilers.
This mode is not ready for production use.])
fi)
# Enable Multibyte Characters for C/C++
AC_ARG_ENABLE(c-mbchar,
[ --enable-c-mbchar Enable multibyte characters for C and C++.],
if test x$enable_c_mbchar != xno; then
extra_c_flags="${extra_c_flags} -DMULTIBYTE_CHARS=1"
AC_DEFINE(MULTIBYTE_CHARS, 1,
[Define if you want the C and C++ compilers to support multibyte
character sets for source code.])
fi)
# Enable threads

View file

@ -458,3 +458,11 @@ cpp_notice_from_errno (pfile, name)
name = "stdout";
cpp_notice (pfile, "%s: %s", name, xstrerror (errno));
}
const char *
cpp_type2name (type)
enum cpp_ttype type;
{
return (const char *) _cpp_token_spellings[type].name;
}

View file

@ -1294,7 +1294,8 @@ lex_line (pfile, list)
if (!(list->flags & LIST_OFFSET))
(abort) ();
retry:
list->file = buffer->nominal_fname;
list->line = CPP_BUF_LINE (buffer);
pfile->col_adjust = 0;
@ -1823,6 +1824,10 @@ lex_line (pfile, list)
first[1].val.node->name);
else
cpp_error (pfile, "invalid preprocessing directive");
/* Discard this line to prevent further errors from cc1. */
_cpp_clear_toklist (list);
goto retry;
}
/* Put EOF at end of known directives. This covers "directives do

View file

@ -477,7 +477,7 @@ do_line (pfile)
/* C99 raised the minimum limit on #line numbers. */
unsigned int cap = CPP_OPTION (pfile, c99) ? 2147483647 : 32767;
int action_number = 0;
int enter = 0, leave = 0;
int enter = 0, leave = 0, rename = 0;
enum cpp_ttype type;
const U_CHAR *str;
char *fname;
@ -492,7 +492,7 @@ do_line (pfile)
if (type != CPP_NUMBER || strtoul_for_line (str, len, &new_lineno))
{
cpp_error (pfile, "token after #line is not a positive integer");
goto done;
return;
}
if (CPP_PEDANTIC (pfile) && (new_lineno == 0 || new_lineno > cap))
@ -511,7 +511,7 @@ do_line (pfile)
{
cpp_error (pfile, "second token after #line is not a string");
ip->lineno = old_lineno; /* malformed #line should have no effect */
goto done;
return;
}
fname = alloca (len + 1);
@ -520,6 +520,7 @@ do_line (pfile)
if (strcmp (fname, ip->nominal_fname))
{
rename = 1;
if (!strcmp (fname, ip->inc->name))
ip->nominal_fname = ip->inc->name;
else
@ -527,7 +528,7 @@ do_line (pfile)
}
if (read_line_number (pfile, &action_number) == 0)
return;
goto done;
if (CPP_PEDANTIC (pfile))
cpp_pedwarn (pfile, "garbage at end of #line");
@ -555,13 +556,13 @@ do_line (pfile)
read_line_number (pfile, &action_number);
}
done:
if (enter && pfile->cb.enter_file)
(*pfile->cb.enter_file) (pfile);
if (leave && pfile->cb.leave_file)
(*pfile->cb.leave_file) (pfile);
done:
return;
if (rename && pfile->cb.rename_file)
(*pfile->cb.rename_file) (pfile);
}
/*
@ -610,7 +611,7 @@ do_ident (pfile)
if (str->type == CPP_STRING && _cpp_get_token (pfile)->type == CPP_EOF)
{
if (pfile->cb.ident)
(*pfile->cb.ident) (pfile, str);
(*pfile->cb.ident) (pfile, str->val.str.text, str->val.str.len);
return;
}

View file

@ -48,6 +48,7 @@ typedef struct cpp_hashnode cpp_hashnode;
/* Positions in the table. */
#define CPP_LAST_EQ CPP_MAX
#define CPP_FIRST_DIGRAPH CPP_HASH
#define CPP_LAST_PUNCTUATOR CPP_DOT_STAR
#define TTYPE_TABLE \
OP(CPP_EQ = 0, "=") \
@ -522,12 +523,13 @@ struct cpp_reader
struct {
void (*enter_file) PARAMS ((cpp_reader *));
void (*leave_file) PARAMS ((cpp_reader *));
void (*rename_file) PARAMS ((cpp_reader *));
void (*include) PARAMS ((cpp_reader *, const unsigned char *,
const unsigned char *, unsigned int, int));
void (*define) PARAMS ((cpp_reader *, cpp_hashnode *));
void (*undef) PARAMS ((cpp_reader *, cpp_hashnode *));
void (*poison) PARAMS ((cpp_reader *));
void (*ident) PARAMS ((cpp_reader *, const cpp_token *));
void (*ident) PARAMS ((cpp_reader *, const unsigned char *, unsigned int));
void (*def_pragma) PARAMS ((cpp_reader *));
} cb;
@ -693,6 +695,8 @@ extern void cpp_pedwarn_with_file_and_line PARAMS ((cpp_reader *, const char *,
extern void cpp_error_from_errno PARAMS ((cpp_reader *, const char *));
extern void cpp_notice_from_errno PARAMS ((cpp_reader *, const char *));
extern const char *cpp_type2name PARAMS ((enum cpp_ttype));
/* In cpplex.c */
extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *,
const unsigned char *, long));

View file

@ -595,7 +595,7 @@ dump_macro_args (fp, list)
unsigned int len;
len = ustrlen (param);
if (!list->flags & VAR_ARGS || ustrcmp (param, U"__VA_ARGS__"))
if (!(list->flags & VAR_ARGS) || ustrcmp (param, U"__VA_ARGS__"))
ufputs (param, fp);
if (i < list->paramc)
fputs (", ", fp);

View file

@ -39,9 +39,11 @@ static void cb_undef PARAMS ((cpp_reader *, cpp_hashnode *));
static void cb_include PARAMS ((cpp_reader *, const unsigned char *,
const unsigned char *, unsigned int, int));
static void cb_ident PARAMS ((cpp_reader *, const cpp_token *));
static void cb_ident PARAMS ((cpp_reader *, const unsigned char *,
unsigned int));
static void cb_enter_file PARAMS ((cpp_reader *));
static void cb_leave_file PARAMS ((cpp_reader *));
static void cb_rename_file PARAMS ((cpp_reader *));
static void cb_def_pragma PARAMS ((cpp_reader *));
static void do_pragma_implementation PARAMS ((cpp_reader *));
@ -90,6 +92,7 @@ main (argc, argv)
{
pfile->cb.enter_file = cb_enter_file;
pfile->cb.leave_file = cb_leave_file;
pfile->cb.rename_file = cb_rename_file;
}
if (CPP_OPTION (pfile, dump_includes))
pfile->cb.include = cb_include;
@ -132,12 +135,12 @@ main (argc, argv)
/* Callbacks */
static void
cb_ident (pfile, token)
cb_ident (pfile, str, len)
cpp_reader *pfile;
const cpp_token *token;
const unsigned char *str;
unsigned int len;
{
cpp_printf (pfile, &parse_out, "#ident \"%.*s\"\n",
(int) token->val.str.len, token->val.str.text);
cpp_printf (pfile, &parse_out, "#ident \"%.*s\"\n", (int) len, str);
}
static void
@ -208,6 +211,19 @@ cb_leave_file (pfile)
parse_out.last_fname = ip->nominal_fname;
}
static void
cb_rename_file (pfile)
cpp_reader *pfile;
{
cpp_buffer *ip = CPP_BUFFER (pfile);
cpp_printf (pfile, &parse_out, "# %u \"%s\"%s\n", ip->lineno,
ip->nominal_fname, cpp_syshdr_flags (pfile, ip));
parse_out.lineno = ip->lineno;
parse_out.last_fname = ip->nominal_fname;
}
static void
cb_def_pragma (pfile)
cpp_reader *pfile;