https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117755
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Joseph Myers <js...@gcc.gnu.org>: https://gcc.gnu.org/g:980929bdb80f1a1490caab5acc6d9740e0f9b539 commit r15-5664-g980929bdb80f1a1490caab5acc6d9740e0f9b539 Author: Joseph Myers <josmy...@redhat.com> Date: Tue Nov 26 03:25:44 2024 +0000 c: Fix ICEs from invalid atomic compound assignment [PR98195, PR117755] As reported in bug 98195, there are ICEs from an _Atomic compound assignment with an incomplete type on the RHS, arising from an invalid temporary being created with such a type. As reported in bug 117755, there are also (different) ICEs in cases with complete types where the binary operation itself is invalid, when inside a nested function, arising from a temporary being created for the RHS, but then not used because the binary operation returns error_mark_node, resulting in the temporary not appearing in a TARGET_EXPR, never getting its DECL_CONTEXT set by the gimplifier and eventually resulting in an ICE in nested function processing (trying to find a function context for the temporary) as a result. Fix the first ICE with an earlier check for a complete type for the RHS of an assignment so the problematic temporary is never created for an incomplete type (which changes the error message three existing tests get for that case; the new message seems as good as the old one). Fix the second ICE by ensuring that once a temporary has been created, it always gets a corresponding TARGET_EXPR even on error. Bootstrapped with no regressions for x86_64-pc-linux-gnu. PR c/98195 PR c/117755 gcc/c/ * c-typeck.cc (build_atomic_assign): Always create a TARGET_EXPR for newval even in case of error from binary operation. (build_modify_expr): Check early for incomplete type of rhs. gcc/testsuite/ * gcc.dg/pr98195-1.c, gcc.dg/pr117755-1.c: New tests. * gcc.dg/noncompile/20020207-1.c, gcc.dg/pr14765-1.c, objc.dg/method-11.m: Update expected error messages.