Make undefined constants keep types

This commit is contained in:
Joey Yakimowich-Payne 2020-05-13 17:29:26 -06:00
commit 0deb2939bf
4 changed files with 22 additions and 27 deletions

View file

@ -42,17 +42,16 @@ extern "C" {
#define REG_STR "regular string"
#define NOTSUPPORTEDSTR "not a " REG_STR
#define NULLCHAR '\0'/* comments should not break things*/
#define OCTCHAR '\012' // nor should this comment
#define NULLCHAR '\0'
#define OCTCHAR '\012'
#define HEXCHAR '\xFE'
#define TRICKYSTR "\x4E\034\nfoo\0\'\"\r\v\a\b\e\f\t\\\?bar"
#define ALLSHL (SHL1 | SHL2 | SHL3)
// disable for windows for now
#ifndef _WIN32
// const not supported yet
const int SOME_CONST = 8;
#ifdef NIMTEROP
#define SOME_CONST 8
#endif
struct some_struct_s
{
@ -65,7 +64,6 @@ struct parent_struct_s
};
typedef struct some_struct_s SOME_ARRAY[SOME_CONST];
#endif
struct A0;
struct A1 {};

View file

@ -35,6 +35,7 @@ cOverride:
type
A1* = A0
cDefine("SOME_CONST=100")
cImport(path, flags="-f:ast2 -ENK_,SDL_ -GVICE=SLICE -TMyInt=cint" & flags)
proc getPragmas(n: NimNode): HashSet[string] =
@ -155,9 +156,8 @@ assert typeof(POINTERPOINTERPOINTEREXPR) is (ptr ptr ptr cint)
assert ALLSHL == (SHL1 or SHL2 or SHL3)
when not defined(windows):
assert not compiles(parent_struct_s().s)
assert not defined(SOME_ARRAY)
assert typeof(parent_struct_s().s) is array[100, some_struct_s]
assert typeof(SOME_ARRAY) is array[100, some_struct_s]
assert A0 is object
testFields(A0, "f1!cint")