<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/111509>111509</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang++] Unnecessary warning "non-void function does not return a value in all control paths"
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mkornaukhov03
      </td>
    </tr>
</table>

<pre>
    I have the following snippet:
```c++
int foo(int) {
    bool matched = false;
    do {
      if (matched) {
        break;
      }
 return 42;
    } while(false);
}


int main() {
 foo(42);
}

```
I compile it with `clang++-18`:
```
$ clang++-18 --version
Ubuntu clang version 18.1.8 (++20240731024944+3b5b5c1ec4a3-1~exp1~20240731145000.144)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang++-18 -Wreturn-type main.cpp 
main.cpp:9:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
    9 | }
      | ^
1 warning generated.
```
Variable `matched` is effectively constant and there are no paths that "do not return a value".
The expected behavior is such that there should be no such warning.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVMGO4ygQ_RpyKdkCDI598KF7si3NfWf3uMK4YrNNwAKcTl_m21fYTk9HM7uXlazEmFev6lU9UDGa0SF2RD4TeTqoJU0-dJdXH5xaXid_pdWh98N79xUmdUVIE8LZW-vfjBshOjPPmEj1ROiJ0CdS0-3RhD_nZ_1qXIKz94Q3xiXCWyDHfQcAoPfewkUlPeEApDrBWdmIpPoEGfxjCIA5A-HNHvUT5UobUL0-sACQ42lfBkxLcCD4A4IcT_A2GYuEN1sVvP0AfAR__s3SLso4wpvHKja9gv8Xw71Z2_IraH-ZjUUwCd5MmiD30So3br0sWJOxP7V6X3IBj2AoiiuGaLzbEN_6xaVlA8G-A6wpWdnAWn6O45QLeqwY5aIVgvDnqpe91Ay1UFXBvuNtZt_vICYkpbRkGdhuSX5XYVz9ALem_qsWxawLa9xyK0a37JApoBrg4ge0GTj7aG7_LuLPbVRFep9xbXWp5xk2_H1JqqeWVE8s072p4Iwb86vzrrh6M8B5cTpluYPHCM6n-_wVXJVdEIwDZS1o71LwFmaVpghEPj9kJ_L0wyp51l8-GWr31xcg8rftE7uXAiM6DCrhUP5ydH-oYFRvMc_77uiagomA5zPqZK5o33NtMSmXQLkhn8KAoAKC83u1aVIJCOeD_4VAwnl57z4C3mbUCQfocVJX40POFRc9bSQbeZz8YjMkp1g3dznlYeiqoa1adcCOHXlTNZRTeZg6IeVwlnUv5KBVVWvUsq6PUg1C1OfjUR9Ml63DKG1oW9VClhJVWzVHygRlsuqRCIoXZWxp7fVS-jAeTIwLdowxSduDVT3auN5VnO9G4fnaCl0OKPpljERQa2KKPyiSSXa94D5Zi8gTfHMONcaowvvHqAjn_881hPPDEmw3pTTHfFj5C-Evo0nT0pfaXwh_yYXtf8Uc_N-oE-Evq9BI-Muu9drxfwIAAP__DyOm0Q">