aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
AgeCommit message (Collapse)AuthorFilesLines
2018-10-25* parser.c (cp_parser_sizeof_operand): Remove redundant grokdeclarator.Jason Merrill1-14/+1
From-SVN: r265503
2018-10-24re PR c++/86288 (Recognize __gnu and/or __gnu__ as attribute-namespace)Jakub Jelinek1-3/+8
PR c++/86288 * parser.c (cp_parser_std_attribute): Canonicalize attr_ns, and when :: is not present and attr_ns non-NULL, canonicalize also attr_id. (cp_parser_attribute_spec): Fix comment typo. * g++.dg/cpp0x/gen-attrs-66.C: New test. From-SVN: r265470
2018-10-12[C++ PATCH] more TU parsing refactoringNathan Sidwell1-63/+63
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00788.html * parser.h (struct cp_parser): Drop implicit_extern_c. * parser.c (cp_debug_parser): Drop implicit_extern_c. (cp_parser_new): Likewise. (cp_parser_translation_unit): Handle implicit extern c here. Call cp_parser_toplevel_declaration. (cp_parser_toplevel_declaration): New, broken out of ... (cp_parser_declaration_seq_opt): ... here. Call it. Drop implicit extern C handling. From-SVN: r265127
2018-10-11[C++ PATCH] parser simplificationNathan Sidwell1-49/+36
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00689.html cp/ * parser.c (cp_parser_translation_unit): Return void. Don't fail at first extra }, simplify logic. (c_parse_file): Call finish_translation_unit here. testsuite/ * g++.dg/parse/close-brace.C: New. * g++.dg/cpp0x/noexcept16.C: Avoid warning. * g++.old-deja/g++.other/crash32.C: Add another error From-SVN: r265055
2018-10-09re PR c++/84423 ([concepts] ICE with invalid using declaration)Paolo Carlini1-9/+13
/cp 2018-10-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/84423 * pt.c (convert_template_argument): Immediately return error_mark_node if the second argument is erroneous. * parser.c (cp_parser_type_id): Add location_t * parameter. (cp_parser_type_id_1): Likewise. (cp_parser_alias_declaration): Adjust cp_parser_type_id call, obtain the location of the type and save it. (cp_parser_template_type_arg): Adjust. (cp_parser_trailing_type_id): Likewise. * decl.c (grokdeclarator): Improve error message for 'auto' in alias declaration. /testsuite 2018-10-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/84423 * g++.dg/concepts/pr84423-1.C: New. * g++.dg/concepts/pr84423-2.C: Likewise. * g++.dg/cpp0x/auto39.C: Test location too. * g++.dg/cpp0x/auto9.C: Likewise. * g++.dg/cpp1y/pr60384.C: Likewise. From-SVN: r264996
2018-10-05Support string locations for C++ in -Wformat (PR c++/56856)David Malcolm1-1/+13
-Wformat in the C++ FE doesn't work as well as it could: (a) it doesn't report precise locations within the string literal, and (b) it doesn't underline arguments for those arguments !CAN_HAVE_LOCATION_P, despite having location wrapper nodes. For example: Wformat-ranges.C:32:10: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'int' [-Wformat=] 32 | printf("hello %s", 42); | ^~~~~~~~~~ (a) is due to not wiring up the langhook for extracting substring locations. This patch uses the one in c-family; it also fixes string literal parsing so that it records string concatenations (needed for extracting substring locations from concatenated strings). (b) is due to the call to maybe_constant_value here: fargs[j] = maybe_constant_value (argarray[j]); within build_over_call. The patch fixes this by building a vec of location_t values when calling check_function_arguments. I attempted to eliminate the maybe_constant_value call here, but it's needed by e.g. check_function_sentinel for detecting NULL, and that code is in "c-family", so it can't simply call into maybe_constant_value (which is in "cp"). With this patch, the output for the above example is improved to: Wformat-ranges.C:32:18: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'int' [-Wformat=] 32 | printf("hello %s", 42); | ~^ ~~ | | | | | int | char* | %d gcc/cp/ChangeLog: PR c++/56856 * call.c (build_over_call): Build a vec of locations of the arguments before the call to maybe_constant_value, and pass to check_function_arguments. * cp-lang.c (LANG_HOOKS_GET_SUBSTRING_LOCATION): Define as c_get_substring_location. * parser.c (cp_parser_string_literal): Capture string concatenation locations. gcc/ChangeLog: PR c++/56856 * input.c (expand_location_to_spelling_point): Add param "aspect" and use rather than hardcoding LOCATION_ASPECT_CARET. (get_substring_ranges_for_loc): Handle the case of a single token within a macro expansion. * input.h (expand_location_to_spelling_point): Add "aspect" param, defaulting to LOCATION_ASPECT_CARET. gcc/testsuite/ChangeLog: PR c++/56856 * g++.dg/ext/builtin4.C: Set expected location for warning to the correct location within the format string. * g++.dg/plugin/plugin.exp (plugin_test_list): Add the plugin and files for testing locations within string literal locations from the C frontend. * g++.dg/warn/Wformat-method.C: New test. * g++.dg/warn/Wformat-pr71863.C: New test. * g++.dg/warn/Wformat-ranges-c++11.C: New test. * g++.dg/warn/Wformat-ranges.C: New test, based on gcc.dg/format/diagnostic-ranges.c. * gcc.dg/plugin/diagnostic-test-string-literals-1.c (test_multitoken_macro): Generalize expected output to work with both C and C++. * gcc.dg/plugin/diagnostic-test-string-literals-2.c (test_stringified_token_1): Likewise. (test_stringified_token_3): Likewise. From-SVN: r264887
2018-10-03Properly mark lambdas in GCOV (PR gcov-profile/86109).Martin Liska1-0/+1
2018-10-03 Martin Liska <mliska@suse.cz> PR gcov-profile/86109 * coverage.c (coverage_begin_function): Do not mark lambdas as artificial. * tree-core.h (struct GTY): Remove tm_clone_flag and introduce new lambda_function. * tree.h (DECL_LAMBDA_FUNCTION): New macro. 2018-10-03 Martin Liska <mliska@suse.cz> PR gcov-profile/86109 * parser.c (cp_parser_lambda_declarator_opt): Set DECL_LAMBDA_FUNCTION for lambdas. 2018-10-03 Martin Liska <mliska@suse.cz> PR gcov-profile/86109 * g++.dg/gcov/pr86109.C: New test. From-SVN: r264806
2018-09-25Remove unused functions and fields.Martin Liska1-8/+0
2018-09-25 Martin Liska <mliska@suse.cz> * alias.c (set_dest_equal_p): Remove unused function. * config/i386/i386.c (def_builtin_pure2): Likewise. * diagnostic-show-locus.c (class layout): Remove unused field. (layout::layout): Likewise here. * dump-context.h (class temp_dump_context): Likewise. * dwarf2out.c (add_AT_fde_ref): Remove unused function. (add_AT_loclistsptr): Likewise. (add_AT_offset): Likewise. (get_AT_hi_pc): Likewise. (is_comdat_die): Likewise. (type_is_enum): Likewise. (ceiling): Likewise. (add_AT_vms_delta): Likewise. (is_class_die): Likewise. * edit-context.c (class line_event): Remove unused field. * graphite-sese-to-poly.c (tree_int_to_gmp): Remove unused function. * ipa-cp.c (ipa_get_vr_lat): Likewise. * lra-constraints.c (ok_for_index_p_nonstrict): Likewise. (ok_for_base_p_nonstrict): Likewise. * tree-chrec.c (is_not_constant_evolution): Likewise. (chrec_fold_poly_cst): Likewise. * tree-if-conv.c (has_pred_critical_p): Likewise. * tree-ssa-coalesce.c (print_exprs): Likewise. * tree-ssa-pre.c (bitmap_set_contains_expr): Likewise. * tree-ssa-uninit.c (is_and_or_or_p): Likewise. * tree-vrp.c (value_ranges_intersect_p): Likewise. (value_range_nonnegative_p): Likewise. 2018-09-25 Martin Liska <mliska@suse.cz> * name-lookup.c (namespace_scope_ht_size): Remove unused function. * parser.c (cp_lexer_next_token_is_not_keyword): Likewise. 2018-09-25 Martin Liska <mliska@suse.cz> * trans.c (remove_suffix): Remove unused function. 2018-09-25 Martin Liska <mliska@suse.cz> * gofrontend/escape.cc (Gogo::analyze_escape): Remove usage of a parameter. (Gogo::assign_connectivity): Likewise. (class Escape_analysis_tag): Likewise. (Gogo::tag_function): Likewise. * gofrontend/expressions.cc (Call_expression::do_type): Likewise. * gofrontend/gogo.h (class Gogo): Likewise. * gofrontend/types.cc (class Call_multiple_result_type): Likewise. (Type::make_call_multiple_result_type): Likewise. * gofrontend/types.h (class Type): Likewise. * gofrontend/wb.cc (class Check_escape): Likewise. (Gogo::add_write_barriers): Likewise. From-SVN: r264561
2018-09-19re PR c++/87324 (g++ ICE with overriding initializers: Segmentation fault)Paolo Carlini1-1/+1
/cp 2018-09-19 Paolo Carlini <paolo.carlini@oracle.com> PR c++/87324 * parser.c (cp_parser_initializer_list): Assign error_mark_node to the index upon error. /testsuite 2018-09-19 Paolo Carlini <paolo.carlini@oracle.com> PR c++/87324 * g++.dg/cpp0x/desig5.C: New. From-SVN: r264428
2018-08-31[C++ PATCH] Remove K&R declaration hack.Nathan Sidwell1-10/+1
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01885.html gcc/ * doc/extend.texi (Backwards Compatibility): Remove implicit extern C leeway of () being (...). gcc/cp/ * decl.c (decls_match): Remove SYSTEM_IMPLICIT_EXTERN_C matching of return types and parms. * parser.c (cp_parser_parameter_declaration_clause): Likewise, '()' always means '(void)'. From-SVN: r264013
2018-08-29re PR c++/85265 ([concepts] ICE with missing identifier)Paolo Carlini1-6/+10
/cp 2018-08-29 Paolo Carlini <paolo.carlini@oracle.com> PR c++/85265 * parser.c (cp_parser_introduction_list): If cp_parser_identifier returns error_mark_node early exit the loop. (cp_parser_template_introduction): Improve error-recovery, remove error call about empty introduction-list. /testsuite 2018-08-29 Paolo Carlini <paolo.carlini@oracle.com> PR c++/85265 * g++.dg/concepts/pr85265.C: New. From-SVN: r263966
2018-08-27C++: fix-it hint for missing "typename" (PR c++/63392)David Malcolm1-2/+4
This patch adds a fix-it hint to missing "typename" errors in the C++ frontend, suggesting the insertion of "typename ". This addresses part of PR c++/63392; however it does not improve the error-recovery for such cases. gcc/cp/ChangeLog: PR c++/63392 * parser.c (cp_parser_diagnose_invalid_type_name): Add fix-it hint. gcc/testsuite/ChangeLog: PR c++/63392 * g++.dg/diagnostic/missing-typename.C: New test. From-SVN: r263899
2018-08-27Less verbose fix-it hints for missing header files (PR 87091)David Malcolm1-3/+3
This patch tweaks maybe_add_include_fixit so that if we're emitting a note about adding the header file, the note's primary location will be replaced by that of the fix-it hint, to avoid repeating a location we've already emitted (or one close to it). For example, this simplifies: ../x86_64-pc-linux-gnu/libstdc++-v3/include/vector:87:27: error: msg 1 87 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>; | ^~~~~~ ../x86_64-pc-linux-gnu/libstdc++-v3/include/vector:87:22: note: msg 2 73 | # include <debug/vector> +++ |+#include <vector> 74 | #endif .... 87 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>; | ^~~ to: ../x86_64-pc-linux-gnu/libstdc++-v3/include/vector:87:27: error: msg 1 87 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>; | ^~~~~~ ../x86_64-pc-linux-gnu/libstdc++-v3/include/vector:74:1: note: msg 2 73 | # include <debug/vector> +++ |+#include <vector> 74 | #endif eliminating the repetition of line 87 in the note. Doing so requires converting show_caret_p to a tri-state, to avoid meaninglessly printing a caret for the first column in the next line (and colorizing it): ../x86_64-pc-linux-gnu/libstdc++-v3/include/vector:74:1: note: msg 2 73 | # include <debug/vector> +++ |+#include <vector> 74 | #endif | ^ gcc/c-family/ChangeLog: PR 87091 * c-common.c (c_cpp_error): Update for conversion of show_caret_p to a tri-state. (maybe_suggest_missing_token_insertion): Likewise. (maybe_add_include_fixit): Add param "override_location". If set, and source-printing is enabled, then override the rich_location's primary location with that of the insertion point for the fix-it hint, marking it with SHOW_LINES_WITHOUT_RANGE. * c-common.h (extern void maybe_add_include_fixit): Add bool param. * c-format.c (selftest::test_type_mismatch_range_labels): Update for conversion of show_caret_p to a tri-state. * c-warn.c (warn_for_restrict): Likewise. * known-headers.cc (suggest_missing_header::~suggest_missing_header): Update call to maybe_add_include_fixit to suggest overriding the location, as it is for a note. gcc/c/ChangeLog: PR 87091 * c-decl.c (implicitly_declare): Update call to maybe_add_include_fixit to suggest overriding the location, as it is for a note. * c-objc-common.c (c_tree_printer): Update for conversion of show_caret_p to a tri-state. gcc/cp/ChangeLog: PR 87091 * decl.c (grokdeclarator): Update for conversion of show_caret_p to a tri-state. * error.c (cp_printer): Likewise. * name-lookup.c (maybe_suggest_missing_std_header): Update call to maybe_add_include_fixit to suggest overriding the location, as it is for a note. * parser.c (cp_parser_string_literal): Update for conversion of show_caret_p to a tri-state. (cp_parser_elaborated_type_specifier): Likewise. (set_and_check_decl_spec_loc): Likewise. * pt.c (listify): Update call to maybe_add_include_fixit to not override the location, as it is for an error. * rtti.c (typeid_ok_p): Likewise. gcc/ChangeLog: PR 87091 * diagnostic-show-locus.c (class layout_range): Update for conversion of show_caret_p to a tri-state. (layout_range::layout_range): Likewise. (make_range): Likewise. (layout::maybe_add_location_range): Likewise. (layout::should_print_annotation_line_p): Don't show annotation lines for ranges that are SHOW_LINES_WITHOUT_RANGE. (layout::get_state_at_point): Update for conversion of show_caret_p to a tri-state. Bail out early for SHOW_LINES_WITHOUT_RANGE, so that such ranges don't affect underlining or source colorization. (gcc_rich_location::add_location_if_nearby): Update for conversion of show_caret_p to a tri-state. (selftest::test_one_liner_multiple_carets_and_ranges): Likewise. (selftest::test_one_liner_fixit_replace_equal_secondary_range): Likewise. (selftest::test_one_liner_labels): Likewise. * gcc-rich-location.c (gcc_rich_location::add_expr): Update for conversion of show_caret_p to a tri-state. * pretty-print.c (text_info::set_location): Likewise. * pretty-print.h (text_info::set_location): Likewise. * substring-locations.c (format_warning_n_va): Likewise. * tree-diagnostic.c (default_tree_printer): Likewise. * tree-pretty-print.c (newline_and_indent): Likewise. gcc/fortran/ChangeLog: PR 87091 * error.c (gfc_format_decoder): Update for conversion of show_caret_p to a tri-state. gcc/testsuite/ChangeLog: PR 87091 * gcc.dg/empty.h: New file. * gcc.dg/fixits-pr84852-1.c: Update for move of fix-it hint to top of file and removal of redundant second printing of warning location. * gcc.dg/fixits-pr84852-2.c: Likewise. * gcc.dg/missing-header-fixit-3.c: Likewise. * gcc.dg/missing-header-fixit-4.c: New test. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Update for conversion of show_caret_p to a tri-state. libcpp/ChangeLog: PR 87091 * include/line-map.h (enum range_display_kind): New enum. (struct location_range): Replace field "m_show_caret_p" with "m_range_display_kind", converting from bool to the new enum. (class rich_location): Add example of line insertion fix-it hint. (rich_location::add_range): Convert param "show_caret_p" from bool to enum range_display_kind and rename to "range_display_kind", giving it a default of SHOW_RANGE_WITHOUT_CARET. (rich_location::set_range): Likewise, albeit without a default. * line-map.c (rich_location::rich_location): Update for conversion of show_caret_p to tri-state enum. (rich_location::add_range): Likewise. (rich_location::set_range): Likewise. From-SVN: r263885
2018-08-21re PR c++/86499 (lambda-expressions with capture-default are allowed at ↵Marek Polacek1-0/+3
namespace scope) PR c++/86499 * parser.c (cp_parser_lambda_introducer): Give error if a non-local lambda has a capture-default. * g++.dg/cpp0x/lambda/lambda-non-local.C: New test. * g++.dg/cpp0x/lambda/lambda-this10.C: Adjust dg-error. From-SVN: r263749
2018-08-20Add support for grouping of related diagnostics (PR other/84889)David Malcolm1-0/+6
We often emit logically-related groups of diagnostics. A relatively simple case is this: if (warning_at (body_loc, OPT_Wmultistatement_macros, "macro expands to multiple statements")) inform (guard_loc, "some parts of macro expansion are not guarded by " "this %qs clause", guard_tinfo_to_string (keyword)); where the "note" diagnostic issued by the "inform" call is guarded by the -Wmultistatement_macros warning. More complicated examples can be seen in the C++ frontend, where e.g. print_z_candidates can lead to numerous "note" diagnostics being emitted. I'm looking at various ways to improve how we handle such related diagnostics, but, prior to this patch, there was no explicit relationship between these diagnostics: the diagnostics subsystem had no way of "knowing" that these were related. This patch introduces a simple way to group the diagnostics: an auto_diagnostic_group class: all diagnostics emitted within the lifetime of an auto_diagnostic_group instance are logically grouped. Hence in the above example, the two diagnostics can be grouped by simply adding an auto_diagnostic_group instance: auto_diagnostic_group d; if (warning_at (body_loc, OPT_Wmultistatement_macros, "macro expands to multiple statements")) inform (guard_loc, "some parts of macro expansion are not guarded by " "this %qs clause", guard_tinfo_to_string (keyword)); Some more awkard cases are of the form: if (some_condition && warning_at (...) && more_conditions) inform (...); which thus need restructuring to: if (some_condition) { auto_diagnostic_group d; warning_at (...); if (more_conditions) inform (...); } so that the lifetime of the auto_diagnostic_group groups the warning_at and the inform call. Nesting is handled by simply tracking a nesting depth within the diagnostic_context.: all diagnostics are treated as grouped until the final auto_diagnostic_group is popped. diagnostic.c uses this internally, so that all diagnostics are part of a group - those that are "by themselves" are treated as being part of a group with one element. The diagnostic_context gains optional callbacks for displaying the start of a group (when the first diagnostic is emitted within it), and the end of a group (for when the group was non-empty); these callbacks are unused by default, but a test plugin demonstrates them (and verifies that the machinery is working). As noted above, I'm looking at various ways to use the grouping to improve how we output the diagnostics. FWIW, I experimented with a more involved implementation, of the form: diagnostic_group d; if (d.warning_at (body_loc, OPT_Wmultistatement_macros, "macro expands to multiple statements")) d.inform (guard_loc, "some parts of macro expansion are not guarded by " "this %qs clause", guard_tinfo_to_string (keyword)); which had the advantage of allowing auto-detection of the places where groups were needed (by converting ::warning_at's return type to bool), but it was a much more invasive patch, especially when dealing with the places in the C++ frontend that can emit numerous notes after an error or warning (and thus having to pass the group around) Hence I went with this simpler approach. gcc/c-family/ChangeLog: PR other/84889 * c-attribs.c (common_handle_aligned_attribute): Add auto_diagnostic_group instance. * c-indentation.c (warn_for_misleading_indentation): Likewise. * c-opts.c (c_common_post_options): Likewise. * c-warn.c (warn_logical_not_parentheses): Likewise. (warn_duplicated_cond_add_or_warn): Likewise. (warn_for_multistatement_macros): Likewise. gcc/c/ChangeLog: PR other/84889 * c-decl.c (pushtag): Add auto_diagnostic_group instance. (diagnose_mismatched_decls): Likewise, in various places. (warn_if_shadowing): Likewise. (implicit_decl_warning): Likewise. (implicitly_declare): Likewise. (undeclared_variable): Likewise. (declare_label): Likewise. (grokdeclarator): Likewise. (start_function): Likewise. * c-parser.c (c_parser_declaration_or_fndef): Likewise. (c_parser_parameter_declaration): Likewise. (c_parser_binary_expression): Likewise. * c-typeck.c (c_expr_sizeof_expr): Likewise. (parser_build_binary_op): Likewise. (build_unary_op): Likewise. (error_init): Likewise. (pedwarn_init): Likewise. (warning_init): Likewise. (convert_for_assignment): Likewise. gcc/cp/ChangeLog: PR other/84889 * call.c (build_user_type_conversion_1): Add auto_diagnostic_group instance(s). (print_error_for_call_failure): Likewise. (build_op_call_1): Likewise. (build_conditional_expr_1): Likewise. (build_new_op_1): Likewise. (build_op_delete_call): Likewise. (convert_like_real): Likewise. (build_over_call): Likewise. (build_new_method_call_1): Likewise. (joust): Likewise. * class.c (check_tag): Likewise. (finish_struct_anon_r): Likewise. (one_inherited_ctor): Likewise. (finalize_literal_type_property): Likewise. (explain_non_literal_class): Likewise. (find_flexarrays): Likewise. (resolve_address_of_overloaded_function): Likewise. * constexpr.c (ensure_literal_type_for_constexpr_object): Likewise. (is_valid_constexpr_fn): Likewise. (cx_check_missing_mem_inits): Likewise. * cp-gimplify.c (cp_genericize_r): Likewise. * cvt.c (maybe_warn_nodiscard): Likewise. * decl.c (warn_extern_redeclared_static): Likewise. (check_redeclaration_exception_specification): Likewise. (check_no_redeclaration_friend_default_args): Likewise. (duplicate_decls): Likewise. (redeclaration_error_message): Likewise. (warn_misplaced_attr_for_class_type): Likewise. * decl2.c (finish_static_data_member_decl): Likewise. (no_linkage_error): Likewise. (cp_warn_deprecated_use): Likewise. * error.c (qualified_name_lookup_error): Likewise. * friend.c (make_friend_class): Likewise. (do_friend): Likewise. * init.c (perform_member_init): Likewise. (build_new_1): Likewise. (build_vec_delete_1): Likewise. (build_delete): Likewise. * lex.c (unqualified_name_lookup_error): Likewise. * name-lookup.c (check_extern_c_conflict): Likewise. (inform_shadowed): New function. (check_local_shadow): Add auto_diagnostic_group instances, replacing goto "inform_shadowed" label with call to subroutine. (set_local_extern_decl_linkage): Add auto_diagnostic_group instance(s). * parser.c (cp_parser_diagnose_invalid_type_name): Likewise. (cp_parser_namespace_name): Likewise. * pt.c (check_specialization_namespace): Likewise. (check_template_variable): Likewise. (warn_spec_missing_attributes): Likewise. (check_explicit_specialization): Likewise. (process_partial_specialization): Likewise. (lookup_template_class_1): Likewise. (finish_template_variable): Likewise. (do_auto_deduction): Likewise. * search.c (check_final_overrider): Likewise. (look_for_overrides_r): Likewise. * tree.c (maybe_warn_parm_abi): Likewise. * typeck.c (cxx_sizeof_expr): Likewise. (cp_build_function_call_vec): Likewise. (cp_build_binary_op): Likewise. (convert_for_assignment): Likewise. (maybe_warn_about_returning_address_of_local): Likewise. * typeck2.c (abstract_virtuals_error_sfinae): Likewise. (check_narrowing): Likewise. gcc/ChangeLog: PR other/84889 * attribs.c (diag_attr_exclusions): Add auto_diagnostic_group instance. (decl_attributes): Likewise. * calls.c (maybe_warn_nonstring_arg): Add auto_diagnostic_group instance. * cgraphunit.c (maybe_diag_incompatible_alias): Likewise. * diagnostic-core.h (class auto_diagnostic_group): New class. * diagnostic.c (diagnostic_initialize): Initialize the new fields. (diagnostic_report_diagnostic): Handle the first diagnostics within a group. (emit_diagnostic): Add auto_diagnostic_group instance. (inform): Likewise. (inform_n): Likewise. (warning): Likewise. (warning_at): Likewise. (warning_n): Likewise. (pedwarn): Likewise. (permerror): Likewise. (error): Likewise. (error_n): Likewise. (error_at): Likewise. (sorry): Likewise. (fatal_error): Likewise. (internal_error): Likewise. (internal_error_no_backtrace): Likewise. (auto_diagnostic_group::auto_diagnostic_group): New ctor. (auto_diagnostic_group::~auto_diagnostic_group): New dtor. * diagnostic.h (struct diagnostic_context): Add fields "diagnostic_group_nesting_depth", "diagnostic_group_emission_count", "begin_group_cb", "end_group_cb". * gimple-ssa-isolate-paths.c (find_implicit_erroneous_behavior): Add auto_diagnostic_group instance(s). (find_explicit_erroneous_behavior): Likewise. * gimple-ssa-warn-alloca.c (pass_walloca::execute): Likewise. * gimple-ssa-warn-restrict.c (maybe_diag_offset_bounds): Likewise. * gimplify.c (warn_implicit_fallthrough_r): Likewise. (gimplify_va_arg_expr): Likewise. * hsa-gen.c (HSA_SORRY_ATV): Likewise. (HSA_SORRY_AT): Likewise. * ipa-devirt.c (compare_virtual_tables): Likewise. (warn_odr): Likewise. * multiple_target.c (expand_target_clones): Likewise. * opts-common.c (cmdline_handle_error): Likewise. * reginfo.c (globalize_reg): Likewise. * substring-locations.c (format_warning_n_va): Likewise. * tree-inline.c (expand_call_inline): Likewise. * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Likewise. * tree-ssa-loop-niter.c (do_warn_aggressive_loop_optimizations): Likewise. * tree-ssa-uninit.c (warn_uninit): Likewise. * tree.c (warn_deprecated_use): Likewise. gcc/testsuite/ChangeLog: PR other/84889 * gcc.dg/plugin/diagnostic-group-test-1.c: New test. * gcc.dg/plugin/diagnostic_group_plugin.c: New test. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add the new tests. From-SVN: r263675
2018-08-11PR c++/86728 - C variadic generic lambda.Jason Merrill1-1/+2
* parser.c (cp_parser_parameter_declaration): Don't turn 'auto' into a pack if it's followed by a declarator-id. From-SVN: r263484
2018-07-31Fix an UBSAN error in cp/parse.c (PR c++/86653).Martin Liska1-1/+1
2018-07-31 Martin Liska <mliska@suse.cz> PR c++/86653 * parser.c (cp_parser_condition): Initialize non_constant_p to false. From-SVN: r263110
2018-07-25cp-tree.h (enum cp_tree_index): Add ↵Jakub Jelinek1-9/+8
CPTI_{ABI_TAG,ALIGNED,BEGIN,END,GET,TUPLE_{ELEMENT,SIZE}}_IDENTIFIER and... * cp-tree.h (enum cp_tree_index): Add CPTI_{ABI_TAG,ALIGNED,BEGIN,END,GET,TUPLE_{ELEMENT,SIZE}}_IDENTIFIER and CPTI_{GNU,TYPE,VALUE,FUN,CLOSURE}_IDENTIFIER. (abi_tag_identifier, aligned_identifier, begin_identifier, end_identifier, get__identifier, gnu_identifier, tuple_element_identifier, tuple_size_identifier, type_identifier, value_identifier, fun_identifier, closure_identifier): Define. * decl.c (initialize_predefined_identifiers): Initialize the above identifiers. (get_tuple_size): Use tuple_size_identifier instead of get_identifier ("tuple_size") and value_identifier instead of get_identifier ("value"). (get_tuple_element_type): Use tuple_element_identifier instead of get_identifier ("tuple_element") and type_identifier instead of get_identifier ("type"). (get_tuple_decomp_init): Use get__identifier instead of get_identifier ("get"). * lambda.c (maybe_add_lambda_conv_op): Use fun_identifier instead of get_identifier ("_FUN"). * parser.c (cp_parser_lambda_declarator_opt): Use closure_identifier instead of get_identifier ("__closure"). (cp_parser_std_attribute): Use gnu_identifier instead of get_identifier ("gnu"). (cp_parser_std_attribute_spec): Likewise. Use aligned_identifier instead of get_identifier ("aligned"). * class.c (check_abi_tags, inherit_targ_abi_tags): Use abi_tag_identifier instead of get_identifier ("abi_tag"). From-SVN: r262976
2018-07-25re PR c++/85515 (Bogus suggestions from "GCC's leaky abstractions")Jakub Jelinek1-6/+5
PR c++/85515 * cp-tree.h (enum cp_tree_index): Add CPTI_FOR_{RANGE,BEGIN,END}{,_}_IDENTIFIER. (for_range__identifier, for_begin__identifier, for_end__identifier, for_range_identifier, for_begin_identifier, for_end_identifier): Define. * decl.c (initialize_predefined_identifiers): Initialize for_{range,begin,end}{,_}_identifier. * parser.c (build_range_temp): Use for_range__identifier instead of get_identifier ("__for_range"). (cp_convert_range_for): Use for_begin__identifier and for_end__identifier instead of get_identifier ("__for_begin") and get_identifier ("__for_end"). * semantics.c (finish_for_stmt): Rename "__for_{range,begin,end} " local symbols to "__for_{range,begin,end}". * g++.dg/pr85515-2.C: Add expected dg-error. * g++.dg/cpp0x/range-for36.C: New test. From-SVN: r262975
2018-07-18re PR c++/86550 (Lambda parsing allows arbitrary types in decl-specifier-seq)Jakub Jelinek1-0/+3
PR c++/86550 * parser.c (cp_parser_decl_specifier_seq): Diagnose invalid type specifier if CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR. * g++.dg/cpp0x/lambda/lambda-86550.C: New test. From-SVN: r262862
2018-07-13[PR c++/86374] Name lookup failure in enclosing templateNathan Sidwell1-4/+3
https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00701.html PR c++/86374 * pt.c (lookup_template_class_1): Use tsubst_aggr_type for contexts that are classes. * parser.c (cp_parser_template_id): Combine entering_scope decl & initializer. PR c++/86374 * g++.dg/pr86374.C: New. From-SVN: r262637
2018-07-05Replace NO_IMPLICIT_EXTERN_C with SYSTEM_IMPLICIT_EXTERN_C.Nathan Sidwell1-1/+1
gcc/ Replace NO_IMPLICIT_EXTERN_C with SYSTEM_IMPLICIT_EXTERN_C. * doc/cpp.texi: Update comment. * doc/tm.texi: Rebuilt. * doc/tm.texi.in (NO_IMPLICIT_EXTERN_C): Replace with ... (SYSTEM_IMPLICIT_EXTERN_C): ... this, opposite sense. * doc/extend.texi (Backwards Compatibility): Clarify it is system headers affected by extern "C". * system.h: Poison NO_IMPLICIT_EXTERN_C. * config/alpha/alpha.h, config/arm/uclinux-elf.h, config/bfin/elf.h, config/cris/cris.h, config/darwin.h, config/dragonfly.h, config/freebsd.h, config/gnu-user.h, config/i386/cygming.h, config/i386/djgpp.h, config/i386/nto.h, config/ia64/hpux.h, config/lm32/lm32.h, config/lm32/uclinux-elf.h, config/lynx.h, config/mips/elf.h, config/mmix/mmix.h, config/netbsd.h, config/pa/pa-hpux.h, config/powerpcspe/sysv4.h, config/riscv/elf.h, config/rs6000/sysv4.h, config/rtems.h, config/s390/tpf.h, config/sh/newlib.h, config/sol2.h, config/sparc/openbsd64.h, config/sparc/sp-elf.h, config/sparc/sp64-elf.h, config/spu/spu.h, config/stormy16/stormy16.h, config/v850/v850.h, config/visium/visium.h, config/vx-common.h, config/xtensa/elf.h: Don't define NO_IMPLICIT_EXTERN_C. * config/rs6000/aix.h: Set SYSTEM_IMPLICIT_EXTERN_C. gcc/c-family/ * c-lex.c (fe_file_change): Check SYSTEM_IMPLICIT_EXTERN_C not NO_IMPLICIT_EXTERN_C. gcc/cp/ * cp/decl.c (decls_match): Check SYSTEM_IMPLICIT_EXTERN_C not NO_IMPLICIT_EXTERN_C. * cp/parser.c (cp_parser_parameter_declaration_clause): Likewise. From-SVN: r262437
2018-07-02parser.c (set_and_check_decl_spec_loc): Use rich_location::add_range in ↵Paolo Carlini1-3/+6
error message about __thread and thread_local... /cp 2018-07-02 Paolo Carlini <paolo.carlini@oracle.com> * parser.c (set_and_check_decl_spec_loc): Use rich_location::add_range in error message about __thread and thread_local at the same time. /testsuite 2018-07-02 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/diagnostic/thread-thread_local.C: New. From-SVN: r262321
2018-06-28C++: less verbose error-recovery for version conflict markersDavid Malcolm1-0/+14
gcc/cp/ChangeLog: * parser.c (cp_parser_error_1): After issuing a conflict marker error, consume tokens until the end of the source line. gcc/testsuite/ChangeLog: * g++.dg/conflict-markers-2.C: New test. From-SVN: r262232
2018-06-26re PR c++/86291 (OpenMP incorrect for-loop collapsing with iterators and at ↵Jakub Jelinek1-1/+1
least 5 nested loops) PR c++/86291 * parser.c (cp_parser_omp_for_loop_init): Change for_block argument type from vec<tree, va_gc> * to vec<tree, va_gc> *&. * testsuite/libgomp.c++/pr86291.C: New test. From-SVN: r262137
2018-06-25C++: Fix PR86082Andreas Krebbel1-1/+16
When turning a user-defined numerical literal into an operator invocation the literal needs to be translated to the execution character set. gcc/cp/ChangeLog: 2018-06-25 Andreas Krebbel <krebbel@linux.ibm.com> PR C++/86082 * parser.c (make_char_string_pack): Pass this literal chars through cpp_interpret_string. (cp_parser_userdef_numeric_literal): Check the result of make_char_string_pack. gcc/testsuite/ChangeLog: 2018-06-25 Andreas Krebbel <krebbel@linux.ibm.com> PR C++/86082 * g++.dg/pr86082.C: New test. From-SVN: r262003
2018-06-20Update OpenACC data clause semantics to the 2.5 behaviorChung-Lin Tang1-78/+36
gcc/c-family/ * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_{FINALIZE,IF_PRESENT}. Remove PRAGMA_OACC_CLAUSE_PRESENT_OR_{COPY,COPYIN,COPYOUT,CREATE}. gcc/c/ * c-parser.c (c_parser_omp_clause_name): Add support for finalize and if_present. Make present_or_{copy,copyin,copyout,create} aliases to their non-present_or_* counterparts. Make 'self' an alias to PRAGMA_OACC_CLAUSE_HOST. (c_parser_oacc_data_clause): Update GOMP mappings for PRAGMA_OACC_CLAUSE_{COPY,COPYIN,COPYOUT,CREATE,DELETE}. Remove PRAGMA_OACC_CLAUSE_{SELF,PRESENT_OR_*}. (c_parser_oacc_all_clauses): Handle finalize and if_present clauses. Remove support for present_or_* clauses. (OACC_KERNELS_CLAUSE_MASK): Remove PRESENT_OR_* clauses. (OACC_PARALLEL_CLAUSE_MASK): Likewise. (OACC_DECLARE_CLAUSE_MASK): Likewise. (OACC_DATA_CLAUSE_MASK): Likewise. (OACC_ENTER_DATA_CLAUSE_MASK): Remove PRESENT_OR_* clauses. (OACC_EXIT_DATA_CLAUSE_MASK): Add FINALIZE clause. (OACC_UPDATE_CLAUSE_MASK): Remove SELF, add IF_PRESENT. (c_parser_oacc_declare): Remove PRESENT_OR_* clauses. * c-typeck.c (c_finish_omp_clauses): Handle IF_PRESENT and FINALIZE. gcc/cp/ * parser.c (cp_parser_omp_clause_name): Add support for finalize and if_present. Make present_or_{copy,copyin,copyout,create} aliases to their non-present_or_* counterparts. Make 'self' an alias to PRAGMA_OACC_CLAUSE_HOST. (cp_parser_oacc_data_clause): Update GOMP mappings for PRAGMA_OACC_CLAUSE_{COPY,COPYIN,COPYOUT,CREATE,DELETE}. Remove PRAGMA_OACC_CLAUSE_{SELF,PRESENT_OR_*}. (cp_parser_oacc_all_clauses): Handle finalize and if_present clauses. Remove support for present_or_* clauses. (OACC_KERNELS_CLAUSE_MASK): Remove PRESENT_OR_* clauses. (OACC_PARALLEL_CLAUSE_MASK): Likewise. (OACC_DECLARE_CLAUSE_MASK): Likewise. (OACC_DATA_CLAUSE_MASK): Likewise. (OACC_ENTER_DATA_CLAUSE_MASK): Remove PRESENT_OR_* clauses. (OACC_EXIT_DATA_CLAUSE_MASK): Add FINALIZE clause. (OACC_UPDATE_CLAUSE_MASK): Remove SELF, add IF_PRESENT. (cp_parser_oacc_declare): Remove PRESENT_OR_* clauses. * pt.c (tsubst_omp_clauses): Handle IF_PRESENT and FINALIZE. * semantics.c (finish_omp_clauses): Handle IF_PRESENT and FINALIZE. gcc/fortran/ * gfortran.h (gfc_omp_clauses): Add unsigned if_present, finalize bitfields. * openmp.c (enum omp_mask2): Remove OMP_CLAUSE_PRESENT_OR_*. Add OMP_CLAUSE_{IF_PRESENT,FINALIZE}. (gfc_match_omp_clauses): Update handling of copy, copyin, copyout, create, deviceptr, present_of_*. Add support for finalize and if_present. (OACC_PARALLEL_CLAUSES): Remove PRESENT_OR_* clauses. (OACC_KERNELS_CLAUSES): Likewise. (OACC_DATA_CLAUSES): Likewise. (OACC_DECLARE_CLAUSES): Likewise. (OACC_UPDATE_CLAUSES): Add IF_PRESENT clause. (OACC_ENTER_DATA_CLAUSES): Remove PRESENT_OR_* clauses. (OACC_EXIT_DATA_CLAUSES): Add FINALIZE clause. (gfc_match_oacc_declare): Update to OpenACC 2.5 semantics. * trans-openmp.c (gfc_trans_omp_clauses): Add support for IF_PRESENT and FINALIZE. gcc/ * gimplify.c (gimplify_scan_omp_clauses): Add support for OMP_CLAUSE_{IF_PRESENT,FINALIZE}. (gimplify_adjust_omp_clauses): Likewise. (gimplify_oacc_declare_1): Add support for GOMP_MAP_RELEASE, remove support for GOMP_MAP_FORCE_{ALLOC,TO,FROM,TOFROM}. (gimplify_omp_target_update): Update handling of acc update and enter/exit data. * omp-low.c (install_var_field): Remove unused parameter base_pointers_restrict. (scan_sharing_clauses): Remove base_pointers_restrict parameter. Update call to install_var_field. Handle OMP_CLAUSE_{IF_PRESENT, FINALIZE} (omp_target_base_pointers_restrict_p): Delete. (scan_omp_target): Update call to scan_sharing_clauses. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_{IF_PRESENT, FINALIZE}. * tree-nested.c (convert_nonlocal_omp_clauses): Handle OMP_CLAUSE_{IF_PRESENT,FINALIZE}. (convert_local_omp_clauses): Likewise. * tree-pretty-print.c (dump_omp_clause): Likewise. * tree.c (omp_clause_num_ops): Add entries for OMP_CLAUSE_{IF_PRESENT, FINALIZE}. (omp_clause_code_name): Likewise. gcc/testsuite/ * c-c++-common/goacc/declare-1.c: Update test case to utilize OpenACC 2.5 data clause semantics. * c-c++-common/goacc/declare-2.c: Likewise. * c-c++-common/goacc/default-4.c: Likewise. * c-c++-common/goacc/finalize-1.c: New test. * c-c++-common/goacc/kernels-alias-2.c: Update test case to utilize OpenACC 2.5 data clause semantics. * c-c++-common/goacc/kernels-alias.c: Likewise. * c-c++-common/goacc/routine-5.c: Likewise. * c-c++-common/goacc/update-if_present-1.c: New test. * c-c++-common/goacc/update-if_present-2.c: New test. * g++.dg/goacc/template.C: Update test case to utilize OpenACC 2.5 data clause semantics. * gfortran.dg/goacc/combined-directives.f90: Likewise. * gfortran.dg/goacc/data-tree.f95: Likewise. * gfortran.dg/goacc/declare-2.f95: Likewise. * gfortran.dg/goacc/default-4.f: Likewise. * gfortran.dg/goacc/enter-exit-data.f95: Likewise. * gfortran.dg/goacc/finalize-1.f: New test. * gfortran.dg/goacc/kernels-alias-2.f95: Update test case to utilize OpenACC 2.5 data clause semantics. * gfortran.dg/goacc/kernels-alias.f95: Likewise. * gfortran.dg/goacc/kernels-tree.f95: Likewise. * gfortran.dg/goacc/nested-function-1.f90: Likewise. * gfortran.dg/goacc/parallel-tree.f95: Likewise. * gfortran.dg/goacc/reduction-promotions.f90: Likewise. * gfortran.dg/goacc/update-if_present-1.f90: New test. * gfortran.dg/goacc/update-if_present-2.f90: New test. libgomp/ * libgomp.h (struct splay_tree_key_s): Add dynamic_refcount member. (gomp_acc_remove_pointer): Update declaration. (gomp_acc_declare_allocate): Declare. (gomp_remove_var): Declare. * libgomp.map (OACC_2.5): Define. * oacc-mem.c (acc_map_data): Update refcount. (acc_unmap_data): Likewise. (present_create_copy): Likewise. (acc_create): Add FLAG_PRESENT when calling present_create_copy. (acc_copyin): Likewise. (FLAG_FINALIZE): Define. (delete_copyout): Update dynamic refcounts, add support for FINALIZE. (acc_delete_finalize): New function. (acc_delete_finalize_async): New function. (acc_copyout_finalize): New function. (acc_copyout_finalize_async): New function. (gomp_acc_insert_pointer): Update refcounts. (gomp_acc_remove_pointer): Return if data is not present on the accelerator. * oacc-parallel.c (find_pset): Rename to find_pointer. (find_pointer): Add support for GOMP_MAP_POINTER. (handle_ftn_pointers): New function. (GOACC_parallel_keyed): Update refcounts of variables. (GOACC_enter_exit_data): Add support for finalized data mappings. Add support for GOMP_MAP_{TO,ALLOC,RELESE,FROM}. Update handling of fortran arrays. (GOACC_update): Add support for GOMP_MAP_{ALWAYS_POINTER,TO,FROM}. (GOACC_declare): Add support for GOMP_MAP_RELEASE, remove support for GOMP_MAP_FORCE_FROM. * openacc.f90 (module openacc_internal): Add acc_copyout_finalize_{32_h,64_h,array_h,_l}, and acc_delete_finalize_{32_h,64_h,array_h,_l}. Add interfaces for acc_copyout_finalize and acc_delete_finalize. (acc_copyout_finalize_32_h): New subroutine. (acc_copyout_finalize_64_h): New subroutine. (acc_copyout_finalize_array_h): New subroutine. (acc_delete_finalize_32_h): New subroutine. (acc_delete_finalize_64_h): New subroutine. (acc_delete_finalize_array_h): New subroutine. * openacc.h (acc_copyout_finalize): Declare. (acc_copyout_finalize_async): Declare. (acc_delete_finalize): Declare. (acc_delete_finalize_async): Declare. * openacc_lib.h (acc_copyout_finalize): New interface. (acc_delete_finalize): New interface. * target.c (gomp_map_vars): Update dynamic_refcount. (gomp_remove_var): New function. (gomp_unmap_vars): Use it. (gomp_unload_image_from_device): Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-1.c: Update test case to utilize OpenACC 2.5 data clause semantics. * testsuite/libgomp.oacc-c-c++-common/data-already-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-5.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-6.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-7.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-8.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-16.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-25.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-32.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-83.c: Likewise. * testsuite/libgomp.oacc-fortran/data-5.f90: New test. * testsuite/libgomp.oacc-fortran/data-already-1.f: Update test case to utilize OpenACC 2.5 data clause semantics. * testsuite/libgomp.oacc-fortran/data-already-2.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-3.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-4.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-5.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-6.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-7.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-8.f: Likewise. * testsuite/libgomp.oacc-fortran/lib-32-1.f: Likewise. * testsuite/libgomp.oacc-fortran/lib-32-2.f: Likewise. Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com> Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com> From-SVN: r261813
2018-06-20[PR c++/85634] Fix tsubst ICENathan Sidwell1-5/+8
https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01237.html PR c++/85634 * cp-tree.h (lookup_keep): Drop KEEP parm. (lookup_list_keep): Delete. (maybe_get_fns): Declare. * parser.c (cp_parser_primary_expression): Call lookup_keep here. (cp_parser_template_id): Not here ... * decl.c (cp_finish_decl): ... nor here ... * init.c (build_raw_new_expr): ... nor here ... * pt.c (process_template_parm): ... nor here ... * semantics.c (perform_koenig_lookup): Call lookup_keep. (finish_call_expr): Not here. * tree.c (ovl_cache): Delete. (ovl_make, ovl_copy): No cache. (lookup_keep): Always keep. (lookup_list_keep): Delete. (maybe_get_fns): New, broken out of ... (get_fns): ... here. Call it. (built_min_nt_loc, build_min, build_min_non_dep): Drop lookup_keep. (build_min_nt_call_vec): Likewise. PR c++/85634 * g++.dg/lookup/pr85634.C: New. From-SVN: r261802
2018-06-18tree.c (cp_expr_location): New.Jason Merrill1-2/+2
* tree.c (cp_expr_location): New. * cp-tree.h (cp_expr_loc_or_loc): New. * call.c, cvt.c, constexpr.c, constraint.cc, cp-gimplify.c, decl.c, error.c, init.c, lex.c, parser.c, pt.c, semantics.c, typeck.c, typeck2.c: Use it instead of EXPR_LOC_OR_LOC. From-SVN: r261728
2018-06-18Use a range for LAMBDA_EXPR_LOCATION.Jason Merrill1-0/+6
* parser.c (cp_parser_lambda_expression): Use a range for LAMBDA_EXPR_LOCATION. From-SVN: r261727
2018-06-06PR c++/86060 - ICE on range for with -std=c++98.Jason Merrill1-6/+3
* parser.c (cp_parser_init_statement): Don't clobber *decl after pedwarn. From-SVN: r261239
2018-06-06PR c++/85710 - ICE with -Wmemset-elt-size.Jason Merrill1-16/+3
c-family/ * c-warn.c (warn_for_memset): Don't crash on incomplete element type. cp/ * semantics.c (finish_call_expr): Call warn_for_memset here. * parser.c (cp_parser_postfix_expression): Not here. (literal_integer_zerop): No longer static. * pt.c (build_non_dependent_expr): Don't wrap CONST_DECL. From-SVN: r261238
2018-05-30Improve error recovery for structured binding in condition.Jason Merrill1-2/+5
* parser.c (cp_parser_check_condition_declarator): Handle cp_error_declarator. From-SVN: r260968
2018-05-25PR c++/85815 - reference to member of enclosing template.Jason Merrill1-4/+1
* search.c (lookup_base): Use currently_open_class. (lookup_member): Use it regardless of -fconcepts. * parser.c (cp_parser_postfix_dot_deref_expression): Check it. From-SVN: r260782
2018-05-24Pedwarn on a non-standard position of a C++ attribute.Ville Voutilainen1-0/+5
From-SVN: r260682
2018-05-24cp-tree.h (INDIRECT_TYPE_P): New.Paolo Carlini1-1/+1
2018-05-24 Paolo Carlini <paolo.carlini@oracle.com> * cp-tree.h (INDIRECT_TYPE_P): New. * call.c (build_trivial_dtor_call, maybe_warn_class_memaccess, joust): Use it instead of POINTER_TYPE_P. * class.c (update_vtable_entry_for_fn, find_flexarrays, * fixed_type_or_null, resolves_to_fixed_type_p): Likewise. * constexpr.c (cxx_eval_binary_expression, cxx_fold_indirect_ref, * cxx_eval_increment_expression, potential_constant_expression_1): Likewise. * cp-gimplify.c (cp_gimplify_expr, cp_genericize_r): Likewise. * cp-objcp-common.c (cxx_get_alias_set): Likewise. * cp-ubsan.c (cp_ubsan_maybe_instrument_member_call, cp_ubsan_maybe_instrument_downcast): Likewise. * cvt.c (cp_convert_to_pointer, ocp_convert, cp_get_fndecl_from_callee, maybe_warn_nodiscard, convert): Likewise. * cxx-pretty-print.c (cxx_pretty_printer::abstract_declarator, pp_cxx_offsetof_expression_1): Likewise. * decl.c (grokparms, static_fn_type): Likewise. * decl2.c (grokbitfield): Likewise. * error.c (dump_expr): Likewise. * except.c (initialize_handler_parm, check_noexcept_r): Likewise. * init.c (warn_placement_new_too_small): Likewise. * lambda.c (build_capture_proxy, add_capture): Likewise. * parser.c (cp_parser_omp_for_loop): Likewise. * pt.c (convert_nontype_argument, fn_type_unification, uses_deducible_template_parms, check_cv_quals_for_unify, dependent_type_p_r): Likewise. * search.c (check_final_overrider): Likewise. * semantics.c (handle_omp_array_sections, finish_omp_clauses, finish_omp_for): Likewise. * tree.c (cp_build_qualified_type_real): Likewise. * typeck.c (build_class_member_access_expr, finish_class_member_access_expr, build_x_indirect_ref, cp_build_indirect_ref_1, cp_build_binary_op, build_const_cast_1): Likewise. From-SVN: r260677
2018-05-23Implement P0614R1, Range-based for statements with initializer.Marek Polacek1-6/+74
* parser.c (cp_parser_range_based_for_with_init_p): New. (cp_parser_init_statement): Use it. Parse the optional init-statement for a range-based for loop. (cp_parser_skip_to_closing_parenthesis_1): Handle balancing ?:. * g++.dg/cpp2a/range-for1.C: New test. * g++.dg/cpp2a/range-for2.C: New test. * g++.dg/cpp2a/range-for3.C: New test. * g++.dg/cpp2a/range-for4.C: New test. * g++.dg/cpp2a/range-for5.C: New test. * g++.dg/cpp2a/range-for6.C: New test. * g++.dg/cpp2a/range-for7.C: New test. From-SVN: r260619
2018-05-21parser.c (cp_parser_parameter_declaration_list): Remove bool* parameter.Paolo Carlini1-12/+9
2018-05-21 Paolo Carlini <paolo.carlini@oracle.com> * parser.c (cp_parser_parameter_declaration_list): Remove bool* parameter. (cp_parser_parameter_declaration_clause): Adjust. (cp_parser_cache_defarg): Likewise. From-SVN: r260486
2018-05-21re PR c++/84588 (internal compiler error: Segmentation fault ↵Paolo Carlini1-11/+62
(contains_struct_check())) /cp 2018-05-21 Paolo Carlini <paolo.carlini@oracle.com> PR c++/84588 * parser.c (cp_parser_maybe_commit_to_declaration, cp_parser_check_condition_declarator): New. (cp_parser_simple_declaration): Use the first above. (cp_parser_condition): Use both the above; enforce [stmt.stmt]/2 about the declarator not specifying a function or an array; improve error-recovery. /testsuite 2018-05-21 Paolo Carlini <paolo.carlini@oracle.com> PR c++/84588 * g++.dg/cpp0x/cond1.C: New. * g++.dg/cpp1y/pr84588-1.C: Likewise. * g++.dg/cpp1y/pr84588-2.C: Likewise. * g++.dg/cpp1y/pr84588-3.C: Likewise. * g++.dg/parse/cond6.C: Likewise. * g++.dg/parse/cond7.C: Likewise. * g++.dg/parse/cond8.C: Likewise. * g++.dg/cpp1z/decomp16.C: Update. * g++.old-deja/g++.jason/cond.C: Likewise. From-SVN: r260482
2018-05-14Handle TYPE_HAS_LATE_RETURN_TYPE like ref-qualifier and eh spec.Jason Merrill1-7/+3
* tree.c (build_cp_fntype_variant): New. (build_ref_qualified_type, build_exception_variant) (strip_typedefs, cxx_copy_lang_qualifiers): Use it. (cxx_type_hash_eq, cp_check_qualified_type): Check TYPE_HAS_LATE_RETURN_TYPE. (cp_build_type_attribute_variant): Check cxx_type_hash_eq. (cp_build_qualified_type_real): No need to preserve C++ qualifiers. * class.c (build_clone): Use cxx_copy_lang_qualifiers. (adjust_clone_args): Likewise. * decl.c (grokfndecl): Add late_return_type_p parameter. Use build_cp_fntype_variant. (grokdeclarator): Pass late_return_type_p to grokfndecl. (check_function_type): Use cxx_copy_lang_qualifiers. (static_fn_type): Use cxx_copy_lang_qualifiers. * decl2.c (build_memfn_type, maybe_retrofit_in_chrg) (cp_reconstruct_complex_type, coerce_new_type, coerce_delete_type) (change_return_type): Use cxx_copy_lang_qualifiers. * mangle.c (write_type): Use cxx_copy_lang_qualifiers. * parser.c (cp_parser_lambda_declarator_opt): Represent an explicit return type on the declarator like a normal trailing return type. * pt.c (tsubst_function_type): Use build_cp_fntype_variant. (copy_default_args_to_explicit_spec): Use cxx_copy_lang_qualifiers. * typeck.c (merge_types): Use build_cp_fntype_variant. From-SVN: r260238
2018-05-14cp-tree.h (TYPE_REF_P): New.Paolo Carlini1-3/+3
2018-05-14 Paolo Carlini <paolo.carlini@oracle.com> * cp-tree.h (TYPE_REF_P): New. (TYPE_OBJ_P, TYPE_REF_OBJ_P, TYPE_REFFN_P): Update. * call.c (build_list_conv, build_aggr_conv, standard_conversion, direct_reference_binding, reference_binding, implicit_conversion, add_builtin_candidate, build_user_type_conversion_1, build_op_call_1, build_new_op_1, build_x_va_arg, conv_binds_ref_to_prvalue, build_over_call, perform_implicit_conversion_flags, extend_ref_init_temps, type_has_extended_temps): Use it. * class.c (one_inheriting_sig, check_field_decls, check_bases_and_members, find_flexarrays, finish_struct, fixed_type_or_null): Likewise. * constexpr.c (literal_type_p, cxx_bind_parameters_in_call, non_const_var_error, cxx_eval_constant_expression, potential_constant_expression_1): Likewise. * cp-gimplify.c (omp_var_to_track, omp_cxx_notice_variable, cp_genericize_r, cxx_omp_privatize_by_reference, cxx_omp_const_qual_no_mutable, cxx_omp_finish_clause, cp_fold_maybe_rvalue): Likewise. * cp-ubsan.c (cp_ubsan_maybe_instrument_downcast): Likewise. * cvt.c (build_up_reference, convert_to_reference, convert_from_reference, convert_to_void, noexcept_conv_p, fnptr_conv_p): Likewise. * decl.c (poplevel, check_for_uninitialized_const_var, check_initializer, initialize_local_var, cp_finish_decl, get_tuple_decomp_init, cp_finish_decomp, grokdeclarator, copy_fn_p, move_signature_fn_p, grok_op_properties, finish_function): Likewise. * decl2.c (grok_array_decl, cp_reconstruct_complex_type, decl_maybe_constant_var_p): Likewise. * error.c (dump_type_prefix, dump_expr): Likewise. * except.c (initialize_handler_parm, complete_ptr_ref_or_void_ptr_p, is_admissible_throw_operand_or_catch_parameter): Likewise. * expr.c (mark_use): Likewise. * init.c (build_zero_init_1, build_value_init_noctor, perform_member_init, diagnose_uninitialized_cst_or_ref_member_1, build_new, build_delete): Likewise. * lambda.c (build_lambda_object): Likewise. * mangle.c (write_expression, write_template_arg): Likewise. * method.c (forward_parm, do_build_copy_constructor, do_build_copy_assign, build_stub_object, constructible_expr, walk_field_subobs): Likewise. * parser.c (cp_parser_omp_for_loop_init, cp_parser_omp_declare_reduction_exprs, cp_parser_omp_declare_reduction): Likewise. * pt.c (convert_nontype_argument_function, convert_nontype_argument, convert_template_argument, tsubst_pack_expansion, tsubst_function_decl, tsubst_decl, tsubst, tsubst_copy_and_build, maybe_adjust_types_for_deduction, check_cv_quals_for_unify, unify, more_specialized_fn, invalid_nontype_parm_type_p, dependent_type_p_r, value_dependent_expression_p, build_deduction_guide): Likewise. * semantics.c (finish_handler_parms, finish_non_static_data_member, finish_compound_literal, omp_privatize_field, handle_omp_array_sections_1, handle_omp_array_sections, cp_check_omp_declare_reduction, finish_omp_reduction_clause, finish_omp_declare_simd_methods, cp_finish_omp_clause_depend_sink, finish_omp_clauses, finish_decltype_type, capture_decltype, finish_builtin_launder): Likewise. * tree.c (lvalue_kind, cp_build_reference_type, move, cp_build_qualified_type_real, stabilize_expr, stabilize_init): Likewise. * typeck.c (cxx_safe_arg_type_equiv_p, build_class_member_access_expr, cp_build_indirect_ref_1, convert_arguments, warn_for_null_address, cp_build_addr_expr_1, maybe_warn_about_useless_cast, build_static_cast_1, build_static_cast, build_reinterpret_cast_1, build_const_cast_1, cp_build_c_cast, cp_build_modify_expr, convert_for_initialization, maybe_warn_about_returning_address_of_local, check_return_expr, cp_type_quals, casts_away_constness, non_reference): Likewise. * typeck2.c (cxx_readonly_error, store_init_value, process_init_constructor_record, build_x_arrow, build_functional_cast, add_exception_specifier): Likewise. From-SVN: r260228
2018-05-10* parser.c (cp_parser_class_head): Use num_template_headers_for_class.Jason Merrill1-14/+1
From-SVN: r260125
2018-05-10decl.c (make_typename_type): s/parameters/arguments/.Jason Merrill1-1/+1
* decl.c (make_typename_type): s/parameters/arguments/. * parser.c (cp_parser_nested_name_specifier_opt): Likewise. * pt.c (make_pack_expansion): Correct error message. From-SVN: r260121
2018-05-09re PR c++/85713 (ICE in dependent_type_p, at cp/pt.c:24582 on valid code)Paolo Carlini1-2/+0
/cp 2018-05-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/85713 Revert: 2018-05-08 Paolo Carlini <paolo.carlini@oracle.com> PR c++/84588 * parser.c (cp_parser_parameter_declaration_list): When the entire parameter-declaration-list is erroneous maybe call abort_fully_implicit_template. /testsuite 2018-05-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/85713 Revert: 2018-05-08 Paolo Carlini <paolo.carlini@oracle.com> PR c++/84588 * g++.dg/cpp1y/pr84588.C: New. From-SVN: r260086
2018-05-08re PR c++/84588 (internal compiler error: Segmentation fault ↵Paolo Carlini1-0/+2
(contains_struct_check())) /cp 2018-05-08 Paolo Carlini <paolo.carlini@oracle.com> PR c++/84588 * parser.c (cp_parser_parameter_declaration_list): When the entire parameter-declaration-list is erroneous maybe call abort_fully_implicit_template. /testsuite 2018-05-08 Paolo Carlini <paolo.carlini@oracle.com> PR c++/84588 * g++.dg/cpp1y/pr84588.C: New. From-SVN: r260050
2018-05-07[C++ PATCH] Kill -fno-for-scopeNathan Sidwell1-21/+4
https://gcc.gnu.org/ml/gcc-patches/2018-05/msg00299.html gcc/cp/ Remove fno-for-scope * cp-tree.h (DECL_ERROR_REPORTED, DECL_DEAD_FOR_LOCAL) (DECL_HAS_SHADOWED_FOR_VAR_P, DECL_SHADOWED_FOR_VAR) (SET_DECL_SHADOWED_FOR_VAR): Delete. (decl_shadowed_for_var_lookup, decl_shadowed_for_var_insert) (check_for_out_of_scope_variable, init_shadowed_var_for_decl): Don't declare. * name-lookup.h (struct cp_binding_level): Remove dead_vars_from_for field. * cp-lang.c (cp_init_ts): Delete. (LANG_HOOKS_INIT_TS): Override to cp_common_init_ts. * cp-objcp-common.c (shadowed_var_for_decl): Delete. (decl_shadowed_for_var_lookup, decl_shadowed_for_var_insert) (init_shadowed_var_for_decl): Delete. * decl.c (poplevel): Remove shadowed for var handling. (cxx_init_decl_processing): Remove -ffor-scope deprecation. * name-lookup.c (find_local_binding): Remove shadowed for var handling. (check_local_shadow): Likewise. (check_for_out_of_scope_variable): Delete. * parser.c (cp_parser_primary_expression): Remove shadowed for var handling. * pt.c (tsubst_decl): Remove DECL_DEAD_FOR_LOCAL setting. * semantics.c (begin_for_scope): Always have a scope. (begin_for_stmt, finish_for_stmt): Remove ARM-for scope handling. (begin_range_for_stmt, finish_id_expression): Likewise. gcc/ * doc/invoke.texi (C++ Dialect Options): Remove -ffor-scope. * doc/extend.texi (Deprecated Features): Remove -fno-for-scope (Backwards Compatibility): Likewise. c-family/ * c.opt (ffor-scope): Remove functionality, issue warning. gcc/objcp/ * objcp-lang.c (objcxx_init_ts): Don't call init_shadowed_var_for_decl. gcc/testsuite/ * g++.dg/cpp0x/range-for10.C: Delete. * g++.dg/ext/forscope1.C: Delete. * g++.dg/ext/forscope2.C: Delete. * g++.dg/template/for1.C: Delete. From-SVN: r260015
2018-04-30PR c++/85305 - pack in lambda init-capture.Jason Merrill1-4/+4
* parser.c (cp_parser_initializer): Add subexpression_p parm; don't check_for_bare_parameter_packs in a subexpression. (cp_parser_lambda_introducer): Use it. From-SVN: r259779
2018-04-23PR c++/69560 - wrong alignof(double) on x86.Jason Merrill1-2/+5
CWG 1879 - Inadequate definition of alignment requirement. * cp-tree.h (ALIGNOF_EXPR_STD_P): New. * typeck.c (cxx_sizeof_or_alignof_type): Add std_alignof parm. (cxx_sizeof_expr, cxx_sizeof_nowarn, cxx_alignas_expr) (cxx_alignof_expr): Pass it. * parser.c (cp_parser_unary_expression): Pass it. * pt.c (tsubst_copy): Copy it. (tsubst_copy_and_build): Pass it. * decl.c (fold_sizeof_expr): Pass it. From-SVN: r259578
2018-04-16[PR c++/85039] no type definitions in builtin offsetofAlexandre Oliva1-1/+7
Types defined within a __builtin_offsetof argument don't always get properly recorded as members of their context types, so if they're anonymous, we may fail to assign them an anon type index for mangling and ICE. We shouldn't allow types to be introduced in __builtin_offsetof, I think, and Jason says the std committee agrees, so I've arranged for us to reject them. Even then, we still parse the definitions and attempt to assign mangled names to its member functions, so the ICE remains. Since we've already reported an error, we might as well complete the name assignment with an arbitrary index, thus avoiding the ICE. We used to have a test that expected to be able to define types in __builtin_offsetof; this patch removes that specific test. for gcc/cp/ChangeLog PR c++/85039 * parser.c (cp_parser_builtin_offset): Reject type definitions. * mangle.c (nested_anon_class_index): Avoid crash returning -1 if we've seen errors. for gcc/testsuite/ChangeLog PR c++/85039 * g++.dg/pr85039-1.C: New. * g++.dg/pr85039-2.C: New. * g++.dg/parse/semicolon3.C: Remove test_offsetof. From-SVN: r259423
2018-04-10PR c++/85312 - P0962 cleanupJakub Jelinek1-11/+2
PR c++/85312 - P0962 cleanup * parser.c (cp_parser_perform_range_for_lookup): Remove unreachable diagnostics. From-SVN: r259279