* 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
+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>
* c-common.h: New file.
#include "cpplib.h"
cpp_reader parse_in;
cpp_options parse_options;
-static enum cpp_token cpp_token;
+enum cpp_token cpp_token;
#endif
#ifndef WCHAR_TYPE_SIZE
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.
We do this in nonblocking mode so we don't get stuck here if
someone clever has asked cpp to process /dev/rmt0;
ih_fake->limit = 0;
if (!finclude (pfile, f, ih_fake))
return 0;
- output_line_command (pfile, same_file);
+ 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);
pfile->only_seen_white = 2;
/* The -imacros files can be scanned now, but the -include files
user_label_prefix = "_";
else if (!strcmp (argv[i], "-fno-leading-underscore"))
user_label_prefix = "";
+ else if (!strcmp (argv[i], "-fpreprocessed"))
+ opts->preprocessed = 1;
+ else if (!strcmp (argv[i], "-fno-preprocessed"))
+ opts->preprocessed = 0;
break;
case 'I': /* Add directory to path for includes. */
handle_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;
cpp_pop_buffer (pfile);
c2 = PEEKC ();
if (c2 == '-' && opts->chill)
goto comment; /* Chill style comment */
- if (c2 == '-' || c2 == '=' || c2 == '>')
+ if (c2 == '-' || c2 == '=')
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;
case '<':
c2 = PEEKC ();
if (c2 == '=')
goto op2;
- if (c2 != c)
+ /* GNU C++ supports MIN and MAX operators <? and >?. */
+ if (c2 != c && (!opts->cplusplus || c2 != '?'))
goto randomchar;
FORWARD(1);
CPP_RESERVE (pfile, 4);
c = GETC ();
goto number;
}
+
+ /* In C++ there's a .* operator. */
+ if (opts->cplusplus && c2 == '*')
+ goto op2;
+
if (c2 == '.' && PEEKN(1) == '.')
{
CPP_RESERVE(pfile, 4);
/* Parse a string starting with C. A single quoted string is treated
like a double -- some programs (e.g., troff) are perverse this way.
(However, a single quoted string is not allowed to extend over
- multiple lines. */
+ multiple lines.) */
static void
parse_string (pfile, c)
cpp_reader *pfile;
escapes are used only in macro buffers, and backslash-newline is removed
from macro expansion text in collect_expansion and/or macarg. */
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;
/* Nonzero means give all the error messages the ANSI standard requires. */
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;
/* Search paths for include files. */
{"%{!M:%{!MM:%{!E:cc1 %i %1 %{!Q:-quiet} %{d*} %{m*} %{a*}\
%{g*} %{O*} %{W*} %{w} %{pedantic*} %{std*}\
%{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}}\
%{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
%{!S:as %a %Y\
{ "-fno-cond-mismatch", "" },
{ "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" },
{ "-fno-dollars-in-identifiers", "" },
+ { "-fpreprocessed", "" },
+ { "-fno-preprocessed", "" },
{ "-fshort-double", "Use the same size for double as for float" },
{ "-fno-short-double", "" },
{ "-fshort-enums", "Use the smallest fitting integer to hold enums"},
abort ();
}
+#ifdef __GNUC__
+void
+(abort) ()
+{
+ raise (6);
+}
+#endif
+
/* Same as `malloc' but report error if no memory available. */
PTR