Last active
December 15, 2015 17:49
-
-
Save tetsuok/5298854 to your computer and use it in GitHub Desktop.
Toy programs to verify nested cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| void test_case(int n) { | |
| switch (n) { | |
| case 0: | |
| case 1: | |
| printf("case %d\n", n); | |
| break; | |
| case 2: | |
| printf("case %d\n", n); | |
| break; | |
| case 3: | |
| printf("case %d\n", n); | |
| break; | |
| default: | |
| printf("default n = %d\n", n); | |
| } | |
| } | |
| int main(void) { | |
| int i; | |
| for (i = 0; i < 5; i++) { | |
| test_case(i); | |
| } | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| void test_case(int n) { | |
| switch (n) { | |
| case 0: | |
| case 1: | |
| printf("case %d\n", n); | |
| break; | |
| case 2: | |
| printf("case %d\n", n); | |
| break; | |
| case 3: | |
| { | |
| printf("case %d\n", n); | |
| break; | |
| default: | |
| printf("default n = %d\n", n); | |
| } | |
| } | |
| } | |
| int main(void) { | |
| int i; | |
| for (i = 0; i < 5; i++) { | |
| test_case(i); | |
| } | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CC = gcc | |
| CFLAGS = -O0 | |
| FILES = \ | |
| case.s \ | |
| case2.s | |
| all: $(FILES) | |
| diff case.s case2.s | |
| clean: | |
| -rm -f *.s | |
| .c.s: | |
| $(CC) $(CFLAGS) -S $< |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment