On 11/21/2017 06:52 AM, Jakub Jelinek wrote:
> Hi!
> 
> The C++ FE now emits __builtin_unreachable () with BUILTINS_LOCATION
> on spots that return from functions/methods returning non-void without
> proper return.  This breaks the -Wreturn-type warning, because we then
> don't see any return stmt without argument on the edges to exit, instead
> we see those __builtin_unreachable () calls at the end of blocks without
> successors.
> 
> I wonder if the C++ FE addition of __builtin_unreachable () shouldn't be
> done only if (optimize).
> 
> Anyway, this patch tweaks tree-cfg.c so that it recognizes those
> __builtin_unreachable () calls and reports the -Wreturn-type warning
> in those cases too (warning in the FE would be too early, we need to
> optimize away unreachable code).
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> The patch regresses g++.dg/gomp/declare-simd-1.C, but given that it revealed
> a real bug, I'm not trying to work around it in the patch and will fix it up
> incrementally instead.
> 
> 2017-11-21  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR c++/83045
>       * tree-cfg.c (pass_warn_function_return::execute): Formatting fix.
>       Also warn if seen __builtin_unreachable () call with BUILTINS_LOCATION.
>       Use LOCATION_LOCUS when comparing against UNKNOWN_LOCATION.
> 
>       * c-c++-common/pr61405.c (fn0, fn1): Add return stmts.
>       * c-c++-common/Wlogical-op-2.c (fn): Likewise.
>       * g++.dg/debug/pr53466.C: Add -Wno-return-type to dg-options.
>       * g++.dg/opt/combine.C: Likewise.
>       * g++.dg/ubsan/return-3.C: Likewise.
>       * g++.dg/pr59445.C: Likewise.
>       * g++.dg/pr49847.C: Likewise.
>       * g++.dg/ipa/pr61800.C: Likewise.
>       * g++.dg/ipa/pr63470.C: Likewise.
>       * g++.dg/ipa/pr68672-1.C: Likewise.
>       * g++.dg/pr58438.C: Likewise.
>       * g++.dg/torture/pr59265.C: Likewise.
>       * g++.dg/tree-ssa/ssa-dse-2.C: Likewise.
>       * g++.old-deja/g++.eh/catch13.C: Likewise.
>       * g++.old-deja/g++.eh/crash1.C: Likewise.
>       * g++.dg/tm/pr60004.C: Expect -Wreturn-type warning.
>       * g++.dg/torture/pr55740.C: Likewise.
>       * g++.dg/torture/pr43257.C: Likewise.
>       * g++.dg/torture/pr64280.C: Likewise.
>       * g++.dg/torture/pr54684.C: Likewise.
>       * g++.dg/torture/pr56694.C: Likewise.
>       * g++.dg/torture/pr68470.C: Likewise.
>       * g++.dg/torture/pr60648.C: Likewise.
>       * g++.dg/torture/pr71281.C: Likewise.
>       * g++.dg/torture/pr52772.C: Add -Wno-return-type dg-additional-options.
>       * g++.dg/torture/pr64669.C: Likewise.
>       * g++.dg/torture/pr58369.C: Likewise.
>       * g++.dg/torture/pr33627.C: Likewise.
>       * g++.dg/torture/predcom-1.C: Add
>       #pragma GCC diagnostic ignored "-Wreturn-type".
>       * g++.dg/lto/20090221_0.C: Likewise.
>       * g++.dg/lto/20091026-1_1.C: Likewise.
>       * g++.dg/lto/pr54625-1_1.C: Likewise.
>       * g++.dg/warn/pr83045.C: New test.
OK.
jeff

Reply via email to