Commit 3773a46b by Jason Merrill

gcc.c (default_compilers, cpp-output): Pass -fpreprocessed.

	* gcc.c (default_compilers, cpp-output): Pass -fpreprocessed.
	* toplev.c (documented_lang_options): Add -fpreprocessed.
	* cpplib.h (struct cpp_buffer): Add preprocessed.
	* cppinit.c (cpp_handle_option): Handle -fpreprocessed.
	(cpp_start_read): Don't expand macros or emit an initial #line
	directive if -fpreprocessed.

	* cpplib.h (struct cpp_buffer): Added manual_pop for
	better C++ tokenization.
	* cpplib.c (cpp_get_token): Return CPP_EOF if manual_pop.
	Also, support C++ tokenization for ->*, .*, <?, and >? operators.
	* c-common.c (cpp_token): Make non-static.

From-SVN: r28190
parent c8649fde
Tue Jul 20 12:12:27 1999 Jason Merrill <jason@yorick.cygnus.com>
* gcc.c (default_compilers, cpp-output): Pass -fpreprocessed.
* toplev.c (documented_lang_options): Add -fpreprocessed.
* cpplib.h (struct cpp_buffer): Add preprocessed.
* cppinit.c (cpp_handle_option): Handle -fpreprocessed.
(cpp_start_read): Don't expand macros or emit an initial #line
directive if -fpreprocessed.
Tue Jul 20 12:12:09 1999 Michael Tiemann <tiemann@holodeck.cygnus.com>
* cpplib.h (struct cpp_buffer): Added manual_pop for
better C++ tokenization.
* cpplib.c (cpp_get_token): Return CPP_EOF if manual_pop.
Also, support C++ tokenization for ->*, .*, <?, and >? operators.
* c-common.c (cpp_token): Make non-static.
Tue Jul 20 11:24:19 1999 Bernd Schmidt <bernds@cygnus.co.uk> Tue Jul 20 11:24:19 1999 Bernd Schmidt <bernds@cygnus.co.uk>
* c-common.h: New file. * c-common.h: New file.
......
...@@ -34,7 +34,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -34,7 +34,7 @@ Boston, MA 02111-1307, USA. */
#include "cpplib.h" #include "cpplib.h"
cpp_reader parse_in; cpp_reader parse_in;
cpp_options parse_options; cpp_options parse_options;
static enum cpp_token cpp_token; enum cpp_token cpp_token;
#endif #endif
#ifndef WCHAR_TYPE_SIZE #ifndef WCHAR_TYPE_SIZE
......
...@@ -961,6 +961,11 @@ cpp_start_read (pfile, fname) ...@@ -961,6 +961,11 @@ cpp_start_read (pfile, fname)
cpp_message (pfile, -1, "End of search list.\n"); cpp_message (pfile, -1, "End of search list.\n");
} }
/* Don't bother trying to do macro expansion if we've already done
preprocessing. */
if (opts->preprocessed)
pfile->no_macro_expand++;
/* Open the main input file. /* Open the main input file.
We do this in nonblocking mode so we don't get stuck here if We do this in nonblocking mode so we don't get stuck here if
someone clever has asked cpp to process /dev/rmt0; someone clever has asked cpp to process /dev/rmt0;
...@@ -988,6 +993,12 @@ cpp_start_read (pfile, fname) ...@@ -988,6 +993,12 @@ cpp_start_read (pfile, fname)
ih_fake->limit = 0; ih_fake->limit = 0;
if (!finclude (pfile, f, ih_fake)) if (!finclude (pfile, f, ih_fake))
return 0; return 0;
if (opts->preprocessed)
/* If we've already processed this code, we want to trust the #line
directives in the input. But we still need to update our line
counter accordingly. */
pfile->lineno = CPP_BUFFER (pfile)->lineno;
else
output_line_command (pfile, same_file); output_line_command (pfile, same_file);
pfile->only_seen_white = 2; pfile->only_seen_white = 2;
...@@ -1155,6 +1166,10 @@ cpp_handle_option (pfile, argc, argv) ...@@ -1155,6 +1166,10 @@ cpp_handle_option (pfile, argc, argv)
user_label_prefix = "_"; user_label_prefix = "_";
else if (!strcmp (argv[i], "-fno-leading-underscore")) else if (!strcmp (argv[i], "-fno-leading-underscore"))
user_label_prefix = ""; user_label_prefix = "";
else if (!strcmp (argv[i], "-fpreprocessed"))
opts->preprocessed = 1;
else if (!strcmp (argv[i], "-fno-preprocessed"))
opts->preprocessed = 0;
break; break;
case 'I': /* Add directory to path for includes. */ case 'I': /* Add directory to path for includes. */
......
...@@ -2029,7 +2029,10 @@ cpp_get_token (pfile) ...@@ -2029,7 +2029,10 @@ cpp_get_token (pfile)
handle_eof: handle_eof:
if (CPP_BUFFER (pfile)->seen_eof) if (CPP_BUFFER (pfile)->seen_eof)
{ {
if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) == CPP_NULL_BUFFER (pfile)) if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) == CPP_NULL_BUFFER (pfile)
/* If we've been reading from redirected input, the
frontend will pop the buffer. */
|| CPP_BUFFER (pfile)->manual_pop)
return CPP_EOF; return CPP_EOF;
cpp_pop_buffer (pfile); cpp_pop_buffer (pfile);
...@@ -2172,8 +2175,25 @@ cpp_get_token (pfile) ...@@ -2172,8 +2175,25 @@ cpp_get_token (pfile)
c2 = PEEKC (); c2 = PEEKC ();
if (c2 == '-' && opts->chill) if (c2 == '-' && opts->chill)
goto comment; /* Chill style comment */ goto comment; /* Chill style comment */
if (c2 == '-' || c2 == '=' || c2 == '>') if (c2 == '-' || c2 == '=')
goto op2; goto op2;
if (c2 == '>')
{
if (opts->cplusplus && PEEKN (1) == '*')
{
/* In C++, there's a ->* operator. */
op3:
token = CPP_OTHER;
pfile->only_seen_white = 0;
CPP_RESERVE (pfile, 4);
CPP_PUTC_Q (pfile, c);
CPP_PUTC_Q (pfile, GETC ());
CPP_PUTC_Q (pfile, GETC ());
CPP_NUL_TERMINATE_Q (pfile);
return token;
}
goto op2;
}
goto randomchar; goto randomchar;
case '<': case '<':
...@@ -2219,7 +2239,8 @@ cpp_get_token (pfile) ...@@ -2219,7 +2239,8 @@ cpp_get_token (pfile)
c2 = PEEKC (); c2 = PEEKC ();
if (c2 == '=') if (c2 == '=')
goto op2; goto op2;
if (c2 != c) /* GNU C++ supports MIN and MAX operators <? and >?. */
if (c2 != c && (!opts->cplusplus || c2 != '?'))
goto randomchar; goto randomchar;
FORWARD(1); FORWARD(1);
CPP_RESERVE (pfile, 4); CPP_RESERVE (pfile, 4);
...@@ -2241,6 +2262,11 @@ cpp_get_token (pfile) ...@@ -2241,6 +2262,11 @@ cpp_get_token (pfile)
c = GETC (); c = GETC ();
goto number; goto number;
} }
/* In C++ there's a .* operator. */
if (opts->cplusplus && c2 == '*')
goto op2;
if (c2 == '.' && PEEKN(1) == '.') if (c2 == '.' && PEEKN(1) == '.')
{ {
CPP_RESERVE(pfile, 4); CPP_RESERVE(pfile, 4);
...@@ -2549,7 +2575,7 @@ parse_name (pfile, c) ...@@ -2549,7 +2575,7 @@ parse_name (pfile, c)
/* Parse a string starting with C. A single quoted string is treated /* Parse a string starting with C. A single quoted string is treated
like a double -- some programs (e.g., troff) are perverse this way. like a double -- some programs (e.g., troff) are perverse this way.
(However, a single quoted string is not allowed to extend over (However, a single quoted string is not allowed to extend over
multiple lines. */ multiple lines.) */
static void static void
parse_string (pfile, c) parse_string (pfile, c)
cpp_reader *pfile; cpp_reader *pfile;
......
...@@ -136,6 +136,10 @@ struct cpp_buffer ...@@ -136,6 +136,10 @@ struct cpp_buffer
escapes are used only in macro buffers, and backslash-newline is removed escapes are used only in macro buffers, and backslash-newline is removed
from macro expansion text in collect_expansion and/or macarg. */ from macro expansion text in collect_expansion and/or macarg. */
char has_escapes; char has_escapes;
/* Used by the C++ frontend to implement redirected input (such as for
default argument and/or template parsing). */
char manual_pop;
}; };
struct file_name_map_list; struct file_name_map_list;
...@@ -454,6 +458,10 @@ struct cpp_options { ...@@ -454,6 +458,10 @@ struct cpp_options {
/* Nonzero means give all the error messages the ANSI standard requires. */ /* Nonzero means give all the error messages the ANSI standard requires. */
char pedantic; char pedantic;
/* Nonzero means we're looking at already preprocessed code, so don't
bother trying to do macro expansion and whatnot. */
char preprocessed;
char done_initializing; char done_initializing;
/* Search paths for include files. */ /* Search paths for include files. */
......
...@@ -694,7 +694,7 @@ static struct compiler default_compilers[] = ...@@ -694,7 +694,7 @@ static struct compiler default_compilers[] =
{"%{!M:%{!MM:%{!E:cc1 %i %1 %{!Q:-quiet} %{d*} %{m*} %{a*}\ {"%{!M:%{!MM:%{!E:cc1 %i %1 %{!Q:-quiet} %{d*} %{m*} %{a*}\
%{g*} %{O*} %{W*} %{w} %{pedantic*} %{std*}\ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{std*}\
%{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\ %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
%{aux-info*} %{Qn:-fno-ident}\ %{aux-info*} %{Qn:-fno-ident} -fpreprocessed\
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ %{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:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
%{!S:as %a %Y\ %{!S:as %a %Y\
......
...@@ -1028,6 +1028,8 @@ documented_lang_options[] = ...@@ -1028,6 +1028,8 @@ documented_lang_options[] =
{ "-fno-cond-mismatch", "" }, { "-fno-cond-mismatch", "" },
{ "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" }, { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
{ "-fno-dollars-in-identifiers", "" }, { "-fno-dollars-in-identifiers", "" },
{ "-fpreprocessed", "" },
{ "-fno-preprocessed", "" },
{ "-fshort-double", "Use the same size for double as for float" }, { "-fshort-double", "Use the same size for double as for float" },
{ "-fno-short-double", "" }, { "-fno-short-double", "" },
{ "-fshort-enums", "Use the smallest fitting integer to hold enums"}, { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
...@@ -2299,6 +2301,14 @@ botch (s) ...@@ -2299,6 +2301,14 @@ botch (s)
abort (); abort ();
} }
#ifdef __GNUC__
void
(abort) ()
{
raise (6);
}
#endif
/* Same as `malloc' but report error if no memory available. */ /* Same as `malloc' but report error if no memory available. */
PTR PTR
......
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