aboutsummaryrefslogtreecommitdiff
path: root/libcpp
AgeCommit message (Collapse)AuthorFilesLines
2015-05-13libcpp: Replace macro usage with C++ constructsDavid Malcolm3-113/+517
libcpp/ChangeLog: * include/line-map.h (MAX_SOURCE_LOCATION): Convert from a macro to a const source_location. (RESERVED_LOCATION_COUNT): Likewise. (linemap_check_ordinary): Convert from a macro to a pair of inline functions, for const/non-const arguments. (MAP_START_LOCATION): Likewise. (ORDINARY_MAP_STARTING_LINE_NUMBER): Likewise. (ORDINARY_MAP_INCLUDER_FILE_INDEX): Likewise. (ORDINARY_MAP_IN_SYSTEM_HEADER_P): Likewise. (ORDINARY_MAP_NUMBER_OF_COLUMN_BITS): Convert from a macro to a pair of inline functions, for const/non-const arguments, where the latter is named... (SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS): New function. (ORDINARY_MAP_FILE_NAME): Convert from a macro to a pair of inline functions, for const/non-const arguments. (MACRO_MAP_MACRO): Likewise. (MACRO_MAP_NUM_MACRO_TOKENS): Likewise. (MACRO_MAP_LOCATIONS): Likewise. (MACRO_MAP_EXPANSION_POINT_LOCATION): Likewise. (LINEMAPS_MAP_INFO): Likewise. (LINEMAPS_MAPS): Likewise. (LINEMAPS_ALLOCATED): Likewise. (LINEMAPS_USED): Likewise. (LINEMAPS_CACHE): Likewise. (LINEMAPS_ORDINARY_CACHE): Likewise. (LINEMAPS_MACRO_CACHE): Likewise. (LINEMAPS_MAP_AT): Convert from a macro to an inline function. (LINEMAPS_LAST_MAP): Likewise. (LINEMAPS_LAST_ALLOCATED_MAP): Likewise. (LINEMAPS_ORDINARY_MAPS): Likewise. (LINEMAPS_ORDINARY_MAP_AT): Likewise. (LINEMAPS_ORDINARY_ALLOCATED): Likewise. (LINEMAPS_ORDINARY_USED): Likewise. (LINEMAPS_LAST_ORDINARY_MAP): Likewise. (LINEMAPS_LAST_ALLOCATED_ORDINARY_MAP): Likewise. (LINEMAPS_MACRO_MAPS): Likewise. (LINEMAPS_MACRO_MAP_AT): Likewise. (LINEMAPS_MACRO_ALLOCATED): Likewise. (LINEMAPS_MACRO_USED): Likewise. (LINEMAPS_MACRO_LOWEST_LOCATION): Likewise. (LINEMAPS_LAST_MACRO_MAP): Likewise. (LINEMAPS_LAST_ALLOCATED_MACRO_MAP): Likewise. (IS_ADHOC_LOC): Likewise. (COMBINE_LOCATION_DATA): Likewise. (SOURCE_LINE): Likewise. (SOURCE_COLUMN): Likewise. (LAST_SOURCE_LINE_LOCATION): Likewise. (LAST_SOURCE_LINE): Likewise. (LAST_SOURCE_COLUMN): Likewise. (LAST_SOURCE_LINE_LOCATION) (INCLUDED_FROM): Likewise. (MAIN_FILE_P): Likewise. (LINEMAP_FILE): Likewise. (LINEMAP_LINE): Likewise. (LINEMAP_SYSP): Likewise. (linemap_location_before_p): Likewise. * line-map.c (linemap_check_files_exited): Make local "map" const. (linemap_add): Use SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS. (linemap_line_start): Likewise. From-SVN: r223152
2015-05-13libcpp: Bump to automake 1.11.6Michael Haubenwallner2-2/+7
2015-05-13 Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com> * aclocal.m4: Regenerated with automake-1.11.6. From-SVN: r223133
2015-05-13line-map.h: move linemap_assert and friends higher up within the fileDavid Malcolm2-35/+44
libcpp/ChangeLog: * include/line-map.h (linemap_assert): Move up within the file to before all of the map accessor macros. (linemap_assert_fails): Likewise. (linemap_check_ordinary): Likewise. (linemap_macro_expansion_map_p): Likewise. From-SVN: r223121
2015-05-12Implement -Wmisleading-indentationDavid Malcolm3-2/+14
gcc/ChangeLog: * doc/invoke.texi (Warning Options): Add -Wmisleading-indentation. (-Wmisleading-indentation): New option. * Makefile.in (C_COMMON_OBJS): Add c-family/c-indentation.o. gcc/c-family/ChangeLog: * c-common.h (warn_for_misleading_indentation): New prototype. * c-indentation.c: New file. * c.opt (Wmisleading-indentation): New option. gcc/c/ChangeLog: * c-parser.c (c_parser_if_body): Add param "if_loc", use it to add a call to warn_for_misleading_indentation. (c_parser_else_body): Likewise, adding param "else_loc". (c_parser_if_statement): Check for misleading indentation. (c_parser_while_statement): Likewise. (c_parser_for_statement): Likewise. gcc/cp/ChangeLog: * parser.c (cp_parser_selection_statement): Add location and guard_kind arguments to calls to cp_parser_implicitly_scoped_statement. (cp_parser_iteration_statement): Likewise for calls to cp_parser_already_scoped_statement. (cp_parser_implicitly_scoped_statement): Add "guard_loc" and "guard_kind" params; use them to warn for misleading indentation. (cp_parser_already_scoped_statement): Likewise. gcc/testsuite/ChangeLog: * c-c++-common/Wmisleading-indentation.c: New testcase. * c-c++-common/Wmisleading-indentation-2.c: New testcase. * c-c++-common/Wmisleading-indentation-2.md: New file. libcpp/ChangeLog: * directives.c (do_line): Set seen_line_directive on line_table. (do_linemarker): Likewise. * include/line-map.h (struct line_maps): Add new field "seen_line_directive". From-SVN: r223098
2015-05-09lex.c (lex_string): Add -Wc++11-compat warning.Jason Merrill4-1/+19
libcpp/ * lex.c (lex_string): Add -Wc++11-compat warning. * include/cpplib.h: Add CPP_W_CXX11_COMPAT. (struct cpp_options): Add cpp_warn_cxx11_compat. * init.c (cpp_create_reader): Initialize it. gcc/c-family/ * c.opt (Wc++0x-compat): Set it. From-SVN: r222961
2015-05-05Fix indentation issues seen by -Wmisleading-indentationDavid Malcolm2-1/+6
gcc/ChangeLog: * auto-profile.c (afdo_find_equiv_class): Fix indentation so that it reflects the block structure. (afdo_propagate_edge): Likewise. (afdo_calculate_branch_prob): Likewise. (afdo_annotate_cfg): Likewise. * cfgcleanup.c (equal_different_set_p): Likewise. (try_crossjump_to_edge): Likewise. * cgraph.c (cgraph_node::verify_node): Likewise. * cgraphunit.c (expand_all_functions): Likewise. * config/i386/i386.c (ix86_expand_copysign): Likewise. (exact_dependency_1): Likewise. * dwarf2asm.c (dw2_output_indirect_constants): Likewise. * dwarf2out.c (tree_add_const_value_attribute_for_decl): Likewise. * gensupport.c (process_define_subst): Likewise. * lto-wrapper.c (merge_and_complain): Likewise. * tree-if-conv.c (if_convertible_bb_p): Likewise. * tree-ssa-loop-prefetch.c (find_or_create_group): Likewise. * tree-ssa-tail-merge.c (gsi_advance_fw_nondebug_nonlocal): Likewise. * tree-vect-data-refs.c (vect_grouped_load_supported): Likewise. * tree-vect-loop.c (vectorizable_reduction): Likewise. * tree-vect-slp.c (vect_transform_slp_perm_load): Likewise. * tree-vect-stmts.c (vectorizable_shift): Likewise. * tree-vrp.c (vrp_finalize): Likewise. * tree.c (variably_modified_type_p): Likewise. gcc/cp/ChangeLog: * parser.c (cp_parser_asm_definition): Only test for error_mark_node if "outputs" was just set. (cp_parser_asm_definition): Likewise for "inputs". gcc/fortran/ChangeLog: * expr.c (check_inquiry): Fix indentation so that it reflects the block structure. * interface.c (compare_parameter): Likewise. * parse.c (parse_oacc_structured_block): Likewise. * target-memory.c (expr_to_char): Likewise. * trans-types.c (gfc_init_kinds): Likewise. libcpp/ChangeLog: * pch.c (cpp_valid_state): Fix indentation so that it reflects the block structure. From-SVN: r222823
2015-05-05libcpp: Improvements to comments in line-map.h/cDavid Malcolm3-3/+78
libcpp/ChangeLog: * include/line-map.h: Fix comment at the top of the file. (source_location): Rewrite and expand the comment for this typedef, adding an ascii-art table to clarify how source_location values are allocated. * line-map.c: Fix comment at the top of the file. From-SVN: r222806
2015-05-01* sv.po: Update.Joseph Myers2-2/+6
From-SVN: r222692
2015-04-30be.po, [...]: Update.Joseph Myers22-1241/+1247
* be.po, ca.po, da.po, de.po, el.po, eo.po, es.po, fi.po, fr.po, id.po, ja.po, nl.po, pr_BR.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po, zh_TW.po: Update. From-SVN: r222646
2015-04-13gcc.pot: Regenerate.Joseph Myers2-9/+13
gcc/po: * gcc.pot: Regenerate. libcpp/po: * cpplib.pot: Regenerate. From-SVN: r222061
2015-04-12* sr.po: Update.Joseph Myers2-49/+25
From-SVN: r222021
2015-04-11* fr.po: Update.Joseph Myers2-180/+141
From-SVN: r221996
2015-04-10* fr.po: Update.Joseph Myers2-19185/+217
From-SVN: r221989
2015-04-09re PR pch/65550 (ICE (segfault) with pch)Richard Biener2-5/+13
2015-04-09 Richard Biener <rguenther@suse.de> PR pch/65550 * files.c (pch_open_file): Allow main and pre-included files when trying to open a PCH. From-SVN: r221949
2015-04-07* da.po: Update.Joseph Myers2-15495/+240
From-SVN: r221908
2015-04-07gcc.pot: Regenerate.Joseph Myers2-63/+67
gcc/po: * gcc.pot: Regenerate. libcpp/po: * cpplib.pot: Regenerate. From-SVN: r221904
2015-04-06re PR preprocessor/61977 (powerpc preprocessor breaks on lines that end with ↵Jakub Jelinek2-2/+11
"vector") PR preprocessor/61977 * lex.c (cpp_peek_token): If peektok is CPP_EOF, back it up with all tokens peeked by the current function. * gcc.dg/cpp/pr61977.c: New test. From-SVN: r221882
2015-04-02re PR preprocessor/61977 (powerpc preprocessor breaks on lines that end with ↵Jakub Jelinek2-0/+12
"vector") PR preprocessor/61977 * lex.c (cpp_peek_token): Temporarily clear pfile->cb.line_change. * gcc.target/powerpc/pr61977-1.c: New test. * gcc.target/powerpc/pr61977-2.c: New test. From-SVN: r221839
2015-03-24* fr.po: Update.Joseph Myers2-2/+6
From-SVN: r221638
2015-03-23* fr.po: Update.Joseph Myers2-6/+11
From-SVN: r221598
2015-03-23re PR preprocessor/65238 (__has_attribute is not handled properly with ↵Jakub Jelinek4-18/+163
-traditional-cpp.) PR preprocessor/65238 * internal.h (_cpp_scan_out_logical_line): Add third argument. * directives.c (prepare_directive_trad): Pass false to it. * traditional.c (_cpp_read_logical_line_trad, _cpp_create_trad_definition): Likewise. (struct fun_macro): Add paramc field. (fun_like_macro): New function. (maybe_start_funlike): Handle NODE_BUILTIN macros. Initialize macro->paramc field. (save_argument): Use macro->paramc instead of macro->node->value.macro->paramc. (push_replacement_text): Formatting fix. (recursive_macro): Use fun_like_macro helper. (_cpp_scan_out_logical_line): Likewise. Add BUILTIN_MACRO_ARG argument. Initialize fmacro.paramc field. Handle builtin function-like macros. * c-c++-common/cpp/pr65238-1.c: New test. * gcc.dg/cpp/pr65238-2.c: New test. * gcc.dg/cpp/trad/pr65238-3.c: New test. * gcc.dg/cpp/trad/pr65238-4.c: New test. From-SVN: r221587
2015-03-17re PR c++/64626 (C++14 single quote should not always be a digit separator)Edward Smith-Rowland2-0/+9
libcpp/ 2015-03-16 Edward Smith-Rowland <3dw4rd@verizon.net> PR c++/64626 * lex.c (lex_number): If a number ends with digit-seps (') skip back and let lex_string take them. gcc/testsuite/ 2015-03-16 Edward Smith-Rowland <3dw4rd@verizon.net> PR c++/64626 g++.dg/cpp1y/pr64626-1.C: New. g++.dg/cpp1y/pr64626-2.C: New. g++.dg/cpp1y/digit-sep-neg.C: Adjust errors and warnings. From-SVN: r221470
2015-03-04re PR target/65261 (bootstrap-ubsan ppc64le: gcc/libcpp/lex.c:552:30: ↵Markus Trippelsdorf2-0/+6
runtime error: load of misaligned address 0x01002172dfc6 for type 'const uchar', which requires 16 byte alignment) Fix PR65261 Running bootstrap-ubsan on ppc64le shows many instances of: libcpp/lex.c:552:30: runtime error: load of misaligned address 0x01001f31d37a for type 'const uchar', which requires 16 byte alignment But the unaligned vector loads are intended in this case, because they are preferable to forced-alignment on POWER8. So just silence the ubsan errors. 2015-03-02 Markus Trippelsdorf <markus@trippelsdorf.de> include/ PR target/65261 * ansidecl.h (ATTRIBUTE_NO_SANITIZE_UNDEFINED): New macro. libcpp/ PR target/65261 * lex.c (search_line_fast): Silence ubsan errors. From-SVN: r221190
2015-02-25be.po, [...]: Update.Joseph Myers22-7254/+5705
* be.po, ca.po, da.po, de.po, el.po, eo.po, es.po, fi.po, fr.po, id.po, ja.po, nl.po, pr_BR.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po, zh_TW.po: Update. From-SVN: r220976
2015-02-03PR preprocessor/64803 - __LINE__ inside macro is not constantDodji Seketeli3-3/+45
Consider the example code mentionned in this PR: $ cat -n test.c 1 #define C(a, b) a ## b 2 #define L(x) C(L, x) 3 #define M(a) goto L(__LINE__); __LINE__; L(__LINE__): 4 M(a /* --> this is the line of the expansion point of M. */ 5 ); /* --> this is the line of the end of the invocation of M. */ $ "cc1 -quiet -E test.c" yields: goto L5; 5; L4: ; Notice how we have a 'L4' there, where it should be L5. That is the issue. My understanding is that during the *second* expansion of __LINE__ (the one between the two L(__LINE__)), builtin_macro() is called by enter_macro_context() with the location of the expansion point of M (which is at line 4). Then _cpp_builtin_macro_text() expands __LINE__ into the line number of the location of the last token that has been lexed, which is the location of the closing parenthesis of the invocation of M, at line 5. So that invocation of __LINE__ is expanded into 5. Now let's see why the last invocation of __LINE__ is expanded into 4. In builtin_macro(), we have this code at some point: /* Set pfile->cur_token as required by _cpp_lex_direct. */ pfile->cur_token = _cpp_temp_token (pfile); cpp_token *token = _cpp_lex_direct (pfile); /* We should point to the expansion point of the builtin macro. */ token->src_loc = loc; The first two statements insert a new token in the stream of lexed token and pfile->cur_token[-1], is the "new" last token that has been lexed. But the location of pfile->cur_token[-1] is the same location as the location of the "previous" pfile->cur_token[-1], by courtesy of _cpp_temp_token(). So normally, in subsequent invocations of builtin_macro(), the location of pfile->cur_token[-1] should always be the location of the closing parenthesis of the invocation of M at line 5. Except that that code in master now has the statement "token->src_loc = loc;" on the next line. That statement actually sets the location of pfile->cur_token[-1] to 'loc'. Which is the location of the expansion point of M, which is on line 4. So in the subsequent call to builtin_macro() (for the last expansion of __LINE__ in L(__LINE__)), for _cpp_builtin_macro_text(), pfile->cur_token[-1].src_loc is going to have a line number of 4. I think the core issue here is that the location that is passed to builtin_macro() from enter_macro_context() is not correct when we are in presence of a top-most function-like macro invocation; in that case, that location should be the location of the closing parenthesis of the macro invocation. Otherwise, if we are in presence of a a top-most object-like macro invocation then the location passed down to builtin_macro should be the location of the expansion point of the macro. That way, in the particular case of the input code above, the location received by builtin_macro() will always have line number 5. Boostrapped and tested on x86_64-unknown-linux-gnu against trunk. libcpp/ChangeLog: * internal.h (cpp_reader::top_most_macro_node): New data member. * macro.c (enter_macro_context): Pass the location of the end of the top-most invocation of the function-like macro, or the location of the expansion point of the top-most object-like macro. (cpp_get_token_1): Store the top-most macro node in the new pfile->top_most_macro_node data member. (_cpp_pop_context): Clear the new cpp_reader::top_most_macro_node data member. gcc/testsuite/ChangeLog: * gcc.dg/cpp/builtin-macro-1.c: New test case. Signed-off-by: Dodji Seketeli <dodji@redhat.com> From-SVN: r220367
2015-02-02Regenerate .pot files.Joseph Myers2-221/+288
gcc/po: * gcc.pot: Regenerate. libcpp/po: * cpplib.pot: Regenerate. From-SVN: r220349
2015-01-30[Patch/libcpp] Change __ARM_NEON__ to __ARM_NEON in lex.cSzabolcs Nagy2-1/+5
2015-01-30 Szabolcs Nagy <szabolcs.nagy@arm.com> * lex.c (search_line_fast): Change __ARM_NEON__ to __ARM_NEON. From-SVN: r220281
2015-01-23re PR preprocessor/60570 (expression in 'elif' directive mis-diagnosed as ↵Marek Polacek2-16/+16
error when group will be skipped) DR#412 PR preprocessor/60570 * directives.c (do_elif): Don't evaluate #elif conditionals when they don't need to be. * gcc.dg/cpp/pr36320.c: Turn dg-error into dg-bogus. * gcc.dg/cpp/pr60570.c: New test. From-SVN: r220035
2015-01-16expr.c (cpp_classify_number): Add N_() around ?...Jakub Jelinek2-3/+8
* expr.c (cpp_classify_number): Add N_() around ?: string literals used in cpp_error_with_line call as format string. From-SVN: r219759
2015-01-05Update copyright years.Jakub Jelinek27-27/+31
From-SVN: r219188
2014-12-19re PR preprocessor/63831 (r217292 causes segfaults with -MM)Jakub Jelinek10-46/+34
PR preprocessor/63831 * c-cppbuiltin.c (c_cpp_builtins): Don't define __has_attribute and __has_cpp_attribute here. * c-ppoutput.c (init_pp_output): Set cb->has_attribute to c_common_has_attribute. * c-common.h (c_common_has_attribute): New prototype. * c-lex.c (init_c_lex): Set cb->has_attribute to c_common_has_attribute instead of cb_has_attribute. (get_token_no_padding): New function. (cb_has_attribute): Renamed to ... (c_common_has_attribute): ... this. No longer static. Use get_token_no_padding, require ()s, don't build TREE_LIST unnecessarily, fix up formatting, adjust diagnostics, call init_attributes. * directives.c (lex_macro_node): Remove __has_attribute__ handling. * internal.h (struct spec_node): Remove n__has_attribute__ field. (struct lexer_state): Remove in__has_attribute__ field. * macro.c (_cpp_builtin_macro_text): Handle BT_HAS_ATTRIBUTE. * identifiers.c (_cpp_init_hashtable): Remove __has_attribute__ handling. * init.c (builtin_array): Add __has_attribute and __has_cpp_attribute. (cpp_init_special_builtins): Don't initialize __has_attribute or __has_cpp_attribute if CLK_ASM or pfile->cb.has_attribute is NULL. * traditional.c (enum ls): Remove ls_has_attribute, ls_has_attribute_close. (_cpp_scan_out_logical_line): Remove __has_attribute__ handling. * include/cpplib.h (enum cpp_builtin_type): Add BT_HAS_ATTRIBUTE. * pch.c (cpp_read_state): Remove __has_attribute__ handling. * expr.c (eval_token): Likewise. (parse_has_attribute): Removed. * c-c++-common/cpp/pr63831-1.c: New test. * c-c++-common/cpp/pr63831-2.c: New test. From-SVN: r218948
2014-12-11xvasprintf.c: New file.Uros Bizjak2-2/+6
* xvasprintf.c: New file. * vprintf-support.h: Likewise. * vprintf-support.c: Likewise. * Makefile.in (CFILES): Add vprintf-support.c, xvasprintf.c. (REQUIRED_OFILES): Add vprintf-support.$(objext), xvasprintf.$(objext). (vprintf-support.$(objext), xvasprintf.$(objext)): New targets. (vasprintf.$(objext)): Depend on $(srcdir)/vprintf-support.h. * functions.texi: Regenerate. * vasprintf.c (int_vasprintf): Use libiberty_vprintf_buffer_size. include/ChangeLog: * libiberty.h (xvasprintf): Declare. libcpp/ChangeLog: * directives.c (cpp_define_formatted): Use xvasprintf. Co-Authored-By: Ben Elliston <bje@au.ibm.com> Co-Authored-By: Manuel López-Ibáñez <manu@gcc.gnu.org> From-SVN: r218618
2014-12-04line-map.c (linemap_position_for_loc_and_offset): Add new linemap_assert_fails.Manuel López-Ibáñez2-1/+7
libcpp/ChangeLog: 2014-12-05 Manuel López-Ibáñez <manu@gcc.gnu.org> * line-map.c (linemap_position_for_loc_and_offset): Add new linemap_assert_fails. gcc/fortran/ChangeLog: 2014-12-05 Manuel López-Ibáñez <manu@gcc.gnu.org> * scanner.c (gfc_next_char_literal): Use gfc_warning_now. (load_file): Use the line length as the column hint for linemap_line_start. Reserve a location for the highest column of the line. From-SVN: r218407
2014-12-02line-map.h (linemap_assert_fails): Declare.Manuel López-Ibáñez3-5/+28
libcpp/ChangeLog: 2014-12-02 Manuel López-Ibáñez <manu@gcc.gnu.org> * include/line-map.h (linemap_assert_fails): Declare. * line-map.c (linemap_position_for_loc_and_offset): Use it. From-SVN: r218277
2014-12-02line-map.c (linemap_add): Fix typo.Manuel López-Ibáñez2-1/+6
2014-12-02 Manuel López-Ibáñez <manu@gcc.gnu.org> * line-map.c (linemap_add): Fix typo. (linemap_line_start): Fix whitespace. From-SVN: r218276
2014-11-29Fix off-by-one bug in utf16 conversion (PR preprocessor/41698).Joseph Myers2-1/+7
libcpp: 2014-11-29 John Schmerge <jbschmerge@gmail.com> PR preprocessor/41698 * charset.c (one_utf8_to_utf16): Do not produce surrogate pairs for 0xffff. gcc/testsuite: 2014-11-29 Joseph Myers <joseph@codesourcery.com> PR preprocessor/41698 * gcc/testsuite/g++.dg/cpp/utf16-pr41698-1.C: New test. From-SVN: r218179
2014-11-25re PR preprocessor/60436 (C preprocessor segfaults on assembly file)Jakub Jelinek2-5/+12
PR preprocessor/60436 * line-map.c (linemap_line_start): If highest is above 0x60000000 and we are still tracking columns or highest is above 0x70000000, force add_map. From-SVN: r218042
2014-11-20re PR target/63966 (inconsistent operand constraints compiling build libcpp)Uros Bizjak2-7/+3
PR target/63966 * lex.c [__i386__ || __x86_64__]: Compile special SSE functions only for (__GNUC__ >= 5 || !defined(__PIC__)). From-SVN: r217851
2014-11-20re PR target/63966 (inconsistent operand constraints compiling build libcpp)Uros Bizjak2-0/+10
PR target/63966 * lex.c [__i386__ || __x86_64__]: Include system <cpuid.h> for GCC_VERSION < 5000. From-SVN: r217830
2014-11-13line-map.h: Include EXPR, so that unused variable warnings do not occur.Manuel López-Ibáñez2-1/+7
* include/line-map.h: Include EXPR, so that unused variable warnings do not occur. From-SVN: r217473
2014-11-11re PR fortran/44054 (Handle -Werror, -Werror=, -fdiagnostics-show-option, ↵Manuel López-Ibáñez3-0/+59
!GCC$ diagnostic (pragmas) and color) libcpp/ChangeLog: 2014-11-11 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/44054 * include/line-map.h (linemap_position_for_loc_and_offset): Declare. * line-map.c (linemap_position_for_loc_and_offset): New. gcc/fortran/ChangeLog: 2014-11-11 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/44054 * gfortran.h (warn_use_without_only): Remove. (gfc_diagnostics_finish): Declare. * error.c: Include tree-diagnostics.h (gfc_format_decoder): New. (gfc_diagnostics_init): Use gfc_format_decoder. Set default caret char. (gfc_diagnostics_finish): Restore tree diagnostics defaults, but keep gfc_diagnostics_starter and finalizer. Restore default caret. * options.c: Remove all uses of warn_use_without_only. * lang.opt (Wuse-without-only): Add Var. * f95-lang.c (gfc_be_parse_file): Call gfc_diagnostics_finish. * module.c (gfc_use_module): Use gfc_warning_now_2. * parse.c (decode_statement): Likewise. (decode_gcc_attribute): Likewise. (next_free): Likewise. (next_fixed): Likewise. gcc/testsuite/ChangeLog: 2014-11-11 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/44054 * lib/gfortran-dg.exp: Update regexp to match locus and message without caret. * gfortran.dg/use_without_only_1.f90: Add column numbers. * gfortran.dg/warnings_are_errors_1.f: Update. From-SVN: r217383
2014-11-11Merger of dmalcolm/jit branch from gitDavid Malcolm2-0/+26
ChangeLog: * ChangeLog.jit: New. * MAINTAINERS (Various Maintainers): Add myself as jit maintainer. contrib/ChangeLog: * ChangeLog.jit: New. * jit-coverage-report.py: New file: a script to print crude code-coverage information for the libgccjit API. gcc/ChangeLog: * ChangeLog.jit: New. * Makefile.in (doc_build_sys): New variable, set to "sphinx" if sphinx is installed, falling back to "texinfo" otherwise. (FULL_DRIVER_NAME): New variable, adapted from the install-driver target. New target, a symlink within the builddir, linked to "xgcc", for use when running the JIT library from the builddir. (MOSTLYCLEANFILES): Add FULL_DRIVER_NAME. (install-driver): Use $(FULL_DRIVER_NAME) rather than spelling it out. * configure.ac (doc_build_sys): New variable, set to "sphinx" if sphinx is installed, falling back to "texinfo" otherwise. (GCC_DRIVER_NAME): Generate a gcc-driver-name.h file containing GCC_DRIVER_NAME for the benefit of jit/internal-api.c. * configure: Regenerate. * doc/install.texi (--enable-host-shared): Specify that this is required when building libgccjit. (Tools/packages necessary for modifying GCC): Add Sphinx. * timevar.def (TV_JIT_REPLAY): New. (TV_ASSEMBLE): New. (TV_LINK): New. (TV_LOAD): New. gcc/java/ChangeLog: * gcc/ChangeLog.jit: New. gcc/jit/ChangeLog: * ChangeLog.jit: New. * ChangeLog: New. * Make-lang.in: New. * TODO.rst: New. * config-lang.in: New. * docs/Makefile: New. * docs/_build/texinfo/Makefile: New. * docs/_build/texinfo/factorial.png: New. * docs/_build/texinfo/libgccjit.texi: New. * docs/_build/texinfo/sum-of-squares.png: New. * docs/conf.py: New. * docs/examples/tut01-hello-world.c: New. * docs/examples/tut02-square.c: New. * docs/examples/tut03-sum-of-squares.c: New. * docs/examples/tut04-toyvm/Makefile: New. * docs/examples/tut04-toyvm/factorial.toy: New. * docs/examples/tut04-toyvm/fibonacci.toy: New. * docs/examples/tut04-toyvm/toyvm.c: New. * docs/index.rst: New. * docs/internals/index.rst: New. * docs/intro/factorial.png: New. * docs/intro/index.rst: New. * docs/intro/sum-of-squares.png: New. * docs/intro/tutorial01.rst: New. * docs/intro/tutorial02.rst: New. * docs/intro/tutorial03.rst: New. * docs/intro/tutorial04.rst: New. * docs/topics/contexts.rst: New. * docs/topics/expressions.rst: New. * docs/topics/functions.rst: New. * docs/topics/index.rst: New. * docs/topics/locations.rst: New. * docs/topics/objects.rst: New. * docs/topics/results.rst: New. * docs/topics/types.rst: New. * dummy-frontend.c: New. * jit-builtins.c: New. * jit-builtins.h: New. * jit-common.h: New. * jit-playback.c: New. * jit-playback.h: New. * jit-recording.c: New. * jit-recording.h: New. * libgccjit++.h: New. * libgccjit.c: New. * libgccjit.h: New. * libgccjit.map: New. * notes.txt: New. gcc/testsuite/ChangeLog: * ChangeLog.jit: New. * jit.dg/all-non-failing-tests.h: New. * jit.dg/harness.h: New. * jit.dg/jit.exp: New. * jit.dg/test-accessing-struct.c: New. * jit.dg/test-accessing-union.c: New. * jit.dg/test-array-as-pointer.c: New. * jit.dg/test-arrays.c: New. * jit.dg/test-calling-external-function.c: New. * jit.dg/test-calling-function-ptr.c: New. * jit.dg/test-combination.c: New. * jit.dg/test-dot-product.c: New. * jit.dg/test-empty.c: New. * jit.dg/test-error-accessing-field-in-other-struct.c: New. * jit.dg/test-error-adding-to-terminated-block.c: New. * jit.dg/test-error-array-as-pointer.c: New. * jit.dg/test-error-bad-cast.c: New. * jit.dg/test-error-block-in-wrong-function.c: New. * jit.dg/test-error-call-through-ptr-with-mismatching-args.c: New. * jit.dg/test-error-call-through-ptr-with-non-function.c: New. * jit.dg/test-error-call-through-ptr-with-non-pointer.c: New. * jit.dg/test-error-call-through-ptr-with-not-enough-args.c: New. * jit.dg/test-error-call-through-ptr-with-too-many-args.c: New. * jit.dg/test-error-call-with-mismatching-args.c: New. * jit.dg/test-error-call-with-not-enough-args.c: New. * jit.dg/test-error-call-with-too-many-args.c: New. * jit.dg/test-error-dereference-field-of-non-pointer.c: New. * jit.dg/test-error-dereference-read-of-non-pointer.c: New. * jit.dg/test-error-get-type-bad-enum.c: New. * jit.dg/test-error-index-not-a-numeric-type.c: New. * jit.dg/test-error-mismatching-types-in-assignment.c: New. * jit.dg/test-error-mismatching-types-in-call.c: New. * jit.dg/test-error-missing-return.c: New. * jit.dg/test-error-new-binary-op-bad-op.c: New. * jit.dg/test-error-new-function-bad-kind.c: New. * jit.dg/test-error-new-unary-op-bad-op.c: New. * jit.dg/test-error-null-passed-to-api.c: New. * jit.dg/test-error-return-within-void-function.c: New. * jit.dg/test-error-unreachable-block.c: New. * jit.dg/test-error-unterminated-block.c: New. * jit.dg/test-error-value-not-a-numeric-type.c: New. * jit.dg/test-expressions.c: New. * jit.dg/test-factorial.c: New. * jit.dg/test-fibonacci.c: New. * jit.dg/test-functions.c: New. * jit.dg/test-fuzzer.c: New. * jit.dg/test-hello-world.c: New. * jit.dg/test-linked-list.c: New. * jit.dg/test-long-names.c: New. * jit.dg/test-nested-contexts.c: New. * jit.dg/test-nested-loops.c: New. * jit.dg/test-operator-overloading.cc: New. * jit.dg/test-quadratic.c: New. * jit.dg/test-quadratic.cc: New. * jit.dg/test-reading-struct.c: New. * jit.dg/test-string-literal.c: New. * jit.dg/test-sum-of-squares.c: New. * jit.dg/test-threads.c: New. * jit.dg/test-types.c: New. * jit.dg/test-using-global.c: New. * jit.dg/test-volatile.c: New. include/ChangeLog: * ChangeLog.jit: New. libbacktrace/ChangeLog: * ChangeLog.jit: New. libcpp/ChangeLog: * ChangeLog.jit: New. libdecnumber/ChangeLog: * ChangeLog.jit: New. libiberty/ChangeLog: * ChangeLog.jit: New. zlib/ChangeLog: * ChangeLog.jit: New. From-SVN: r217374
2014-11-10cpplib.h (cpp_callbacks): Add has_attribute.Edward Smith-Rowland8-3/+62
libcpp: 2014-11-10 Edward Smith-Rowland <3dw4rd@verizon.net> * include/cpplib.h (cpp_callbacks): Add has_attribute. * internal.h (lexer_state): Add in__has_attribute__. * directives.c (lex_macro_node): Prevent use of __has_attribute__ as a macro. * expr.c (parse_has_attribute): New function; (eval_token): Look for __has_attribute__ and route to parse_has_attribute. * identifiers.c (_cpp_init_hashtable): Initialize n__has_attribute__. * pch.c (cpp_read_state): Initialize n__has_attribute__. * traditional.c (enum ls): Add ls_has_attribute, ls_has_attribute_close; (_cpp_scan_out_logical_line): Attend to __has_attribute__. gcc/c-family: 2014-11-10 Edward Smith-Rowland <3dw4rd@verizon.net> * c-cppbuiltin.c (__has_attribute, __has_cpp_attribute): New macros; (__cpp_rtti, __cpp_exceptions): New macros for C++98; (__cpp_range_based_for, __cpp_initializer_lists, __cpp_delegating_constructors, __cpp_nsdmi, __cpp_inheriting_constructors, __cpp_ref_qualifiers): New macros for C++11; (__cpp_attribute_deprecated): Remove in favor of __has_cpp_attribute. * c-lex.c (cb_has_attribute): New callback CPP function; (init_c_lex): Set has_attribute callback. gcc/testsuite: 2014-11-10 Edward Smith-Rowland <3dw4rd@verizon.net> * g++.dg/cpp1y/feat-cxx11.C: Test new feature macros for C++98 and C++11; Test existence of __has_cpp_attribute; Test C++11 attributes. * g++.dg/cpp1y/feat-cxx11-neg.C: Ditto. * g++.dg/cpp1y/feat-cxx14.C: Ditto and test for C++14 attributes. * g++.dg/cpp1y/feat-cxx98.C: Test new feature macros for C++98. * g++.dg/cpp1y/feat-cxx98-neg.C: Ditto. * g++.dg/cpp1y/feat-neg.C: Test that __cpp_rtti, _cpp_exceptions will be undefined for -fno-rtti -fno-exceptions. From-SVN: r217292
2014-11-07* ja.po: Update.Joseph Myers2-18/+13
From-SVN: r217220
2014-11-06Preserve original spellings of extended identifiers.Joseph Myers7-46/+132
This patch makes cpplib track the original spellings of extended identifiers, as well as the canonical UTF-8 version, in order to follow standard semantics properly without needing a convoluted and undocumented canonicalization in translation phase 1 (see bug 9449 comments 39-46 regarding such a canonicalization). The spelling is tracked in cpp_identifier and cpp_macro_arg without making cpp_token any larger. The original spelling is used for checks of duplicate macro definitions, stringizing (see the C++ tests added; this case is only an issue for C++ not C because C makes it implementation-defined whether a \ is inserted before the \ of a UCN in a string or character constant when stringizing, while C++ does not), pasting (relevant when the result is then stringized for C++) and when macro definitions are output as text (e.g. for -d options). Once a macro has been defined, only the original spelling of the argument names needs keeping in the argument list. While it is being defined, however, both spellings are needed: the original one for subsequent saving for checks of duplicate macro definitions, and the canonical one which is the node marked specially to generate macro argument tokens rather than normal identifier tokens. The buffer that is used to save the original values of the identifier tokens is changed so that it stores both those original values and a pointer to the canonical hash nodes, so that those canonical nodes can be found when their values need restoring after the macro definition has been parsed. I believe this covers the known standards issues in extended identifiers support (the remaining unimplemented C99 areas in GCC all being floating-point-related), except for C++ translation of extended characters to UCNs in phase 1 (which I have no plans to work on). There are however probably issues left with handling of extended identifiers in other places, as listed in <https://gcc.gnu.org/ml/gcc-patches/2014-11/msg00337.html> (those issues are generally the sort of thing that could be addressed as bugs outside development stage 1). (The bulk of the potential issues Zack was concerned about in 2003-5, that resulted in extended identifiers being disabled in the absence of -fextended-identifiers, were effectively eliminated by the audit and fixes I did in 2009, however; that todo list reflects what was left over after that audit.) Bootstrapped with no regressions on x86_64-unknown-linux-gnu. libcpp: * include/cpp-id-data.h (struct cpp_macro): Update comment regarding parameters. * include/cpplib.h (struct cpp_macro_arg, struct cpp_identifier): Add spelling fields. (struct cpp_token): Update comment on macro_arg. * internal.h (_cpp_save_parameter): Add extra argument. (_cpp_spell_ident_ucns): New declaration. * lex.c (lex_identifier): Add SPELLING argument. Set *SPELLING to original spelling of identifier. (_cpp_lex_direct): Update calls to lex_identifier. (_cpp_spell_ident_ucns): New function, factored out of cpp_spell_token. (cpp_spell_token): Adjust FORSTRING argument semantics to return original spelling of identifiers. Use _cpp_spell_ident_ucns in !FORSTRING case. (_cpp_equiv_tokens): Check spellings of identifiers and macro arguments are identical. * macro.c (macro_arg_saved_data): New structure. (paste_tokens): Use original spellings of identifiers from cpp_spell_token. (_cpp_save_parameter): Add argument SPELLING. Save both canonical node and its value. (parse_params): Update calls to _cpp_save_parameter. (lex_expansion_token): Save spelling of macro argument tokens. (_cpp_create_definition): Extract canonical node from saved data. (cpp_macro_definition): Use UCNs in spelling of macro name. Use original spellings of macro argument tokens and identifiers. * traditional.c (scan_parameters): Update call to _cpp_save_parameter. gcc: * doc/invoke.texi (-std=c99, -std=c11): Don't refer to corner cases of extended identifiers. gcc/testsuite: * g++.dg/cpp/ucnid-2.C, g++.dg/cpp/ucnid-3.C, gcc.dg/cpp/ucnid-11.c, gcc.dg/cpp/ucnid-12.c, gcc.dg/cpp/ucnid-13.c, gcc.dg/cpp/ucnid-14.c, gcc.dg/cpp/ucnid-15.c: New tests. From-SVN: r217202
2014-11-05Enable -fextended-identifiers by default.Joseph Myers2-16/+18
As proposed at <https://gcc.gnu.org/ml/gcc/2014-11/msg00014.html>, this patch enables -fextended-identifiers by default for all standard versions including this feature (all C++ versions, C99 and above for C, but not C90 / C94 / gnu89 / preprocessing assembler). It adds a couple of tests for areas where I previously noted testsuite coverage for extended identifiers was lacking, removes -fextended-identifiers from existing tests, adds -g to various such tests to verify that extended identifiers don't break debug info generation and removes the test that was only there to verify that the feature was off by default. The current state of the feature may not correspond exactly to any particular checklist from 2004/5 (see bug 9449) of what was wanted before enabling the feature by default, but I don't think it's any worse than plenty of other features supported by default before every corner case is fully functional, and think problems can readily be fixed incrementally. The following aspects of extended identifiers could still do with more work (and should be straightforward): * C -aux-info (output should use UCNs). * ObjC -gen-decls (output should use UCNs; associated diagnostics from the ObjC front end should use extended characters or UCNs as appropriate to the locale, via using %qE or identifier_to_locale). * Use DW_AT_use_UTF8 in DWARF-3 debug info for compilation units built with extended identifiers enabled (or unconditionally). * cpplib diagnostics (outputting characters or UCNs as appropriate depending on the locale, as done for identifiers in non-cpplib diagnostics). * C++ test for UCN linking with C and extern "C". * Check GDB support / file issues for support if needed. * Actual UTF-8 in identifiers (?). (Be careful about not affecting performance for the normal fast path of lexing identifiers, if possible.) The following may be trickier: * cpplib spelling preservation (required to diagnose macro redefinition with different spellings of the same identifier in the definition or argument names; different spellings of the name of the macro itself are OK, however; also required for correct handling of multiple stringizing in C++); correct output for -d (UCNs), DWARF debug info for macros (UCNs), PCH and PCH tests. (Spelling preservation is the issue that needs fixing to remove references to corner cases in the documentation of -std=c99 and -std=c11 and in c99status.html.) The idea would be to add a second pointer to cpp_identifier that stores the original spelling (whether for extended identifiers only, or for all identifiers); this does not enlarge cpp_token because the resulting larger cpp_identifier structure is no bigger than cpp_string. * C++ translation of extended characters (including $@` and various control characters) to UCNs in phase 1 (note diagnostics thus needed, but not for C++11, for control characters in strings / character constants as those UCNs invalid); a likely implementation approach is to do translation when identifiers / strings / character constants are lexed, together with errors for stray $@` / control characters in program as not being valid UCNs in identifiers ($ only if not accepted in identifiers); note that this translation should not take place inside raw string literals. Bootstrapped with no regressions on x86_64-unknown-linux-gnu. libcpp: PR preprocessor/9449 * init.c (lang_defaults): Enable extended identifiers for C++ and C99-based standards. gcc: PR preprocessor/9449 * doc/cpp.texi (Character sets, Tokenization) (Implementation-defined behavior): Don't refer to UCNs in identifiers requiring -fextended-identifiers. * doc/cppopts.texi (-fextended-identifiers): Document as enabled by default for C99 and later and C++. * doc/invoke.texi (-std=c99, -std=c11): Don't refer to extended identifiers needing -fextended-identifiers. gcc/testsuite: PR preprocessor/9449 * lib/target-supports.exp (check_effective_target_ucn_nocache): Don't use -fextended-identifiers. * c-c++-common/cpp/normalize-3.c, c-c++-common/cpp/ucnid-2011-1.c, g++.dg/cpp/ucn-1.C, g++.dg/cpp/ucnid-1.C, g++.dg/other/ucnid-1.C, gcc.dg/cpp/normalize-1.c, gcc.dg/cpp/normalize-2.c, gcc.dg/cpp/normalize-4.c: Don't use -fextended-identifiers. * gcc.dg/cpp/ucnid-1.c: Don't use -fextended-identifiers. Use -g3. * gcc.dg/cpp/ucnid-10.c, gcc.dg/cpp/ucnid-2.c, gcc.dg/cpp/ucnid-3.c, gcc.dg/cpp/ucnid-4.c, gcc.dg/cpp/ucnid-5.c, gcc.dg/cpp/ucnid-7.c, gcc.dg/cpp/ucnid-9.c, gcc.dg/cpp/warn-normalized-1.c, gcc.dg/cpp/warn-normalized-2.c, gcc.dg/cpp/warn-normalized-3.c: Don't use -fextended-identifiers. * gcc.dg/ucnid-1.c, gcc.dg/ucnid-2.c, gcc.dg/ucnid-3.c, gcc.dg/ucnid-4.c, gcc.dg/ucnid-5.c, gcc.dg/ucnid-6.c: Don't use -fextended-identifiers. Use -g. * gcc.dg/ucnid-7.c, gcc.dg/ucnid-8.c: Don't use -fextended-identifiers. * gcc.dg/ucnid-9.c: Don't use -fextended-identifiers. Use -g. * gcc.dg/ucnid-10.c: Don't use -fextended-identifiers. * gcc.dg/ucnid-11.c, gcc.dg/ucnid-12.c: Don't use -fextended-identifiers. Use -g. * gcc.dg/ucnid-13.c: Don't use -fextended-identifiers. * gcc.dg/cpp/ucnid-8.c: Remove test. * gcc.dg/cpp/ucnid-10.c, gcc.dg/ucnid-14.c: New tests. From-SVN: r217144
2014-10-22gengtype.h (obstack_chunk_alloc, [...]): Remove cast.Alan Modra5-24/+25
gcc/ * gengtype.h (obstack_chunk_alloc, obstack_chunk_free): Remove cast. * coretypes.h (obstack_chunk_alloc, obstack_chunk_free): Likewise. (gcc_obstack_init): Use obstack_specify_allocation in place of _obstack_begin. * genautomata.c (next_sep_el): Cast result of obstack_base to (char *). (regexp_representation): Likewise. * godump.c (go_output_type): Likewise. gcc/java/ * mangle.c (finish_mangling): Cast result of obstack_base to (char *). * typeck.c (build_java_argument_signature): Likewise. (build_java_signature): Likewise. gcc/objc/ * objc-encoding.c (encode_array): Cast result of obstack_base. (encode_type): Likewise. libcpp/ * symtab.c (ht_create): Use obstack_specify_allocation in place of _obstack_begin. * files.c (_cpp_init_files): Likewise. * init.c (cpp_create_reader): Likewise. * identifiers.c (_cpp_init_hashtable): Likewise. From-SVN: r216539
2014-10-14line-map.h (linemap_location_from_macro_expansion_p): const struct line_maps ↵Manuel López-Ibáñez3-17/+31
* argument. libcpp/ChangeLog: 2014-10-14 Manuel López-Ibáñez <manu@gcc.gnu.org> * include/line-map.h (linemap_location_from_macro_expansion_p): const struct line_maps * argument. (linemap_position_for_line_and_column): const struct line_map * argument. * line-map.c (linemap_add_macro_token): Use correct argument name in comment. (linemap_position_for_line_and_column): const struct line_map * argument. (linemap_macro_map_loc_to_def_point): Fix comment. Make static. (linemap_location_from_macro_expansion_p): const struct line_maps * argument. (linemap_resolve_location): Fix argument names in comment. From-SVN: r216205
2014-10-03lex.c (search_line_fast): Add new version to be used for Power8 and later ↵Bill Schmidt2-11/+112
targets when Altivec is enabled. 2014-10-03 Bill Schmidt <wschmidt@linux.vnet.ibm.com> * lex.c (search_line_fast): Add new version to be used for Power8 and later targets when Altivec is enabled. Restrict the existing Altivec version to big-endian systems so that lvsr is not used on little endian, where it is deprecated. Remove LE-specific code from the now-BE-only version. From-SVN: r215873
2014-10-02charset.c (convert_no_conversion): Reallocate memory with 25% headroom.Bernd Edlinger2-0/+7
2014-10-02 Bernd Edlinger <bernd.edlinger@hotmail.de> Jeff Law <law@redhat.com> * charset.c (convert_no_conversion): Reallocate memory with 25% headroom. Co-Authored-By: Jeff Law <law@redhat.com> From-SVN: r215785