X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fc-lex.c;h=b9c219091529c31582e4dd616ba36195a961b7b0;hb=c76251c17fd1812f7f84adbd5b9e26b32eb793f6;hp=51479beb53f3b31ca7c1595376da7f7f8e89b4f3;hpb=b97b38c02c932375b9aa195545c341707cd5038d;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 51479beb53f..b9c21909152 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -398,14 +398,30 @@ check_newline () && getc (finput) == 'a' && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n')) { + while (c == ' ' || c == '\t') + c = getc (finput); + if (c == '\n') + return c; #ifdef HANDLE_SYSV_PRAGMA - return handle_sysv_pragma (finput, c); + ungetc (c, finput); + token = yylex (); + if (token != IDENTIFIER) + goto skipline; + return handle_sysv_pragma (finput, token); #else /* !HANDLE_SYSV_PRAGMA */ #ifdef HANDLE_PRAGMA - HANDLE_PRAGMA (finput, c); + ungetc (c, finput); + token = yylex (); + if (token != IDENTIFIER) + goto skipline; + if (HANDLE_PRAGMA (finput, yylval.ttype)) + { + c = getc (finput); + return c; + } #endif /* HANDLE_PRAGMA */ - goto skipline; #endif /* !HANDLE_SYSV_PRAGMA */ + goto skipline; } } @@ -418,12 +434,8 @@ check_newline () && getc (finput) == 'e' && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n')) { -#ifdef DWARF_DEBUGGING_INFO - if (c != '\n' - && (debug_info_level == DINFO_LEVEL_VERBOSE) - && (write_symbols == DWARF_DEBUG)) - dwarfout_define (lineno, get_directive_line (finput)); -#endif /* DWARF_DEBUGGING_INFO */ + if (c != '\n') + debug_define (lineno, get_directive_line (finput)); goto skipline; } } @@ -435,12 +447,8 @@ check_newline () && getc (finput) == 'f' && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n')) { -#ifdef DWARF_DEBUGGING_INFO - if (c != '\n' - && (debug_info_level == DINFO_LEVEL_VERBOSE) - && (write_symbols == DWARF_DEBUG)) - dwarfout_undef (lineno, get_directive_line (finput)); -#endif /* DWARF_DEBUGGING_INFO */ + if (c != '\n') + debug_undef (lineno, get_directive_line (finput)); goto skipline; } } @@ -592,16 +600,7 @@ linenum: p->name = input_filename; input_file_stack = p; input_file_stack_tick++; -#ifdef DBX_DEBUGGING_INFO - if (write_symbols == DBX_DEBUG) - dbxout_start_new_source_file (input_filename); -#endif -#ifdef DWARF_DEBUGGING_INFO - if (debug_info_level == DINFO_LEVEL_VERBOSE - && write_symbols == DWARF_DEBUG) - dwarfout_start_new_source_file (input_filename); -#endif /* DWARF_DEBUGGING_INFO */ - + debug_start_source_file (input_filename); used_up = 1; } else if (TREE_INT_CST_LOW (yylval.ttype) == 2) @@ -613,15 +612,7 @@ linenum: input_file_stack = p->next; free (p); input_file_stack_tick++; -#ifdef DBX_DEBUGGING_INFO - if (write_symbols == DBX_DEBUG) - dbxout_resume_previous_source_file (); -#endif -#ifdef DWARF_DEBUGGING_INFO - if (debug_info_level == DINFO_LEVEL_VERBOSE - && write_symbols == DWARF_DEBUG) - dwarfout_resume_previous_source_file (input_file_stack->line); -#endif /* DWARF_DEBUGGING_INFO */ + debug_end_source_file (input_file_stack->line); } else error ("#-lines for entering and leaving files don't match"); @@ -684,28 +675,22 @@ linenum: #ifdef HANDLE_SYSV_PRAGMA /* Handle a #pragma directive. INPUT is the current input stream, - and C is a character to reread. Processes the entire input line - and returns a character for the caller to reread: either \n or EOF. */ + and TOKEN is the token we read after `#pragma'. Processes the entire input + line and returns a character for the caller to reread: either \n or EOF. */ /* This function has to be in this file, in order to get at the token types. */ int -handle_sysv_pragma (input, c) +handle_sysv_pragma (input, token) FILE *input; - int c; + register int token; { + register int c; + for (;;) { - while (c == ' ' || c == '\t') - c = getc (input); - if (c == '\n' || c == EOF) - { - handle_pragma_token (0, 0); - return c; - } - ungetc (c, input); - switch (yylex ()) + switch (token) { case IDENTIFIER: case TYPENAME: @@ -716,10 +701,21 @@ handle_sysv_pragma (input, c) default: handle_pragma_token (token_buffer, 0); } + if (nextchar >= 0) c = nextchar, nextchar = -1; else c = getc (input); + + while (c == ' ' || c == '\t') + c = getc (input); + if (c == '\n' || c == EOF) + { + handle_pragma_token (0, 0); + return c; + } + ungetc (c, input); + token = yylex (); } } @@ -965,11 +961,6 @@ yylex () value = ENDFILE; break; - case '$': - if (dollars_in_ident) - goto letter; - return '$'; - case 'L': /* Capital L may start a wide-string or wide-character constant. */ { @@ -1020,6 +1011,7 @@ yylex () case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '_': + case '$': letter: p = token_buffer; while (isalnum (c) || c == '_' || c == '$' || c == '@') @@ -1027,8 +1019,13 @@ yylex () /* Make sure this char really belongs in an identifier. */ if (c == '@' && ! doing_objc_thang) break; - if (c == '$' && ! dollars_in_ident) - break; + if (c == '$') + { + if (! dollars_in_ident) + error ("`$' in identifier"); + else if (pedantic) + pedwarn ("`$' in identifier"); + } if (p >= token_buffer + maxtoken) p = extend_token_buffer (p); @@ -1118,7 +1115,23 @@ yylex () break; - case '0': case '1': case '2': case '3': case '4': + case '0': case '1': + { + int next_c; + /* Check first for common special case: single-digit 0 or 1. */ + + next_c = getc (finput); + ungetc (next_c, finput); /* Always undo this lookahead. */ + if (!isalnum (next_c) && next_c != '.') + { + token_buffer[0] = (char)c, token_buffer[1] = '\0'; + yylval.ttype = (c == '0') ? integer_zero_node : integer_one_node; + value = CONSTANT; + break; + } + /*FALLTHRU*/ + } + case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': { @@ -1428,7 +1441,8 @@ yylex () /* Create a node with determined type and value. */ if (imag) - yylval.ttype = build_complex (convert (type, integer_zero_node), + yylval.ttype = build_complex (NULL_TREE, + convert (type, integer_zero_node), build_real (type, value)); else yylval.ttype = build_real (type, value); @@ -1597,8 +1611,9 @@ yylex () if (TYPE_PRECISION (type) <= TYPE_PRECISION (integer_type_node)) yylval.ttype - = build_complex (integer_zero_node, - convert (integer_type_node, yylval.ttype)); + = build_complex (NULL_TREE, integer_zero_node, + convert (integer_type_node, + yylval.ttype)); else error ("complex integer constant is too wide for `complex int'"); } @@ -1619,7 +1634,7 @@ yylex () ungetc (c, finput); *p = 0; - if (isalnum (c) || c == '.' || c == '_' + if (isalnum (c) || c == '.' || c == '_' || c == '$' || (!flag_traditional && (c == '-' || c == '+') && (p[-1] == 'e' || p[-1] == 'E'))) error ("missing white space after number `%s'", token_buffer);