diff options
Diffstat (limited to 'tests/ccgbugs')
-rw-r--r-- | tests/ccgbugs/t10964.nim | 3 | ||||
-rw-r--r-- | tests/ccgbugs/t13062.nim | 7 | ||||
-rw-r--r-- | tests/ccgbugs/t20141.nim | 4 | ||||
-rw-r--r-- | tests/ccgbugs/t22462.nim | 20 | ||||
-rw-r--r-- | tests/ccgbugs/t23796.nim | 25 | ||||
-rw-r--r-- | tests/ccgbugs/tcgbug.nim | 38 | ||||
-rw-r--r-- | tests/ccgbugs/tsamename3.nim | 9 |
7 files changed, 101 insertions, 5 deletions
diff --git a/tests/ccgbugs/t10964.nim b/tests/ccgbugs/t10964.nim index a331b16cd..c19db6997 100644 --- a/tests/ccgbugs/t10964.nim +++ b/tests/ccgbugs/t10964.nim @@ -3,4 +3,5 @@ func test*(input: var openArray[int32], start: int = 0, fin: int = input.len - 1 var someSeq = @[1'i32] -test(someSeq) \ No newline at end of file +test(someSeq) +# bug with gcc 14 \ No newline at end of file diff --git a/tests/ccgbugs/t13062.nim b/tests/ccgbugs/t13062.nim index a8d2c1fec..cfda1da7c 100644 --- a/tests/ccgbugs/t13062.nim +++ b/tests/ccgbugs/t13062.nim @@ -24,7 +24,10 @@ type fulfilled: Atomic[bool] var x: Pledge -when defined(gcRefc): +when defined(cpp): + # TODO: fixme + discard "it doesn't work for refc/orc because of contrived `Atomic` in cpp" +elif defined(gcRefc): doAssert x.repr == "[p = nil]" -elif not defined(cpp): # fixme # bug #20081 +else: # fixme # bug #20081 doAssert x.repr == "Pledge(p: nil)" diff --git a/tests/ccgbugs/t20141.nim b/tests/ccgbugs/t20141.nim index 499cd21aa..60e130690 100644 --- a/tests/ccgbugs/t20141.nim +++ b/tests/ccgbugs/t20141.nim @@ -16,7 +16,7 @@ template n[T, U](x: U): T = proc k() = var res: A - m(n[B](res)) + m(n[B, A](res)) proc w(mounter: U) = discard @@ -24,4 +24,4 @@ proc mount(proto: U) = discard proc v() = mount k # This is required for failure -w(v) \ No newline at end of file +w(v) diff --git a/tests/ccgbugs/t22462.nim b/tests/ccgbugs/t22462.nim new file mode 100644 index 000000000..9adfbb19b --- /dev/null +++ b/tests/ccgbugs/t22462.nim @@ -0,0 +1,20 @@ +discard """ + action: "run" + output: ''' +1 +1 +1 +''' + matrix: "--mm:refc" + targets: "c cpp" +""" + +type Object = object + someComplexType: seq[int] + index: Natural + +func newObject(): Object = result.index.inc + +for i in 1..3: + let o = newObject() + echo o.index diff --git a/tests/ccgbugs/t23796.nim b/tests/ccgbugs/t23796.nim new file mode 100644 index 000000000..421ec04d8 --- /dev/null +++ b/tests/ccgbugs/t23796.nim @@ -0,0 +1,25 @@ +discard """ + targets: "c cpp" +""" + +# bug #23796 + +{.emit: """ +#ifdef __cplusplus +extern "C" { +#endif + +void fooArr(float data[3]) {} +void fooIntArr(int id, float data[3]) {} + +#ifdef __cplusplus +} +#endif +""".} + +proc fooArr(data: var array[3, cfloat]) {.importc.} +proc fooIntArr(id: cint, data: var array[3, cfloat]) {.importc, nodecl.} + +var arr = [cfloat 1, 2, 3] +fooArr(arr) +fooIntArr(1, arr) diff --git a/tests/ccgbugs/tcgbug.nim b/tests/ccgbugs/tcgbug.nim index 14ed390d4..2eddc6fdd 100644 --- a/tests/ccgbugs/tcgbug.nim +++ b/tests/ccgbugs/tcgbug.nim @@ -4,6 +4,7 @@ success M1 M2 ok ''' +matrix: "--mm:refc;--mm:orc" """ type @@ -123,3 +124,40 @@ proc bug19613 = doAssert x.bid.root.data[0] == 42 bug19613() + +proc foo = # bug #23280 + let foo = @[1,2,3,4,5,6] + doAssert toOpenArray(foo, 0, 5).len == 6 + doAssert toOpenArray(foo, 0, 5).len mod 6 == 0 # this should output 0 + doAssert toOpenArray(foo, 0, 5).max mod 6 == 0 + let L = toOpenArray(foo, 0, 5).len + doAssert L mod 6 == 0 + +foo() + +block: # bug #9940 + {.emit:"""/*TYPESECTION*/ +typedef struct { int base; } S; +""".} + + type S {.importc: "S", completeStruct.} = object + base: cint + proc init(x:ptr S) = + x.base = 1 + + type + Foo = object + a: seq[float] + b: seq[float] + c: seq[float] + d: seq[float] + s: S + + proc newT(): Foo = + var t: Foo + t.s.addr.init + doAssert t.s.base == 1 + t + + var t = newT() + doAssert t.s.base == 1 diff --git a/tests/ccgbugs/tsamename3.nim b/tests/ccgbugs/tsamename3.nim index a69391e5c..ded18e9f8 100644 --- a/tests/ccgbugs/tsamename3.nim +++ b/tests/ccgbugs/tsamename3.nim @@ -109,3 +109,12 @@ block: # make sure `hashType` doesn't recurse infinitely a, b: PFoo c: int var a: PFoo + +block: # issue #22571 + macro foo(x: typed) = + result = x + + block: # or `proc main =` + foo: + type Foo = object + doAssert $Foo() == "()" |