On Tue, May 30, 2023 at 10:03:05AM +0200, Eric Botcazou wrote: > > We want to be able to treat such things as invariant somehow even if we > > can't do that for references to user data that might be changed by > > intervening code. > > > > That is, indicate that we know that the _REF actually refers to a const > > variable or is otherwise known to be unchanging. > > > > Perhaps that should be a new flag that tree_invariant_p can check > > instead of TREE_READONLY. > > Richard earlier suggested a langhook; given that Ada will be the main (sole?) > user of it, this would probably be better.
Are the DECL_INVARIANT_P FIELD_DECLs in Ada really invariant no matter how exactly they are accessed? Or can Ada suffer from the same problem as C/C++, where the FIELD_DECL is TREE_READONLY, but could go out of scope or a pointer to it could change. I mean the p->fld cases in C/C++, where there could be free (p); or p++ etc. in between the place where save_expr is first evaluated and later uses? Jakub