Commit 66a6250f by Jason Merrill

lang-specs.h (c++-cpp-output): Pass -fpreprocessed.

	* lang-specs.h (c++-cpp-output): Pass -fpreprocessed.

	* lex.c (token_getch, token_put_back): New fns.
	(real_yylex): Use them.

	* lex.c (lang_init): Generalize.
	(lang_init_options): Tell cpplib this is C++.
	(nextchar): Remove.  Replace uses with put_back.
	(skip_white_space): Handle linemode here.  Optimize for cpplib.
	(extend_token_buffer_to): New fn.
	(extend_token_buffer): Use it.
	(read_line_number, check_newline): Just deal with tokens.
	(real_yylex): More cpplib optimizations.  Simplify.  Don't produce
	EXTERN_LANG_STRING, LEFT_RIGHT or PAREN_STAR_PAREN here.
	* spew.c (yylex): Produce LEFT_RIGHT and EXTERN_LANG_STRING.
	* parse.y (PAREN_STAR_PAREN): Remove.
	* input.c: Don't use the putback machinery with cpplib.
	(sub_getch): Fold back into getch.
	(getch): Don't handle linemode here.
	(feed_input): Unget any text in the token buffer.

	* lex.c	(set_typedecl_interface_info, set_vardecl_interface_info,
	nextyychar, nextyylval): Remove.

	* lex.c (indent_level): New variable.
	(init_parse): Set cpp_token to CPP_DIRECTIVE.
	(consume_string): Make this smart about USE_CPPLIB.
	(yyungetc): Use put_back function.
	(pragma_getc, pragma_ungetc): Functions deleted.
	(check_newline): Rewrite to be intelligent about USE_CPPLIB.
	Also, call HANDLE_PRAGMA with getch, yyungetc, not pragma_getc and
	pragma_ungetc.
	(real_yylex): Rewrite to be intelligent about USE_CPPLIB.
	Also, clean up cases where we redundantly set token_buffer[0].
	(read_line_number): New fn.
	* input.c (feed_input): Use integrated cpplib if USE_CPPLIB.
	(end_input): Call cpp_pop_buffer if USE_CPPLIB.
	(sub_getch): Conditionalize out code that's not appropriate if
	USE_CPPLIB.
	(put_back): Rewrite in case USE_CPPLIB is defined.
	(input_redirected): Ditto.

From-SVN: r28193
parent 81f374eb
1999-07-20 Jason Merrill <jason@yorick.cygnus.com>
* lang-specs.h (c++-cpp-output): Pass -fpreprocessed.
* lex.c (token_getch, token_put_back): New fns.
(real_yylex): Use them.
* lex.c (lang_init): Generalize.
(lang_init_options): Tell cpplib this is C++.
(nextchar): Remove. Replace uses with put_back.
(skip_white_space): Handle linemode here. Optimize for cpplib.
(extend_token_buffer_to): New fn.
(extend_token_buffer): Use it.
(read_line_number, check_newline): Just deal with tokens.
(real_yylex): More cpplib optimizations. Simplify. Don't produce
EXTERN_LANG_STRING, LEFT_RIGHT or PAREN_STAR_PAREN here.
* spew.c (yylex): Produce LEFT_RIGHT and EXTERN_LANG_STRING.
* parse.y (PAREN_STAR_PAREN): Remove.
* input.c: Don't use the putback machinery with cpplib.
(sub_getch): Fold back into getch.
(getch): Don't handle linemode here.
(feed_input): Unget any text in the token buffer.
* lex.c (set_typedecl_interface_info, set_vardecl_interface_info,
nextyychar, nextyylval): Remove.
1999-07-20 Michael Tiemann <tiemann@holodeck.cygnus.com>
Jason Merrill <jason@yorick.cygnus.com>
* lex.c (indent_level): New variable.
(init_parse): Set cpp_token to CPP_DIRECTIVE.
(consume_string): Make this smart about USE_CPPLIB.
(yyungetc): Use put_back function.
(pragma_getc, pragma_ungetc): Functions deleted.
(check_newline): Rewrite to be intelligent about USE_CPPLIB.
Also, call HANDLE_PRAGMA with getch, yyungetc, not pragma_getc and
pragma_ungetc.
(real_yylex): Rewrite to be intelligent about USE_CPPLIB.
Also, clean up cases where we redundantly set token_buffer[0].
(read_line_number): New fn.
* input.c (feed_input): Use integrated cpplib if USE_CPPLIB.
(end_input): Call cpp_pop_buffer if USE_CPPLIB.
(sub_getch): Conditionalize out code that's not appropriate if
USE_CPPLIB.
(put_back): Rewrite in case USE_CPPLIB is defined.
(input_redirected): Ditto.
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>
* cp-tree.h: Delete lots of declarations of tree nodes; replaced by * cp-tree.h: Delete lots of declarations of tree nodes; replaced by
......
...@@ -1176,8 +1176,8 @@ struct lang_type ...@@ -1176,8 +1176,8 @@ struct lang_type
/* For FUNCTION_TYPE or METHOD_TYPE, a list of the exceptions that /* For FUNCTION_TYPE or METHOD_TYPE, a list of the exceptions that
this type can raise. Each TREE_VALUE is a _TYPE. The TREE_VALUE this type can raise. Each TREE_VALUE is a _TYPE. The TREE_VALUE
will be NULL_TREE to indicate a throw specification of `(...)', or, will be NULL_TREE to indicate a throw specification of `()', or
equivalently, no throw specification. */ no exceptions allowed. */
#define TYPE_RAISES_EXCEPTIONS(NODE) TYPE_NONCOPIED_PARTS (NODE) #define TYPE_RAISES_EXCEPTIONS(NODE) TYPE_NONCOPIED_PARTS (NODE)
/* For FUNCTION_TYPE or METHOD_TYPE, return 1 iff it is declared `throw()'. */ /* For FUNCTION_TYPE or METHOD_TYPE, return 1 iff it is declared `throw()'. */
......
/* Input handling for G++. /* Input handling for G++.
Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc. Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc.
Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing. Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
Enhanced by Michael Tiemann (tiemann@cygnus.com) to better support USE_CPPLIB
This file is part of GNU CC. This file is part of GNU CC.
...@@ -31,14 +32,16 @@ Boston, MA 02111-1307, USA. */ ...@@ -31,14 +32,16 @@ Boston, MA 02111-1307, USA. */
#include "system.h" #include "system.h"
extern FILE *finput; #if !USE_CPPLIB
struct putback_buffer { struct putback_buffer {
char *buffer; char *buffer;
int buffer_size; int buffer_size;
int index; int index;
}; };
static struct putback_buffer putback = {NULL, 0, -1};
#endif
struct input_source { struct input_source {
/* saved string */ /* saved string */
char *str; char *str;
...@@ -51,7 +54,9 @@ struct input_source { ...@@ -51,7 +54,9 @@ struct input_source {
char *filename; char *filename;
int lineno; int lineno;
struct pending_input *input; struct pending_input *input;
#if !USE_CPPLIB
struct putback_buffer putback; struct putback_buffer putback;
#endif
}; };
static struct input_source *input, *free_inputs; static struct input_source *input, *free_inputs;
...@@ -62,9 +67,6 @@ extern int lineno; ...@@ -62,9 +67,6 @@ extern int lineno;
#if USE_CPPLIB #if USE_CPPLIB
extern unsigned char *yy_cur, *yy_lim; extern unsigned char *yy_cur, *yy_lim;
extern int yy_get_token (); extern int yy_get_token ();
#define GETC() (yy_cur < yy_lim ? *yy_cur++ : yy_get_token ())
#else
#define GETC() getc (finput)
#endif #endif
extern void feed_input PROTO((char *, int)); extern void feed_input PROTO((char *, int));
...@@ -76,7 +78,6 @@ extern int input_redirected PROTO((void)); ...@@ -76,7 +78,6 @@ extern int input_redirected PROTO((void));
static inline struct input_source * allocate_input PROTO((void)); static inline struct input_source * allocate_input PROTO((void));
static inline void free_input PROTO((struct input_source *)); static inline void free_input PROTO((struct input_source *));
static inline void end_input PROTO((void)); static inline void end_input PROTO((void));
static inline int sub_getch PROTO((void));
static inline struct input_source * static inline struct input_source *
allocate_input () allocate_input ()
...@@ -104,8 +105,6 @@ free_input (inp) ...@@ -104,8 +105,6 @@ free_input (inp)
free_inputs = inp; free_inputs = inp;
} }
static struct putback_buffer putback = {NULL, 0, -1};
/* Some of these external functions are declared inline in case this file /* Some of these external functions are declared inline in case this file
is included in lex.c. */ is included in lex.c. */
...@@ -121,21 +120,28 @@ feed_input (str, len) ...@@ -121,21 +120,28 @@ feed_input (str, len)
while (len && !str[len-1]) while (len && !str[len-1])
len--; len--;
#if USE_CPPLIB
if (yy_lim > yy_cur)
/* If we've started reading the next token, we're hosed. */
my_friendly_abort (990710);
cpp_push_buffer (&parse_in, str, len);
CPP_BUFFER (&parse_in)->manual_pop = 1;
#else
inp->str = str; inp->str = str;
inp->length = len; inp->length = len;
inp->offset = 0; inp->offset = 0;
inp->next = input;
inp->filename = input_filename;
inp->lineno = lineno;
inp->input = save_pending_input ();
inp->putback = putback; inp->putback = putback;
putback.buffer = NULL; putback.buffer = NULL;
putback.buffer_size = 0; putback.buffer_size = 0;
putback.index = -1; putback.index = -1;
#endif
inp->next = input;
inp->filename = input_filename;
inp->lineno = lineno;
inp->input = save_pending_input ();
input = inp; input = inp;
} }
struct pending_input *to_be_restored; /* XXX */
extern int end_of_file; extern int end_of_file;
static inline void static inline void
...@@ -143,20 +149,28 @@ end_input () ...@@ -143,20 +149,28 @@ end_input ()
{ {
struct input_source *inp = input; struct input_source *inp = input;
#if USE_CPPLIB
cpp_pop_buffer (&parse_in);
#else
putback = inp->putback;
#endif
end_of_file = 0; end_of_file = 0;
input = inp->next; input = inp->next;
input_filename = inp->filename; input_filename = inp->filename;
lineno = inp->lineno; lineno = inp->lineno;
/* Get interface/implementation back in sync. */ /* Get interface/implementation back in sync. */
extract_interface_info (); extract_interface_info ();
putback = inp->putback;
restore_pending_input (inp->input); restore_pending_input (inp->input);
free_input (inp); free_input (inp);
} }
static inline int inline int
sub_getch () getch ()
{ {
#if USE_CPPLIB
return (yy_cur < yy_lim ? *yy_cur++ : yy_get_token ());
#else
if (putback.index != -1) if (putback.index != -1)
{ {
int ch = putback.buffer[putback.index]; int ch = putback.buffer[putback.index];
...@@ -178,7 +192,8 @@ sub_getch () ...@@ -178,7 +192,8 @@ sub_getch ()
} }
return (unsigned char)input->str[input->offset++]; return (unsigned char)input->str[input->offset++];
} }
return GETC (); return getc (finput);
#endif
} }
inline inline
...@@ -186,6 +201,14 @@ void ...@@ -186,6 +201,14 @@ void
put_back (ch) put_back (ch)
int ch; int ch;
{ {
#if USE_CPPLIB
if (ch == EOF)
;
else if (yy_cur[-1] != ch)
my_friendly_abort (990709);
else
yy_cur--;
#else
if (ch != EOF) if (ch != EOF)
{ {
if (putback.index == putback.buffer_size - 1) if (putback.index == putback.buffer_size - 1)
...@@ -196,25 +219,16 @@ put_back (ch) ...@@ -196,25 +219,16 @@ put_back (ch)
my_friendly_assert (putback.buffer != NULL, 224); my_friendly_assert (putback.buffer != NULL, 224);
putback.buffer[++putback.index] = ch; putback.buffer[++putback.index] = ch;
} }
} #endif
extern int linemode;
int
getch ()
{
int ch = sub_getch ();
if (linemode && ch == '\n')
{
put_back (ch);
ch = EOF;
}
return ch;
} }
inline inline
int int
input_redirected () input_redirected ()
{ {
#ifdef USE_CPPLIB
return CPP_BUFFER(&parse_in)->manual_pop;
#else
return input != 0; return input != 0;
#endif
} }
...@@ -88,7 +88,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -88,7 +88,7 @@ Boston, MA 02111-1307, USA. */
{"@c++-cpp-output", {"@c++-cpp-output",
{"%{!M:%{!MM:%{!E:cc1plus %i %1 %2 %{!Q:-quiet} %{d*} %{m*} %{a}\ {"%{!M:%{!MM:%{!E:cc1plus %i %1 %2 %{!Q:-quiet} %{d*} %{m*} %{a}\
%{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
%{v:-version} %{pg:-p} %{p}\ %{v:-version} %{pg:-p} %{p} -fpreprocessed\
%{f*} %{+e*} %{aux-info*} %{Qn:-fno-ident}\ %{f*} %{+e*} %{aux-info*} %{Qn:-fno-ident}\
%{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\
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -69,21 +69,20 @@ typedef union {long itype; tree ttype; char *strtype; enum tree_code code; flagg ...@@ -69,21 +69,20 @@ typedef union {long itype; tree ttype; char *strtype; enum tree_code code; flagg
#define PLUSPLUS 325 #define PLUSPLUS 325
#define MINUSMINUS 326 #define MINUSMINUS 326
#define HYPERUNARY 327 #define HYPERUNARY 327
#define PAREN_STAR_PAREN 328 #define POINTSAT 328
#define POINTSAT 329 #define TRY 329
#define TRY 330 #define CATCH 330
#define CATCH 331 #define PRE_PARSED_FUNCTION_DECL 331
#define PRE_PARSED_FUNCTION_DECL 332 #define EXTERN_LANG_STRING 332
#define EXTERN_LANG_STRING 333 #define ALL 333
#define ALL 334 #define PRE_PARSED_CLASS_DECL 334
#define PRE_PARSED_CLASS_DECL 335 #define DEFARG 335
#define DEFARG 336 #define DEFARG_MARKER 336
#define DEFARG_MARKER 337 #define TYPENAME_DEFN 337
#define TYPENAME_DEFN 338 #define IDENTIFIER_DEFN 338
#define IDENTIFIER_DEFN 339 #define PTYPENAME_DEFN 339
#define PTYPENAME_DEFN 340 #define END_OF_LINE 340
#define END_OF_LINE 341 #define END_OF_SAVED_INPUT 341
#define END_OF_SAVED_INPUT 342
extern YYSTYPE yylval; extern YYSTYPE yylval;
......
...@@ -178,7 +178,7 @@ empty_parms () ...@@ -178,7 +178,7 @@ empty_parms ()
%left <code> POINTSAT_STAR DOT_STAR %left <code> POINTSAT_STAR DOT_STAR
%right <code> UNARY PLUSPLUS MINUSMINUS '~' %right <code> UNARY PLUSPLUS MINUSMINUS '~'
%left HYPERUNARY %left HYPERUNARY
%left <ttype> PAREN_STAR_PAREN LEFT_RIGHT %left <ttype> LEFT_RIGHT
%left <code> POINTSAT '.' '(' '[' %left <code> POINTSAT '.' '(' '['
%right SCOPE /* C++ extension */ %right SCOPE /* C++ extension */
...@@ -3174,7 +3174,6 @@ direct_abstract_declarator: ...@@ -3174,7 +3174,6 @@ direct_abstract_declarator:
'(' absdcl_intern ')' '(' absdcl_intern ')'
{ $$ = $2; } { $$ = $2; }
/* `(typedef)1' is `int'. */ /* `(typedef)1' is `int'. */
| PAREN_STAR_PAREN
| direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.' | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
{ $$ = make_call_declarator ($$, $3, $5, $6); } { $$ = make_call_declarator ($$, $3, $5, $6); }
| direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.' | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
......
/* Type Analyzer for GNU C++. /* Type Analyzer for GNU C++.
Copyright (C) 1987, 89, 92-97, 1998 Free Software Foundation, Inc. Copyright (C) 1987, 89, 92-97, 1998, 1999 Free Software Foundation, Inc.
Hacked... nay, bludgeoned... by Mark Eichin (eichin@cygnus.com) Hacked... nay, bludgeoned... by Mark Eichin (eichin@cygnus.com)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -305,6 +305,16 @@ yylex () ...@@ -305,6 +305,16 @@ yylex ()
#endif #endif
goto retry; goto retry;
case '(':
scan_tokens (1);
if (nth_token (1)->yychar == ')')
{
consume_token ();
tmp_token.yychar = LEFT_RIGHT;
}
consume_token ();
break;
case IDENTIFIER: case IDENTIFIER:
scan_tokens (1); scan_tokens (1);
if (nth_token (1)->yychar == SCOPE) if (nth_token (1)->yychar == SCOPE)
...@@ -361,21 +371,31 @@ yylex () ...@@ -361,21 +371,31 @@ yylex ()
break; break;
case SCSPEC: case SCSPEC:
if (tmp_token.yylval.ttype == ridpointers[RID_EXTERN])
{
scan_tokens (1);
if (nth_token (1)->yychar == STRING)
{
tmp_token.yychar = EXTERN_LANG_STRING;
tmp_token.yylval.ttype = get_identifier
(TREE_STRING_POINTER (nth_token (1)->yylval.ttype));
consume_token ();
}
}
/* If export, warn that it's unimplemented and go on. */ /* If export, warn that it's unimplemented and go on. */
if (tmp_token.yylval.ttype == get_identifier("export")) else if (tmp_token.yylval.ttype == ridpointers[RID_EXPORT])
{ {
warning ("keyword 'export' not implemented and will be ignored"); warning ("keyword 'export' not implemented and will be ignored");
consume_token (); consume_token ();
goto retry; goto retry;
} }
else /* do_aggr needs to check if the previous token was `friend',
{ so just increment first_token instead of calling consume_token. */
++first_token; ++first_token;
break; break;
}
case NEW: case NEW:
/* do_aggr needs to check if the previous token was RID_NEW, /* do_aggr needs to check if the previous token was `new',
so just increment first_token instead of calling consume_token. */ so just increment first_token instead of calling consume_token. */
++first_token; ++first_token;
break; break;
......
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