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
This commit is contained in:
parent
81f374ebfb
commit
66a6250faa
@ -1,3 +1,50 @@
|
||||
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>
|
||||
|
||||
* cp-tree.h: Delete lots of declarations of tree nodes; replaced by
|
||||
|
@ -1176,8 +1176,8 @@ struct lang_type
|
||||
|
||||
/* 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
|
||||
will be NULL_TREE to indicate a throw specification of `(...)', or,
|
||||
equivalently, no throw specification. */
|
||||
will be NULL_TREE to indicate a throw specification of `()', or
|
||||
no exceptions allowed. */
|
||||
#define TYPE_RAISES_EXCEPTIONS(NODE) TYPE_NONCOPIED_PARTS (NODE)
|
||||
|
||||
/* For FUNCTION_TYPE or METHOD_TYPE, return 1 iff it is declared `throw()'. */
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* Input handling for G++.
|
||||
Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc.
|
||||
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.
|
||||
|
||||
@ -31,14 +32,16 @@ Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "system.h"
|
||||
|
||||
extern FILE *finput;
|
||||
|
||||
#if !USE_CPPLIB
|
||||
struct putback_buffer {
|
||||
char *buffer;
|
||||
int buffer_size;
|
||||
int index;
|
||||
};
|
||||
|
||||
static struct putback_buffer putback = {NULL, 0, -1};
|
||||
#endif
|
||||
|
||||
struct input_source {
|
||||
/* saved string */
|
||||
char *str;
|
||||
@ -51,7 +54,9 @@ struct input_source {
|
||||
char *filename;
|
||||
int lineno;
|
||||
struct pending_input *input;
|
||||
#if !USE_CPPLIB
|
||||
struct putback_buffer putback;
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct input_source *input, *free_inputs;
|
||||
@ -62,9 +67,6 @@ extern int lineno;
|
||||
#if USE_CPPLIB
|
||||
extern unsigned char *yy_cur, *yy_lim;
|
||||
extern int yy_get_token ();
|
||||
#define GETC() (yy_cur < yy_lim ? *yy_cur++ : yy_get_token ())
|
||||
#else
|
||||
#define GETC() getc (finput)
|
||||
#endif
|
||||
|
||||
extern void feed_input PROTO((char *, int));
|
||||
@ -76,7 +78,6 @@ extern int input_redirected PROTO((void));
|
||||
static inline struct input_source * allocate_input PROTO((void));
|
||||
static inline void free_input PROTO((struct input_source *));
|
||||
static inline void end_input PROTO((void));
|
||||
static inline int sub_getch PROTO((void));
|
||||
|
||||
static inline struct input_source *
|
||||
allocate_input ()
|
||||
@ -104,8 +105,6 @@ free_input (inp)
|
||||
free_inputs = inp;
|
||||
}
|
||||
|
||||
static struct putback_buffer putback = {NULL, 0, -1};
|
||||
|
||||
/* Some of these external functions are declared inline in case this file
|
||||
is included in lex.c. */
|
||||
|
||||
@ -121,21 +120,28 @@ feed_input (str, len)
|
||||
while (len && !str[len-1])
|
||||
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->length = len;
|
||||
inp->offset = 0;
|
||||
inp->next = input;
|
||||
inp->filename = input_filename;
|
||||
inp->lineno = lineno;
|
||||
inp->input = save_pending_input ();
|
||||
inp->putback = putback;
|
||||
putback.buffer = NULL;
|
||||
putback.buffer_size = 0;
|
||||
putback.index = -1;
|
||||
#endif
|
||||
inp->next = input;
|
||||
inp->filename = input_filename;
|
||||
inp->lineno = lineno;
|
||||
inp->input = save_pending_input ();
|
||||
input = inp;
|
||||
}
|
||||
|
||||
struct pending_input *to_be_restored; /* XXX */
|
||||
extern int end_of_file;
|
||||
|
||||
static inline void
|
||||
@ -143,20 +149,28 @@ end_input ()
|
||||
{
|
||||
struct input_source *inp = input;
|
||||
|
||||
#if USE_CPPLIB
|
||||
cpp_pop_buffer (&parse_in);
|
||||
#else
|
||||
putback = inp->putback;
|
||||
#endif
|
||||
|
||||
end_of_file = 0;
|
||||
input = inp->next;
|
||||
input_filename = inp->filename;
|
||||
lineno = inp->lineno;
|
||||
/* Get interface/implementation back in sync. */
|
||||
extract_interface_info ();
|
||||
putback = inp->putback;
|
||||
restore_pending_input (inp->input);
|
||||
free_input (inp);
|
||||
}
|
||||
|
||||
static inline int
|
||||
sub_getch ()
|
||||
inline int
|
||||
getch ()
|
||||
{
|
||||
#if USE_CPPLIB
|
||||
return (yy_cur < yy_lim ? *yy_cur++ : yy_get_token ());
|
||||
#else
|
||||
if (putback.index != -1)
|
||||
{
|
||||
int ch = putback.buffer[putback.index];
|
||||
@ -178,7 +192,8 @@ sub_getch ()
|
||||
}
|
||||
return (unsigned char)input->str[input->offset++];
|
||||
}
|
||||
return GETC ();
|
||||
return getc (finput);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
@ -186,6 +201,14 @@ void
|
||||
put_back (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 (putback.index == putback.buffer_size - 1)
|
||||
@ -196,25 +219,16 @@ put_back (ch)
|
||||
my_friendly_assert (putback.buffer != NULL, 224);
|
||||
putback.buffer[++putback.index] = ch;
|
||||
}
|
||||
}
|
||||
|
||||
extern int linemode;
|
||||
|
||||
int
|
||||
getch ()
|
||||
{
|
||||
int ch = sub_getch ();
|
||||
if (linemode && ch == '\n')
|
||||
{
|
||||
put_back (ch);
|
||||
ch = EOF;
|
||||
}
|
||||
return ch;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
int
|
||||
input_redirected ()
|
||||
{
|
||||
#ifdef USE_CPPLIB
|
||||
return CPP_BUFFER(&parse_in)->manual_pop;
|
||||
#else
|
||||
return input != 0;
|
||||
#endif
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ Boston, MA 02111-1307, USA. */
|
||||
{"@c++-cpp-output",
|
||||
{"%{!M:%{!MM:%{!E:cc1plus %i %1 %2 %{!Q:-quiet} %{d*} %{m*} %{a}\
|
||||
%{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
|
||||
%{v:-version} %{pg:-p} %{p}\
|
||||
%{v:-version} %{pg:-p} %{p} -fpreprocessed\
|
||||
%{f*} %{+e*} %{aux-info*} %{Qn:-fno-ident}\
|
||||
%{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\
|
||||
|
1195
gcc/cp/lex.c
1195
gcc/cp/lex.c
File diff suppressed because it is too large
Load Diff
6986
gcc/cp/parse.c
6986
gcc/cp/parse.c
File diff suppressed because it is too large
Load Diff
@ -69,21 +69,20 @@ typedef union {long itype; tree ttype; char *strtype; enum tree_code code; flagg
|
||||
#define PLUSPLUS 325
|
||||
#define MINUSMINUS 326
|
||||
#define HYPERUNARY 327
|
||||
#define PAREN_STAR_PAREN 328
|
||||
#define POINTSAT 329
|
||||
#define TRY 330
|
||||
#define CATCH 331
|
||||
#define PRE_PARSED_FUNCTION_DECL 332
|
||||
#define EXTERN_LANG_STRING 333
|
||||
#define ALL 334
|
||||
#define PRE_PARSED_CLASS_DECL 335
|
||||
#define DEFARG 336
|
||||
#define DEFARG_MARKER 337
|
||||
#define TYPENAME_DEFN 338
|
||||
#define IDENTIFIER_DEFN 339
|
||||
#define PTYPENAME_DEFN 340
|
||||
#define END_OF_LINE 341
|
||||
#define END_OF_SAVED_INPUT 342
|
||||
#define POINTSAT 328
|
||||
#define TRY 329
|
||||
#define CATCH 330
|
||||
#define PRE_PARSED_FUNCTION_DECL 331
|
||||
#define EXTERN_LANG_STRING 332
|
||||
#define ALL 333
|
||||
#define PRE_PARSED_CLASS_DECL 334
|
||||
#define DEFARG 335
|
||||
#define DEFARG_MARKER 336
|
||||
#define TYPENAME_DEFN 337
|
||||
#define IDENTIFIER_DEFN 338
|
||||
#define PTYPENAME_DEFN 339
|
||||
#define END_OF_LINE 340
|
||||
#define END_OF_SAVED_INPUT 341
|
||||
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
@ -178,7 +178,7 @@ empty_parms ()
|
||||
%left <code> POINTSAT_STAR DOT_STAR
|
||||
%right <code> UNARY PLUSPLUS MINUSMINUS '~'
|
||||
%left HYPERUNARY
|
||||
%left <ttype> PAREN_STAR_PAREN LEFT_RIGHT
|
||||
%left <ttype> LEFT_RIGHT
|
||||
%left <code> POINTSAT '.' '(' '['
|
||||
|
||||
%right SCOPE /* C++ extension */
|
||||
@ -3174,7 +3174,6 @@ direct_abstract_declarator:
|
||||
'(' absdcl_intern ')'
|
||||
{ $$ = $2; }
|
||||
/* `(typedef)1' is `int'. */
|
||||
| PAREN_STAR_PAREN
|
||||
| direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
|
||||
{ $$ = make_call_declarator ($$, $3, $5, $6); }
|
||||
| direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* 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)
|
||||
|
||||
This file is part of GNU CC.
|
||||
@ -305,6 +305,16 @@ yylex ()
|
||||
#endif
|
||||
goto retry;
|
||||
|
||||
case '(':
|
||||
scan_tokens (1);
|
||||
if (nth_token (1)->yychar == ')')
|
||||
{
|
||||
consume_token ();
|
||||
tmp_token.yychar = LEFT_RIGHT;
|
||||
}
|
||||
consume_token ();
|
||||
break;
|
||||
|
||||
case IDENTIFIER:
|
||||
scan_tokens (1);
|
||||
if (nth_token (1)->yychar == SCOPE)
|
||||
@ -361,21 +371,31 @@ yylex ()
|
||||
break;
|
||||
|
||||
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 (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");
|
||||
consume_token ();
|
||||
goto retry;
|
||||
}
|
||||
else
|
||||
{
|
||||
++first_token;
|
||||
break;
|
||||
}
|
||||
/* do_aggr needs to check if the previous token was `friend',
|
||||
so just increment first_token instead of calling consume_token. */
|
||||
++first_token;
|
||||
break;
|
||||
|
||||
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. */
|
||||
++first_token;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user