Re: [PATCH 1/3] Come up with startswith function.

2021-05-18 Thread Ian Lance Taylor via Gcc-patches
On Tue, May 18, 2021 at 5:32 AM Martin Liška  wrote:
>
> On 5/18/21 12:07 PM, Iain Buclaw wrote:
> > Excerpts from Martin Liska's message of March 17, 2021 4:36 pm:
> >>
> >> gcc/d/ChangeLog:
> >>
> >>  * d-builtins.cc (do_build_builtin_fn): Use startswith
> >>  function instead of strncmp.
> >>  * dmd/dinterpret.c (evaluateIfBuiltin): Likewise.
> >>  * dmd/dmangle.c: Likewise.
> >>  * dmd/hdrgen.c: Likewise.
> >>  * dmd/identifier.c (Identifier::toHChars2): Likewise.
> >>
> >
> > Hi,
> >
> > Sorry for just noticing, but the sources in dmd/ (unless noted
> > otherwise) are maintained in an external repository.  All changes must
> > first go through there.
> >
> > That aside, the DMD front-end is meant to be a common implementation
> > shared between two other compilers, therefore does not have any
> > dependency on GCC itself.  This patch changes that status quo.
> >
> > So without prejudice, I'll revert the changes to dmd/ only.  There are,
> > I note, a few other places in d/*.cc that use strncmp() but could
> > instead use startswith().
> >
> > d/d-incpath.cc:37:if (!strncmp (path, cpp_PREFIX, len))
> > d/d-incpath.cc:61:if (!strncmp (path, cpp_GCC_INCLUDE_DIR, len))
> > d/types.cc:877:gcc_assert (strncmp (ident, "__c_", strlen ("__c_")) == 0);
> >
> >
> >> gcc/go/ChangeLog:
> >>
> >>  * gofrontend/runtime.cc (Runtime::name_to_code): Use startswith
> >>  function instead of strncmp.
> >>
> >
> > I might be wrong, but I'm pretty certain that Go is the same in having
> > an external repository for these sources.
>
> Hello.
>
> Sorry for that. Feel free to revert these changes.


I've reverted the change in gcc/go/gofrontend.

Ian


Re: [PATCH 1/3] Come up with startswith function.

2021-05-18 Thread Martin Liška

On 5/18/21 12:07 PM, Iain Buclaw wrote:

Excerpts from Martin Liska's message of March 17, 2021 4:36 pm:


gcc/d/ChangeLog:

* d-builtins.cc (do_build_builtin_fn): Use startswith
function instead of strncmp.
* dmd/dinterpret.c (evaluateIfBuiltin): Likewise.
* dmd/dmangle.c: Likewise.
* dmd/hdrgen.c: Likewise.
* dmd/identifier.c (Identifier::toHChars2): Likewise.



Hi,

Sorry for just noticing, but the sources in dmd/ (unless noted
otherwise) are maintained in an external repository.  All changes must
first go through there.

That aside, the DMD front-end is meant to be a common implementation
shared between two other compilers, therefore does not have any
dependency on GCC itself.  This patch changes that status quo.

So without prejudice, I'll revert the changes to dmd/ only.  There are,
I note, a few other places in d/*.cc that use strncmp() but could
instead use startswith().

d/d-incpath.cc:37:if (!strncmp (path, cpp_PREFIX, len))
d/d-incpath.cc:61:if (!strncmp (path, cpp_GCC_INCLUDE_DIR, len))
d/types.cc:877:gcc_assert (strncmp (ident, "__c_", strlen ("__c_")) == 0);



gcc/go/ChangeLog:

* gofrontend/runtime.cc (Runtime::name_to_code): Use startswith
function instead of strncmp.



I might be wrong, but I'm pretty certain that Go is the same in having
an external repository for these sources.


Hello.

Sorry for that. Feel free to revert these changes.

Martin



Iain.





Re: [PATCH 1/3] Come up with startswith function.

2021-05-18 Thread Iain Buclaw via Gcc-patches
Excerpts from Martin Liska's message of March 17, 2021 4:36 pm:
> 
> gcc/d/ChangeLog:
> 
>   * d-builtins.cc (do_build_builtin_fn): Use startswith
>   function instead of strncmp.
>   * dmd/dinterpret.c (evaluateIfBuiltin): Likewise.
>   * dmd/dmangle.c: Likewise.
>   * dmd/hdrgen.c: Likewise.
>   * dmd/identifier.c (Identifier::toHChars2): Likewise.
> 

Hi,

Sorry for just noticing, but the sources in dmd/ (unless noted
otherwise) are maintained in an external repository.  All changes must
first go through there.

That aside, the DMD front-end is meant to be a common implementation
shared between two other compilers, therefore does not have any
dependency on GCC itself.  This patch changes that status quo.

So without prejudice, I'll revert the changes to dmd/ only.  There are,
I note, a few other places in d/*.cc that use strncmp() but could
instead use startswith().

d/d-incpath.cc:37:if (!strncmp (path, cpp_PREFIX, len))
d/d-incpath.cc:61:if (!strncmp (path, cpp_GCC_INCLUDE_DIR, len))
d/types.cc:877:gcc_assert (strncmp (ident, "__c_", strlen ("__c_")) == 0);


> gcc/go/ChangeLog:
> 
>   * gofrontend/runtime.cc (Runtime::name_to_code): Use startswith
>   function instead of strncmp.
> 

I might be wrong, but I'm pretty certain that Go is the same in having
an external repository for these sources.

Iain.


Re: [PATCH 1/3] Come up with startswith function.

2021-05-10 Thread Richard Biener via Gcc-patches
On Wed, Apr 21, 2021 at 11:39 AM Martin Liška  wrote:
>
> On 4/21/21 9:32 AM, Arnaud Charlet wrote:
> >> gcc/ada/ChangeLog:
> >>
> >>  * adadecode.c (has_prefix): Remove has_prefix and replace it
> >>  with startswith.
> >>  (__gnat_decode): Likewise.
> >
> > This change is not OK: adadecode.c is also a runtime file and as such cannot
> > include compiler include files.
> >
> >>  * gcc-interface/utils.c (def_builtin_1): Use startswith
> >>  function instead of strncmp.
> >
> >>  * init.c (__gnat_install_handler): Likewise.
> >
> > Same for init.c which is both a host and a runtime/target file.
> >
> > Only the change in utils.c is OK.
> >
> > Arno
> >
>
> Thank you for a quick reply.
>
> There's an updated version of the patch.

OK.

Thanks,
Richard.

> Cheers,
> Martin


Re: [PATCH 1/3] Come up with startswith function.

2021-04-25 Thread Arnaud Charlet
> Thank you for a quick reply.
> There's an updated version of the patch.

The Ada part is OK now, thanks.


Re: [PATCH 1/3] Come up with startswith function.

2021-04-21 Thread Martin Liška
On 4/21/21 9:32 AM, Arnaud Charlet wrote:
>> gcc/ada/ChangeLog:
>>
>>  * adadecode.c (has_prefix): Remove has_prefix and replace it
>>  with startswith.
>>  (__gnat_decode): Likewise.
> 
> This change is not OK: adadecode.c is also a runtime file and as such cannot
> include compiler include files.
> 
>>  * gcc-interface/utils.c (def_builtin_1): Use startswith
>>  function instead of strncmp.
> 
>>  * init.c (__gnat_install_handler): Likewise.
> 
> Same for init.c which is both a host and a runtime/target file.
> 
> Only the change in utils.c is OK.
> 
> Arno
> 

Thank you for a quick reply.

There's an updated version of the patch.

Cheers,
Martin
>From 23431b3fa6e0ad69e66cc7d3fe8bee5da29a Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Wed, 17 Mar 2021 16:36:44 +0100
Subject: [PATCH 1/3] Come up with startswith function.

gcc/ada/ChangeLog:

	* gcc-interface/utils.c (def_builtin_1): Use startswith
	function instead of strncmp.

gcc/analyzer/ChangeLog:

	* sm-file.cc (is_file_using_fn_p): Use startswith
	function instead of strncmp.

gcc/ChangeLog:

	* builtins.c (is_builtin_name): Use startswith
	function instead of strncmp.
	* collect2.c (main): Likewise.
	(has_lto_section): Likewise.
	(scan_libraries): Likewise.
	* coverage.c (coverage_checksum_string): Likewise.
	(coverage_init): Likewise.
	* dwarf2out.c (is_cxx): Likewise.
	(gen_compile_unit_die): Likewise.
	* gcc-ar.c (main): Likewise.
	* gcc.c (init_spec): Likewise.
	(read_specs): Likewise.
	(execute): Likewise.
	(check_live_switch): Likewise.
	* genattrtab.c (write_attr_case): Likewise.
	(IS_ATTR_GROUP): Likewise.
	* gencfn-macros.c (main): Likewise.
	* gengtype.c (type_for_name): Likewise.
	(gen_rtx_next): Likewise.
	(get_file_langdir): Likewise.
	(write_local): Likewise.
	* genmatch.c (get_operator): Likewise.
	(get_operand_type): Likewise.
	(expr::gen_transform): Likewise.
	* genoutput.c (validate_optab_operands): Likewise.
	* incpath.c (add_sysroot_to_chain): Likewise.
	* langhooks.c (lang_GNU_C): Likewise.
	(lang_GNU_CXX): Likewise.
	(lang_GNU_Fortran): Likewise.
	(lang_GNU_OBJC): Likewise.
	* lto-wrapper.c (run_gcc): Likewise.
	* omp-general.c (omp_max_simt_vf): Likewise.
	* omp-low.c (omp_runtime_api_call): Likewise.
	* opts-common.c (parse_options_from_collect_gcc_options): Likewise.
	* read-rtl-function.c (function_reader::read_rtx_operand_r): Likewise.
	* real.c (real_from_string): Likewise.
	* selftest.c (assert_str_startswith): Likewise.
	* timevar.c (timer::validate_phases): Likewise.
	* tree.c (get_file_function_name): Likewise.
	* ubsan.c (ubsan_use_new_style_p): Likewise.
	* varasm.c (default_function_rodata_section): Likewise.
	(incorporeal_function_p): Likewise.
	(default_section_type_flags): Likewise.
	* system.h (startswith): Define startswith.

gcc/c-family/ChangeLog:

	* c-ada-spec.c (print_destructor): Use startswith
	function instead of strncmp.
	(dump_ada_declaration): Likewise.
	* c-common.c (disable_builtin_function): Likewise.
	(def_builtin_1): Likewise.
	* c-format.c (check_tokens): Likewise.
	(check_plain): Likewise.
	(convert_format_name_to_system_name): Likewise.

gcc/c/ChangeLog:

	* c-aux-info.c (affix_data_type): Use startswith
	function instead of strncmp.
	* c-typeck.c (build_function_call_vec): Likewise.
	* gimple-parser.c (c_parser_gimple_parse_bb_spec): Likewise.

gcc/cp/ChangeLog:

	* decl.c (duplicate_decls): Use startswith
	function instead of strncmp.
	(cxx_builtin_function): Likewise.
	(omp_declare_variant_finalize_one): Likewise.
	(grokfndecl): Likewise.
	* error.c (dump_decl_name): Likewise.
	* mangle.c (find_decomp_unqualified_name): Likewise.
	(write_guarded_var_name): Likewise.
	(decl_tls_wrapper_p): Likewise.
	* parser.c (cp_parser_simple_type_specifier): Likewise.
	(cp_parser_tx_qualifier_opt): Likewise.
	* pt.c (template_parm_object_p): Likewise.
	(dguide_name_p): Likewise.

gcc/d/ChangeLog:

	* d-builtins.cc (do_build_builtin_fn): Use startswith
	function instead of strncmp.
	* dmd/dinterpret.c (evaluateIfBuiltin): Likewise.
	* dmd/dmangle.c: Likewise.
	* dmd/hdrgen.c: Likewise.
	* dmd/identifier.c (Identifier::toHChars2): Likewise.

gcc/fortran/ChangeLog:

	* decl.c (variable_decl): Use startswith
	function instead of strncmp.
	(gfc_match_end): Likewise.
	* gfortran.h (gfc_str_startswith): Likewise.
	* module.c (load_omp_udrs): Likewise.
	(read_module): Likewise.
	* options.c (gfc_handle_runtime_check_option): Likewise.
	* primary.c (match_arg_list_function): Likewise.
	* trans-decl.c (gfc_get_symbol_decl): Likewise.
	* trans-expr.c (gfc_conv_procedure_call): Likewise.
	* trans-intrinsic.c (gfc_conv_ieee_arithmetic_function): Likewise.

gcc/go/ChangeLog:

	* gofrontend/runtime.cc (Runtime::name_to_code): Use startswith
	function instead of strncmp.

gcc/objc/ChangeLog:

	* objc-act.c (objc_string_ref_type_p): Use startswith
	function instead of strncmp.
	* objc-encoding.

Re: [PATCH 1/3] Come up with startswith function.

2021-04-21 Thread Arnaud Charlet
> gcc/ada/ChangeLog:
> 
>   * adadecode.c (has_prefix): Remove has_prefix and replace it
>   with startswith.
>   (__gnat_decode): Likewise.

This change is not OK: adadecode.c is also a runtime file and as such cannot
include compiler include files.

>   * gcc-interface/utils.c (def_builtin_1): Use startswith
>   function instead of strncmp.

>   * init.c (__gnat_install_handler): Likewise.

Same for init.c which is both a host and a runtime/target file.

Only the change in utils.c is OK.

Arno


[PATCH 1/3] Come up with startswith function.

2021-04-21 Thread Martin Liska

gcc/ada/ChangeLog:

* adadecode.c (has_prefix): Remove has_prefix and replace it
with startswith.
(__gnat_decode): Likewise.
* gcc-interface/utils.c (def_builtin_1): Use startswith
function instead of strncmp.
* init.c (__gnat_install_handler): Likewise.

gcc/analyzer/ChangeLog:

* sm-file.cc (is_file_using_fn_p): Use startswith
function instead of strncmp.

gcc/ChangeLog:

* builtins.c (is_builtin_name): Use startswith
function instead of strncmp.
* collect2.c (main): Likewise.
(has_lto_section): Likewise.
(scan_libraries): Likewise.
* coverage.c (coverage_checksum_string): Likewise.
(coverage_init): Likewise.
* dwarf2out.c (is_cxx): Likewise.
(gen_compile_unit_die): Likewise.
* gcc-ar.c (main): Likewise.
* gcc.c (init_spec): Likewise.
(read_specs): Likewise.
(execute): Likewise.
(check_live_switch): Likewise.
* genattrtab.c (write_attr_case): Likewise.
(IS_ATTR_GROUP): Likewise.
* gencfn-macros.c (main): Likewise.
* gengtype.c (type_for_name): Likewise.
(gen_rtx_next): Likewise.
(get_file_langdir): Likewise.
(write_local): Likewise.
* genmatch.c (get_operator): Likewise.
(get_operand_type): Likewise.
(expr::gen_transform): Likewise.
* genoutput.c (validate_optab_operands): Likewise.
* incpath.c (add_sysroot_to_chain): Likewise.
* langhooks.c (lang_GNU_C): Likewise.
(lang_GNU_CXX): Likewise.
(lang_GNU_Fortran): Likewise.
(lang_GNU_OBJC): Likewise.
* lto-wrapper.c (run_gcc): Likewise.
* omp-general.c (omp_max_simt_vf): Likewise.
* omp-low.c (omp_runtime_api_call): Likewise.
* opts-common.c (parse_options_from_collect_gcc_options): Likewise.
* read-rtl-function.c (function_reader::read_rtx_operand_r): Likewise.
* real.c (real_from_string): Likewise.
* selftest.c (assert_str_startswith): Likewise.
* timevar.c (timer::validate_phases): Likewise.
* tree.c (get_file_function_name): Likewise.
* ubsan.c (ubsan_use_new_style_p): Likewise.
* varasm.c (default_function_rodata_section): Likewise.
(incorporeal_function_p): Likewise.
(default_section_type_flags): Likewise.
* system.h (startswith): Define startswith.

gcc/c-family/ChangeLog:

* c-ada-spec.c (print_destructor): Use startswith
function instead of strncmp.
(dump_ada_declaration): Likewise.
* c-common.c (disable_builtin_function): Likewise.
(def_builtin_1): Likewise.
* c-format.c (check_tokens): Likewise.
(check_plain): Likewise.
(convert_format_name_to_system_name): Likewise.

gcc/c/ChangeLog:

* c-aux-info.c (affix_data_type): Use startswith
function instead of strncmp.
* c-typeck.c (build_function_call_vec): Likewise.
* gimple-parser.c (c_parser_gimple_parse_bb_spec): Likewise.

gcc/cp/ChangeLog:

* decl.c (duplicate_decls): Use startswith
function instead of strncmp.
(cxx_builtin_function): Likewise.
(omp_declare_variant_finalize_one): Likewise.
(grokfndecl): Likewise.
* error.c (dump_decl_name): Likewise.
* mangle.c (find_decomp_unqualified_name): Likewise.
(write_guarded_var_name): Likewise.
(decl_tls_wrapper_p): Likewise.
* parser.c (cp_parser_simple_type_specifier): Likewise.
(cp_parser_tx_qualifier_opt): Likewise.
* pt.c (template_parm_object_p): Likewise.
(dguide_name_p): Likewise.

gcc/d/ChangeLog:

* d-builtins.cc (do_build_builtin_fn): Use startswith
function instead of strncmp.
* dmd/dinterpret.c (evaluateIfBuiltin): Likewise.
* dmd/dmangle.c: Likewise.
* dmd/hdrgen.c: Likewise.
* dmd/identifier.c (Identifier::toHChars2): Likewise.

gcc/fortran/ChangeLog:

* decl.c (variable_decl): Use startswith
function instead of strncmp.
(gfc_match_end): Likewise.
* gfortran.h (gfc_str_startswith): Likewise.
* module.c (load_omp_udrs): Likewise.
(read_module): Likewise.
* options.c (gfc_handle_runtime_check_option): Likewise.
* primary.c (match_arg_list_function): Likewise.
* trans-decl.c (gfc_get_symbol_decl): Likewise.
* trans-expr.c (gfc_conv_procedure_call): Likewise.
* trans-intrinsic.c (gfc_conv_ieee_arithmetic_function): Likewise.

gcc/go/ChangeLog:

* gofrontend/runtime.cc (Runtime::name_to_code): Use startswith
function instead of strncmp.

gcc/objc/ChangeLog:

* objc-act.c (objc_string_ref_type_p): Use startswith
function instead of strncmp.
* objc-encoding.c (encode_type): Likewise.
* objc-next-runtime-abi-02.c (has_load_impl): Likewise.
---
 gcc/ada/adadecode