Change HANDLE_PRAGMA macro so that it will work with USE_CPPLIB

From-SVN: r22166
This commit is contained in:
Nick Clifton 1998-09-02 10:02:27 +00:00 committed by Nick Clifton
parent f09db6e0ca
commit ae4d12ca9f
4 changed files with 147 additions and 22 deletions

View File

@ -1,3 +1,16 @@
Wed Sep 02 09:25:29 1998 Nick Clifton <nickc@cygnus.com>
* lex.c (check_newline): Call HANDLE_PRAGMA before
HANDLE_SYSV_PRAGMA if both are defined. Generate warning messages
if unknown pragmas are encountered.
(handle_sysv_pragma): Interpret return code from
handle_pragma_token (). Return success/failure indication rather
than next unprocessed character.
(pragma_getc): New function: retrieves characters from the
input stream. Defined when HANDLE_PRAGMA is defined.
(pragma_ungetc): New function: replaces characters back into the
input stream. Defined when HANDLE_PRAGMA is defined.
1998-09-01 Jason Merrill <jason@yorick.cygnus.com>
* decl2.c (output_vtable_inherit): Use %cDIGIT in the operands.

View File

@ -2216,6 +2216,32 @@ get_last_nonwhite_on_line ()
return c;
}
#if defined HANDLE_PRAGMA
/* Local versions of these macros, that can be passed as function pointers. */
static int
pragma_getc ()
{
int c;
if (nextchar != EOF)
{
c = nextchar;
nextchar = EOF;
}
else
c = getch ();
return c;
}
static void
pragma_ungetc (arg)
int arg;
{
yyungetc (arg, 0);
}
#endif /* HANDLE_PRAGMA */
/* At the beginning of a line, increment the line number
and process any #-directive on this line.
If the line is a #-directive, read the entire line and return a newline.
@ -2282,21 +2308,29 @@ check_newline ()
else if (token == END_OF_LINE)
goto skipline;
#ifdef HANDLE_PRAGMA
/* We invoke HANDLE_PRAGMA before HANDLE_SYSV_PRAGMA
(if both are defined), in order to give the back
end a chance to override the interpretation of
SYSV style pragmas. */
if (HANDLE_PRAGMA (pragma_getc, pragma_ungetc,
IDENTIFIER_POINTER (yylval.ttype)))
goto skipline;
#endif /* HANDLE_PRAGMA */
#ifdef HANDLE_SYSV_PRAGMA
if (handle_sysv_pragma (token))
goto skipline;
#else
#ifdef HANDLE_PRAGMA
#if USE_CPPLIB
/* TODO: ??? */
goto skipline;
#else
if (HANDLE_PRAGMA (finput, yylval.ttype))
goto skipline;
#endif /* !USE_CPPLIB */
#endif
#endif
#endif /* !HANDLE_SYSV_PRAGMA */
/* Issue a warning message if we have been asked to do so.
Ignoring unknown pragmas in system header file unless
an explcit -Wunknown-pragmas has been given. */
if (warn_unknown_pragmas > 1
|| (warn_unknown_pragmas && ! in_system_header))
warning ("ignoring pragma: %s", token_buffer);
}
goto skipline;
}
else if (c == 'd')
@ -4730,7 +4764,33 @@ handle_cp_pragma (pname)
{
register int token;
if (! strcmp (pname, "unit"))
if (! strcmp (pname, "vtable"))
{
extern tree pending_vtables;
/* More follows: it must be a string constant (class name). */
token = real_yylex ();
if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
{
error ("invalid #pragma vtable");
return -1;
}
if (write_virtuals != 2)
{
warning ("use `+e2' option to enable #pragma vtable");
return -1;
}
pending_vtables
= perm_tree_cons (NULL_TREE,
get_identifier (TREE_STRING_POINTER (yylval.ttype)),
pending_vtables);
token = real_yylex ();
if (token != END_OF_LINE)
warning ("trailing characters ignored");
return 1;
}
else if (! strcmp (pname, "unit"))
{
/* More follows: it must be a string constant (unit name). */
token = real_yylex ();
@ -4895,7 +4955,7 @@ handle_sysv_pragma (token)
case TYPENAME:
case STRING:
case CONSTANT:
handle_pragma_token ("ignored", yylval.ttype);
handle_pragma_token (IDENTIFIER_POINTER(yylval.ttype), yylval.ttype);
break;
case '(':
handle_pragma_token ("(", NULL_TREE);
@ -4915,8 +4975,7 @@ handle_sysv_pragma (token)
break;
case END_OF_LINE:
default:
handle_pragma_token (NULL_PTR, NULL_TREE);
return 1;
return handle_pragma_token (NULL_PTR, NULL_TREE);
}
token = real_yylex ();
}

View File

@ -1,3 +1,14 @@
Wed Sep 02 09:25:29 1998 Nick Clifton <nickc@cygnus.com>
* lex.c (ffe_lex_hash): Change how HANDLE_PRAGMA and
HANDLE_SYSV_PRAGMA would be called if they pragma parsing was
enabled in this code.
Generate warning messages if unknown pragmas are encountered.
(pragma_getc): New function: retrieves characters from the
input stream. Defined when HANDLE_PRAGMA is defined.
(pragma_ungetc): New function: replaces characters back into the
input stream. Defined when HANDLE_PRAGMA is defined.
Tue Sep 1 10:00:21 1998 Craig Burley <burley@gnu.org>
* bugs.texi, g77.1, g77.texi, intdoc.in, news.texi: Doc updates

View File

@ -1,5 +1,5 @@
/* Implementation of Fortran lexer
Copyright (C) 1995-1997 Free Software Foundation, Inc.
Copyright (C) 1995-1998 Free Software Foundation, Inc.
Contributed by James Craig Burley (burley@gnu.org).
This file is part of GNU Fortran.
@ -1077,6 +1077,23 @@ ffelex_get_directive_line_ (char **text, FILE *finput)
Returns the next character unhandled, which is always newline or EOF. */
#if FFECOM_targetCURRENT == FFECOM_targetGCC
#if defined HANDLE_PRAGMA
/* Local versions of these macros, that can be passed as function pointers. */
static int
pragma_getc ()
{
return getc (finput);
}
static void
pragma_ungetc (arg)
int arg;
{
ungetc (arg, finput);
}
#endif /* HANDLE_PRAGMA */
static int
ffelex_hash_ (FILE *finput)
{
@ -1105,17 +1122,42 @@ ffelex_hash_ (FILE *finput)
&& ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'
|| c == EOF))
{
goto skipline;
#if 0 /* g77 doesn't handle pragmas, so ignores them FOR NOW. */
#ifdef HANDLE_SYSV_PRAGMA
return handle_sysv_pragma (finput, c);
#else /* !HANDLE_SYSV_PRAGMA */
static char buffer [128];
char * buff = buffer;
/* Read the pragma name into a buffer. */
while (isspace (c = getc (finput)))
continue;
do
{
* buff ++ = c;
c = getc (finput);
}
while (c != EOF && ! isspace (c) && c != '\n'
&& buff < buffer + 128);
pragma_ungetc (c);
* -- buff = 0;
#ifdef HANDLE_PRAGMA
HANDLE_PRAGMA (finput);
if (HANDLE_PRAGMA (pragma_getc, pragma_ungetc, buffer))
goto skipline;
#endif /* HANDLE_PRAGMA */
goto skipline;
#ifdef HANDLE_SYSV_PRAGMA
if (handle_sysv_pragma (buffer))
goto skipline;
#endif /* !HANDLE_SYSV_PRAGMA */
/* Issue a warning message if we have been asked to do so.
Ignoring unknown pragmas in system header file unless
an explcit -Wunknown-pragmas has been given. */
if (warn_unknown_pragmas > 1
|| (warn_unknown_pragmas && ! in_system_header))
warning ("ignoring pragma: %s", token_buffer);
#endif /* 0 */
goto skipline;
}
}