Commit 3df89291 by Neil Booth Committed by Neil Booth

Makefile.in: Update.

	* Makefile.in: Update.
	* c-common.c (flag_iso, flag_undef, cb_register_builtins,
	builtin_define_std): New.
	(c_common_init): Register CPP builtins callback.
	* c-common.h (flag_iso, flag_undef): New.
	* c-decl.c (c_decode_option): Set flag_iso and flag_undef.
	* c-lex.c: Don't include target.h.
	(cb_register_builtins): Move to c-common.c.
	(init_c_lex): Don't register hook here.
	* c-lex.h (builtin_define, builtin_assert, builtin_define_std): New.
	(cpp_define, cpp_assert): Remove.
	* gcc.c (cc1_options): Pass -undef to front end.
	* target-def.h (TARGET_REGISTER_CPP_BUILTINS): Remove.
	(TARGET_INITIALIZER): Update.
	* target.h (struct cpp_reader): Don't predeclare.
	(struct gcc_target): Remove cpp builtin hook.
	* tree.c (default_register_cpp_builtins): Remove.
cp:
	* cp-tree.h (flag_ansi): Remove.
	* decl2.c (flag_ansi): Remove.
	(cxx_decode_option): Set flag_iso and flag_undef.
doc:
	* tm.texi: Update.

From-SVN: r53349
parent 32fa4565
2002-05-09 Neil Booth <neil@daikokuya.demon.co.uk>
* Makefile.in: Update.
* c-common.c (flag_iso, flag_undef, cb_register_builtins,
builtin_define_std): New.
(c_common_init): Register CPP builtins callback.
* c-common.h (flag_iso, flag_undef): New.
* c-decl.c (c_decode_option): Set flag_iso and flag_undef.
* c-lex.c: Don't include target.h.
(cb_register_builtins): Move to c-common.c.
(init_c_lex): Don't register hook here.
* c-lex.h (builtin_define, builtin_assert, builtin_define_std): New.
(cpp_define, cpp_assert): Remove.
* gcc.c (cc1_options): Pass -undef to front end.
* target-def.h (TARGET_REGISTER_CPP_BUILTINS): Remove.
(TARGET_INITIALIZER): Update.
* target.h (struct cpp_reader): Don't predeclare.
(struct gcc_target): Remove cpp builtin hook.
* tree.c (default_register_cpp_builtins): Remove.
doc:
* tm.texi: Update.
2002-05-09 Neil Booth <neil@daikokuya.demon.co.uk>
* cppexp.c (_cpp_expand_op_stack): Set op_limit.
2002-05-09 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
......
......@@ -1158,7 +1158,7 @@ c-typeck.o : c-typeck.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \
c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \
langhooks.h langhooks-def.h c-common.h
c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) c-lex.h \
debug.h $(C_TREE_H) c-common.h $(TARGET_H) \
debug.h $(C_TREE_H) c-common.h \
c-pragma.h input.h intl.h flags.h toplev.h output.h \
mbchar.h $(CPPLIB_H) $(EXPR_H) $(TM_P_H)
c-objc-common.o : c-objc-common.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \
......
......@@ -184,6 +184,14 @@ tree c_global_trees[CTI_MAX];
/* Nonzero if prepreprocessing only. */
int flag_preprocess_only;
/* Nonzero if an ISO standard was selected. It rejects macros in the
user's namespace. */
int flag_iso;
/* Nonzero if -undef was given. It suppresses target built-in macros
and assertions. */
int flag_undef;
/* Nonzero means don't recognize the non-ANSI builtin functions. */
int flag_no_builtin;
......@@ -275,6 +283,8 @@ static int if_stack_space = 0;
/* Stack pointer. */
static int if_stack_pointer = 0;
static void cb_register_builtins PARAMS ((cpp_reader *));
static tree handle_packed_attribute PARAMS ((tree *, tree, tree, int,
bool *));
static tree handle_nocommon_attribute PARAMS ((tree *, tree, tree, int,
......@@ -4298,6 +4308,73 @@ c_common_post_options ()
warning ("-Wmissing-format-attribute ignored without -Wformat");
}
/* Hook that registers front end and target-specific built-ins. */
static void
cb_register_builtins (pfile)
cpp_reader *pfile;
{
/* -undef turns off target-specific built-ins. */
if (flag_undef)
return;
if (c_language == clk_cplusplus)
{
if (SUPPORTS_ONE_ONLY)
cpp_define (pfile, "__GXX_WEAK__");
else
cpp_define (pfile, "__GXX_WEAK__=0");
}
/* A straightforward target hook doesn't work, because of problems
linking that hook's body when part of non-C front ends. */
#ifdef TARGET_REGISTER_CPP_BUILTINS
TARGET_REGISTER_CPP_BUILTINS;
#endif
}
/* Pass an object-like macro. If it doesn't lie in the user's
namespace, defines it unconditionally. Otherwise define a version
with two leading underscores, and another version with two leading
and trailing underscores, and define the original only if an ISO
standard was not nominated.
e.g. passing "unix" defines "__unix", "__unix__" and possibly
"unix". Passing "_mips" defines "__mips", "__mips__" and possibly
"_mips". */
void
builtin_define_std (macro)
const char *macro;
{
size_t len = strlen (macro);
char *buff = alloca (len + 5);
char *p = buff + 2;
char *q = p + len;
/* prepend __ (or maybe just _) if in user's namespace. */
memcpy (p, macro, len + 1);
if (*p != '_')
*--p = '_';
if (p[1] != '_' && !ISUPPER (p[1]))
*--p = '_';
cpp_define (parse_in, p);
/* If it was in user's namespace... */
if (p != buff + 2)
{
/* Define the original macro if permitted. */
if (!flag_iso)
cpp_define (parse_in, macro);
/* Define the macro with leading and following __. */
if (q[-1] != '_')
*q++ = '_';
if (q[-2] != '_')
*q++ = '_';
*q = '\0';
cpp_define (parse_in, p);
}
}
/* Front end initialization common to C, ObjC and C++. */
const char *
c_common_init (filename)
......@@ -4322,6 +4399,10 @@ c_common_init (filename)
options->warn_multichar = warn_multichar;
/* Register preprocessor built-ins before calls to
cpp_main_file. */
cpp_get_callbacks (parse_in)->register_builtins = cb_register_builtins;
/* NULL is passed up to toplev.c and we exit quickly. */
if (flag_preprocess_only)
{
......
......@@ -378,6 +378,14 @@ extern c_language_kind c_language;
/* Nonzero if prepreprocessing only. */
extern int flag_preprocess_only;
/* Nonzero if an ISO standard was selected. It rejects macros in the
user's namespace. */
extern int flag_iso;
/* Nonzero if -undef was given. It suppresses target built-in macros
and assertions. */
extern int flag_undef;
/* Nonzero means give string constants the type `const char *', rather
than `char *'. */
......
......@@ -541,6 +541,7 @@ c_decode_option (argc, argv)
flag_no_nonansi_builtin = 1;
flag_noniso_default_format_attributes = 0;
flag_isoc99 = 0;
flag_iso = 1;
}
else if (!strcmp (argstart, "iso9899:199409"))
{
......@@ -558,6 +559,7 @@ c_decode_option (argc, argv)
flag_noniso_default_format_attributes = 0;
flag_isoc99 = 1;
flag_isoc94 = 1;
flag_iso = 1;
}
else if (!strcmp (argstart, "gnu89"))
{
......@@ -636,6 +638,8 @@ c_decode_option (argc, argv)
;
else if (!strcmp (p, "-ansi"))
goto iso_1990;
else if (!strcmp (p, "-undef"))
flag_undef = 1;
else if (!strcmp (p, "-Werror-implicit-function-declaration"))
mesg_implicit_function_declaration = 2;
else if (!strncmp (p, "-Wformat=", 9))
......
......@@ -39,7 +39,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "tm_p.h"
#include "splay-tree.h"
#include "debug.h"
#include "target.h"
#ifdef MULTIBYTE_CHARS
#include "mbchar.h"
......@@ -81,7 +80,6 @@ static tree lex_string PARAMS ((const unsigned char *, unsigned int,
static tree lex_charconst PARAMS ((const cpp_token *));
static void update_header_times PARAMS ((const char *));
static int dump_one_header PARAMS ((splay_tree_node, void *));
static void cb_register_builtins PARAMS ((cpp_reader *));
static void cb_line_change PARAMS ((cpp_reader *, const cpp_token *, int));
static void cb_ident PARAMS ((cpp_reader *, unsigned int,
const cpp_string *));
......@@ -123,7 +121,6 @@ init_c_lex (filename)
cb->ident = cb_ident;
cb->file_change = cb_file_change;
cb->def_pragma = cb_def_pragma;
cb->register_builtins = cb_register_builtins;
/* Set the debug callbacks if we can use them. */
if (debug_info_level == DINFO_LEVEL_VERBOSE
......@@ -228,25 +225,6 @@ dump_time_statistics ()
splay_tree_foreach (file_info_tree, dump_one_header, 0);
}
/* Register preprocessor built-ins. */
static void
cb_register_builtins (pfile)
cpp_reader *pfile;
{
if (c_language == clk_cplusplus)
{
if (SUPPORTS_ONE_ONLY)
cpp_define (pfile, "__GXX_WEAK__");
else
cpp_define (pfile, "__GXX_WEAK__=0");
}
(*targetm.register_cpp_builtins) (pfile);
}
/* Not yet handled: #pragma, #define, #undef.
No need to deal with linemarkers under normal conditions. */
static void
cb_ident (pfile, line, str)
cpp_reader *pfile ATTRIBUTE_UNUSED;
......
......@@ -34,9 +34,19 @@ extern int indent_level;
struct cpp_reader;
extern struct cpp_reader* parse_in;
/* Copied from cpplib.h to avoid target code having to pull in all of
cpplib.h. */
extern void cpp_define PARAMS ((struct cpp_reader *, const char *));
extern void cpp_assert PARAMS ((struct cpp_reader *, const char *));
#define builtin_define(TXT) cpp_define (parse_in, TXT)
#define builtin_assert(TXT) cpp_assert (parse_in, TXT)
/* Pass an object-like macro. If it doesn't lie in the user's
namespace, defines it unconditionally. Otherwise define a version
with two leading underscores, and another version with two leading
and trailing underscores, and define the original only if an ISO
standard was not nominated.
e.g. passing "unix" defines "__unix", "__unix__" and possibly
"unix". Passing "_mips" defines "__mips", "__mips__" and possibly
"_mips". */
extern void builtin_define_std PARAMS ((const char *));
#endif /* ! GCC_C_LEX_H */
2002-05-09 Neil Booth <neil@daikokuya.demon.co.uk>
* cp-tree.h (flag_ansi): Remove.
* decl2.c (flag_ansi): Remove.
(cxx_decode_option): Set flag_iso and flag_undef.
2002-05-09 Jason Merrill <jason@redhat.com>
* typeck.c (get_member_function_from_ptrfunc): Reorganize.
......
......@@ -1021,12 +1021,6 @@ extern int interface_only, interface_unknown;
extern int flag_elide_constructors;
/* Nonzero means enable obscure standard features and disable GNU
extensions that might cause standard-compliant code to be
miscompiled. */
extern int flag_ansi;
/* Nonzero means that member functions defined in class scope are
inline by default. */
......
......@@ -136,12 +136,6 @@ int flag_no_gnu_keywords;
int flag_signed_bitfields = 1;
/* Nonzero means enable obscure standard features and disable GNU
extensions that might cause standard-compliant code to be
miscompiled. */
int flag_ansi;
/* Nonzero means do emit exported implementations of functions even if
they can be inlined. */
......@@ -699,8 +693,10 @@ cxx_decode_option (argc, argv)
}
else if (!strcmp (p, "-E"))
flag_preprocess_only = 1;
else if (!strcmp (p, "-undef"))
flag_undef = 1;
else if (!strcmp (p, "-ansi"))
flag_no_nonansi_builtin = 1, flag_ansi = 1,
flag_no_nonansi_builtin = 1, flag_iso = 1,
flag_noniso_default_format_attributes = 0, flag_no_gnu_keywords = 1;
#ifdef SPEW_DEBUG
/* Undocumented, only ever used when you're invoking cc1plus by hand, since
......
......@@ -622,19 +622,32 @@ The macro @code{STANDARD_STARTFILE_PREFIX}.
@c prevent bad page break with this line
Here are run-time target specifications.
@deftypefn {Target Hook} void TARGET_REGISTER_CPP_BUILTINS (cpp_reader *@var{pfile})
This macro expands to a target-specific function, called by the C
family of front ends, that allows you to define preprocessor built-in
macros and assertions at run-time.
Pass the argument (a preprocessor handle) as the first argument to the
functions @code{cpp_define} and @code{cpp_assert}, declared in
@file{c-lex.h}. The second argument is the same as the argument to
the respective command-line option, for example @code{__mips__} for
@code{cpp_define}, and @code{cpu=mips} for @code{cpp_assert}.
@end deftypefn
@table @code
@findex TARGET_REGISTER_CPP_BUILTINS
@item TARGET_REGISTER_CPP_BUILTINS
This macro expands to a block of code that defines target-specific
built-in preprocessor macros and assertions, using the functions
@code{builtin_macro}, @code{builtin_macro_std} and
@code{builtin_assert} declared in @file{c-lex.h}.
@code{builtin_assert} takes a string in the form you pass to the
command-line option @option{-A}, such as @code{cpu=mips}, and creates
the assertion. @code{builtin_macro} takes a string in the form
accepted by option @option{-D} and unconditionally defines the macro.
@code{builtin_macro_std} takes a string representing the name of an
object-like macro. If it doesn't lie in the user's namespace,
@code{builtin_macro_std} defines it unconditionally. Otherwise, it
defines a version with two leading underscores, and another version
with two leading and trailing underscores, and defines the original
only if an ISO standard was not requested on the command line. For
example, passing @code{unix} defines @code{__unix}, @code{__unix__}
and possibly @code{unix}; passing @code{_mips} defines @code{__mips},
@code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64}
defines only @code{_ABI64}.
This macro obsoletes the @code{CPP_PREDEFINES} target macro.
@findex CPP_PREDEFINES
@item CPP_PREDEFINES
Define this to be a string constant containing @option{-D} options to
......
......@@ -701,7 +701,7 @@ static const char *cc1_options =
"%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
%1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\
%{g*} %{O*} %{W*&pedantic*} %{w} %{std*} %{ansi}\
%{v:-version} %{pg:-p} %{p} %{f*}\
%{v:-version} %{pg:-p} %{p} %{f*} %{undef}\
%{Qn:-fno-ident} %{--help:--help}\
%{--target-help:--target-help}\
%{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\
......
......@@ -179,7 +179,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES default_set_default_type_attributes
#define TARGET_INSERT_ATTRIBUTES default_insert_attributes
#define TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P default_function_attribute_inlinable_p
#define TARGET_REGISTER_CPP_BUILTINS default_register_cpp_builtins
#define TARGET_MS_BITFIELD_LAYOUT_P default_ms_bitfield_layout_p
/* In builtins.c. */
......@@ -206,7 +205,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_SET_DEFAULT_TYPE_ATTRIBUTES, \
TARGET_INSERT_ATTRIBUTES, \
TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P, \
TARGET_REGISTER_CPP_BUILTINS, \
TARGET_MS_BITFIELD_LAYOUT_P, \
TARGET_INIT_BUILTINS, \
TARGET_EXPAND_BUILTIN, \
......
......@@ -44,8 +44,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
to gradually reduce the amount of conditional compilation that is
scattered throughout GCC. */
struct cpp_reader;
struct gcc_target
{
/* Functions that output assembler for the target. */
......@@ -200,8 +198,6 @@ struct gcc_target
can be inlined despite its machine attributes, false otherwise. */
bool (* function_attribute_inlinable_p) PARAMS ((tree fndecl));
void (* register_cpp_builtins) PARAMS ((struct cpp_reader *));
/* Return true if bitfields in RECORD_TYPE should follow the
Microsoft Visual C++ bitfield layout rules. */
bool (* ms_bitfield_layout_p) PARAMS ((tree record_type));
......
......@@ -2543,13 +2543,6 @@ build_type_attribute_variant (ttype, attribute)
return ttype;
}
/* Default registration of target-specific CPP built-ins. */
void
default_register_cpp_builtins (pfile)
struct cpp_reader *pfile ATTRIBUTE_UNUSED;
{
}
/* Default value of targetm.comp_type_attributes that always returns 1. */
int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment