OSDN Git Service

PR c++/15463
[pf3gnuchains/gcc-fork.git] / gcc / cppmacro.c
index c797100..e3d0dc3 100644 (file)
@@ -116,6 +116,7 @@ static const char * const monthnames[] =
 const uchar *
 _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
 {
+  const struct line_map *map;
   const uchar *result = NULL;
   unsigned int number = 1;
 
@@ -132,7 +133,7 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
        unsigned int len;
        const char *name;
        uchar *buf;
-       const struct line_map *map = pfile->map;
+       map = linemap_lookup (pfile->line_table, pfile->line_table->highest_line);
 
        if (node->value.builtin == BT_BASE_FILE)
          while (! MAIN_FILE_P (map))
@@ -157,14 +158,15 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
       break;
 
     case BT_SPECLINE:
+      map = &pfile->line_table->maps[pfile->line_table->used-1];
       /* If __LINE__ is embedded in a macro, it must expand to the
         line of the macro's invocation, not its definition.
         Otherwise things like assert() will not work properly.  */
       if (CPP_OPTION (pfile, traditional))
-       number = pfile->line;
+       number = pfile->line_table->highest_line;
       else
-       number = pfile->cur_token[-1].line;
-      number = SOURCE_LINE (pfile->map, number);
+       number = pfile->cur_token[-1].src_loc;
+      number = SOURCE_LINE (map, number);
       break;
 
       /* __STDC__ has the value 1 under normal circumstances.
@@ -174,7 +176,7 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
         value 0.  */
     case BT_STDC:
       {
-       if (CPP_IN_SYSTEM_HEADER (pfile)
+       if (cpp_in_system_header (pfile)
            && CPP_OPTION (pfile, stdc_0_in_system_headers)
            && !CPP_OPTION (pfile,std))
          number = 0;
@@ -1136,6 +1138,10 @@ cpp_sys_macro_p (cpp_reader *pfile)
 void
 cpp_scan_nooutput (cpp_reader *pfile)
 {
+  /* Request a CPP_EOF token at the end of this file, rather than
+     transparently continuing with the including file.  */
+  pfile->buffer->return_at_eof = true;
+
   if (CPP_OPTION (pfile, traditional))
     while (_cpp_read_logical_line_trad (pfile))
       ;
@@ -1321,11 +1327,14 @@ parse_params (cpp_reader *pfile, cpp_macro *macro)
              _cpp_save_parameter (pfile, macro,
                                   pfile->spec_nodes.n__VA_ARGS__);
              pfile->state.va_args_ok = 1;
-             if (! CPP_OPTION (pfile, c99) && CPP_OPTION (pfile, pedantic))
+             if (! CPP_OPTION (pfile, c99)
+                 && CPP_OPTION (pfile, pedantic)
+                 && CPP_OPTION (pfile, warn_variadic_macros))
                cpp_error (pfile, CPP_DL_PEDWARN,
                           "anonymous variadic macros were introduced in C99");
            }
-         else if (CPP_OPTION (pfile, pedantic))
+         else if (CPP_OPTION (pfile, pedantic)
+                  && CPP_OPTION (pfile, warn_variadic_macros))
            cpp_error (pfile, CPP_DL_PEDWARN,
                       "ISO C does not permit named variadic macros");
 
@@ -1488,7 +1497,7 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node)
   macro->count = 0;
   macro->fun_like = 0;
   /* To suppress some diagnostics.  */
-  macro->syshdr = pfile->map->sysp != 0;
+  macro->syshdr = pfile->buffer && pfile->buffer->sysp != 0;
 
   if (CPP_OPTION (pfile, traditional))
     ok = _cpp_create_trad_definition (pfile, macro);