Skip to content
  • Michael Tautschnig's avatar
    Insert assert(0) into the body of reach_error · 07dd9f37
    Michael Tautschnig authored
    As discussed in the (virtual) community meeting on 2020-09-18,
    unreach-call may be turned into plain assertion checking. As first step,
    make the body of reach_error() `assert(0);`. For preprocessed files, the
    result of assert(0) expansion is what we get on Ubuntu 18.04 with glibc
    and GCC 7.5.0.
    This change was previously made in 7341f59b, which did not properly handle
    the case of reach_error not being defined in the main source file. This
    commit now only handle files that do define it in the main source file. Other
    tasks will be handled in a separate commit.
    The changes were done using the following command:
    for f in c/*/*.c
    export bn=$(basename $f .c)
    dn=$(dirname $f)
    test -e $dn/$bn.i
    export p=$?
    perl -i -e \
      '$p = $ENV{p}; $i = 0; $e = 0;
       while(<>) {
         if(p == 0 && /^#include\s*<assert.h>/) {
           $p = 2;
         elsif(p == 1 && /^extern void __assert_fail/) {
           $p = 3;
         elsif(/^void reach_error\(\)\s*\{\...