terminate called without an active exception

Hi,

Given the following (invalid, type_5 is not defined) code.

// BEGIN
typedef enum { type_1 , type_2 , type_3 , type_4 } types;

_Bool testfunc(types t){
        switch(t)
        {
                case type_1:
                case type_2:
                case type_5:{
                        return true;
                } break;
                default: {
                        return false;
                }
        }
}
// END

clang called as follows
# clang -c -emit-llvm test.c -o test.bc

results in

test.c:8:8: error: use of undeclared identifier 'type_5'
                case type_5:{
                     ^
test.c:9:11: error: use of undeclared identifier 'true'
                        return true;
                               ^
test.c:12:11: error: use of undeclared identifier 'false'
                        return false;
                               ^
pure virtual method called
terminate called without an active exception
0 clang-cc 0x000000000120a0a4
1 clang-cc 0x000000000120a585
2 libpthread.so.0 0x00007f3f226bda00
3 libc.so.6 0x00007f3f217cd1e5 gsignal + 53
4 libc.so.6 0x00007f3f217ce703 abort + 387
5 libstdc++.so.6 0x00007f3f22051e44 __gnu_cxx::__verbose_terminate_handler() + 276
6 libstdc++.so.6 0x00007f3f22050246
7 libstdc++.so.6 0x00007f3f22050273
8 libstdc++.so.6 0x00007f3f22050b1f
9 clang-cc 0x000000000045fc50
10 clang-cc 0x0000000000679792
11 clang-cc 0x00000000007a61b0
12 clang-cc 0x00000000007a4341
13 clang-cc 0x00000000007a78b0
14 clang-cc 0x00000000007a7e48
15 clang-cc 0x0000000000779833
16 clang-cc 0x000000000077a379
17 clang-cc 0x000000000077a934
18 clang-cc 0x000000000077a9e5
19 clang-cc 0x00000000005e2fd6
20 clang-cc 0x00000000004896cd
21 clang-cc 0x000000000048ab28 main + 2154
22 libc.so.6 0x00007f3f217b95c6 __libc_start_main + 230
23 clang-cc 0x000000000042d269
Stack dump:
0. Program arguments: /home/scott/software2/bin/../libexec/clang-cc -triple x86_64-unknown-linux-gnu -emit-llvm-bc -disable-free -main-file-name test.c --relocation-model static --disable-fp-elim --unwind-tables=1 --mcpu=x86-64 --fmath-errno=1 -fdiagnostics-show-option -o test.bc -x c test.c
1. test.c:15:1: current parser token '}'
2. test.c:3:24: parsing function body 'testfunc'
3. test.c:3:24: in compound statement ('{}')

Regards,

Scott

Given the following (invalid, type_5 is not defined) code.

[snip]

pure virtual method called
terminate called without an active exception

This looks like http://llvm.org/bugs/show_bug.cgi?id=3444 .

-Eli

Eli Friedman wrote:

Hi Scott,

I think this is related to http://llvm.org/bugs/show_bug.cgi?id=3444 . In short, we have some serious problems handling error recovery + switch statements right now. I added your example to the PR.

-Chris