Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-04-15 Thread Jason Merrill
On 3/30/25 6:12 PM, Jan Hubicka wrote: Hi, I noticed that this patch got forgotten and I think it may be useful to solve this next stage 1. cp_apply_type_quals_to_decl drops 'const' if the type has mutable members. Unfortunately TREE_READONLY on the PARM_DECL isn't helpful in the case of an inv

Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-03-30 Thread Jan Hubicka
Hi, I noticed that this patch got forgotten and I think it may be useful to solve this next stage 1. > > cp_apply_type_quals_to_decl drops 'const' if the type has mutable members. > Unfortunately TREE_READONLY on the PARM_DECL isn't helpful in the case of an > invisiref parameter. > > > > But ma

Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-01-08 Thread Jason Merrill
On 1/8/25 10:16 AM, Jan Hubicka wrote: On Wed, 8 Jan 2025, Jan Hubicka wrote: On Tue, 10 Dec 2024, Jan Hubicka wrote: Hi, int: struct foo { int a; void bar() const; ~foo() { if (a != 42) __builtin_abort (); } }; __attribute__ ((noinline)) void test(const struct foo a

Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-01-08 Thread Jan Hubicka
> On Wed, 8 Jan 2025, Jan Hubicka wrote: > > > > On Tue, 10 Dec 2024, Jan Hubicka wrote: > > > > > > > Hi, > > > > int: > > > > struct foo > > > > { > > > > int a; > > > > void bar() const; > > > > ~foo() > > > > { > > > > if (a != 42) > > > > __builtin_abort (); > > > > } > >

Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-01-08 Thread Richard Biener
On Wed, 8 Jan 2025, Jan Hubicka wrote: > > On Tue, 10 Dec 2024, Jan Hubicka wrote: > > > > > Hi, > > > int: > > > struct foo > > > { > > > int a; > > > void bar() const; > > > ~foo() > > > { > > > if (a != 42) > > > __builtin_abort (); > > > } > > > }; > > > __attribute__ ((no

Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-01-08 Thread Jan Hubicka
> On Tue, 10 Dec 2024, Jan Hubicka wrote: > > > Hi, > > int: > > struct foo > > { > > int a; > > void bar() const; > > ~foo() > > { > > if (a != 42) > > __builtin_abort (); > > } > > }; > > __attribute__ ((noinline)) > > void test(const struct foo a) > > { > > int b = a

Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-01-07 Thread Richard Biener
On Tue, 10 Dec 2024, Jan Hubicka wrote: > Hi, > int: > struct foo > { > int a; > void bar() const; > ~foo() > { > if (a != 42) > __builtin_abort (); > } > }; > __attribute__ ((noinline)) > void test(const struct foo a) > { > int b = a.a; > a.bar(); > if

Mark const parameters passed by invisible reference as readonly in the function body

2024-12-10 Thread Jan Hubicka
Hi, int: struct foo { int a; void bar() const; ~foo() { if (a != 42) __builtin_abort (); } }; __attribute__ ((noinline)) void test(const struct foo a) { int b = a.a; a.bar(); if (a.a != b) __builtin_printf ("optimize me away"); } struct foo is p