diff options
author | Vincent Burns <discoloda@gmail.com> | 2014-01-13 01:51:36 -0500 |
---|---|---|
committer | Vincent Burns <discoloda@gmail.com> | 2014-01-13 01:51:36 -0500 |
commit | 5f905865bed2080c49b29dd48decdd24c4702cc9 (patch) | |
tree | 8fead84fbf7640df25467069f5bbaf6ce419afe7 /compiler | |
parent | 58855c2fc71294bd08ca6637473a33389ecc7de5 (diff) | |
download | Nim-5f905865bed2080c49b29dd48decdd24c4702cc9.tar.gz |
Fix for some comments during if statements
added test files
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/c2nim/cparse.nim | 2 | ||||
-rw-r--r-- | compiler/c2nim/tests/vincent.c | 21 | ||||
-rw-r--r-- | compiler/c2nim/tests/vincent.h | 3 |
3 files changed, 25 insertions, 1 deletions
diff --git a/compiler/c2nim/cparse.nim b/compiler/c2nim/cparse.nim index aa2dfa3e1..30cee180a 100644 --- a/compiler/c2nim/cparse.nim +++ b/compiler/c2nim/cparse.nim @@ -1473,12 +1473,12 @@ proc parseIf(p: var TParser): PNode = while true: getTok(p) # skip ``if`` var branch = newNodeP(nkElifBranch, p) - skipCom(p, branch) eat(p, pxParLe, branch) addSon(branch, expression(p)) eat(p, pxParRi, branch) addSon(branch, nestedStatement(p)) addSon(result, branch) + skipCom(p, branch) if p.tok.s == "else": getTok(p, result) if p.tok.s != "if": diff --git a/compiler/c2nim/tests/vincent.c b/compiler/c2nim/tests/vincent.c new file mode 100644 index 000000000..b9436c39b --- /dev/null +++ b/compiler/c2nim/tests/vincent.c @@ -0,0 +1,21 @@ +#include <stdlib.h> +#include <stdio.h> + +int rand(void); + +int main() { + float f = .2, + g = 2., + h = 1.0+rand(), + i = 1.0e+3; + int j, a; + for(j = 0, a = 10; j < 0; j++, a++) ; + do { + printf("howdy"); + } while(--i, 0); + if(1) + printf("1"); // error from this comment + else + printf("2"); + return '\x00'; +} diff --git a/compiler/c2nim/tests/vincent.h b/compiler/c2nim/tests/vincent.h new file mode 100644 index 000000000..b4e761ee1 --- /dev/null +++ b/compiler/c2nim/tests/vincent.h @@ -0,0 +1,3 @@ +struct foo { + int x,y,z; +}; |