* c-decl.c (diagnose_mismatched_decls, grokdeclarator, grokfield)
(finish_struct): Refer to C11 in comments. Use flag_isoc11.
* c-parser.c (c_parser_static_assert_declaration)
(c_parser_static_assert_declaration_no_semi, c_parser_declspecs)
(c_parser_alignas_specifier, c_parser_alignof_expression): Refer
to C11 in comments. Use flag_isoc11.
* c-typeck.c (comptypes_check_different_types): Refer to C11 in
comment.
* doc/cpp.texi (Overview): Refer to -std=c11 instead of -std=c1x.
* doc/cppopts.texi (-std=c11, -std=gnu11): Document in preference
to -std=c1x and -std=gnu1x.
* doc/extend.texi (Inline, Alternate Keywords, Other Builtins)
(__builtin_complex, Unnamed Fields): Refer to -std=c11 and C11
instead of -std=c1x and C1X.
* doc/invoke.texi (-std=c11, -std=iso9899:2011): Document in
preference to -std=c1x.
(-std=gnu11): Document in preference to -std=gnu1x.
* doc/standards.texi: Document C11 instead of C1X. Document C11
as actual standard. Document headers required from freestanding
C11 implementations.
* ginclude/float.h, ginclude/stddef.h: Test __STDC_VERSION__ >=
201112L for C11. Update comments to refer to C11.
gcc/c-family:
* c-common.c (flag_isoc99): Update comment to refer to C11.
(flag_isoc1x): Change to flag_isoc11.
* c-common.h (flag_isoc99): Update comment to refer to C11.
(flag_isoc1x): Change to flag_isoc11.
* c-cppbuiltin.c (cpp_atomic_builtins): Change comment to refer to
C11.
* c-opts.c (set_std_c1x): Change to set_std_c11.
(c_common_handle_option): Handle OPT_std_c11 and OPT_std_gnu11.
Call set_std_c11.
(set_std_c89, set_std_c99, set_std_c11): Use flag_isoc11.
(set_std_c1): Use CLK_STDC11 and CLK_GNUC11.
* c.opt (std=c1x): Change to std=c11. Document as non-draft
standard.
(std=c1x, std=iso9899:2011): Add as aliases of std=c11.
(std=gnu1x): Change to std=gnu11. Refer to non-draft standard.
(std=gnu1x): Make alias of std=gnu11.
gcc/testsuite:
* gcc.dg/c11-version-1.c, gcc.dg/c11-version-2.c,
gcc.dg/c94-version-1.c, gcc.dg/c99-version-1.c,
gcc.dg/gnu11-version-1.c: New tests.
libcpp:
* include/cpplib.h (CLK_GNUC1X): Change to CLK_GNUC11.
(CLK_STDC1X): Change to CLK_STDC11.
* init.c (lang_defaults): Update comments.
(cpp_init_builtins): Update language tests. Use 201112L for C11
__STDC_VERSION__.
From-SVN: r182551
PR c++/50958
gcc/cp/
* parser.c (lookup_literal_operator): New.
(cp_parser_userdef_char_literal): Use it.
(cp_parser_userdef_numeric_literal): Use it.
(cp_parser_userdef_string_literal): Use lookup_name.
libcpp/
* expr.c (cpp_userdef_char_remove_type): Fix typo.
From-SVN: r181595
libcpp/
* include/line-map.h (linemap_expand_location): Take a line table
parameter. Update comment.
(linemap_resolve_location): Update comment.
(linemap_expand_location_full): Remove.
* line-map.c (linemap_resolve_location): Handle reserved
locations; return a NULL map in those cases.
(linemap_expand_location): If location is reserved, return a
zeroed expanded location. Update comment. Take a line table to
assert that the function takes non-virtual locations only.
(linemap_expand_location_full): remove.
(linemap_dump_location): Handle the fact that
linemap_resolve_location can return NULL line maps when the
location resolves to a reserved location.
gcc/
* input.c (expand_location): Rewrite using
linemap_resolve_location and linemap_expand_location. Add a
comment.
From-SVN: r180426
libcpp/
* include/internal.h (_cpp_remaining_tokens_num_in_context): Take the
context to act upon.
* lex.c (_cpp_remaining_tokens_num_in_context): Likewise. Update
comment.
(cpp_token_from_context_at): Likewise.
(cpp_peek_token): Use the context to peek tokens from.
From-SVN: r180328
libcpp/
* include/line-map.h (struct linemap_stats): Change the type of
the members from size_t to long.
* macro.c (macro_arg_token_iter_init): Unconditionally initialize
iter->location_ptr.
gcc/c-family/
* c-lex.c (fe_file_change): Use LINEMAP_SYSP when
!NO_IMPLICIT_EXTERN_C.
gcc/
* input.c (dump_line_table_statistics): Use long, not size_t.
From-SVN: r180124
libcpp/ChangeLog
* line-map.c (linemap_macro_map_loc_to_exp_point): Avoid setting a
variable without using it if ENABLE_CHECKING is not defined. Mark
the LOCATION parameter as being unused.
From-SVN: r180090
This patch basically arranges for the allocation size of line_map
buffers to be as close as possible to a power of two. This
*significantly* decreases peak memory consumption as (macro) maps are
numerous and stay live during all the compilation.
The patch adds a new ggc_round_alloc_size interface to the ggc
allocator. In each of the two main allocator implementations ('page'
and 'zone') the function has been extracted from the main allocation
function code and returns the actual size of the allocated memory
region, thus giving a chance to the caller to maximize the amount of
memory it actually uses from the allocated memory region. In the
'none' allocator implementation (that uses xmalloc) the
ggc_round_alloc_size just returns the requested allocation size.
Co-Authored-By: Dodji Seketeli <dodji@redhat.com>
From-SVN: r180086
This patch adds statistics about line maps' memory consumption and
macro expansion to the output of -fmem-report. It has been useful in
trying to reduce the memory consumption of the macro maps support.
Co-Authored-By: Dodji Seketeli <dodji@redhat.com>
From-SVN: r180085
This patch adds -fdebug-cpp option. When used with -E this dumps the
relevant macro map before every single token. This clutters the output
a lot but has proved to be invaluable in tracking some bugs during the
development of the virtual location support.
Co-Authored-By: Dodji Seketeli <dodji@redhat.com>
From-SVN: r180084
This second instalment uses the infrastructure of the previous patch
to allocate a macro map for each macro expansion and assign a virtual
location to each token resulting from the expansion.
To date when cpp_get_token comes across a token that happens to be a
macro, the macro expander kicks in, expands the macro, pushes the
resulting tokens onto a "token context" and returns a dummy padding
token. The next call to cpp_get_token goes look into the token context
for the next token [which is going to result from the previous macro
expansion] and returns it. If the token is a macro, the macro expander
kicks in and you know the story.
This patch piggy-backs on that macro expansion process, so to speak.
First it modifies the macro expander to make it create a macro map for
each macro expansion. It then allocates a virtual location for each
resulting token. Virtual locations of tokens resulting from macro
expansions are then stored on a special kind of context called an
"expanded tokens context". In other words, in an expanded tokens
context, there are tokens resulting from macro expansion and their
associated virtual locations. cpp_get_token_with_location is modified
to return the virtual location of tokens resulting from macro
expansion. Note that once all tokens from an expanded token context have
been consumed and the context and is freed, the memory used to store the
virtual locations of the tokens held in that context is freed as well.
This helps reducing the overall peak memory consumption.
The client code that was getting macro expansion point location from
cpp_get_token_with_location now gets virtual location from it. Those
virtual locations can in turn be resolved into the different
interesting physical locations thanks to the linemap API exposed by
the previous patch.
Expensive progress. Possibly. So this whole virtual location
allocation business is switched off by default. So by default no
extended token is created. No extended token context is created
either. One has to use -ftrack-macro-expansion to switch this on. This
complicates the code but I believe it can be useful as some of our
friends found out at http://llvm.org/bugs/show_bug.cgi?id=5610
The patch tries to reduce the memory consumption by freeing some token
context memory that was being reused before. I didn't notice any
compilation slow down due to this immediate freeing on my GNU/Linux
system.
As no client code tries to resolve virtual locations to anything but
what was being done before, no new test case has been added.
Co-Authored-By: Dodji Seketeli <dodji@redhat.com>
From-SVN: r180082
This is the first instalment of a set which goal is to track locations
of tokens across macro expansions. Tom Tromey did the original work
and attached the patch to PR preprocessor/7263. This opus is a
derivative of that original work.
This patch modifies the linemap module of libcpp to add virtual
locations support.
A virtual location is a mapped location that can resolve to several
different physical locations. It can always resolve to the spelling
location of a token. For tokens resulting from macro expansion it can
resolve to:
- either the location of the expansion point of the macro.
- or the location of the token in the definition of the
macro
- or, if the token is an argument of a function-like macro,
the location of the use of the matching macro parameter in
the definition of the macro
The patch creates a new type of line map called a macro map. For every
single macro expansion, there is a macro map that generates a virtual
location for every single resulting token of the expansion.
The good old type of line map we all know is now called an ordinary
map. That one still encodes spelling locations as it has always had.
As a result linemap_lookup as been extended to return a macro map when
given a virtual location resulting from a macro expansion. The layout
of structs line_map has changed to support this new type of map. So
did the layout of struct line_maps. Accessor macros have been
introduced to avoid messing with the implementation details of these
datastructures directly. This helped already as we have been testing
different ways of arranging these datastructure. Having to constantly
adjust client code that is too tied with the internals of line_map and
line_maps would have been even more painful.
Of course, many new public functions have been added to the linemap
module to handle the resolution of virtual locations.
This patch introduces the infrastructure but no part of the compiler
uses virtual locations yet.
However the client code of the linemap data structures has been
adjusted as per the changes. E.g, it's not anymore reliable for a
client code to manipulate struct line_map directly if it just wants to
deal with spelling locations, because struct line_map can now
represent a macro map as well. In that case, it's better to use the
convenient API to resolve the initial (possibly virtual) location to a
spelling location (or to an ordinary map) and use that.
This is the reason why the patch adjusts the Java, Ada and Fortran
front ends.
Also, note that virtual locations are not supposed to be ordered for
relations '<' and '>' anymore. To test if a virtual location appears
"before" another one, one has to use a new operator exposed by the
line map interface. The patch updates the only spot (in the
diagnostics module) I have found that was making the assumption that
locations were ordered for these relations. This is the only change
that introduces a use of the new line map API in this patch, so I am
adding a regression test for it only.
From-SVN: r180081
libcpp/
* line-map.c (linemap_add): Assert that reason must not be
LC_RENAME when called for the first time on a "main input file".
c-family/
* c-pch.c (c_common_read_pch): Call linemap_add with LC_ENTER as it's
the first time it's being called on this main TU.
gcc/lto/
* lto-lang.c (lto_init): Likewise. Also, avoid calling
linemap_add twice.
gcc/fortran/
* scanner.c (load_file): Don't abuse LC_RENAME reason while
(indirectly) calling linemap_add.
From-SVN: r178146
Use it to force BUILTINS_LOCATION when declaring builtins instead of creating a <built-in> entry in the line_table which is wrong.
* c-opts.c (c_finish_options): Force BUILTINS_LOCATION for tokens
defined in cpp_init_builtins and c_cpp_builtins.
gcc/fortran/ChangeLog
* cpp.c (gfc_cpp_init): Force BUILTINS_LOCATION for tokens
defined in cpp_define_builtins.
libcpp/ChangeLog
* init.c (cpp_create_reader): Inititalize forced_token_location_p.
* internal.h (struct cpp_reader): Add field forced_token_location_p.
* lex.c (_cpp_lex_direct): Use forced_token_location_p.
(cpp_force_token_locations): New.
(cpp_stop_forcing_token_locations): New.
From-SVN: r177973
LINEMAP_POSITION_FOR_COLUMN had the exact same effect as
linemap_position_for_column, removed it and updated users
to use linemap_position_for_column instead
libcpp/ChangeLog
* include/line-map.h (LINEMAP_POSITION_FOR_COLUMN): Remove.
Update all users to use linemap_position_for_column instead.
gcc/go/ChangeLog
* gofrontend/lex.cc (Lex::location): Update to use
linemap_position_for_column instead.
(Lex::earlier_location): Likewise.
From-SVN: r177768
gcc/
2011-07-28 H.J. Lu <hongjiu.lu@intel.com>
* config.gcc: Set need_64bit_hwint to yes for x86 targets.
libcpp/
2011-07-28 H.J. Lu <hongjiu.lu@intel.com>
* configure.ac: Set need_64bit_hwint to yes for x86 targets.
* configure: Regenerated.
From-SVN: r176871
* system.h [__cplusplus]: Wrap C function declarations in extern "C".
-This line, and those below, will be ignored--
M ChangeLog
M system.h
From-SVN: r176748
libcpp/
* directives.c (struct if_stack): Use source_location as type
here.
* include/cpplib.h (struct cpp_callbacks)<include, define, undef,
indent, def_pragma, used_define, used_undef>: Properly use
source_location as parameter type, rather than unsigned int.
From-SVN: r176333
PR preprocessor/48532
libcpp/
* directives.c (do_pragma): Don't forget the invocation location
when parsing the pragma name of a namespaced pragma directive.
gcc/testsuite/
* gcc.dg/cpp/pragma-3.c: New test case.
From-SVN: r174694
PR target/49104
* config/i386/cpuid.h (bit_MMXEXT): New define.
libcpp/ChangeLog:
2011-05-22 Uros Bizjak <ubizjak@gmail.com>
PR target/49104
* lex.c (init_vectorized_lexer): Do not set "minimum" when __3dNOW_A__
is defined. Check bit_MMXEXT and bit_CMOV to use search_line_mmx.
From-SVN: r174032
PR preprocessor/48740
* lex.c (lex_raw_string): When raw string ends with
??) followed by raw prefix and ", ensure it is preprocessed
with ??) rather than ??].
* c-c++-common/raw-string-11.c: New test.
From-SVN: r172903
Change "if (E) free (E);" to "free (E);" everywhere except in the
libgo/, intl/, zlib/ and classpath/ directories.
Also transform equivalent variants like
"if (E != NULL) free (E);" and allow an extra cast on the
argument to free. Otherwise, the tested and freed "E"
expressions must be identical, modulo white space.
From-SVN: r172785