Menu

#158 Multi-dimensional parameters are not handled correctly

open
5
2012-12-29
2005-01-13
Anonymous
No

Definitions of functions having a parameter with a
multi-dimensional array type are not parsed correctly.
For example, the following snippet is a legal piece of
C code. f2 accepts a two-dimensional array where the
first dimension can vary, whereas the second one may vary.

---8<---
void f1(int x[]) {
}

void f2(int x[][2]) {
int a;
a = 1;
}

int main() {
int x[5];
int y[5][2];

f1(x);
f2(y);

return 0;
}
---8<---

If you query the global definitions in this code, you
will get the following:

---8<---
% cscope -L -1 ".*" test.c
test.c .* 1 void f1(int x[]) {
test.c .* 5 int a;
test.c .* 6 a = 1;
test.c .* 9 int main() {
---8<---

If you replace the definition of f2 by "void f2(int
x[][]) {" (which is no longer valid C code), the query
returns the expected result:

---8<---
% cscope -L -1 ".*" test.c
test.c .* 1 void f1(int x[]) {
test.c .* 4 void f2(int x[][]) {
test.c .* 9 int main() {
---8<---
--
Andreas Mayer (amayer@fzi.de)

Discussion


Log in to post a comment.

MongoDB Logo MongoDB