Mercurial > hg > CbC > CbC_gcc
comparison gcc/c-family/c-ppoutput.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Preprocess only, using cpplib. | 1 /* Preprocess only, using cpplib. |
2 Copyright (C) 1995-2017 Free Software Foundation, Inc. | 2 Copyright (C) 1995-2018 Free Software Foundation, Inc. |
3 Written by Per Bothner, 1994-95. | 3 Written by Per Bothner, 1994-95. |
4 | 4 |
5 This program is free software; you can redistribute it and/or modify it | 5 This program is free software; you can redistribute it and/or modify it |
6 under the terms of the GNU General Public License as published by the | 6 under the terms of the GNU General Public License as published by the |
7 Free Software Foundation; either version 3, or (at your option) any | 7 Free Software Foundation; either version 3, or (at your option) any |
20 #include "system.h" | 20 #include "system.h" |
21 #include "coretypes.h" | 21 #include "coretypes.h" |
22 #include "c-common.h" /* For flags. */ | 22 #include "c-common.h" /* For flags. */ |
23 #include "../libcpp/internal.h" | 23 #include "../libcpp/internal.h" |
24 #include "c-pragma.h" /* For parse_in. */ | 24 #include "c-pragma.h" /* For parse_in. */ |
25 #include "file-prefix-map.h" /* remap_macro_filename() */ | |
25 | 26 |
26 /* Encapsulates state used to convert a stream of tokens into a text | 27 /* Encapsulates state used to convert a stream of tokens into a text |
27 file. */ | 28 file. */ |
28 static struct | 29 static struct |
29 { | 30 { |
149 cb->used_undef = cb_used_undef; | 150 cb->used_undef = cb_used_undef; |
150 } | 151 } |
151 | 152 |
152 cb->has_attribute = c_common_has_attribute; | 153 cb->has_attribute = c_common_has_attribute; |
153 cb->get_source_date_epoch = cb_get_source_date_epoch; | 154 cb->get_source_date_epoch = cb_get_source_date_epoch; |
155 cb->remap_filename = remap_macro_filename; | |
154 | 156 |
155 /* Initialize the print structure. */ | 157 /* Initialize the print structure. */ |
156 print.src_line = 1; | 158 print.src_line = 1; |
157 print.printed = false; | 159 print.printed = false; |
158 print.prev = 0; | 160 print.prev = 0; |
297 scan_translation_unit_directives_only (cpp_reader *pfile) | 299 scan_translation_unit_directives_only (cpp_reader *pfile) |
298 { | 300 { |
299 struct _cpp_dir_only_callbacks cb; | 301 struct _cpp_dir_only_callbacks cb; |
300 | 302 |
301 cb.print_lines = print_lines_directives_only; | 303 cb.print_lines = print_lines_directives_only; |
302 cb.maybe_print_line = (void (*) (source_location)) maybe_print_line; | 304 cb.maybe_print_line = maybe_print_line; |
303 | 305 |
304 _cpp_preprocess_dir_only (pfile, &cb); | 306 _cpp_preprocess_dir_only (pfile, &cb); |
305 } | 307 } |
306 | 308 |
307 /* Adjust print.src_line for newlines embedded in output. */ | 309 /* Adjust print.src_line for newlines embedded in output. */ |
528 | 530 |
529 static void | 531 static void |
530 cb_used_define (cpp_reader *pfile, source_location line ATTRIBUTE_UNUSED, | 532 cb_used_define (cpp_reader *pfile, source_location line ATTRIBUTE_UNUSED, |
531 cpp_hashnode *node) | 533 cpp_hashnode *node) |
532 { | 534 { |
533 macro_queue *q; | 535 if (cpp_user_macro_p (node)) |
534 if (node->flags & NODE_BUILTIN) | 536 { |
535 return; | 537 macro_queue *q; |
536 q = XNEW (macro_queue); | 538 q = XNEW (macro_queue); |
537 q->macro = xstrdup ((const char *) cpp_macro_definition (pfile, node)); | 539 q->macro = xstrdup ((const char *) cpp_macro_definition (pfile, node)); |
538 q->next = define_queue; | 540 q->next = define_queue; |
539 define_queue = q; | 541 define_queue = q; |
542 } | |
540 } | 543 } |
541 | 544 |
542 static void | 545 static void |
543 cb_used_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, | 546 cb_used_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, |
544 source_location line ATTRIBUTE_UNUSED, | 547 source_location line ATTRIBUTE_UNUSED, |
659 else | 662 else |
660 { | 663 { |
661 /* Bring current file to correct line when entering a new file. */ | 664 /* Bring current file to correct line when entering a new file. */ |
662 if (map->reason == LC_ENTER) | 665 if (map->reason == LC_ENTER) |
663 { | 666 { |
664 const line_map_ordinary *from = INCLUDED_FROM (line_table, map); | 667 maybe_print_line (linemap_included_from (map)); |
665 maybe_print_line (LAST_SOURCE_LINE_LOCATION (from)); | 668 flags = " 1"; |
666 } | 669 } |
667 if (map->reason == LC_ENTER) | |
668 flags = " 1"; | |
669 else if (map->reason == LC_LEAVE) | 670 else if (map->reason == LC_LEAVE) |
670 flags = " 2"; | 671 flags = " 2"; |
671 print_line (map->start_location, flags); | 672 print_line (map->start_location, flags); |
672 } | 673 } |
673 } | 674 } |
686 | 687 |
687 /* Dump out the hash table. */ | 688 /* Dump out the hash table. */ |
688 static int | 689 static int |
689 dump_macro (cpp_reader *pfile, cpp_hashnode *node, void *v ATTRIBUTE_UNUSED) | 690 dump_macro (cpp_reader *pfile, cpp_hashnode *node, void *v ATTRIBUTE_UNUSED) |
690 { | 691 { |
691 if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN)) | 692 if (cpp_user_macro_p (node)) |
692 { | 693 { |
693 fputs ("#define ", print.outf); | 694 fputs ("#define ", print.outf); |
694 fputs ((const char *) cpp_macro_definition (pfile, node), | 695 fputs ((const char *) cpp_macro_definition (pfile, node), |
695 print.outf); | 696 print.outf); |
696 putc ('\n', print.outf); | 697 putc ('\n', print.outf); |