]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Set the outer brace marker for missed cases.
authorIain Sandoe <iain@sandoe.co.uk>
Sat, 10 May 2025 16:12:44 +0000 (17:12 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Tue, 29 Jul 2025 15:00:56 +0000 (16:00 +0100)
In some cases, a function might be declared as FUNCTION_NEEDS_BODY_BLOCK
but all the content is contained within that block.  However, poplevel
is currently assuming that such cases would always contain subblocks.

In the case that we do have a body block, but there are no subblocks
then st the outer brace marker on the body block.  This situation occurs
for at least coroutine lambda ramp functions and empty constructors.

gcc/cp/ChangeLog:

* decl.cc (poplevel): Set BLOCK_OUTER_CURLY_BRACE_P on the
body block for functions with no subblocks.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 689bc394efe9e042acb37799deec6568c0f63a45)

gcc/cp/decl.cc

index 4e97093b1341d0e62be97963436d91321db383ca..9cf75936d7af1ce594a68ddcf94a6d61b9443ee8 100644 (file)
@@ -846,11 +846,9 @@ poplevel (int keep, int reverse, int functionbody)
       DECL_INITIAL (current_function_decl) = block ? block : subblocks;
       if (subblocks)
        {
-         if (FUNCTION_NEEDS_BODY_BLOCK (current_function_decl))
-           {
-             if (BLOCK_SUBBLOCKS (subblocks))
-               BLOCK_OUTER_CURLY_BRACE_P (BLOCK_SUBBLOCKS (subblocks)) = 1;
-           }
+         if (FUNCTION_NEEDS_BODY_BLOCK (current_function_decl)
+             && BLOCK_SUBBLOCKS (subblocks))
+           BLOCK_OUTER_CURLY_BRACE_P (BLOCK_SUBBLOCKS (subblocks)) = 1;
          else
            BLOCK_OUTER_CURLY_BRACE_P (subblocks) = 1;
        }