aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/cvt.c
AgeCommit message (Collapse)AuthorFilesLines
2020-07-02c++: Support C++20 virtual consteval functions. [PR88335]Jason Merrill1-6/+5
Jakub's partial implementation of consteval virtual had trouble with the current ABI requirement that we omit the vtable slot for a consteval virtual function; it's difficult to use the normal code for constant evaluation and also magically make the slots disappear if the vtables get written out. I notice that Clang trunk also doesn't implement that requirement, and it seems unnecessary to me; I expect consteval virtual functions to be extremely rare, so it should be fine to just give them a vtable slot as normal but put zero in it if the vtable gets emitted. I've commented as much to the ABI committee. One of Jakub's testcases points out that we weren't handling thunks in our constexpr virtual handling; that is fixed here as well. Incidentally, being able to use C++11 range-for definitely simplified clear_consteval_vfns. gcc/c-family/ChangeLog: * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_consteval. gcc/cp/ChangeLog: * decl.c (grokfndecl): Allow consteval virtual. * search.c (check_final_overrider): Check consteval mismatch. * constexpr.c (cxx_eval_thunk_call): New. (cxx_eval_call_expression): Call it. * cvt.c (cp_get_fndecl_from_callee): Handle FDESC_EXPR. * decl2.c (mark_vtable_entries): Track vtables with consteval. (maybe_emit_vtables): Pass consteval_vtables through. (clear_consteval_vfns): Replace consteval with nullptr. (c_parse_final_cleanups): Call it. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/consteval-virtual1.C: New test. * g++.dg/cpp2a/consteval-virtual2.C: New test. * g++.dg/cpp2a/consteval-virtual3.C: New test. * g++.dg/cpp2a/consteval-virtual4.C: New test. * g++.dg/cpp2a/consteval-virtual5.C: New test. Co-authored-by: Jakub Jelinek <jakub@redhat.com>
2020-05-18c++: ICE with -Wall and constexpr if [PR94937]Marek Polacek1-2/+1
An ICE arises here because we call cp_get_callee_fndecl_nofold in a template, and we've got a CALL_EXPR whose CALL_EXPR_FN is a BASELINK. This tickles the INDIRECT_TYPE_P assert in cp_get_fndecl_from_callee. Fixed by turning the assert into a condition and returning NULL_TREE in that case. PR c++/94937 * cvt.c (cp_get_fndecl_from_callee): Return NULL_TREE if the function type is not INDIRECT_TYPE_P. * decl.c (omp_declare_variant_finalize_one): Call cp_get_callee_fndecl_nofold instead of looking for the function decl manually. * g++.dg/cpp1z/constexpr-if34.C: New test. * g++.dg/cpp2a/is-constant-evaluated10.C: New test.
2020-04-16c++: Error recovery with erroneous DECL_INITIAL [PR94475]Patrick Palka1-1/+3
Here we're ICE'ing in do_narrow during error-recovery, because ocp_convert returns error_mark_node after it attempts to reduce a const decl to its erroneous DECL_INITIAL via scalar_constant_value, and we later pass this error_mark_node to fold_build2 which isn't prepared to handle error_mark_nodes. We could fix this ICE in do_narrow by checking if ocp_convert returns error_mark_node, but for the sake of consistency and for better error recovery it seems it'd be preferable if ocp_convert didn't care that a const decl's initializer is erroneous and would instead proceed as if the decl was not const, which is the approach that this patch takes. gcc/cp/ChangeLog: PR c++/94475 * cvt.c (ocp_convert): If the result of scalar_constant_value is erroneous, ignore it and use the original expression. gcc/testsuite/ChangeLog: PR c++/94475 * g++.dg/conversion/err-recover2.C: New test. * g++.dg/diagnostic/pr84138.C: Remove now-bogus warning. * g++.dg/warn/Wsign-compare-8.C: Remove now-bogus warning.
2020-03-27c++: Handle COMPOUND_EXPRs in ocp_convert [PR94339]Jakub Jelinek1-0/+11
My recent change to get_narrower/warnings_for_convert_and_check broke the following testcase, warnings_for_convert_and_check is upset that expr is a COMPOUND_EXPR with INTEGER_CST at the rightmost operand, while result is a COMPOUND_EXPR with a NOP_EXPR of INTEGER_CST at the rightmost operand, it expects such conversions to be simplified. The easiest fix seems to be to handle COMPOUND_EXPRs in ocp_convert too, by converting the rightmost operand and recreating COMPOUND_EXPR(s) if that changed. The attr-copy-2.C change is a workaround for PR94346, where we now ICE on the testcase, while previously we'd ICE only if it contained a comma expression at the outer level rather than cast of a COMPOUND_EXPR to something. I'll defer that to Martin. 2020-03-27 Jakub Jelinek <jakub@redhat.com> PR c++/94339 * cvt.c (ocp_convert): Handle COMPOUND_EXPR by recursion on the second operand and creating a new COMPOUND_EXPR if anything changed. * g++.dg/other/pr94339.C: New test. * g++.dg/ext/attr-copy-2.C: Comment out failing tests due to PR94346.
2020-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r279813
2019-12-23[C++] Fix ICE for binding lax vector conversions to references (PR 93014)Richard Sandiford1-2/+2
This test: typedef unsigned int v4si __attribute__ ((vector_size(16))); typedef unsigned char v16qi __attribute__ ((vector_size(16))); extern v16qi x; v4si &y = x; ICEs with: a.c:4:11: internal compiler error: in convert_like_real, at cp/call.c:7670 This started with r260780, which had the effect of making lvalue_kind look through VIEW_CONVERT_EXPR in all cases, not just for location wrappers. This also means that: typedef unsigned int v4si __attribute__ ((vector_size(16))); typedef unsigned char v16qi __attribute__ ((vector_size(16))); extern v16qi x; v4si &y = reinterpret_cast<v4si>(x); is now valid despite the result of the cast being an rvalue. The patch attempts to fix that by calling rvalue on the input to the conversion, so that the tree looks the same as for: extern v16qi x; v4si &y = (v4si)x; which is already handled correctly. 2019-12-23 Richard Sandiford <richard.sandiford@arm.com> gcc/cp/ * cvt.c (ocp_convert): Apply rvalue to the source of vector conversions. * typeck.c (build_reinterpret_cast_1): Likewise. gcc/testsuite/ * g++.dg/ext/vector39.C: New test. From-SVN: r279716
2019-12-09cvt.c (maybe_warn_nodiscard): Add workaround for GCC 3.4-4.4 - cast msg to ↵Jakub Jelinek1-12/+14
(const char *) in conditional... * cvt.c (maybe_warn_nodiscard): Add workaround for GCC 3.4-4.4 - cast msg to (const char *) in conditional expressions. Formatting fixes. From-SVN: r279101
2019-12-04[C++] Opt out of GNU vector extensions for built-in SVE typesRichard Sandiford1-1/+12
This is the C++ equivalent of r277950. The changes are very similar to there. Perhaps the only noteworthy thing (that I know of) is that the patch continues to treat !gnu_vector_type_p vector types as literal types/potential constexprs. Disabling the GNU vector extensions shouldn't in itself stop the types from being literal types, since whatever the target provides instead might be constexpr material. 2019-12-04 Richard Sandiford <richard.sandiford@arm.com> gcc/cp/ * cp-tree.h (CP_AGGREGATE_TYPE_P): Check for gnu_vector_type_p instead of VECTOR_TYPE. * call.c (build_conditional_expr_1): Restrict vector handling to vectors that satisfy gnu_vector_type_p. * cvt.c (ocp_convert): Only allow vectors to be converted to bool if they satisfy gnu_vector_type_p. (build_expr_type_conversion): Only allow conversions from vectors if they satisfy gnu_vector_type_p. * typeck.c (cp_build_binary_op): Only allow binary operators to be applied to vectors if they satisfy gnu_vector_type_p. (cp_build_unary_op): Likewise unary operators. (build_reinterpret_cast_1): gcc/testsuite/ * g++.target/aarch64/sve/acle/general-c++/gnu_vectors_1.C: New test. * g++.target/aarch64/sve/acle/general-c++/gnu_vectors_2.C: New test. From-SVN: r278957
2019-11-27re PR c++/92236 ([concepts] Explain non-satisfaction in static_assert)Andrew Sutton1-0/+6
2019-11-27 Andrew Sutton <asutton@lock3software.com> PR c++/92236 Defer evaluation of concept checks so that static assertions can emit more detailed diagnostics. gcc/cp/ * constexpr.c (cxx_eval_call_expression): Handle concept checks. (cxx_eval_constant_expression): Diagnose misuse of function concepts as template-id expressions. Follow the usual return path for results. (cxx_eval_outermost_constant_expr): Avoid calling cp_get_callee_fndecl_nofold for function concepts. * constraint.cc (build_function_check): Fully type the concept check so that we don't ICE in conversions. * cp-gimplify.c (cp_genericize_r) [CALL_EXPR]: Handle concept checks. [TEMPLATE_ID_EXPR] Likewise. * cvt.c (convert_to_void): Always evaluate concept checks so we don't accidentally ignore them. Substitution during satisfaction can make a program ill-formed (example in g++.dg/cpp2a/concepts6.C). * pt.c (tsubst_copy_and_build): [CALL_EXPR]: Don't evaluate concepts. [TEMPLATE_ID_EXPR]: Likewise. * semantics.c (finish_call_expr): Don't evaluate concepts. (finish_id_expression_1): Likewise. (finish_static_assert): Preserve the original condition so we can diagnose concept errors when a check returns false. gcc/testsuite/ * g++.dg/cpp2a/concepts-iconv1.C: Update diagnostics. * g++.dg/cpp2a/concepts-requires5.C: Likewise. * g++.dg/cpp2a/concepts6.C: New test. From-SVN: r278775
2019-11-20cvt.c (ocp_convert): Use additional warning sentinel.Paolo Carlini1-0/+1
/cp 2019-11-20 Paolo Carlini <paolo.carlini@oracle.com> * cvt.c (ocp_convert): Use additional warning sentinel. /testsuite 2019-11-20 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/warn/multiple-sign-compare-warn-1.C: New. From-SVN: r278475
2019-11-15typeck.c (cp_truthvalue_conversion): Add tsubst_flags_t parameter and use it ↵Paolo Carlini1-2/+2
in calls... /cp 2019-11-15 Paolo Carlini <paolo.carlini@oracle.com> * typeck.c (cp_truthvalue_conversion): Add tsubst_flags_t parameter and use it in calls; also pass the location_t of the expression to cp_build_binary_op and c_common_truthvalue_conversion. * rtti.c (build_dynamic_cast_1): Adjust call. * cvt.c (ocp_convert): Likewise. * cp-gimplify.c (cp_fold): Likewise. * cp-tree.h (cp_truthvalue_conversion): Update declaration. /testsuite 2019-11-15 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/warn/Walways-true-1.C: Check locations too. * g++.dg/warn/Walways-true-2.C: Likewise. * g++.dg/warn/Walways-true-3.C: Likewise. * g++.dg/warn/Waddress-1.C: Check additional location. From-SVN: r278320
2019-11-13PR c++/89070 - bogus [[nodiscard]] warning in SFINAE.Marek Polacek1-3/+6
This is a complaint that we issue a [[nodiscard]] warning even in SFINAE contexts. Here 'complain' is tf_decltype, but not tf_warning so I guess we can fix it as below. * cvt.c (convert_to_void): Guard maybe_warn_nodiscard calls with tf_warning. * g++.dg/cpp1z/nodiscard7.C: New test. From-SVN: r278147
2019-10-19Implement C++20 P1301 [[nodiscard("should have a reason")]].JeanHeyd Meneide1-9/+27
2019-10-17 JeanHeyd Meneide <phdofthehouse@gmail.com> gcc/ * escaped_string.h (escaped_string): New header. * tree.c (escaped_string): Remove escaped_string class. gcc/c-family * c-lex.c (c_common_has_attribute): Update nodiscard value. gcc/cp/ * tree.c (handle_nodiscard_attribute) Added C++2a nodiscard string message. (std_attribute_table) Increase nodiscard argument handling max_length from 0 to 1. * parser.c (cp_parser_check_std_attribute): Add requirement that nodiscard only be seen once in attribute-list. (cp_parser_std_attribute): Check that empty parenthesis lists are not specified for attributes that have max_length > 0 (e.g. [[attr()]]). * cvt.c (maybe_warn_nodiscard): Add nodiscard message to output, if applicable. (convert_to_void): Allow constructors to be nodiscard-able (P1771). gcc/testsuite/g++.dg/cpp0x * gen-attrs-67.C: Test new error message for empty-parenthesis-list. gcc/testsuite/g++.dg/cpp2a * nodiscard-construct.C: New test. * nodiscard-once.C: New test. * nodiscard-reason-nonstring.C: New test. * nodiscard-reason-only-one.C: New test. * nodiscard-reason.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com> From-SVN: r277200
2019-08-05cp-tree.h (cp_expr_loc_or_input_loc): New.Paolo Carlini1-6/+6
2019-08-05 Paolo Carlini <paolo.carlini@oracle.com> * cp-tree.h (cp_expr_loc_or_input_loc): New. (cxx_incomplete_type_diagnostic): Use it. * call.c (build_converted_constant_expr_internal, convert_like_real, convert_arg_to_ellipsis, convert_for_arg_passing, build_over_call, build_cxx_call, perform_implicit_conversion_flags, initialize_reference): Likewise. * constexpr.c (cxx_eval_internal_function, cxx_eval_call_expression, eval_and_check_array_index, cxx_eval_store_expression, cxx_eval_statement_list, cxx_eval_loop_expr, cxx_eval_constant_expression, potential_constant_expression_1): Likewise. * constraint.cc (check_for_logical_overloads, satisfy_predicate_constraint): Likewise. * cp-gimplify.c (cp_gimplify_expr): Likewise. * cvt.c (cp_convert_to_pointer, convert_to_reference, cp_convert_and_check, ocp_convert, maybe_warn_nodiscard): Likewise. * decl.c (pop_switch): Likewise. * decl2.c (delete_sanity): Likewise. * error.c (location_of): Likewise. * init.c (maybe_warn_list_ctor, build_aggr_init, warn_placement_new_too_small, build_new_1, build_vec_init): Likewise. * lex.c (unqualified_name_lookup_error): Likewise. * parser.c (cp_parser_initializer_list, cp_parser_omp_for_cond): Likewise. * pt.c (check_for_bare_parameter_packs, check_valid_ptrmem_cst_expr, unify_arg_conversion, convert_nontype_argument, tsubst_copy_and_build, resolve_typename_type): Likewise. * semantics.c (maybe_convert_cond, finish_call_expr, cp_build_vec_convert): Likewise. * typeck.c (decay_conversion, rationalize_conditional_expr, cp_build_unary_op, build_x_compound_expr_from_list, maybe_warn_about_returning_address_of_local, maybe_warn_pessimizing_move): Likewise. * typeck2.c (check_narrowing, digest_init_r, process_init_constructor_array): Likewise. From-SVN: r274124
2019-06-22PR c++/90881 - bogus -Wunused-value in unevaluated context.Marek Polacek1-1/+2
* cvt.c (convert_to_void): Don't emit unused warnings in an unevaluated context. * g++.dg/cpp0x/Wunused-value1.C: New test. From-SVN: r272585
2019-06-05c-decl.c (start_decl): Adjust quoting and hyphenation in diagnostics.Martin Sebor1-1/+1
gcc/c/ChangeLog: * c-decl.c (start_decl): Adjust quoting and hyphenation in diagnostics. (finish_decl): Same. (finish_enum): Same. (start_function): Same. (declspecs_add_type): Same. * c-parser.c (warn_for_abs): Same. * c-typeck.c (build_binary_op): Same. gcc/c-family/ChangeLog: * c-attribs.c (handle_mode_attribute): Adjust quoting and hyphenation. (handle_alias_ifunc_attribute): Same. (handle_copy_attribute): Same. (handle_weakref_attribute): Same. (handle_nonnull_attribute): Same. * c-warn.c (warn_for_sign_compare): Same. (warn_for_restrict): Same. * c.opt: Same. gcc/cp/ChangeLog: * call.c (build_conditional_expr_1): Adjust quoting and hyphenation. (convert_like_real): Same. (convert_arg_to_ellipsis): Same. * constexpr.c (diag_array_subscript): Same. * constraint.cc (diagnose_trait_expression): Same. * cvt.c (ocp_convert): Same. * decl.c (start_decl): Same. (check_for_uninitialized_const_var): Same. (grokfndecl): Same. (check_special_function_return_type): Same. (finish_enum_value_list): Same. (start_preparsed_function): Same. * parser.c (cp_parser_decl_specifier_seq): Same. * typeck.c (cp_build_binary_op): Same. (build_static_cast_1): Same. gcc/lto/ChangeLog: * lto-common.c (lto_file_finalize): Adjust quoting and hyphenation. gcc/objc/ChangeLog: * objc-act.c (objc_build_setter_call): Adjust quoting and hyphenation. * objc-encoding.c (encode_gnu_bitfield): Same. gcc/ChangeLog: * config/i386/i386-features.c (ix86_get_function_versions_dispatcher): Adjust quoting and hyphenation. * convert.c (convert_to_real_1): Same. * gcc.c (driver_wrong_lang_callback): Same. (driver::handle_unrecognized_options): Same. * gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Same. * opts-common.c (cmdline_handle_error): Same. (read_cmdline_option): Same. * opts-global.c (complain_wrong_lang): Same. (print_ignored_options): Same. (handle_common_deferred_options): Same. * pretty-print.h: Same. * print-rtl.c (debug_bb_n_slim): Same. * sched-rgn.c (make_pass_sched_fusion): Same. * tree-cfg.c (verify_gimple_assign_unary): Same. (verify_gimple_label): Same. * tree-ssa-operands.c (verify_ssa_operands): Same. * varasm.c (do_assemble_alias): Same. (assemble_alias): Same. From-SVN: r271971
2019-05-17trans.c (check_inlining_for_nested_subprog): Quote reserved names.Martin Sebor1-5/+5
gcc/ada/ChangeLog: * gcc-interface/trans.c (check_inlining_for_nested_subprog): Quote reserved names. gcc/brig/ChangeLog: * brigfrontend/brig-control-handler.cc (brig_directive_control_handler::operator): Remove trailing newline from a diagnostic. * brigfrontend/brig-module-handler.cc (brig_directive_module_handler::operator): Remove a duplicated space from a diagnostic. gcc/c/ChangeLog: * c-decl.c (start_decl): Quote keywords, operators, and types in diagnostics. (finish_decl): Same. * c-parser.c (c_parser_asm_statement): Same. (c_parser_conditional_expression): Same. (c_parser_transaction_cancel): Same. * c-typeck.c (c_common_type): Same. (build_conditional_expr): Same. (digest_init): Same. (process_init_element): Same. (build_binary_op): Same. gcc/c-family/ChangeLog: * c-attribs.c (handle_no_sanitize_attribute): Quote identifiers, keywords, operators, and types in diagnostics. (handle_scalar_storage_order_attribute): Same. (handle_mode_attribute): Same. (handle_visibility_attribute): Same. (handle_assume_aligned_attribute): Same. (handle_no_split_stack_attribute): Same. * c-common.c (shorten_compare): Same. (c_common_truthvalue_conversion): Same. (cb_get_source_date_epoch): Same. * c-lex.c (cb_def_pragma): Quote keywords, operators, and types in diagnostics. (interpret_float): Same. * c-omp.c (c_finish_omp_for): Same. * c-opts.c (c_common_post_options): Same. * c-pch.c (c_common_pch_pragma): Same. * c-pragma.c (pop_alignment): Same. (handle_pragma_pack): Same. (apply_pragma_weak): Same. (handle_pragma_weak): Same. (handle_pragma_scalar_storage_order): Same. (handle_pragma_redefine_extname): Same. (add_to_renaming_pragma_list): Same. (maybe_apply_renaming_pragma): Same. (push_visibility): Same. (handle_pragma_visibility): Same. (handle_pragma_optimize): Same. (handle_pragma_message): Same. * c-warn.c (warn_for_omitted_condop): Same. (lvalue_error): Same. gcc/cp/ChangeLog: * call.c (print_z_candidate): Wrap diagnostic text in a gettext macro. Adjust. (print_z_candidates): Same. (build_conditional_expr_1): Quote keywords, operators, and types in diagnostics. (build_op_delete_call): Same. (maybe_print_user_conv_context): Wrap diagnostic text in a gettext macro. (convert_like_real): Same. (convert_arg_to_ellipsis): Quote keywords, operators, and types in diagnostics. (build_over_call): Same. (joust): Break up an overlong line. Wrap diagnostic text in a gettext macro. * constexpr.c (cxx_eval_check_shift_p): Spell out >= in English. (cxx_eval_constant_expression): Quote keywords, operators, and types in diagnostics. (potential_constant_expression_1): Same. * cp-gimplify.c (cp_genericize_r): Same. * cvt.c (maybe_warn_nodiscard): Quote keywords, operators, and types in diagnostics. (type_promotes_to): Same. * decl.c (check_previous_goto_1): Same. (check_goto): Same. (start_decl): Same. (cp_finish_decl): Avoid parenthesizing a sentence for consistency. (grok_op_properties): Quote keywords, operators, and types in diagnostics. * decl2.c (grokfield): Same. (coerce_delete_type): Same. * except.c (is_admissible_throw_operand_or_catch_parameter): Same. * friend.c (do_friend): Quote C++ tokens. * init.c (build_new_1): Quote keywords, operators, and types in diagnostics. (build_vec_delete_1): Same. (build_delete): Same. * lex.c (parse_strconst_pragma): Same. (handle_pragma_implementation): Same. (unqualified_fn_lookup_error): Same. * mangle.c (write_type): Same. * method.c (defaulted_late_check): Avoid two consecutive punctuators. * name-lookup.c (cp_binding_level_debug): Remove a trailing newline. (pop_everything): Same. * parser.c (cp_lexer_start_debugging): Quote a macro name. in a diagnostic (cp_lexer_stop_debugging): Same. (cp_parser_userdef_numeric_literal): Quote a C++ header name in a diagnostic. (cp_parser_nested_name_specifier_opt): Quote keywords, operators, and types in diagnostics. (cp_parser_question_colon_clause): Same. (cp_parser_asm_definition): Same. (cp_parser_init_declarator): Same. (cp_parser_template_declaration_after_parameters): Avoid capitalizing a sentence in a diagnostic. (cp_parser_omp_declare_reduction): Quote keywords, operators, and types in diagnostics. (cp_parser_transaction): Same. * pt.c (maybe_process_partial_specialization): Replace second call to permerror with inform for consistency with other uses. (expand_integer_pack): Quote keywords, operators, and types in diagnostics. * rtti.c (get_typeid): Quote keywords, operators, and types in diagnostics. (build_dynamic_cast_1): Same. * semantics.c (finish_asm_stmt): Same. (finish_label_decl): Same. (finish_bases): Same. (finish_offsetof): Same. (cp_check_omp_declare_reduction): Same. (finish_decltype_type): Same. * tree.c (handle_init_priority_attribute): Same. Add detail to diagnostics. (maybe_warn_zero_as_null_pointer_constant): Same. * typeck.c (cp_build_binary_op): Quote keywords, operators, and types in diagnostics. (cp_build_unary_op): Same. (check_for_casting_away_constness): Same. (build_static_cast): Same. (build_const_cast_1): Same. (maybe_warn_about_returning_address_of_local): Same. (check_return_expr): Same. * typeck2.c (abstract_virtuals_error_sfinae): Same. (digest_init_r): Replace a tab with spaces in a diagnostic. (build_functional_cast): Quote keywords, operators, and types in diagnostics. gcc/d/ChangeLog: * d-builtins.cc (d_init_builtins): Quote keywords, operators, and types in diagnostics. * d-codegen.cc (get_array_length): Same. Replace can't with cannot. * d-convert.cc (convert_expr): Same. * d-frontend.cc (getTypeInfoType): Quote an option name in a diagnostic. * d-lang.cc (d_handle_option): Same. (d_parse_file): Same. * decl.cc: Remove a trailing period from a diagnostic. * expr.cc: Use a directive for an apostrophe. * toir.cc: Quote keywords, operators, and types in diagnostics. * typeinfo.cc (build_typeinfo): Quote an option name in a diagnostic. gcc/fortran/ChangeLog: * gfortranspec.c (append_arg): Spell out the word "argument." gcc/ChangeLog: * config/i386/i386-expand.c (get_element_number): Quote keywords and other internal names in diagnostics. Adjust other diagnostic formatting issues noted by -Wformat-diag. * config/i386/i386-features.c (ix86_mangle_function_version_assembler_name): Same. * config/i386/i386-options.c (ix86_handle_abi_attribute): Same. * config/i386/i386.c (ix86_function_type_abi): Same. (ix86_function_ms_hook_prologue): Same. (classify_argument): Same. (ix86_expand_prologue): Same. (ix86_md_asm_adjust): Same. (ix86_memmodel_check): Same. gcc/ChangeLog: * builtins.c (expand_builtin_atomic_always_lock_free): Quote identifiers, keywords, operators, and types in diagnostics. Correct quoting, spelling, and sentence capitalization issues. (expand_builtin_atomic_is_lock_free): Same. (fold_builtin_next_arg): Same. * cfgexpand.c (expand_one_var): Same. (tree_conflicts_with_clobbers_p): Same. (expand_asm_stmt): Same. (verify_loop_structure): Same. * cgraphunit.c (process_function_and_variable_attributes): Same. * collect-utils.c (collect_execute): Same. * collect2.c (maybe_run_lto_and_relink): Same. (is_lto_object_file): Same. (scan_prog_file): Same. * convert.c (convert_to_real_1): Same. * dwarf2out.c (dwarf2out_begin_prologue): Same. * except.c (verify_eh_tree): Same. * gcc.c (execute): Same. (eval_spec_function): Same. (run_attempt): Same. (driver::set_up_specs): Same. (compare_debug_auxbase_opt_spec_function): Same. * gcov-tool.c (unlink_gcda_file): Same. (do_merge): Same. (do_rewrite): Same. * gcse.c (gcse_or_cprop_is_too_expensive): Same. * gimplify.c (gimplify_asm_expr): Same. (gimplify_adjust_omp_clauses): Same. * hsa-gen.c (gen_hsa_addr_insns): Same. (gen_hsa_insns_for_load): Same. (gen_hsa_cmp_insn_from_gimple): Same. (gen_hsa_insns_for_operation_assignment): Same. (gen_get_level): Same. (gen_hsa_alloca): Same. (omp_simple_builtin::generate): Same. (gen_hsa_atomic_for_builtin): Same. (gen_hsa_insns_for_call): Same. * input.c (dump_location_info): Same. * ipa-devirt.c (compare_virtual_tables): Same. * ira.c (ira_setup_eliminable_regset): Same. * lra-assigns.c (lra_assign): Same. * lra-constraints.c (lra_constraints): Same. * lto-streamer-in.c (lto_input_mode_table): Same. * lto-wrapper.c (get_options_from_collect_gcc_options): Same. (merge_and_complain): Same. (compile_offload_image): Same. (compile_images_for_offload_targets): Same. (debug_objcopy): Same. (run_gcc): Same. (main): Same. * opts.c (print_specific_help): Same. (parse_no_sanitize_attribute): Same. (print_help): Same. (handle_param): Same. * plugin.c (add_new_plugin): Same. (parse_plugin_arg_opt): Same. (try_init_one_plugin): Same. * print-rtl.c (debug_bb_n_slim): Quote identifiers, keywords, operators, and types in diagnostics. Correct quoting and spelling issues. * read-rtl-function.c (parse_edge_flag_token): Same. (function_reader::parse_enum_value): Same. * reg-stack.c (check_asm_stack_operands): Same. * regcprop.c (validate_value_data): Same. * sched-rgn.c (make_pass_sched_fusion): Same. * stmt.c (check_unique_operand_names): Same. * targhooks.c (default_target_option_pragma_parse): Same. * tlink.c (recompile_files): Same. * toplev.c (process_options): Same. (do_compile): Same. * trans-mem.c (diagnose_tm_1): Same. (ipa_tm_scan_irr_block): Same. (ipa_tm_diagnose_transaction): Same. * tree-cfg.c (verify_address): Same. Use get_tree_code_name to format a tree code name in a diagnostic. (verify_types_in_gimple_min_lval): Same. (verify_types_in_gimple_reference): Same. (verify_gimple_call): Same. (verify_gimple_assign_unary): Same. (verify_gimple_assign_binary): Same. (verify_gimple_assign_ternary): Same. (verify_gimple_assign_single): Same. (verify_gimple_switch): Same. (verify_gimple_label): Same. (verify_gimple_phi): Same. (verify_gimple_in_seq): Same. (verify_eh_throw_stmt_node): Same. (collect_subblocks): Same. (gimple_verify_flow_info): Same. (do_warn_unused_result): Same. * tree-inline.c (expand_call_inline): Same. * tree-into-ssa.c (update_ssa): Same. * tree.c (tree_int_cst_elt_check_failed): Same. (tree_vec_elt_check_failed): Same. (omp_clause_operand_check_failed): Same. (verify_type_variant): Same. (verify_type): Same. * value-prof.c (verify_histograms): Same. * varasm.c (assemble_start_function): Same. gcc/lto/ChangeLog: * lto-dump.c (lto_main): Same. * lto.c (stream_out): Same. gcc/objc/ChangeLog: * objc-act.c (objc_begin_catch_clause): Quote keywords and options in diagnostics. (objc_build_throw_stmt): Same. (objc_finish_message_expr): Same. (get_super_receiver): Same. * objc-next-runtime-abi-01.c (objc_next_runtime_abi_01_init): Spell out "less than" in English./ * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Spell out "greater" in English. gcc/testsuite/ChangeLog: * c-c++-common/Wbool-operation-1.c: Adjust text of expected diagnostics. * c-c++-common/Wvarargs-2.c: Same. * c-c++-common/Wvarargs.c: Same. * c-c++-common/pr51768.c: Same. * c-c++-common/tm/inline-asm.c: Same. * c-c++-common/tm/safe-1.c: Same. * g++.dg/asm-qual-1.C: Same. * g++.dg/asm-qual-3.C: Same. * g++.dg/conversion/dynamic1.C: Same. * g++.dg/cpp0x/constexpr-89599.C: Same. * g++.dg/cpp0x/constexpr-cast.C: Same. * g++.dg/cpp0x/constexpr-shift1.C: Same. * g++.dg/cpp0x/lambda/lambda-conv11.C: Same. * g++.dg/cpp0x/nullptr04.C: Same. * g++.dg/cpp0x/static_assert12.C: Same. * g++.dg/cpp0x/static_assert8.C: Same. * g++.dg/cpp1y/lambda-conv1.C: Same. * g++.dg/cpp1y/pr79393-3.C: Same. * g++.dg/cpp1y/static_assert1.C: Same. * g++.dg/cpp1z/constexpr-if4.C: Same. * g++.dg/cpp1z/constexpr-if5.C: Same. * g++.dg/cpp1z/constexpr-if9.C: Same. * g++.dg/eh/goto2.C: Same. * g++.dg/eh/goto3.C: Same. * g++.dg/expr/static_cast8.C: Same. * g++.dg/ext/flexary5.C: Same. * g++.dg/ext/utf-array-short-wchar.C: Same. * g++.dg/ext/utf-array.C: Same. * g++.dg/ext/utf8-2.C: Same. * g++.dg/gomp/loop-4.C: Same. * g++.dg/gomp/macro-4.C: Same. * g++.dg/gomp/udr-1.C: Same. * g++.dg/init/initializer-string-too-long.C: Same. * g++.dg/other/offsetof9.C: Same. * g++.dg/ubsan/pr63956.C: Same. * g++.dg/warn/Wbool-operation-1.C: Same. * g++.dg/warn/Wtype-limits-Wextra.C: Same. * g++.dg/warn/Wtype-limits.C: Same. * g++.dg/wrappers/pr88680.C: Same. * g++.old-deja/g++.mike/eh55.C: Same. * gcc.dg/Wsign-compare-1.c: Same. * gcc.dg/Wtype-limits-Wextra.c: Same. * gcc.dg/Wtype-limits.c: Same. * gcc.dg/Wunknownprag.c: Same. * gcc.dg/Wunsuffixed-float-constants-1.c: Same. * gcc.dg/asm-6.c: Same. * gcc.dg/asm-qual-1.c: Same. * gcc.dg/cast-1.c: Same. * gcc.dg/cast-2.c: Same. * gcc.dg/cast-3.c: Same. * gcc.dg/cpp/source_date_epoch-2.c: Same. * gcc.dg/debug/pr85252.c: Same. * gcc.dg/dfp/cast-bad.c: Same. * gcc.dg/format/gcc_diag-1.c: Same. * gcc.dg/format/gcc_diag-11.c: Same.New test. * gcc.dg/gcc_diag-11.c: Same.New test. * gcc.dg/gnu-cond-expr-2.c: Same. * gcc.dg/gnu-cond-expr-3.c: Same. * gcc.dg/gomp/macro-4.c: Same. * gcc.dg/init-bad-1.c: Same. * gcc.dg/init-bad-2.c: Same. * gcc.dg/init-bad-3.c: Same. * gcc.dg/pr27528.c: Same. * gcc.dg/pr48552-1.c: Same. * gcc.dg/pr48552-2.c: Same. * gcc.dg/pr59846.c: Same. * gcc.dg/pr61096-1.c: Same. * gcc.dg/pr8788-1.c: Same. * gcc.dg/pr90082.c: Same. * gcc.dg/simd-2.c: Same. * gcc.dg/spellcheck-params-2.c: Same. * gcc.dg/spellcheck-params.c: Same. * gcc.dg/strlenopt-49.c: Same. * gcc.dg/tm/pr52141.c: Same. * gcc.dg/torture/pr51106-1.c: Same. * gcc.dg/torture/pr51106-2.c: Same. * gcc.dg/utf-array-short-wchar.c: Same. * gcc.dg/utf-array.c: Same. * gcc.dg/utf8-2.c: Same. * gcc.dg/warn-sprintf-no-nul.c: Same. * gcc.target/i386/asm-flag-0.c: Same. * gcc.target/i386/inline_error.c: Same. * gcc.target/i386/pr30848.c: Same. * gcc.target/i386/pr39082-1.c: Same. * gcc.target/i386/pr39678.c: Same. * gcc.target/i386/pr57756.c: Same. * gcc.target/i386/pr68843-1.c: Same. * gcc.target/i386/pr79804.c: Same. * gcc.target/i386/pr82673.c: Same. * obj-c++.dg/class-protocol-1.mm: Same. * obj-c++.dg/exceptions-3.mm: Same. * obj-c++.dg/exceptions-4.mm: Same. * obj-c++.dg/exceptions-5.mm: Same. * obj-c++.dg/exceptions-6.mm: Same. * obj-c++.dg/method-12.mm: Same. * obj-c++.dg/method-13.mm: Same. * obj-c++.dg/method-6.mm: Same. * obj-c++.dg/method-7.mm: Same. * obj-c++.dg/method-9.mm: Same. * obj-c++.dg/method-lookup-1.mm: Same. * obj-c++.dg/proto-lossage-4.mm: Same. * obj-c++.dg/protocol-qualifier-2.mm: Same. * objc.dg/call-super-2.m: Same. * objc.dg/class-protocol-1.m: Same. * objc.dg/desig-init-1.m: Same. * objc.dg/exceptions-3.m: Same. * objc.dg/exceptions-4.m: Same. * objc.dg/exceptions-5.m: Same. * objc.dg/exceptions-6.m: Same. * objc.dg/method-19.m: Same. * objc.dg/method-2.m: Same. * objc.dg/method-5.m: Same. * objc.dg/method-6.m: Same. * objc.dg/method-7.m: Same. * objc.dg/method-lookup-1.m: Same. * objc.dg/proto-hier-1.m: Same. * objc.dg/proto-lossage-4.m: Same. From-SVN: r271338
2019-05-13Use releasing_vec more broadly.Jason Merrill1-4/+2
* cp-tree.h (struct releasing_vec): Replace get_ref method with operator&. (vec_safe_push, vec_safe_reserve, vec_safe_length, vec_safe_splice): Forwarding functions for releasing_vec. (release_tree_vector): Declare but don't define. * call.c (build_op_delete_call, build_temp, call_copy_ctor) (perform_direct_initialization_if_possible): Use releasing_vec. * constexpr.c (cxx_eval_vec_init_1, cxx_eval_store_expression): Likewise. * cp-gimplify.c (cp_fold): Likewise. * cvt.c (force_rvalue, ocp_convert): Likewise. * decl.c (get_tuple_decomp_init): Likewise. * except.c (build_throw): Likewise. * init.c (perform_member_init, expand_default_init): Likewise. * method.c (do_build_copy_assign, locate_fn_flags): Likewise. * parser.c (cp_parser_userdef_char_literal) (cp_parser_userdef_numeric_literal) (cp_parser_userdef_string_literal) (cp_parser_perform_range_for_lookup) (cp_parser_range_for_member_function, cp_parser_omp_for_loop) (cp_parser_omp_for_loop_init): Likewise. * pt.c (tsubst_copy_and_build, do_class_deduction): Likewise. * semantics.c (calculate_direct_bases, calculate_bases) (finish_omp_barrier, finish_omp_flush, finish_omp_taskwait) (finish_omp_taskyield, finish_omp_cancel) (finish_omp_cancellation_point): Likewise. * tree.c (build_vec_init_elt, strip_typedefs, strip_typedefs_expr) (build_min_non_dep_op_overload): Likewise. * typeck.c (build_function_call_vec, cp_build_function_call_nary) (cp_build_modify_expr): Likewise. * typeck2.c (build_functional_cast): Likewise. From-SVN: r271138
2019-05-10call.c (build_call_a): Use FUNC_OR_METHOD_TYPE_P.Paolo Carlini1-2/+1
2019-05-10 Paolo Carlini <paolo.carlini@oracle.com> * call.c (build_call_a): Use FUNC_OR_METHOD_TYPE_P. * cp-gimplify.c (cp_fold): Likewise. * cp-objcp-common.c (cp_type_dwarf_attribute): Likewise. * cp-tree.h (TYPE_OBJ_P, TYPE_PTROBV_P): Likewise. * cvt.c (perform_qualification_conversions): Likewise. * decl.c (grokdeclarator): Likewise. * decl2.c (build_memfn_type): Likewise. * mangle.c (canonicalize_for_substitution, write_type): Likewise. * parser.c (cp_parser_omp_declare_reduction): Likewise. * pt.c (check_explicit_specialization, uses_deducible_template_parms, check_cv_quals_for_unify, dependent_type_p_r): Likewise. * rtti.c (ptr_initializer): Likewise. * semantics.c (finish_asm_stmt, finish_offsetof, cp_check_omp_declare_reduction): Likewise. * tree.c (cp_build_qualified_type_real, cp_build_type_attribute_variant, cxx_type_hash_eq, cxx_copy_lang_qualifiers, cp_free_lang_data): Likewise. * typeck.c (structural_comptypes, convert_arguments, cp_build_addr_expr_1, unary_complex_lvalue, cp_build_c_cast, cp_build_modify_expr, comp_ptr_ttypes_real, type_memfn_rqual): Likewise. From-SVN: r271069
2019-03-11Wrap apostrophes in gcc internal format with %'.Martin Liska1-1/+1
2019-03-11 Martin Liska <mliska@suse.cz> * check-internal-format-escaping.py: Uncomment apostrophes check. 2019-03-11 Martin Liska <mliska@suse.cz> * collect-utils.c (collect_wait): Wrap apostrophes in gcc internal format with %'. * collect2.c (main): Likewise. (scan_prog_file): Likewise. (scan_libraries): Likewise. * config/i386/i386.c (ix86_expand_call): Likewise. (ix86_handle_interrupt_attribute): Likewise. * config/nds32/nds32-intrinsic.c (nds32_expand_builtin_impl): Likewise. * config/nds32/nds32.c (nds32_insert_attributes): Likewise. * config/rl78/rl78.c (rl78_handle_saddr_attribute): Likewise. * lto-wrapper.c (find_crtoffloadtable): Likewise. * symtab.c (symtab_node::verify_base): Likewise. * tree-cfg.c (verify_gimple_label): Likewise. * tree.c (verify_type_variant): Likewise. 2019-03-11 Martin Liska <mliska@suse.cz> * c-opts.c (c_common_post_options): Wrap apostrophes in gcc internal format with %'. 2019-03-11 Martin Liska <mliska@suse.cz> * cvt.c (build_expr_type_conversion): Wrap apostrophes in gcc internal format with %'. * decl.c (check_no_redeclaration_friend_default_args): Likewise. (grokfndecl): Likewise. * name-lookup.c (do_pushtag): Likewise. * pt.c (unify_parameter_deduction_failure): Likewise. (unify_template_deduction_failure): Likewise. From-SVN: r269587
2019-03-11Wrap option names in gcc internal messages with %< and %>.Martin Liska1-1/+1
2019-03-11 Martin Liska <mliska@suse.cz> * check-internal-format-escaping.py: New file. 2019-03-11 Martin Liska <mliska@suse.cz> * builtins.c (expand_builtin_thread_pointer): Wrap an option name in a string format message and fix GNU coding style. (expand_builtin_set_thread_pointer): Likewise. * common/config/aarch64/aarch64-common.c (aarch64_rewrite_selected_cpu): Likewise. * common/config/alpha/alpha-common.c (alpha_handle_option): Likewise. * common/config/arc/arc-common.c (arc_handle_option): Likewise. * common/config/arm/arm-common.c (arm_parse_fpu_option): Likewise. * common/config/bfin/bfin-common.c (bfin_handle_option): Likewise. * common/config/i386/i386-common.c (ix86_handle_option): Likewise. * common/config/ia64/ia64-common.c (ia64_handle_option): Likewise. * common/config/m68k/m68k-common.c (m68k_handle_option): Likewise. * common/config/msp430/msp430-common.c (msp430_handle_option): Likewise. * common/config/nds32/nds32-common.c (nds32_handle_option): Likewise. * common/config/powerpcspe/powerpcspe-common.c (rs6000_handle_option): Likewise. * common/config/riscv/riscv-common.c (riscv_subset_list::parsing_subset_version): Likewise. (riscv_subset_list::parse_std_ext): Likewise. (riscv_subset_list::parse_sv_or_non_std_ext): Likewise. (riscv_subset_list::parse): Likewise. * common/config/rs6000/rs6000-common.c (rs6000_handle_option): Likewise. * config/aarch64/aarch64.c (aarch64_parse_one_option_token): Likewise. (aarch64_override_options_internal): Likewise. (aarch64_validate_mcpu): Likewise. (aarch64_validate_march): Likewise. (aarch64_validate_mtune): Likewise. (aarch64_override_options): Likewise. * config/alpha/alpha.c (alpha_option_override): Likewise. * config/arc/arc.c (arc_init): Likewise. (parse_mrgf_banked_regs_option): Likewise. (arc_override_options): Likewise. (arc_expand_builtin_aligned): Likewise. * config/arm/arm-builtins.c (arm_expand_neon_builtin): Likewise. (arm_expand_builtin): Likewise. * config/arm/arm.c (arm_option_check_internal): Likewise. (arm_configure_build_target): Likewise. (arm_option_override): Likewise. (arm_options_perform_arch_sanity_checks): Likewise. (arm_handle_cmse_nonsecure_entry): Likewise. (arm_handle_cmse_nonsecure_call): Likewise. (arm_tls_referenced_p): Likewise. (thumb1_expand_prologue): Likewise. * config/avr/avr.c (avr_option_override): Likewise. * config/bfin/bfin.c (bfin_option_override): Likewise. * config/c6x/c6x.c (c6x_option_override): Likewise. * config/cr16/cr16.c (cr16_override_options): Likewise. * config/cris/cris.c (cris_option_override): Likewise. * config/csky/csky.c (csky_handle_isr_attribute): Likewise. * config/darwin-c.c (macosx_version_as_macro): Likewise. * config/darwin.c (darwin_override_options): Likewise. * config/frv/frv.c (frv_expand_builtin): Likewise. * config/h8300/h8300.c (h8300_option_override): Likewise. * config/i386/i386.c (parse_mtune_ctrl_str): Likewise. (ix86_option_override_internal): Likewise. (warn_once_call_ms2sysv_xlogues): Likewise. (ix86_expand_prologue): Likewise. (split_stack_prologue_scratch_regno): Likewise. (ix86_warn_parameter_passing_abi): Likewise. * config/ia64/ia64.c (fix_range): Likewise. * config/m68k/m68k.c (m68k_option_override): Likewise. * config/microblaze/microblaze.c (microblaze_option_override): Likewise. * config/mips/mips.c (mips_emit_probe_stack_range): Likewise. (mips_set_compression_mode): Likewise. * config/mmix/mmix.c (mmix_option_override): Likewise. * config/mn10300/mn10300.c (mn10300_option_override): Likewise. * config/msp430/msp430.c (msp430_option_override): Likewise. * config/nds32/nds32.c (nds32_option_override): Likewise. * config/nios2/nios2.c (nios2_custom_check_insns): Likewise. (nios2_option_override): Likewise. (nios2_expand_custom_builtin): Likewise. * config/nvptx/mkoffload.c (main): Likewise. * config/nvptx/nvptx.c (diagnose_openacc_conflict): Likewise. * config/pa/pa.c (fix_range): Likewise. (pa_option_override): Likewise. * config/riscv/riscv.c (riscv_parse_cpu): Likewise. (riscv_option_override): Likewise. * config/rl78/rl78.c (rl78_option_override): Likewise. * config/rs6000/aix61.h: Likewise. * config/rs6000/aix71.h: Likewise. * config/rs6000/aix72.h: Likewise. * config/rs6000/driver-rs6000.c (elf_platform): Likewise. * config/rs6000/freebsd64.h: Likewise. * config/rs6000/linux64.h: Likewise. * config/rs6000/rs6000.c (rs6000_option_override_internal): Likewise. (rs6000_expand_zeroop_builtin): Likewise. (rs6000_expand_mtfsb_builtin): Likewise. (rs6000_expand_set_fpscr_rn_builtin): Likewise. (rs6000_expand_set_fpscr_drn_builtin): Likewise. (rs6000_invalid_builtin): Likewise. (rs6000_expand_split_stack_prologue): Likewise. * config/rs6000/rtems.h: Likewise. * config/rx/rx.c (valid_psw_flag): Likewise. (rx_expand_builtin): Likewise. * config/s390/s390-c.c (s390_resolve_overloaded_builtin): Likewise. * config/s390/s390.c (s390_expand_builtin): Likewise. (s390_function_profiler): Likewise. (s390_option_override_internal): Likewise. (s390_option_override): Likewise. * config/sh/sh.c (sh_option_override): Likewise. (sh_builtin_saveregs): Likewise. (sh_fix_range): Likewise. * config/sh/vxworks.h: Likewise. * config/sparc/sparc.c (sparc_option_override): Likewise. * config/spu/spu.c (spu_option_override): Likewise. (fix_range): Likewise. * config/visium/visium.c (visium_option_override): Likewise. (visium_handle_interrupt_attr): Likewise. * config/xtensa/xtensa.c (xtensa_option_override): Likewise. * dbgcnt.c (dbg_cnt_set_limit_by_name): Likewise. (dbg_cnt_process_opt): Likewise. * dwarf2out.c (output_dwarf_version): Likewise. * except.c (expand_eh_return): Likewise. * gcc.c (defined): Likewise. (driver_handle_option): Likewise. (process_command): Likewise. (compare_files): Likewise. (driver::prepare_infiles): Likewise. (driver::do_spec_on_infiles): Likewise. (driver::maybe_run_linker): Likewise. * omp-offload.c (oacc_parse_default_dims): Likewise. * opts-global.c (handle_common_deferred_options): Likewise. * opts.c (parse_sanitizer_options): Likewise. (common_handle_option): Likewise. (enable_warning_as_error): Likewise. * passes.c (enable_disable_pass): Likewise. * plugin.c (parse_plugin_arg_opt): Likewise. (default_plugin_dir_name): Likewise. * targhooks.c (default_expand_builtin_saveregs): Likewise. (default_pch_valid_p): Likewise. * toplev.c (init_asm_output): Likewise. (process_options): Likewise. (toplev::run_self_tests): Likewise. * tree-cfg.c (verify_gimple_call): Likewise. * tree-inline.c (inline_forbidden_p_stmt): Likewise. (tree_inlinable_function_p): Likewise. * var-tracking.c (vt_find_locations): Likewise. 2019-03-11 Martin Liska <mliska@suse.cz> * gcc-interface/misc.c (gnat_post_options) Wrap an option name in a string format message and fix GNU coding style.: 2019-03-11 Martin Liska <mliska@suse.cz> * c-attribs.c (handle_nocf_check_attribute): Wrap an option name in a string format message and fix GNU coding style. * c-common.c (vector_types_convertible_p): Likewise. (c_build_vec_perm_expr): Likewise. * c-indentation.c (get_visual_column): Likewise. * c-opts.c (c_common_handle_option): Likewise. (c_common_post_options): Likewise. (sanitize_cpp_opts): Likewise. * c-pch.c (c_common_pch_pragma): Likewise. * c-pragma.c (handle_pragma_pack): Likewise. 2019-03-11 Martin Liska <mliska@suse.cz> * c-decl.c (check_for_loop_decls): Wrap an option name in a string format message and fix GNU coding style. * c-parser.c (c_parser_declspecs): Likewise. 2019-03-11 Martin Liska <mliska@suse.cz> * call.c (convert_arg_to_ellipsis): Wrap an option name in a string format message and fix GNU coding style. (build_over_call): Likewise. * class.c (check_field_decl): Likewise. (layout_nonempty_base_or_field): Likewise. * constexpr.c (cxx_eval_loop_expr): Likewise. * cvt.c (type_promotes_to): Likewise. * decl.c (cxx_init_decl_processing): Likewise. (mark_inline_variable): Likewise. (grokdeclarator): Likewise. * decl2.c (record_mangling): Likewise. * error.c (maybe_warn_cpp0x): Likewise. * except.c (doing_eh): Likewise. * mangle.c (maybe_check_abi_tags): Likewise. * parser.c (cp_parser_diagnose_invalid_type_name): Likewise. (cp_parser_userdef_numeric_literal): Likewise. (cp_parser_primary_expression): Likewise. (cp_parser_unqualified_id): Likewise. (cp_parser_pseudo_destructor_name): Likewise. (cp_parser_builtin_offsetof): Likewise. (cp_parser_lambda_expression): Likewise. (cp_parser_lambda_introducer): Likewise. (cp_parser_lambda_declarator_opt): Likewise. (cp_parser_selection_statement): Likewise. (cp_parser_init_statement): Likewise. (cp_parser_decomposition_declaration): Likewise. (cp_parser_function_specifier_opt): Likewise. (cp_parser_static_assert): Likewise. (cp_parser_simple_type_specifier): Likewise. (cp_parser_namespace_definition): Likewise. (cp_parser_using_declaration): Likewise. (cp_parser_ctor_initializer_opt_and_function_body): Likewise. (cp_parser_initializer_list): Likewise. (cp_parser_type_parameter_key): Likewise. (cp_parser_member_declaration): Likewise. (cp_parser_try_block): Likewise. (cp_parser_std_attribute_spec): Likewise. (cp_parser_requires_clause_opt): Likewise. * pt.c (check_template_variable): Likewise. (check_default_tmpl_args): Likewise. (push_tinst_level_loc): Likewise. (instantiate_pending_templates): Likewise. (invalid_nontype_parm_type_p): Likewise. * repo.c (get_base_filename): Likewise. * rtti.c (typeid_ok_p): Likewise. (build_dynamic_cast_1): Likewise. * tree.c (maybe_warn_parm_abi): Likewise. 2019-03-11 Martin Liska <mliska@suse.cz> * decl.c (match_record_decl): Wrap an option name in a string format message and fix GNU coding style. (gfc_match_pointer): Likewise. * expr.c (find_array_section): Likewise. * intrinsic.c (gfc_is_intrinsic): Likewise. * options.c (gfc_post_options): Likewise. * primary.c (match_integer_constant): Likewise. * trans-common.c (translate_common): Likewise. 2019-03-11 Martin Liska <mliska@suse.cz> * lto-lang.c (lto_post_options): Wrap an option name in a string format message and fix GNU coding style. * lto-symtab.c (lto_symtab_merge_decls_2): Likewise. 2019-03-11 Martin Liska <mliska@suse.cz> * g++.dg/conversion/simd3.C (foo): Wrap option names with apostrophe character. * g++.dg/cpp1z/decomp3.C (test): Likewise. (test3): Likewise. * g++.dg/cpp1z/decomp4.C (test): Likewise. * g++.dg/cpp1z/decomp44.C (foo): Likewise. * g++.dg/cpp1z/decomp45.C (f): Likewise. * g++.dg/opt/pr34036.C: Likewise. * g++.dg/spellcheck-c++-11-keyword.C: Likewise. * gcc.dg/c90-fordecl-1.c (foo): Likewise. * gcc.dg/cpp/dir-only-4.c: Likewise. * gcc.dg/cpp/dir-only-5.c: Likewise. * gcc.dg/cpp/pr71591.c: Likewise. * gcc.dg/format/opt-1.c: Likewise. * gcc.dg/format/opt-2.c: Likewise. * gcc.dg/format/opt-3.c: Likewise. * gcc.dg/format/opt-4.c: Likewise. * gcc.dg/format/opt-5.c: Likewise. * gcc.dg/format/opt-6.c: Likewise. * gcc.dg/pr22231.c: Likewise. * gcc.dg/pr33007.c: Likewise. * gcc.dg/simd-1.c (hanneke): Likewise. * gcc.dg/simd-5.c: Likewise. * gcc.dg/simd-6.c: Likewise. * gcc.dg/spellcheck-options-14.c: Likewise. * gcc.dg/spellcheck-options-15.c: Likewise. * gcc.dg/spellcheck-options-16.c: Likewise. * gcc.dg/spellcheck-options-17.c: Likewise. * gcc.dg/tree-ssa/pr23109.c: Likewise. * gcc.dg/tree-ssa/recip-5.c: Likewise. * gcc.target/i386/cet-notrack-1a.c (func): Likewise. (__attribute__): Likewise. * gcc.target/i386/cet-notrack-icf-1.c (fn3): Likewise. * gcc.target/i386/cet-notrack-icf-3.c (__attribute__): Likewise. * gcc.target/powerpc/warn-1.c: Likewise. * gcc.target/powerpc/warn-2.c: Likewise. From-SVN: r269586
2019-01-17[PR88146] avoid diagnostics diffs if cdtor_returns_thisAlexandre Oliva1-0/+10
Diagnostics for testsuite/g++.dg/cpp0x/inh-ctor32.C varied across platforms. Specifically, on ARM, the diagnostics within the subtest derived_ctor::inherited_derived_ctor::constexpr_noninherited_ctor did not match those displayed on other platforms, and the test failed. The difference seemed to have to do with locations assigned to ctors, but it was more subtle: on ARM, the instantiation of bor's template ctor was nested within the instantiation of bar's template ctor inherited from bor. The reason turned out to be related with the internal return type of ctors: arm_cxx_cdtor_returns_this is enabled for because of AAPCS, while cxx.cdtor_returns_this is disabled on most other platforms. While convert_to_void returns early with a VOID expr, the non-VOID return type of the base ctor CALL_EXPR causes convert_to_void to inspect the called decl for nodiscard attributes: maybe_warn_nodiscard -> cp_get_fndecl_from_callee -> maybe_constant_init -> cxx_eval_outermost_constant_expr -> instantiate_constexpr_fns -> nested instantiation. The internal return type assigned to a cdtor should not affect instantiation (constexpr or template) decisions, IMHO. We know it affects diagnostics, but I have a hunch this might bring deeper issues with it, so I've arranged for the CALL_EXPR handler in convert_to_void to disregard cdtors, regardless of the ABI. for gcc/cp/ChangeLog PR c++/88146 * cvt.c (convert_to_void): Handle all cdtor calls as if returning void. From-SVN: r268004
2019-01-14Implement P0482R5, char8_t: A type for UTF-8 characters and stringsTom Honermann1-0/+1
gcc/cp/ * cvt.c (type_promotes_to): Handle char8_t promotion. * decl.c (grokdeclarator): Handle invalid type specifier combinations involving char8_t. * lex.c (init_reswords): Add char8_t as a reserved word. * mangle.c (write_builtin_type): Add name mangling for char8_t (Du). * parser.c (cp_keyword_starts_decl_specifier_p) (cp_parser_simple_type_specifier): Recognize char8_t as a simple type specifier. (cp_parser_string_literal): Use char8_array_type_node for the type of CPP_UTF8STRING. (cp_parser_set_decl_spec_type): Tolerate char8_t typedefs in system headers. * rtti.c (emit_support_tinfos): type_info support for char8_t. * tree.c (char_type_p): Recognize char8_t as a character type. * typeck.c (string_conv_p): Handle conversions of u8 string literals of char8_t type. (check_literal_operator_args): Handle UDLs with u8 string literals of char8_t type. * typeck2.c (ordinary_char_type_p): New. (digest_init_r): Disallow initializing a char array with a u8 string literal. gcc/c-family/ * c-common.c (c_common_reswords): Add char8_t. (fix_string_type): Use char8_t for the type of u8 string literals. (c_common_get_alias_set): char8_t doesn't alias. (c_common_nodes_and_builtins): Define char8_t as a builtin type in C++. (c_stddef_cpp_builtins): Add __CHAR8_TYPE__. (keyword_begins_type_specifier): Add RID_CHAR8. * c-common.h (rid): Add RID_CHAR8. (c_tree_index): Add CTI_CHAR8_TYPE and CTI_CHAR8_ARRAY_TYPE. Define D_CXX_CHAR8_T and D_CXX_CHAR8_T_FLAGS. Define char8_type_node and char8_array_type_node. * c-cppbuiltin.c (cpp_atomic_builtins): Predefine __GCC_ATOMIC_CHAR8_T_LOCK_FREE. (c_cpp_builtins): Predefine __cpp_char8_t. * c-lex.c (lex_string): Use char8_array_type_node as the type of CPP_UTF8STRING. (lex_charconst): Use char8_type_node as the type of CPP_UTF8CHAR. * c-opts.c: If not otherwise specified, enable -fchar8_t when targeting C++2a. * c.opt: Add the -fchar8_t command line option. libiberty/ * cp-demangle.c (cplus_demangle_builtin_types) (cplus_demangle_type): Add name demangling for char8_t (Du). * cp-demangle.h: Increase D_BUILTIN_TYPE_COUNT to accommodate the new char8_t type. From-SVN: r267923
2019-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r267494
2018-12-19C++: more location wrapper nodes (PR c++/43064, PR c++/43486)David Malcolm1-8/+14
This is v6 of the patch, as posted to: https://gcc.gnu.org/ml/gcc-patches/2018-12/msg01331.html The C++ frontend gained various location wrapper nodes in r256448 (GCC 8). That patch: https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00799.html added wrapper nodes around all nodes with !CAN_HAVE_LOCATION_P for: * arguments at callsites, and for * typeid, alignof, sizeof, and offsetof. This is a followup to that patch, adding many more location wrappers to the C++ frontend. It adds location wrappers for nodes with !CAN_HAVE_LOCATION_P to: * all literal nodes (in cp_parser_primary_expression) * all id-expression nodes (in finish_id_expression), except within a decltype. * all mem-initializer nodes within a mem-initializer-list (in cp_parser_mem_initializer) However, the patch also adds some suppressions: regions in the parser for which wrapper nodes will not be created: * within a template-parameter-list or template-argument-list (in cp_parser_template_parameter_list and cp_parser_template_argument_list respectively), to avoid encoding the spelling location of the nodes in types. For example, "array<10>" and "array<10>" are the same type, despite the fact that the two different "10" tokens are spelled in different locations in the source. * within a gnu-style attribute (none of are handlers are set up to cope with location wrappers yet) * within various OpenMP clauses The patch enables various improvements to locations for bad initializations, for -Wchar-subscripts, and enables various other improvements in the followup patch. For example, given the followup buggy mem-initializer: class X { X() : bad(42), good(42) { } void* bad; int good; }; previously, our diagnostic was on the final close parenthesis of the mem-initializer-list, leaving it unclear where the problem is: t.cc: In constructor 'X::X()': t.cc:3:16: error: invalid conversion from 'int' to 'void*' [-fpermissive] 3 | good(42) | ^ | | | int whereas with the patch we highlight which expression is bogus: t.cc: In constructor 'X::X()': t.cc:2:13: error: invalid conversion from 'int' to 'void*' [-fpermissive] 2 | X() : bad(42), | ^~ | | | int Similarly, the diagnostic for this bogus initialization: i.cc:1:44: error: initializer-string for array of chars is too long [-fpermissive] 1 | char test[3][4] = { "ok", "too long", "ok" }; | ^ is improved by the patch so that it indicates which string is too long: i.cc:1:27: error: initializer-string for array of chars is too long [-fpermissive] 1 | char test[3][4] = { "ok", "too long", "ok" }; | ^~~~~~~~~~ gcc/c-family/ChangeLog: PR c++/43064 PR c++/43486 * c-common.c (unsafe_conversion_p): Fold any location wrapper. (verify_tree): Handle location wrappers. (c_common_truthvalue_conversion): Strip any location wrapper. Handle CONST_DECL. (fold_offsetof): Strip any location wrapper. (complete_array_type): Likewise for initial_value. (convert_vector_to_array_for_subscript): Call fold_for_warn on the index before checking for INTEGER_CST. * c-pretty-print.c (c_pretty_printer::primary_expression): Don't print parentheses around location wrappers. * c-warn.c (warn_logical_operator): Call fold_for_warn on op_right before checking for INTEGER_CST. (warn_tautological_bitwise_comparison): Call tree_strip_any_location_wrapper on lhs, rhs, and bitop's operand before checking for INTEGER_CST. (readonly_error): Strip any location wrapper. (warn_array_subscript_with_type_char): Strip location wrappers before checking for INTEGER_CST. Use the location of the index if available. gcc/ChangeLog: PR c++/43064 PR c++/43486 * convert.c: Include "selftest.h". (preserve_any_location_wrapper): New function. (convert_to_pointer_maybe_fold): Update to handle location wrappers. (convert_to_real_maybe_fold): Likewise. (convert_to_integer_1): Strip expr when using TREE_OVERFLOW. Handle location wrappers when checking for INTEGER_CST. (convert_to_integer_maybe_fold): Update to handle location wrappers. (convert_to_complex_maybe_fold): Likewise. (selftest::test_convert_to_integer_maybe_fold): New functions. (selftest::convert_c_tests): New function. * convert.h (preserve_any_location_wrapper): New decl. * fold-const.c (size_binop_loc): Strip location wrappers when using TREE_OVERFLOW. (operand_equal_p): Strip any location wrappers. (integer_valued_real_p): Strip any location wrapper. * selftest-run-tests.c (selftest::run_tests): Call selftest::convert_c_tests. * selftest.h (selftest::convert_c_tests): New decl. * tree.c (build_complex): Assert that REAL and IMAG are constants. (integer_zerop): Look through location wrappers. (integer_onep): Likewise. (integer_each_onep): Likewise. (integer_all_onesp): Likewise. (integer_minus_onep): Likewise. (integer_pow2p): Likewise. (integer_nonzerop): Likewise. (integer_truep): Likewise. (fixed_zerop): Likewise. (real_zerop): Likewise. (real_onep): Likewise. (real_minus_onep): Likewise. (tree_int_cst_equal): Likewise. (simple_cst_equal): Treat location wrappers with non-equal source locations as being unequal. (uniform_integer_cst_p): Look through location wrappers. (maybe_wrap_with_location): Don't create wrappers if any auto_suppress_location_wrappers are active. (suppress_location_wrappers): New variable. (selftest::test_predicates): New test. (selftest::tree_c_tests): Call it. * tree.h (CONSTANT_CLASS_OR_WRAPPER_P): New macro. (suppress_location_wrappers): New decl. (class auto_suppress_location_wrappers): New class. gcc/cp/ChangeLog: PR c++/43064 PR c++/43486 * call.c (build_conditional_expr_1): Strip location wrappers when checking for CONST_DECL. (conversion_null_warnings): Use location of "expr" if available. * class.c (fixed_type_or_null): Handle location wrappers. * constexpr.c (potential_constant_expression_1): Likewise. * cvt.c (ignore_overflows): Strip location wrappers when checking for INTEGER_CST, and re-wrap the result if present. (ocp_convert): Call fold_for_warn before checking for INTEGER_CST. * decl.c (reshape_init_r): Strip any location wrapper. (undeduced_auto_decl): Likewise. * expr.c (mark_discarded_use): Likewise for expr. * init.c (build_aggr_init): Likewise before checking init for DECL_P. (warn_placement_new_too_small): Call fold_for_warn on adj before checking for CONSTANT_CLASS_P, and on nelts. Strip any location wrapper from op0 and on oper before checking for VAR_P. * parser.c (cp_parser_primary_expression): Call maybe_add_location_wrapper on numeric and string literals. (cp_parser_postfix_expression): Strip any location wrapper when checking for DECL_IS_BUILTIN_CONSTANT_P. (cp_parser_unary_expression): Ensure that folding of NEGATE_EXPR around a constant happens in the presence of location wrappers and returns a wrapped result. (cp_parser_has_attribute_expression): Strip any location wrapper from "oper". (cp_parser_binary_expression): Strip any location wrapper when checking for DECL_P on the lhs. (cp_parser_decltype): Strip any location wrapper from result of cp_parser_decltype_expr. (cp_parser_mem_initializer): Add location wrappers to the parenthesized expression list. (cp_parser_template_parameter_list): Don't create wrapper nodes within a template-parameter-list. (cp_parser_template_argument_list): Don't create wrapper nodes within a template-argument-list. (cp_parser_parameter_declaration): Strip location wrappers from default arguments. (cp_parser_gnu_attribute_list): Don't create wrapper nodes. (cp_parser_std_attribute_spec_seq): Likewise. (cp_parser_omp_all_clauses): Don't create wrapper nodes within OpenMP clauses. (cp_parser_omp_for_loop): Likewise. (cp_parser_omp_declare_reduction_exprs): Likewise. * pt.c (convert_nontype_argument_function): Strip location wrappers from fn_no_ptr before checking for FUNCTION_DECL. (tsubst_default_argument): Move note about which callsite led to instantiation to after the check_default_argument call. (do_auto_deduction): Likewise from init before checking for DECL_P. * semantics.c (force_paren_expr): Likewise from expr before checking for DECL_P. (finish_parenthesized_expr): Likewise from expr before checking for STRING_CST. (perform_koenig_lookup): Likewise from fn. (finish_call_expr): Likewise. (finish_id_expression): Rename to... (finish_id_expression_1): ...this, calling maybe_add_location_wrapper on the result. (capture_decltype): Use lookup_name_real rather than value_member when looking up decl within the capture-list. * tree.c (cp_stabilize_reference): Strip any location wrapper. (builtin_valid_in_constant_expr_p): Likewise. (strip_typedefs_expr): Strip any location wrapper before checking for decls or constants. (is_overloaded_fn): Likewise. (maybe_get_fns): Likewise. (selftest::test_lvalue_kind): Verify lvalue_p. * typeck.c (cxx_sizeof_expr): Strip any location wrapper. (cxx_alignof_expr): Likewise. (is_bitfield_expr_with_lowered_type): Handle location wrappers. (cp_build_array_ref): Call maybe_constant_value on "idx". (cp_build_binary_op): Strip location wrapper from first_arg before checking for PARM_DECL. Likewise for op1 before checking for INTEGER_CST in two places. Likewise for orig_op0 and orig_op1 when checking for STRING_CST. (cp_build_addr_expr_1): Likewise for arg when checking for FUNCTION_DECL. (cp_build_modify_expr): Likewise for newrhs when checking for STRING_CST. (convert_for_assignment): Don't strip location wrappers when stripping NON_LVALUE_EXPR. (maybe_warn_about_returning_address_of_local): Strip location wrapper from whats_returned before checking for DECL_P. (can_do_nrvo_p): Strip location wrapper from retval. (treat_lvalue_as_rvalue_p): Likewise. (check_return_expr): Likewise. * typeck2.c (cxx_incomplete_type_diagnostic): Strip location wrapper from value before checking for VAR_P or PARM_DECL. (digest_init_r): Strip location wrapper from init. When copying "init", also copy the wrapped node. gcc/objc/ChangeLog: PR c++/43064 PR c++/43486 * objc-act.c (objc_maybe_build_component_ref): Strip any location wrapper before checking for UOBJC_SUPER_decl and self_decl. (objc_finish_message_expr): Strip any location wrapper. (gen_declaration): Strip location wrappers from "w". gcc/testsuite/ChangeLog: PR c++/43064 PR c++/43486 * c-c++-common/pr51712.c (valid2): Mark xfail as passing on C++. * g++.dg/cpp0x/constexpr-47969.C: Update column of expected error. * g++.dg/cpp0x/constexpr-ex2.C: Likewise. * g++.dg/cpp0x/scoped_enum2.C: Likewise. * g++.dg/cpp1z/decomp48.C: Update expected location of warning for named local variables to use that of the local variable. * g++.dg/ext/vla1.C: Update column. * g++.dg/init/array43.C: Update expected column to be that of the initializer. * g++.dg/init/initializer-string-too-long.C: New test. * g++.dg/init/new44.C: Add "-ftrack-macro-expansion=0". * g++.dg/init/pr43064-1.C: New test. * g++.dg/init/pr43064-2.C: New test. * g++.dg/init/pr43064-3.C: New test. * g++.dg/other/fold1.C: Update column of expected error. * g++.dg/parse/crash36.C: Likewise. * g++.dg/plugin/diagnostic-test-expressions-1.C: Add negative integer and float expressions. * g++.dg/template/defarg6.C: Move expected error to the default argument; add expected message about where instantiated. * g++.dg/wrappers/Wparentheses.C: New test. * g++.old-deja/g++.bugs/900402_02.C: Update column of expected error. From-SVN: r267272
2018-11-13Eliminate source_location in favor of location_tDavid Malcolm1-1/+1
Historically GCC used location_t, while libcpp used source_location. This inconsistency has been annoying me for a while, so this patch removes source_location in favor of location_t throughout (as the latter is shorter). gcc/ChangeLog: * builtins.c: Replace "source_location" with "location_t". * diagnostic-show-locus.c: Likewise. * diagnostic.c: Likewise. * dumpfile.c: Likewise. * gcc-rich-location.h: Likewise. * genmatch.c: Likewise. * gimple.h: Likewise. * gimplify.c: Likewise. * input.c: Likewise. * input.h: Likewise. Eliminate the typedef. * omp-expand.c: Likewise. * selftest.h: Likewise. * substring-locations.h (get_source_location_for_substring): Rename to.. (get_location_within_string): ...this. * tree-cfg.c: Replace "source_location" with "location_t". * tree-cfgcleanup.c: Likewise. * tree-diagnostic.c: Likewise. * tree-into-ssa.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-phinodes.c: Likewise. * tree-phinodes.h: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-threadupdate.c: Likewise. * tree-ssa.c: Likewise. * tree-ssa.h: Likewise. * tree-vect-loop-manip.c: Likewise. gcc/c-family/ChangeLog: * c-common.c (c_get_substring_location): Update for renaming of get_source_location_for_substring to get_location_within_string. * c-lex.c: Replace "source_location" with "location_t". * c-opts.c: Likewise. * c-ppoutput.c: Likewise. gcc/c/ChangeLog: * c-decl.c: Replace "source_location" with "location_t". * c-tree.h: Likewise. * c-typeck.c: Likewise. * gimple-parser.c: Likewise. gcc/cp/ChangeLog: * call.c: Replace "source_location" with "location_t". * cp-tree.h: Likewise. * cvt.c: Likewise. * name-lookup.c: Likewise. * parser.c: Likewise. * typeck.c: Likewise. gcc/fortran/ChangeLog: * cpp.c: Replace "source_location" with "location_t". * gfortran.h: Likewise. gcc/go/ChangeLog: * go-gcc-diagnostics.cc: Replace "source_location" with "location_t". * go-gcc.cc: Likewise. * go-linemap.cc: Likewise. * go-location.h: Likewise. * gofrontend/README: Likewise. gcc/jit/ChangeLog: * jit-playback.c: Replace "source_location" with "location_t". gcc/testsuite/ChangeLog: * g++.dg/plugin/comment_plugin.c: Replace "source_location" with "location_t". * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Likewise. libcc1/ChangeLog: * libcc1plugin.cc: Replace "source_location" with "location_t". (plugin_context::get_source_location): Rename to... (plugin_context::get_location_t): ...this. * libcp1plugin.cc: Likewise. libcpp/ChangeLog: * charset.c: Replace "source_location" with "location_t". * directives-only.c: Likewise. * directives.c: Likewise. * errors.c: Likewise. * expr.c: Likewise. * files.c: Likewise. * include/cpplib.h: Likewise. Rename MAX_SOURCE_LOCATION to MAX_LOCATION_T. * include/line-map.h: Likewise. * init.c: Likewise. * internal.h: Likewise. * lex.c: Likewise. * line-map.c: Likewise. * location-example.txt: Likewise. * macro.c: Likewise. * pch.c: Likewise. * traditional.c: Likewise. From-SVN: r266085
2018-11-05Fix various latent issues revealed by P0732 work.Jason Merrill1-1/+9
The initialized_type hunk fixes handling of void AGGR_INIT_EXPRs that call a non-constructor; an AGGR_INIT_EXPR can have void type if its initialization semantics are more complicated than just expanding the call. The cxx_eval_vec_init_1 hunk corrects AGGR_INIT_EXPRs that were nonsensically built to initialize an object of void type. And the build_aggr_init_expr hunk makes sure we don't do that again. The ocp_convert and cxx_eval_outermost_constant_expr hunks deal with making sure that a constant CONSTRUCTOR has the right type. * cvt.c (ocp_convert): Don't wrap a CONSTRUCTOR in a NOP_EXPR. * constexpr.c (initialized_type): Fix AGGR_INIT_EXPR handling. (cxx_eval_vec_init_1): Correct type of AGGR_INIT_EXPR. (cxx_eval_outermost_constant_expr): Make sure a CONSTRUCTOR has the right type. Don't wrap a CONSTRUCTOR if one was passed in. * tree.c (build_aggr_init_expr): Check for void. From-SVN: r265788
2018-08-20Add support for grouping of related diagnostics (PR other/84889)David Malcolm1-0/+3
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-06-18tree.c (cp_expr_location): New.Jason Merrill1-6/+6
* 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-03PR c++/85739 - ICE with pointer to member template parm.Jason Merrill1-2/+3
* cvt.c (perform_qualification_conversions): Use cp_fold_convert. From-SVN: r261129
2018-05-24cp-tree.h (INDIRECT_TYPE_P): New.Paolo Carlini1-5/+5
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-23Fix cast to rvalue reference from prvalue.Jason Merrill1-1/+2
* cvt.c (diagnose_ref_binding): Handle rvalue reference. * rtti.c (build_dynamic_cast_1): Don't try to build a reference to non-class type. Handle xvalue argument. * typeck.c (build_reinterpret_cast_1): Allow cast from prvalue to rvalue reference. * semantics.c (finish_compound_literal): Do direct-initialization, not cast, to initialize a reference. From-SVN: r260622
2018-05-14cp-tree.h (TYPE_REF_P): New.Paolo Carlini1-10/+9
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-05cvt.c (ocp_convert): Early handle the special case of a null_ptr_cst_p expr ↵Paolo Carlini1-6/+9
converted to a... 2018-05-05 Paolo Carlini <paolo.carlini@oracle.com> * cvt.c (ocp_convert): Early handle the special case of a null_ptr_cst_p expr converted to a NULLPTR_TYPE_P type. From-SVN: r259966
2018-04-27cvt.c (cp_fold_convert): Use convert_ptrmem.Jason Merrill1-5/+9
* cvt.c (cp_fold_convert): Use convert_ptrmem. * typeck.c (convert_ptrmem): Add a NOP even if no adjustment. From-SVN: r259717
2018-04-27PR c++/85545 - ICE with noexcept PMF conversion.Jason Merrill1-3/+5
* cvt.c (cp_fold_convert): Pass PMF CONSTRUCTORs to build_ptrmemfunc. * typeck.c (build_ptrmemfunc): Don't build a NOP_EXPR for zero adjustment. (build_ptrmemfunc_access_expr): Special-case CONSTRUCTORs. From-SVN: r259712
2018-04-26PR c++/85545 - ICE with noexcept PMF conversion.Jason Merrill1-1/+3
* cvt.c (cp_fold_convert): Handle PMF CONSTRUCTORs directly. From-SVN: r259689
2018-03-20PR c++/84978, ICE with NRVO.Jason Merrill1-2/+11
* cvt.c (cp_get_fndecl_from_callee): Add fold parameter. (cp_get_callee_fndecl_nofold): New. * cp-gimplify.c (cp_genericize_r): Use it instead. * call.c (check_self_delegation): Likewise. From-SVN: r258689
2018-03-04PR c++/84686 - missing volatile loads.Jason Merrill1-0/+2
* cvt.c (convert_to_void): Call maybe_undo_parenthesized_ref. From-SVN: r258231
2018-01-29PR c++/68810 - wrong location for reinterpret_cast error.Jason Merrill1-0/+5
* cvt.c (cp_convert_to_pointer): Always build a CONVERT_EXPR when !dofold. From-SVN: r257161
2018-01-29PR c++/83942 - wrong unused warning with static_cast.Jason Merrill1-1/+4
* cvt.c (ocp_convert): Call mark_rvalue_use. From-SVN: r257155
2018-01-10Preserving locations for variable-uses and constants (PR c++/43486)David Malcolm1-1/+1
This patch implements location wrapper nodes, preserving source locations of the uses of variables and constants in various places in the C++ frontend: at the arguments at callsites, and for typeid, alignof, sizeof, and offsetof. For example, it allows the C++ FE to underline the pertinent argument for mismatching calls, for such expressions, improving: extern int callee (int one, const char *two, float three); int caller (int first, int second, float third) { return callee (first, second, third); } from test.cc: In function 'int caller(int, int, float)': test.cc:5:38: error: invalid conversion from 'int' to 'const char*' [-fpermissive] return callee (first, second, third); ^ test.cc:1:41: note: initializing argument 2 of 'int callee(int, const char*, float)' extern int callee (int one, const char *two, float three); ~~~~~~~~~~~~^~~ to: test.cc: In function 'int caller(int, int, float)': test.cc:5:25: error: invalid conversion from 'int' to 'const char*' [-fpermissive] return callee (first, second, third); ^~~~~~ test.cc:1:41: note: initializing argument 2 of 'int callee(int, const char*, float)' extern int callee (int one, const char *two, float three); ~~~~~~~~~~~~^~~ This is the combination of the following patches: "[PATCH 01/14] C++: preserve locations within build_address" https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00883.html "[PATCH v2.4 of 02/14] Support for adding and stripping location_t wrapper nodes" https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00591.html "[PATCH] Eliminate location wrappers in tree_nop_conversion/STRIP_NOPS" https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01330.html "[PATCH v4 of 03/14] C++: add location_t wrapper nodes during parsing (minimal impl)" https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00660.html "[PATCH 04/14] Update testsuite to show improvements" https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00891.html "[v3 of 05/14] C++: handle locations wrappers when calling warn_for_memset" https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01378.html "[PATCH 07/14] reject_gcc_builtin: strip any location wrappers" https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00886.html "[v3 of PATCH 08/14] cp/tree.c: strip location wrappers in lvalue_kind" https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01433.html "[PATCH 09/14] Strip location wrappers in null_ptr_cst_p" https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00888.html "[PATCH 11/14] Handle location wrappers in string_conv_p" https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00890.html "[PATCH 12/14] C++: introduce null_node_p" https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00894.html "[v3 of PATCH 13/14] c-format.c: handle location wrappers" https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01494.html "[PATCH 14/14] pp_c_cast_expression: don't print casts for location wrappers" https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00893.html "[v3 of PATCH 15/14] Use fold_for_warn in get_atomic_generic_size" https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01380.html "[PATCH] Add selftest for "fold_for_warn (error_mark_node)"" https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01385.html gcc/c-family/ChangeLog: PR c++/43486 * c-common.c: Include "selftest.h". (get_atomic_generic_size): Perform the test for integral type before the range test for any integer constant, fixing indentation of braces. Call fold_for_warn before testing for an INTEGER_CST. (reject_gcc_builtin): Strip any location wrapper from EXPR. (selftest::test_fold_for_warn): New function. (selftest::c_common_c_tests): New function. (selftest::c_family_tests): Call it, and selftest::c_pretty_print_c_tests. * c-common.h (selftest::c_pretty_print_c_tests): New decl. * c-format.c (check_format_arg): Convert VAR_P check to a fold_for_warn. * c-pretty-print.c: Include "selftest.h". (pp_c_cast_expression): Don't print casts for location wrappers. (selftest::assert_c_pretty_printer_output): New function. (ASSERT_C_PRETTY_PRINTER_OUTPUT): New macro. (selftest::test_location_wrappers): New function. (selftest::c_pretty_print_c_tests): New function. * c-warn.c (warn_for_memset): Call fold_for_warn on the arguments. gcc/cp/ChangeLog: PR c++/43486 * call.c (null_ptr_cst_p): Strip location wrappers when converting from '0' to a pointer type in C++11 onwards. (conversion_null_warnings): Replace comparison with null_node with call to null_node_p. (build_over_call): Likewise. * cp-gimplify.c (cp_fold): Remove the early bailout when processing_template_decl. * cp-lang.c (selftest::run_cp_tests): Call selftest::cp_pt_c_tests and selftest::cp_tree_c_tests. * cp-tree.h (cp_expr::maybe_add_location_wrapper): New method. (selftest::run_cp_tests): Move decl to bottom of file. (null_node_p): New inline function. (selftest::cp_pt_c_tests): New decl. (selftest::cp_tree_c_tests): New decl. * cvt.c (build_expr_type_conversion): Replace comparison with null_node with call to null_node_p. * error.c (args_to_string): Likewise. * except.c (build_throw): Likewise. * mangle.c (write_expression): Skip location wrapper nodes. * parser.c (literal_integer_zerop): New function. (cp_parser_postfix_expression): Call maybe_add_location_wrapper on the result for RID_TYPEID. Pass true for new "wrap_locations_p" param of cp_parser_parenthesized_expression_list. When calling warn_for_memset, replace integer_zerop calls with literal_integer_zerop, eliminating the double logical negation cast to bool. Eliminate the special-casing for CONST_DECL in favor of the fold_for_warn within warn_for_memset. (cp_parser_parenthesized_expression_list): Add "wrap_locations_p" param, defaulting to false. Convert "expr" to a cp_expr, and call maybe_add_location_wrapper on it when wrap_locations_p is true. (cp_parser_unary_expression): Call maybe_add_location_wrapper on the result for RID_ALIGNOF and RID_SIZEOF. (cp_parser_builtin_offsetof): Likewise. * pt.c: Include "selftest.h". (tsubst_copy): Handle location wrappers. (tsubst_copy_and_build): Likewise. (build_non_dependent_expr): Likewise. (selftest::test_build_non_dependent_expr): New function. (selftest::cp_pt_c_tests): New function. * tree.c: Include "selftest.h". (lvalue_kind): Handle VIEW_CONVERT_EXPR location wrapper nodes. (selftest::test_lvalue_kind): New function. (selftest::cp_tree_c_tests): New function. * typeck.c (string_conv_p): Strip any location wrapper from "exp". (cp_build_binary_op): Replace comparison with null_node with call to null_node_p. (build_address): Use location of operand when building address expression. gcc/testsuite/ChangeLog: PR c++/43486 * g++.dg/diagnostic/param-type-mismatch.C: Update expected results to reflect that the arguments are correctly underlined. * g++.dg/plugin/diagnostic-test-expressions-1.C: Add test coverage for globals, params, locals and literals. (test_sizeof): Directly test the location of "sizeof", rather than when used in compound expressions. (test_alignof): Likewise for "alignof". (test_string_literals): Likewise for string literals. (test_numeric_literals): Likewise for numeric literals. (test_builtin_offsetof): Likewise for "__builtin_offsetof". (test_typeid): Likewise for typeid. (test_unary_plus): New. * g++.dg/warn/Wformat-1.C: Add tests of pointer arithmetic on format strings. gcc/ChangeLog: PR c++/43486 * tree-core.h: Document EXPR_LOCATION_WRAPPER_P's usage of "public_flag". * tree.c (tree_nop_conversion): Return true for location wrapper nodes. (maybe_wrap_with_location): New function. (selftest::check_strip_nops): New function. (selftest::test_location_wrappers): New function. (selftest::tree_c_tests): Call it. * tree.h (STRIP_ANY_LOCATION_WRAPPER): New macro. (maybe_wrap_with_location): New decl. (EXPR_LOCATION_WRAPPER_P): New macro. (location_wrapper_p): New inline function. (tree_strip_any_location_wrapper): New inline function. From-SVN: r256448
2018-01-03Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r256169
2017-10-24re PR c++/82307 (unscoped enum-base incorrect cast)Mukesh Kapoor1-3/+18
/cp 2017-10-24 Mukesh Kapoor <mukesh.kapoor@oracle.com> Paolo Carlini <paolo.carlini@oracle.com> PR c++/82307 * cvt.c (type_promotes_to): Implement C++17, 7.6/4, about unscoped enumeration type whose underlying type is fixed. /testsuite 2017-10-24 Mukesh Kapoor <mukesh.kapoor@oracle.com> Paolo Carlini <paolo.carlini@oracle.com> PR c++/82307 * g++.dg/cpp0x/enum35.C: New. * g++.dg/cpp0x/enum36.C: Likewise. Co-Authored-By: Paolo Carlini <paolo.carlini@oracle.com> From-SVN: r254046
2017-10-10More delayed lambda capture fixes.Jason Merrill1-16/+2
* call.c (add_function_candidate): Use build_address. (build_op_call_1): Call mark_lvalue_use early. (build_over_call): Handle error from build_this. * constexpr.c (cxx_bind_parameters_in_call): Use build_address. (cxx_eval_increment_expression): Don't use rvalue(). * cvt.c (convert_to_void): Use mark_discarded_use. * expr.c (mark_use): Handle PARM_DECL, NON_DEPENDENT_EXPR. Fix reference handling. Don't copy the expression. (mark_discarded_use): New. * lambda.c (insert_capture_proxy): Add some sanity checking. (maybe_add_lambda_conv_op): Set cp_unevaluated_operand. * pt.c (register_local_specialization): Add sanity check. * semantics.c (process_outer_var_ref): Fix check for existing proxy. * typeck.c (cp_build_addr_expr_1): Handle error from mark_lvalue_use. (cp_build_modify_expr): Call mark_lvalue_use_nonread, handle error from rvalue. Handle generic lambda capture in dependent expressions. * lambda.c (need_generic_capture, dependent_capture_r) (do_dependent_capture): New. * pt.c (processing_nonlambda_template): Use need_generic_capture. * semantics.c (maybe_cleanup_point_expr) (maybe_cleanup_point_expr_void, finish_goto_stmt) (maybe_convert_cond): Call do_dependent_capture. * typeck.c (build_static_cast): Remove dependent capture handling. From-SVN: r253601
2017-10-10Require wi::to_wide for treesRichard Sandiford1-1/+1
The wide_int routines allow things like: wi::add (t, 1) to add 1 to an INTEGER_CST T in its native precision. But we also have: wi::to_offset (t) // Treat T as an offset_int wi::to_widest (t) // Treat T as a widest_int Recently we also gained: wi::to_wide (t, prec) // Treat T as a wide_int in preccision PREC This patch therefore requires: wi::to_wide (t) when operating on INTEGER_CSTs in their native precision. This is just as efficient, and makes it clearer that a deliberate choice is being made to treat the tree as a wide_int in its native precision. This also removes the inconsistency that a) INTEGER_CSTs in their native precision can be used without an accessor but must use wi:: functions instead of C++ operators b) the other forms need an explicit accessor but the result can be used with C++ operators. It also helps with SVE, where there's the additional possibility that the tree could be a runtime value. 2017-10-10 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * wide-int.h (wide_int_ref_storage): Make host_dependent_precision a template parameter. (WIDE_INT_REF_FOR): Update accordingly. * tree.h (wi::int_traits <const_tree>): Delete. (wi::tree_to_widest_ref, wi::tree_to_offset_ref): New typedefs. (wi::to_widest, wi::to_offset): Use them. Expand commentary. (wi::tree_to_wide_ref): New typedef. (wi::to_wide): New function. * calls.c (get_size_range): Use wi::to_wide when operating on trees as wide_ints. * cgraph.c (cgraph_node::create_thunk): Likewise. * config/i386/i386.c (ix86_data_alignment): Likewise. (ix86_local_alignment): Likewise. * dbxout.c (stabstr_O): Likewise. * dwarf2out.c (add_scalar_info, gen_enumeration_type_die): Likewise. * expr.c (const_vector_from_tree): Likewise. * fold-const-call.c (host_size_t_cst_p, fold_const_call_1): Likewise. * fold-const.c (may_negate_without_overflow_p, negate_expr_p) (fold_negate_expr_1, int_const_binop_1, const_binop) (fold_convert_const_int_from_real, optimize_bit_field_compare) (all_ones_mask_p, sign_bit_p, unextend, extract_muldiv_1) (fold_div_compare, fold_single_bit_test, fold_plusminus_mult_expr) (pointer_may_wrap_p, expr_not_equal_to, fold_binary_loc) (fold_ternary_loc, multiple_of_p, fold_negate_const, fold_abs_const) (fold_not_const, round_up_loc): Likewise. * gimple-fold.c (gimple_fold_indirect_ref): Likewise. * gimple-ssa-warn-alloca.c (alloca_call_type_by_arg): Likewise. (alloca_call_type): Likewise. * gimple.c (preprocess_case_label_vec_for_gimple): Likewise. * godump.c (go_output_typedef): Likewise. * graphite-sese-to-poly.c (tree_int_to_gmp): Likewise. * internal-fn.c (get_min_precision): Likewise. * ipa-cp.c (ipcp_store_vr_results): Likewise. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::ipa_polymorphic_call_context): Likewise. * ipa-prop.c (ipa_print_node_jump_functions_for_edge): Likewise. (ipa_modify_call_arguments): Likewise. * match.pd: Likewise. * omp-low.c (scan_omp_1_op, lower_omp_ordered_clauses): Likewise. * print-tree.c (print_node_brief, print_node): Likewise. * stmt.c (expand_case): Likewise. * stor-layout.c (layout_type): Likewise. * tree-affine.c (tree_to_aff_combination): Likewise. * tree-cfg.c (group_case_labels_stmt): Likewise. * tree-data-ref.c (dr_analyze_indices): Likewise. (prune_runtime_alias_test_list): Likewise. * tree-dump.c (dequeue_and_dump): Likewise. * tree-inline.c (remap_gimple_op_r, copy_tree_body_r): Likewise. * tree-predcom.c (is_inv_store_elimination_chain): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. * tree-scalar-evolution.c (iv_can_overflow_p): Likewise. (simple_iv_with_niters): Likewise. * tree-ssa-address.c (addr_for_mem_ref): Likewise. * tree-ssa-ccp.c (ccp_finalize, evaluate_stmt): Likewise. * tree-ssa-loop-ivopts.c (constant_multiple_of): Likewise. * tree-ssa-loop-niter.c (split_to_var_and_offset) (refine_value_range_using_guard, number_of_iterations_ne_max) (number_of_iterations_lt_to_ne, number_of_iterations_lt) (get_cst_init_from_scev, record_nonwrapping_iv) (scev_var_range_cant_overflow): Likewise. * tree-ssa-phiopt.c (minmax_replacement): Likewise. * tree-ssa-pre.c (compute_avail): Likewise. * tree-ssa-sccvn.c (vn_reference_fold_indirect): Likewise. (vn_reference_maybe_forwprop_address, valueized_wider_op): Likewise. * tree-ssa-structalias.c (get_constraint_for_ptr_offset): Likewise. * tree-ssa-uninit.c (is_pred_expr_subset_of): Likewise. * tree-ssanames.c (set_nonzero_bits, get_nonzero_bits): Likewise. * tree-switch-conversion.c (collect_switch_conv_info, array_value_type) (dump_case_nodes, try_switch_expansion): Likewise. * tree-vect-loop-manip.c (vect_gen_vector_loop_niters): Likewise. (vect_do_peeling): Likewise. * tree-vect-patterns.c (vect_recog_bool_pattern): Likewise. * tree-vect-stmts.c (vectorizable_load): Likewise. * tree-vrp.c (compare_values_warnv, vrp_int_const_binop): Likewise. (zero_nonzero_bits_from_vr, ranges_from_anti_range): Likewise. (extract_range_from_binary_expr_1, adjust_range_with_scev): Likewise. (overflow_comparison_p_1, register_edge_assert_for_2): Likewise. (is_masked_range_test, find_switch_asserts, maybe_set_nonzero_bits) (vrp_evaluate_conditional_warnv_with_ops, intersect_ranges): Likewise. (range_fits_type_p, two_valued_val_range_p, vrp_finalize): Likewise. (evrp_dom_walker::before_dom_children): Likewise. * tree.c (cache_integer_cst, real_value_from_int_cst, integer_zerop) (integer_all_onesp, integer_pow2p, integer_nonzerop, tree_log2) (tree_floor_log2, tree_ctz, mem_ref_offset, tree_int_cst_sign_bit) (tree_int_cst_sgn, get_unwidened, int_fits_type_p): Likewise. (get_type_static_bounds, num_ending_zeros, drop_tree_overflow) (get_range_pos_neg): Likewise. * ubsan.c (ubsan_expand_ptr_ifn): Likewise. * config/darwin.c (darwin_mergeable_constant_section): Likewise. * config/aarch64/aarch64.c (aapcs_vfp_sub_candidate): Likewise. * config/arm/arm.c (aapcs_vfp_sub_candidate): Likewise. * config/avr/avr.c (avr_fold_builtin): Likewise. * config/bfin/bfin.c (bfin_local_alignment): Likewise. * config/msp430/msp430.c (msp430_attr): Likewise. * config/nds32/nds32.c (nds32_insert_attributes): Likewise. * config/powerpcspe/powerpcspe-c.c (altivec_resolve_overloaded_builtin): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_aggregate_candidate) (rs6000_expand_ternop_builtin): Likewise. * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Likewise. * config/rs6000/rs6000.c (rs6000_aggregate_candidate): Likewise. (rs6000_expand_ternop_builtin): Likewise. * config/s390/s390.c (s390_handle_hotpatch_attribute): Likewise. gcc/ada/ * gcc-interface/decl.c (annotate_value): Use wi::to_wide when operating on trees as wide_ints. gcc/c/ * c-parser.c (c_parser_cilk_clause_vectorlength): Use wi::to_wide when operating on trees as wide_ints. * c-typeck.c (build_c_cast, c_finish_omp_clauses): Likewise. (c_tree_equal): Likewise. gcc/c-family/ * c-ada-spec.c (dump_generic_ada_node): Use wi::to_wide when operating on trees as wide_ints. * c-common.c (pointer_int_sum): Likewise. * c-pretty-print.c (pp_c_integer_constant): Likewise. * c-warn.c (match_case_to_enum_1): Likewise. (c_do_switch_warnings): Likewise. (maybe_warn_shift_overflow): Likewise. gcc/cp/ * cvt.c (ignore_overflows): Use wi::to_wide when operating on trees as wide_ints. * decl.c (check_array_designated_initializer): Likewise. * mangle.c (write_integer_cst): Likewise. * semantics.c (cp_finish_omp_clause_depend_sink): Likewise. gcc/fortran/ * target-memory.c (gfc_interpret_logical): Use wi::to_wide when operating on trees as wide_ints. * trans-const.c (gfc_conv_tree_to_mpz): Likewise. * trans-expr.c (gfc_conv_cst_int_power): Likewise. * trans-intrinsic.c (trans_this_image): Likewise. (gfc_conv_intrinsic_bound): Likewise. (conv_intrinsic_cobound): Likewise. gcc/lto/ * lto.c (compare_tree_sccs_1): Use wi::to_wide when operating on trees as wide_ints. gcc/objc/ * objc-act.c (objc_decl_method_attributes): Use wi::to_wide when operating on trees as wide_ints. From-SVN: r253595
2017-08-30[34/77] Add a SCALAR_INT_TYPE_MODE macroRichard Sandiford1-2/+2
This patch adds a SCALAR_INT_TYPE_MODE macro that asserts that the type has a scalar integer mode and returns it as a scalar_int_mode. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (SCALAR_INT_TYPE_MODE): New macro. * builtins.c (expand_builtin_signbit): Use it. * cfgexpand.c (expand_debug_expr): Likewise. * dojump.c (do_jump): Likewise. (do_compare_and_jump): Likewise. * dwarf2cfi.c (expand_builtin_init_dwarf_reg_sizes): Likewise. * expmed.c (make_tree): Likewise. * expr.c (expand_expr_real_2): Likewise. (expand_expr_real_1): Likewise. (try_casesi): Likewise. * fold-const-call.c (fold_const_call_ss): Likewise. * fold-const.c (unextend): Likewise. (extract_muldiv_1): Likewise. (fold_single_bit_test): Likewise. (native_encode_int): Likewise. (native_encode_string): Likewise. (native_interpret_int): Likewise. * gimple-fold.c (gimple_fold_builtin_memset): Likewise. * internal-fn.c (expand_addsub_overflow): Likewise. (expand_neg_overflow): Likewise. (expand_mul_overflow): Likewise. (expand_arith_overflow): Likewise. * match.pd: Likewise. * stor-layout.c (layout_type): Likewise. * tree-cfg.c (verify_gimple_assign_ternary): Likewise. * tree-ssa-math-opts.c (convert_mult_to_widen): Likewise. * tree-ssanames.c (get_range_info): Likewise. * tree-switch-conversion.c (array_value_type) Likewise. * tree-vect-patterns.c (vect_recog_rotate_pattern): Likewise. (vect_recog_divmod_pattern): Likewise. (vect_recog_mixed_size_cond_pattern): Likewise. * tree-vrp.c (extract_range_basic): Likewise. (simplify_float_conversion_using_ranges): Likewise. * tree.c (int_fits_type_p): Likewise. * ubsan.c (instrument_bool_enum_load): Likewise. * varasm.c (mergeable_string_section): Likewise. (narrowing_initializer_constant_valid_p): Likewise. (output_constant): Likewise. gcc/cp/ * cvt.c (cp_convert_to_pointer): Use SCALAR_INT_TYPE_MODE. gcc/fortran/ * target-memory.c (size_integer): Use SCALAR_INT_TYPE_MODE. (size_logical): Likewise. gcc/objc/ * objc-encoding.c (encode_type): Use SCALAR_INT_TYPE_MODE. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251486
2017-08-08trans.c: Include header files.Martin Liska1-0/+2
. 2017-08-08 Martin Liska <mliska@suse.cz> * gcc-interface/trans.c: Include header files. 2017-08-08 Martin Liska <mliska@suse.cz> * objc-gnu-runtime-abi-01.c: Include header files. * objc-next-runtime-abi-01.c: Likewise. * objc-next-runtime-abi-02.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * asan.c: Include header files. * attribs.c (build_decl_attribute_variant): New function moved from tree.[ch]. (build_type_attribute_qual_variant): Likewise. (cmp_attrib_identifiers): Likewise. (simple_cst_list_equal): Likewise. (omp_declare_simd_clauses_equal): Likewise. (attribute_value_equal): Likewise. (comp_type_attributes): Likewise. (build_type_attribute_variant): Likewise. (lookup_ident_attribute): Likewise. (remove_attribute): Likewise. (merge_attributes): Likewise. (merge_type_attributes): Likewise. (merge_decl_attributes): Likewise. (merge_dllimport_decl_attributes): Likewise. (handle_dll_attribute): Likewise. (attribute_list_equal): Likewise. (attribute_list_contained): Likewise. * attribs.h (lookup_attribute): New function moved from tree.[ch]. (lookup_attribute_by_prefix): Likewise. * bb-reorder.c: Include header files. * builtins.c: Likewise. * calls.c: Likewise. * cfgexpand.c: Likewise. * cgraph.c: Likewise. * cgraphunit.c: Likewise. * convert.c: Likewise. * dwarf2out.c: Likewise. * final.c: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * gimple-expr.c: Likewise. * gimple-fold.c: Likewise. * gimple-pretty-print.c: Likewise. * gimple.c: Likewise. * gimplify.c: Likewise. * hsa-common.c: Likewise. * hsa-gen.c: Likewise. * internal-fn.c: Likewise. * ipa-chkp.c: Likewise. * ipa-cp.c: Likewise. * ipa-devirt.c: Likewise. * ipa-fnsummary.c: Likewise. * ipa-inline.c: Likewise. * ipa-visibility.c: Likewise. * ipa.c: Likewise. * lto-cgraph.c: Likewise. * omp-expand.c: Likewise. * omp-general.c: Likewise. * omp-low.c: Likewise. * omp-offload.c: Likewise. * omp-simd-clone.c: Likewise. * opts-global.c: Likewise. * passes.c: Likewise. * predict.c: Likewise. * sancov.c: Likewise. * sanopt.c: Likewise. * symtab.c: Likewise. * toplev.c: Likewise. * trans-mem.c: Likewise. * tree-chkp.c: Likewise. * tree-eh.c: Likewise. * tree-into-ssa.c: Likewise. * tree-object-size.c: Likewise. * tree-parloops.c: Likewise. * tree-profile.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa.c: Likewise. * tree-streamer-in.c: Likewise. * tree-vectorizer.c: Likewise. * tree-vrp.c: Likewise. * tsan.c: Likewise. * ubsan.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * tree.c: Remove functions moved to attribs.[ch]. * tree.h: Likewise. * config/aarch64/aarch64.c: Add attrs.h header file. * config/alpha/alpha.c: Likewise. * config/arc/arc.c: Likewise. * config/arm/arm.c: Likewise. * config/avr/avr.c: Likewise. * config/bfin/bfin.c: Likewise. * config/c6x/c6x.c: Likewise. * config/cr16/cr16.c: Likewise. * config/cris/cris.c: Likewise. * config/darwin.c: Likewise. * config/epiphany/epiphany.c: Likewise. * config/fr30/fr30.c: Likewise. * config/frv/frv.c: Likewise. * config/ft32/ft32.c: Likewise. * config/h8300/h8300.c: Likewise. * config/i386/winnt.c: Likewise. * config/ia64/ia64.c: Likewise. * config/iq2000/iq2000.c: Likewise. * config/lm32/lm32.c: Likewise. * config/m32c/m32c.c: Likewise. * config/m32r/m32r.c: Likewise. * config/m68k/m68k.c: Likewise. * config/mcore/mcore.c: Likewise. * config/microblaze/microblaze.c: Likewise. * config/mips/mips.c: Likewise. * config/mmix/mmix.c: Likewise. * config/mn10300/mn10300.c: Likewise. * config/moxie/moxie.c: Likewise. * config/msp430/msp430.c: Likewise. * config/nds32/nds32-isr.c: Likewise. * config/nds32/nds32.c: Likewise. * config/nios2/nios2.c: Likewise. * config/nvptx/nvptx.c: Likewise. * config/pa/pa.c: Likewise. * config/pdp11/pdp11.c: Likewise. * config/powerpcspe/powerpcspe.c: Likewise. * config/riscv/riscv.c: Likewise. * config/rl78/rl78.c: Likewise. * config/rx/rx.c: Likewise. * config/s390/s390.c: Likewise. * config/sh/sh.c: Likewise. * config/sol2.c: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/tilegx/tilegx.c: Likewise. * config/tilepro/tilepro.c: Likewise. * config/v850/v850.c: Likewise. * config/vax/vax.c: Likewise. * config/visium/visium.c: Likewise. * config/xtensa/xtensa.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * call.c: Include header files. * cp-gimplify.c: Likewise. * cp-ubsan.c: Likewise. * cvt.c: Likewise. * init.c: Likewise. * search.c: Likewise. * semantics.c: Likewise. * typeck.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * lto-lang.c: Include header files. * lto-symtab.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * c-convert.c: Include header files. * c-typeck.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * c-ada-spec.c: Include header files. * c-ubsan.c: Likewise. * c-warn.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * trans-types.c: Include header files. From-SVN: r250946
2017-06-09Missing bits from N4268, constant evaluation for all non-type args.Jason Merrill1-3/+6
* call.c (build_converted_constant_expr): Rename from build_integral_nontype_arg_conv, handle all types. * pt.c (convert_nontype_argument): In C++17 call it for all types. Move NOP stripping inside pointer case, don't strip ADDR_EXPR. * cvt.c (strip_fnptr_conv): Also strip conversions to the same type. From-SVN: r249089
2017-06-09Overhaul pointer-to-member conversion and template argument handling.Jason Merrill1-8/+21
* call.c (standard_conversion): Avoid creating ck_pmem when the class type is the same. * cvt.c (can_convert_qual): Split from perform_qualification_conversions. * constexpr.c (cxx_eval_constant_expression): Check it. * typeck.c (convert_ptrmem): Only cplus_expand_constant if adjustment is necessary. * pt.c (check_valid_ptrmem_cst_expr): Compare class types. (convert_nontype_argument): Avoid redundant error. From-SVN: r249088