summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2019-09-04 19:39:25 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2019-09-15 17:12:45 +0000
commit073dcd088215c4eaafe90a256e398b83327888e6 (patch)
tree53117303d734ff3651243e043b2fc8c67f763f71 /giscanner
parentd08b5019099a6375563ede434d29038e6916256e (diff)
downloadgobject-introspection-073dcd088215c4eaafe90a256e398b83327888e6.tar.gz
Support array arguments with static keyword
C99 allows defining an array argument with a fixed size as: void foo (int arr[static 10]) Compilers conforming to the C99 specification will be able to warn if the function is called with NULL or with an array smaller than the specified length, something that does not happen when using pre-C99 declarations like: void foo (int arr[10]) As the declaration above is identical to: void foo (int arr[]) Which is, in turn, identical to: void foo (int *arr) Fixes: #309
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/scannerparser.y11
1 files changed, 11 insertions, 0 deletions
diff --git a/giscanner/scannerparser.y b/giscanner/scannerparser.y
index 6a2ffc1d..decd0f2b 100644
--- a/giscanner/scannerparser.y
+++ b/giscanner/scannerparser.y
@@ -1091,6 +1091,12 @@ enum_keyword
}
;
+static_keyword
+ : STATIC
+ {
+ }
+ ;
+
enumerator_list
:
{
@@ -1174,6 +1180,11 @@ direct_declarator
{
$$ = $2;
}
+ | direct_declarator '[' static_keyword assignment_expression ']'
+ {
+ $$ = $1;
+ gi_source_symbol_merge_type ($$, gi_source_array_new ($4));
+ }
| direct_declarator '[' assignment_expression ']'
{
$$ = $1;