Integrate cpplib into the C and C++ front ends.
Wed Jun 10 13:07:02 1998 Dave Brolley <brolley@cygnus.com> * objc/objc-act.c: Add cpplib declarations. (lang_decode_option): Initialize cpplib if necessary. (lang_decode_option): New argc/argv interface. * tree.h (lang_decode_option): New argc/argv interface. * toplev.c (lang_options): Add cpp options. (main): New interface for lang_decode_option. * gcc.c (default_compilers): Don't call cpp for a cpplib-enabled C compiler unless -E, -M or -MM is specified. * cpplib.h (cpp_handle_option): New function. * cpplib.c (cpp_handle_option): New function. (cpp_handle_options): Now calls cpp_handle_option. * c-tree.h (c_decode_option): New argc/argv interface. * c-lex.c (init_parse): cpplib now initialized in c_decode_option. * c-lang.c (lang_decode_option): New argc/argv interface. * c-decl.c: Add cpplib declarations. (c_decode_option): New argc/argv interface. (c_decode_option): Call cpp_handle_option. (c_decode_option): Now returns number of strings processed. From-SVN: r20407
This commit is contained in:
parent
0875c2f39b
commit
a0d85b7572
|
@ -1,3 +1,24 @@
|
|||
Wed Jun 10 13:07:02 1998 Dave Brolley <brolley@cygnus.com>
|
||||
|
||||
* objc/objc-act.c: Add cpplib declarations.
|
||||
(lang_decode_option): Initialize cpplib if necessary.
|
||||
(lang_decode_option): New argc/argv interface.
|
||||
* tree.h (lang_decode_option): New argc/argv interface.
|
||||
* toplev.c (lang_options): Add cpp options.
|
||||
(main): New interface for lang_decode_option.
|
||||
* gcc.c (default_compilers): Don't call cpp for a cpplib-enabled C compiler
|
||||
unless -E, -M or -MM is specified.
|
||||
* cpplib.h (cpp_handle_option): New function.
|
||||
* cpplib.c (cpp_handle_option): New function.
|
||||
(cpp_handle_options): Now calls cpp_handle_option.
|
||||
* c-tree.h (c_decode_option): New argc/argv interface.
|
||||
* c-lex.c (init_parse): cpplib now initialized in c_decode_option.
|
||||
* c-lang.c (lang_decode_option): New argc/argv interface.
|
||||
* c-decl.c: Add cpplib declarations.
|
||||
(c_decode_option): New argc/argv interface.
|
||||
(c_decode_option): Call cpp_handle_option.
|
||||
(c_decode_option): Now returns number of strings processed.
|
||||
|
||||
Wed Jun 10 09:47:13 1998 Richard Earnshaw (rearnsha@arm.com)
|
||||
|
||||
* unroll.c (verify_addresses): Use validate_replace_rtx to undo the
|
||||
|
|
|
@ -6,6 +6,13 @@ time as we can formally start documenting the interface this file will
|
|||
serve as a repository for information on these interface and any incompatable
|
||||
changes we've made.
|
||||
|
||||
Jun 10, 1998:
|
||||
The interface to lang_decode_option has changed. It now uses and argc/argv
|
||||
interface to allow for options that use more than one input string. The new
|
||||
declaration is: int lang_decode_option (int argc, char** argv). It now
|
||||
returns the number of input strings processed, or 0 if the option is
|
||||
unknown.
|
||||
|
||||
Jun 7, 1998:
|
||||
Front-ends must now define lang_init_options. It is safe for this
|
||||
function to do nothing. See c-lang.c.
|
||||
|
|
32
gcc/c-decl.c
32
gcc/c-decl.c
|
@ -35,6 +35,13 @@ Boston, MA 02111-1307, USA. */
|
|||
#include "c-lex.h"
|
||||
#include "toplev.h"
|
||||
|
||||
#if USE_CPPLIB
|
||||
#include "cpplib.h"
|
||||
extern cpp_reader parse_in;
|
||||
extern cpp_options parse_options;
|
||||
static int cpp_initialized;
|
||||
#endif
|
||||
|
||||
/* In grokdeclarator, distinguish syntactic contexts of declarators. */
|
||||
enum decl_context
|
||||
{ NORMAL, /* Ordinary declaration */
|
||||
|
@ -578,13 +585,28 @@ int warn_sign_compare = -1;
|
|||
int dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
|
||||
|
||||
/* Decode the string P as a language-specific option for C.
|
||||
Return 1 if it is recognized (and handle it);
|
||||
return 0 if not recognized. */
|
||||
Return the number of strings consumed. */
|
||||
|
||||
int
|
||||
c_decode_option (p)
|
||||
char *p;
|
||||
c_decode_option (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int strings_processed;
|
||||
char *p = argv[0];
|
||||
#if USE_CPPLIB
|
||||
if (! cpp_initialized)
|
||||
{
|
||||
cpp_reader_init (&parse_in);
|
||||
parse_in.data = &parse_options;
|
||||
cpp_options_init (&parse_options);
|
||||
cpp_initialized = 1;
|
||||
}
|
||||
strings_processed = cpp_handle_option (&parse_in, argc, argv);
|
||||
#else
|
||||
strings_processed = 0;
|
||||
#endif /* ! USE_CPPLIB */
|
||||
|
||||
if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional"))
|
||||
{
|
||||
flag_traditional = 1;
|
||||
|
@ -799,7 +821,7 @@ c_decode_option (p)
|
|||
warn_unknown_pragmas = 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
return strings_processed;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -31,10 +31,11 @@ Boston, MA 02111-1307, USA. */
|
|||
is an alternative to a function in objc-actions.c. */
|
||||
|
||||
int
|
||||
lang_decode_option (p)
|
||||
char *p;
|
||||
lang_decode_option (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
return c_decode_option (p);
|
||||
return c_decode_option (argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -200,10 +200,6 @@ init_parse (filename)
|
|||
yy_cur = "\n";
|
||||
yy_lim = yy_cur+1;
|
||||
|
||||
cpp_reader_init (&parse_in);
|
||||
parse_in.data = &parse_options;
|
||||
cpp_options_init (&parse_options);
|
||||
cpp_handle_options (&parse_in, 0, NULL); /* FIXME */
|
||||
parse_in.show_column = 1;
|
||||
if (! cpp_start_read (&parse_in, filename))
|
||||
abort ();
|
||||
|
|
|
@ -263,7 +263,7 @@ extern tree build_enumerator PROTO((tree, tree));
|
|||
extern tree builtin_function PROTO((char *, tree, enum built_in_function function_, char *));
|
||||
/* Add qualifiers to a type, in the fashion for C. */
|
||||
extern tree c_build_type_variant PROTO((tree, int, int));
|
||||
extern int c_decode_option PROTO((char *));
|
||||
extern int c_decode_option PROTO((int, char **));
|
||||
extern void c_mark_varargs PROTO((void));
|
||||
extern tree check_identifier PROTO((tree, tree));
|
||||
extern void clear_parm_order PROTO((void));
|
||||
|
|
995
gcc/cpplib.c
995
gcc/cpplib.c
File diff suppressed because it is too large
Load Diff
|
@ -94,6 +94,7 @@ extern void parse_clear_mark PARAMS ((struct parse_marker *));
|
|||
extern void parse_goto_mark PARAMS((struct parse_marker *, cpp_reader *));
|
||||
extern void parse_move_mark PARAMS((struct parse_marker *, cpp_reader *));
|
||||
|
||||
extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
|
||||
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
|
||||
extern enum cpp_token cpp_get_token PARAMS ((cpp_reader *));
|
||||
extern void cpp_skip_hspace PARAMS((cpp_reader *));
|
||||
|
|
47
gcc/gcc.c
47
gcc/gcc.c
|
@ -597,7 +597,46 @@ static struct compiler default_compilers[] =
|
|||
/* Next come the entries for C. */
|
||||
{".c", {"@c"}},
|
||||
{"@c",
|
||||
{"cpp -lang-c%{ansi:89} %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
|
||||
{
|
||||
#if USE_CPPLIB
|
||||
#define CPP_FOR_C \
|
||||
"cpp -lang-c%{ansi:89} %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
|
||||
%{C:%{!E:%eGNU C does not support -C without using -E}}\
|
||||
%{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
|
||||
-undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
|
||||
%{ansi:-trigraphs -D__STRICT_ANSI__}\
|
||||
%{!undef:%{!ansi:%p} %P} %{trigraphs} \
|
||||
%c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
|
||||
%{traditional} %{ftraditional:-traditional}\
|
||||
%{traditional-cpp:-traditional}\
|
||||
%{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
|
||||
%i %{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}}\n"
|
||||
|
||||
"%{E:"CPP_FOR_C"}"
|
||||
"%{!E:%{M:"CPP_FOR_C"}"
|
||||
"%{!M:%{MM:"CPP_FOR_C"}"
|
||||
"%{!MM:cc1 %i %1 \
|
||||
-lang-c%{ansi:89} %{nostdinc*} %{A*} %{I*} %I\
|
||||
%{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a*}\
|
||||
%{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
|
||||
-undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
|
||||
%{ansi:-trigraphs -D__STRICT_ANSI__}\
|
||||
%{!undef:%{!ansi:%p} %P} %{trigraphs} \
|
||||
%c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
|
||||
%{H} %C %{D*} %{U*} %{i*} %Z\
|
||||
%{ftraditional:-traditional}\
|
||||
%{traditional-cpp:-traditional}\
|
||||
%{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
|
||||
%{aux-info*}\
|
||||
%{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} \
|
||||
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
|
||||
%{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
|
||||
%{!S:as %a %Y\
|
||||
%{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
|
||||
%{!pipe:%g.s} %A\n }}}}"
|
||||
}},
|
||||
#else /* ! USE_CPPLIB */
|
||||
"cpp -lang-c%{ansi:89} %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
|
||||
%{C:%{!E:%eGNU C does not support -C without using -E}}\
|
||||
%{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
|
||||
-undef -D__GNUC__=%v1 -D__GNUC_MINOR__=%v2\
|
||||
|
@ -608,7 +647,7 @@ static struct compiler default_compilers[] =
|
|||
%{traditional-cpp:-traditional}\
|
||||
%{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
|
||||
%i %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
|
||||
"%{!M:%{!MM:%{!E:cc1 %{!pipe:%g.i} %1 \
|
||||
"%{!M:%{!MM:%{!E:cc1 %{!pipe:%g.i} %1 \
|
||||
%{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a*}\
|
||||
%{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} \
|
||||
%{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
|
||||
|
@ -617,7 +656,9 @@ static struct compiler default_compilers[] =
|
|||
%{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
|
||||
%{!S:as %a %Y\
|
||||
%{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
|
||||
%{!pipe:%g.s} %A\n }}}}"}},
|
||||
%{!pipe:%g.s} %A\n }}}}"
|
||||
}},
|
||||
#endif /* ! USE_CPPLIB */
|
||||
{"-",
|
||||
{"%{E:cpp -lang-c%{ansi:89} %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
|
||||
%{C:%{!E:%eGNU C does not support -C without using -E}}\
|
||||
|
|
23
gcc/toplev.c
23
gcc/toplev.c
|
@ -894,6 +894,19 @@ char *lang_options[] =
|
|||
"-Wno-protocol",
|
||||
"-print-objc-runtime-info",
|
||||
|
||||
/* These are for languages with USE_CPPLIB. */
|
||||
"-A",
|
||||
"-D",
|
||||
"-I",
|
||||
"-iprefix",
|
||||
"-isystem",
|
||||
"-lang-c",
|
||||
"-lang-c89",
|
||||
"-lang-c++",
|
||||
"-nostdinc++",
|
||||
"-U",
|
||||
"-undef",
|
||||
|
||||
#include "options.h"
|
||||
0
|
||||
};
|
||||
|
@ -3853,9 +3866,13 @@ main (argc, argv, envp)
|
|||
strlen (lang_options[j])))
|
||||
break;
|
||||
if (lang_options[j] != 0)
|
||||
/* If the option is valid for *some* language,
|
||||
treat it as valid even if this language doesn't understand it. */
|
||||
lang_decode_option (argv[i]);
|
||||
{
|
||||
/* If the option is valid for *some* language,
|
||||
treat it as valid even if this language doesn't understand it. */
|
||||
int strings_processed = lang_decode_option (argc - i, argv + i);
|
||||
if (strings_processed != 0)
|
||||
i += strings_processed - 1;
|
||||
}
|
||||
else if (argv[i][0] == '-' && argv[i][1] != 0)
|
||||
{
|
||||
register char *str = argv[i] + 1;
|
||||
|
|
|
@ -1967,7 +1967,7 @@ extern int yyparse PROTO((void));
|
|||
/* Function called with option as argument
|
||||
to decode options starting with -f or -W or +.
|
||||
It should return nonzero if it handles the option. */
|
||||
extern int lang_decode_option PROTO((char *));
|
||||
extern int lang_decode_option PROTO((int, char **));
|
||||
|
||||
/* Functions for processing symbol declarations. */
|
||||
/* Function to enter a new lexical scope.
|
||||
|
|
Loading…
Reference in New Issue