-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parser: check argument size on static array parameters
- Loading branch information
Showing
5 changed files
with
64 additions
and
1 deletion.
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
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,19 @@ | ||
//aro-args -std=c23 | ||
#include <stddef.h> | ||
void foo(int x[static 10]) { | ||
|
||
} | ||
|
||
void bar(void) { | ||
foo(NULL); | ||
foo(nullptr); | ||
foo(0); | ||
} | ||
|
||
#define EXPECTED_ERRORS "array argument is null.c:8:9: warning: null passed to a callee that requires a non-null argument [-Wnonnull]"\ | ||
"stddef.h:17:14: note: expanded from here"\ | ||
"array argument is null.c:3:14: note: callee declares array parameter as static here"\ | ||
"array argument is null.c:9:9: warning: null passed to a callee that requires a non-null argument [-Wnonnull]"\ | ||
"array argument is null.c:3:14: note: callee declares array parameter as static here"\ | ||
"array argument is null.c:10:9: warning: null passed to a callee that requires a non-null argument [-Wnonnull]"\ | ||
"array argument is null.c:3:14: note: callee declares array parameter as static here" |
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,11 @@ | ||
void foo(int x[static 10]) { | ||
|
||
} | ||
|
||
void bar(void) { | ||
int x[5]; | ||
foo(x); | ||
} | ||
|
||
#define EXPECTED_ERRORS "array argument too small.c:7:9: warning: array argument is too small; contains 5 elements, callee requires at least 10 [-Warray-bounds]"\ | ||
"array argument too small.c:1:14: note: callee declares array parameter as static here" |