diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2008-07-25 01:11:38 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2008-07-25 01:11:38 +0000 |
| commit | 0e5845c13a70e429d896f032da45211a746c8267 (patch) | |
| tree | 1b47178c2cba5e4529610e7e00ec13e79f5ac4cf /clang/test/CodeGen/rdr-6098585-empty-case-range.c | |
| parent | dd49a04d18ef6068c7bb6763e83a351d43563d84 (diff) | |
| download | bcm5719-llvm-0e5845c13a70e429d896f032da45211a746c8267.tar.gz bcm5719-llvm-0e5845c13a70e429d896f032da45211a746c8267.zip | |
Rework codegen of case ranges
- Fix multiple issues with the way case ranges were emitted, see test
cases details about the specific issues.
- The root issue was not being careful about how basic blocks were
emitted which led to them being chained together incorrectly,
resulting in improper control flow.
- Fixes <rdar://problem/6098585>
llvm-svn: 54006
Diffstat (limited to 'clang/test/CodeGen/rdr-6098585-empty-case-range.c')
| -rw-r--r-- | clang/test/CodeGen/rdr-6098585-empty-case-range.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/test/CodeGen/rdr-6098585-empty-case-range.c b/clang/test/CodeGen/rdr-6098585-empty-case-range.c new file mode 100644 index 00000000000..2dc3cf3da85 --- /dev/null +++ b/clang/test/CodeGen/rdr-6098585-empty-case-range.c @@ -0,0 +1,23 @@ +// RUN: clang --emit-llvm-bc -o - %s | opt -std-compile-opts | llvm-dis > %t && +// RUN: grep "ret i32" %t | count 2 && +// RUN: grep "ret i32 3" %t | count 2 + +// This generated incorrect code because of poor switch chaining. +int f1(int x) { + switch(x) { + default: + return 3; + case 10 ... 0xFFFFFFFF: + return 0; + } +} + +// This just asserted because of the way case ranges were calculated. +int f2(int x) { + switch (x) { + default: + return 3; + case 10 ... -1: + return 0; + } +} |

