summary refs log tree commit diff stats
path: root/compiler/c2nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-03-16 20:07:36 +0100
committerAraq <rumpf_a@web.de>2013-03-16 20:07:36 +0100
commit2782e885915e5405f878517358370255aea9488d (patch)
tree76d3d10339a9b4c8410124db7a74d2df6881d94d /compiler/c2nim
parentc445bd140aed6b731efb4b953f0f3768311cdf51 (diff)
downloadNim-2782e885915e5405f878517358370255aea9488d.tar.gz
fixes #323
Diffstat (limited to 'compiler/c2nim')
-rwxr-xr-xcompiler/c2nim/cparse.nim11
-rwxr-xr-xcompiler/c2nim/tests/systest.c14
2 files changed, 23 insertions, 2 deletions
diff --git a/compiler/c2nim/cparse.nim b/compiler/c2nim/cparse.nim
index 9f7a7bf36..b964ed976 100755
--- a/compiler/c2nim/cparse.nim
+++ b/compiler/c2nim/cparse.nim
@@ -955,15 +955,22 @@ proc enumSpecifier(p: var TParser): PNode =
     result = newNodeP(nkConstSection, p)
     getTok(p, result)
     var i = 0
+    var hasUnknown = false
     while true:
       var name = skipIdentExport(p)
       var val: PNode
       if p.tok.xkind == pxAsgn: 
         getTok(p, name)
         val = constantExpression(p)
-        if val.kind == nkIntLit: i = int(val.intVal)+1
-        else: parMessage(p, errXExpected, "int literal")
+        if val.kind == nkIntLit:  
+          i = int(val.intVal)+1
+          hasUnknown = false
+        else:
+          hasUnknown = true
       else:
+        if hasUnknown:
+          parMessage(p, warnUser, "computed const value may be wrong: " &
+            name.renderTree)
         val = newIntNodeP(nkIntLit, i, p)
         inc(i)
       var c = createConst(name, ast.emptyNode, val, p)
diff --git a/compiler/c2nim/tests/systest.c b/compiler/c2nim/tests/systest.c
index 2a9dd6c28..b73eb5bee 100755
--- a/compiler/c2nim/tests/systest.c
+++ b/compiler/c2nim/tests/systest.c
@@ -9,6 +9,20 @@ extern "C" {
 #  endif
 #endif
 
+enum
+{
+/* 8bit, color or not */
+    CV_LOAD_IMAGE_UNCHANGED  =-1,
+/* 8bit, gray */
+    CV_LOAD_IMAGE_GRAYSCALE  =0,
+/* ?, color */
+    CV_LOAD_IMAGE_COLOR      =1,
+/* any depth, ? */
+    CV_LOAD_IMAGE_ANYDEPTH   =2,
+/* ?, any color */
+    CV_LOAD_IMAGE_ANYCOLOR   =4
+};
+
 typedef void (*callback_t) (int rc);
 typedef const char* (*callback2)(int rc, long L, const char* buffer);