-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parser: improve return detection for switch statments
- Loading branch information
1 parent
557fcc0
commit 7d79206
Showing
2 changed files
with
91 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
int test1(int a){ | ||
switch(a){ | ||
return 1; | ||
}; | ||
return 1; | ||
} | ||
int test2(int a){ | ||
switch(a){ | ||
return 1; | ||
a=1; | ||
a=1; | ||
}; | ||
return 1; | ||
} | ||
int test3(int a){ | ||
switch(a){ | ||
default: | ||
return 1; | ||
}; | ||
return 1; | ||
} | ||
int test4(int a){ | ||
switch(a) { | ||
case 1: a=1; break; | ||
} | ||
return 1; | ||
} | ||
int test5(int a){ | ||
switch(a) { | ||
default: return 1; break; | ||
} | ||
return 1; | ||
} | ||
int test6(int a){ | ||
switch(a) { | ||
default: a=1; break; | ||
} | ||
if (a) return 0; | ||
return 1; | ||
} | ||
int test7(int a){ | ||
{ | ||
return 0; | ||
} | ||
} | ||
int test8(int a){ | ||
{ | ||
return 0; | ||
a=1; | ||
} | ||
} | ||
int test9(int a){ | ||
{ | ||
return 0; | ||
a=1; | ||
a=1; | ||
a=1; | ||
} | ||
} | ||
int test10(int a){ | ||
switch (a)case a: return 1; | ||
return 1; | ||
} | ||
#define EXPECTED_ERRORS "unreachable code.c:4:3: warning: unreachable code [-Wunreachable-code]" \ | ||
"unreachable code.c:10:3: warning: unreachable code [-Wunreachable-code]" \ | ||
"unreachable code.c:12:3: warning: unreachable code [-Wunreachable-code]" \ | ||
"unreachable code.c:19:3: warning: unreachable code [-Wunreachable-code]" \ | ||
"unreachable code.c:32:2: warning: unreachable code [-Wunreachable-code]" \ | ||
"unreachable code.c:49:3: warning: unreachable code [-Wunreachable-code]" \ | ||
"unreachable code.c:55:3: warning: unreachable code [-Wunreachable-code]" \ | ||
"unreachable code.c:61:16: error: case value must be an integer constant expression" |