OSDN Git Service

* cppfiles.c (open_file): Correct typo.
[pf3gnuchains/gcc-fork.git] / gcc / c-ppoutput.c
index 692ea7a..10540b7 100644 (file)
@@ -246,7 +246,8 @@ print_line (source_location src_loc, const char *special_flags)
       const struct line_map *map = linemap_lookup (&line_table, src_loc);
 
       size_t to_file_len = strlen (map->to_file);
-      unsigned char *to_file_quoted = alloca (to_file_len * 4 + 1);
+      unsigned char *to_file_quoted =
+         (unsigned char *) alloca (to_file_len * 4 + 1);
       unsigned char *p;
 
       print.src_line = SOURCE_LINE (map, src_loc);
@@ -256,7 +257,8 @@ print_line (source_location src_loc, const char *special_flags)
       p = cpp_quote_string (to_file_quoted,
                            (unsigned char *) map->to_file, to_file_len);
       *p = '\0';
-      fprintf (print.outf, "# %u \"%s\"%s", print.src_line,
+      fprintf (print.outf, "# %u \"%s\"%s",
+              print.src_line == 0 ? 1 : print.src_line,
               to_file_quoted, special_flags);
 
       if (map->sysp == 2)
@@ -322,7 +324,8 @@ cb_define (cpp_reader *pfile, source_location line, cpp_hashnode *node)
     fputs ((const char *) NODE_NAME (node), print.outf);
 
   putc ('\n', print.outf);
-  print.src_line++;
+  if (linemap_lookup (&line_table, line)->to_line != 0)
+    print.src_line++;
 }
 
 static void
@@ -367,7 +370,8 @@ void
 pp_dir_change (cpp_reader *pfile ATTRIBUTE_UNUSED, const char *dir)
 {
   size_t to_file_len = strlen (dir);
-  unsigned char *to_file_quoted = alloca (to_file_len * 4 + 1);
+  unsigned char *to_file_quoted =
+     (unsigned char *) alloca (to_file_len * 4 + 1);
   unsigned char *p;
 
   /* cpp_quote_string does not nul-terminate, so we have to do it ourselves.  */
@@ -448,7 +452,7 @@ cb_read_pch (cpp_reader *pfile, const char *name,
             int fd, const char *orig_name ATTRIBUTE_UNUSED)
 {
   c_common_read_pch (pfile, name, fd, orig_name);
-  
+
   fprintf (print.outf, "#pragma GCC pch_preprocess \"%s\"\n", name);
   print.src_line++;
 }