diff options
author | Jack Palevich <jackpal@google.com> | 2009-08-19 10:53:43 -0700 |
---|---|---|
committer | Jack Palevich <jackpal@google.com> | 2009-08-19 10:53:43 -0700 |
commit | 0a01a5db5672b65f81732eaed6fb9fcccea16d06 (patch) | |
tree | dc4de12e9e6217fd8df453aaf7035a8163603b1c /libacc | |
parent | 761aeb431e6d1482754a98bba2b683ba8111ef88 (diff) | |
download | system_core-0a01a5db5672b65f81732eaed6fb9fcccea16d06.tar.gz system_core-0a01a5db5672b65f81732eaed6fb9fcccea16d06.tar.bz2 system_core-0a01a5db5672b65f81732eaed6fb9fcccea16d06.zip |
Handle functions with anonymous arguments
Example:
int f(int a, int, int c) {
return a + c;
}
Diffstat (limited to 'libacc')
-rw-r--r-- | libacc/acc.cpp | 8 | ||||
-rw-r--r-- | libacc/tests/data/funcargs.c | 8 | ||||
-rw-r--r-- | libacc/tests/test.py | 5 |
3 files changed, 19 insertions, 2 deletions
diff --git a/libacc/acc.cpp b/libacc/acc.cpp index 483a1ac62..6e195033a 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -4891,11 +4891,15 @@ class Compiler : public ErrorSink { int argCount = 0; for (Type* pP = pDecl->pTail; pP; pP = pP->pTail) { Type* pArg = pP->pHead; - addLocalSymbol(pArg); + if (pArg->id) { + addLocalSymbol(pArg); + } /* read param name and compute offset */ size_t alignment = pGen->stackAlignmentOf(pArg); a = (a + alignment - 1) & ~ (alignment-1); - VI(pArg->id)->pAddress = (void*) a; + if (pArg->id) { + VI(pArg->id)->pAddress = (void*) a; + } a = a + pGen->stackSizeOf(pArg); argCount++; } diff --git a/libacc/tests/data/funcargs.c b/libacc/tests/data/funcargs.c new file mode 100644 index 000000000..1dce2263c --- /dev/null +++ b/libacc/tests/data/funcargs.c @@ -0,0 +1,8 @@ +int f(int a,int, int c) { + return a + c; +} + +int main() { + return f(1,2,3); +} + diff --git a/libacc/tests/test.py b/libacc/tests/test.py index ed203341f..bef9fc64e 100644 --- a/libacc/tests/test.py +++ b/libacc/tests/test.py @@ -439,6 +439,11 @@ result: 0 result: 3 ""","""""") + def testFuncArgs(self): + self.compileCheck(["-R", "data/funcargs.c"], """Executing compiled code: +result: 4 +""","""""") + def main(): parseArgv() if not outputCanRun(): |