On Thu, Jan 28, 2021 at 12:08 AM Martin Sebor via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Attached is another attempt to fix the problem caused by allowing > front-end trees representing nontrivial VLA bound expressions to > stay in attribute access attached to functions. Since removing > these trees seems to be everyone's preference this patch does that > by extending the free_lang_data pass to look for and zero out these > trees. > > Because free_lang_data only frees anything when LTO is enabled and > we want these trees cleared regardless to keep them from getting > clobbered during gimplification, this change also modifies the pass > to do the clearing even when the pass is otherwise inactive.
if (TREE_CODE (bound) == NOP_EXPR) + bound = TREE_OPERAND (bound, 0); + + if (TREE_CODE (bound) == CONVERT_EXPR) + { + tree op0 = TREE_OPERAND (bound, 0); + tree bndtyp = TREE_TYPE (bound); + tree op0typ = TREE_TYPE (op0); + if (TYPE_PRECISION (bndtyp) == TYPE_PRECISION (op0typ)) + bound = op0; + } + + if (TREE_CODE (bound) == NON_LVALUE_EXPR) + bound = TREE_OPERAND (bound, 0); all of the above can be just STRIP_NOPS (bound); which also handles nesting of the above in any order. + if (TREE_CODE (bound) == PLUS_EXPR + && integer_all_onesp (TREE_OPERAND (bound, 1))) + { + bound = TREE_OPERAND (bound, 0); + if (TREE_CODE (bound) == NOP_EXPR) + bound = TREE_OPERAND (bound, 0); + } so it either does or does not strip a -1 but has no indication on whether it did that? That looks fragile and broken. Anyway, the split out of this function seems unrelated to the original problem and should be submitted separately. + for (vblist = TREE_VALUE (vblist); vblist; vblist = TREE_CHAIN (vblist)) + { + tree *pvbnd = &TREE_VALUE (vblist); + if (!*pvbnd || DECL_P (*pvbnd)) + continue; so this doesn't let constant bounds prevail but only symbolical ones? Not that I care but I'd have expected || CONSTANT_CLASS_P (*pvbnd) The free-lang-data parts are OK. Richard. > Tested on x86_64-linux. > > Martin