Skip to content

Commit a584505

Browse files
committed
Fix compile errors on Windows with Clang
1 parent 4551b55 commit a584505

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ jobs:
77
strategy:
88
fail-fast: false
99
matrix:
10-
os: [ubuntu-latest, macos-latest, windows-latest]
10+
os: [ubuntu-latest, macos-latest, windows-2025]
1111
cc: [gcc, clang]
1212
exclude:
1313
- os: macos-latest
1414
cc: gcc
15-
- os: windows-latest
16-
cc: clang
1715
runs-on: ${{matrix.os}}
1816
env:
1917
CC: ${{matrix.cc}}
@@ -29,13 +27,13 @@ jobs:
2927
- name: Test
3028
run: make test CC=${{matrix.cc}}
3129
- name: Install (Unix)
32-
if: ${{ matrix.os != 'windows-latest' }}
30+
if: ${{ matrix.os != 'windows-2025' }}
3331
run: sudo make install
3432
- name: Install (Windows)
35-
if: ${{ matrix.os == 'windows-latest' }}
33+
if: ${{ matrix.os == 'windows-2025' }}
3634
run: make install
3735
- name: Run hello world example
38-
if: ${{ matrix.os != 'windows-latest' }}
36+
if: ${{ matrix.os != 'windows-2025' }}
3937
run: nelua --verbose examples/helloworld.nelua
4038

4139
test-32bits:

lib/errorhandling.nelua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ function cgenerator.visitors.Call(context, node, emitter, ...)
4848
end
4949
if #funcsym.type.rettypes > 1 then
5050
local rettypename = context:funcrettypename(funcsym.type)
51-
emitter:add_indent_ln('return (',rettypename,'){0};')
51+
emitter:add_indent('return')
52+
emitter:add_zeroed_type_literal(rettypename, rettypename);
53+
emitter:add_ln(';')
5254
elseif #funcsym.type.rettypes == 1 then
5355
local rettypename = context:funcrettypename(funcsym.type)
5456
emitter:add_indent('return ')

lib/span.nelua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Remarks: A span initialized from a list of unnamed fields points to an array of
1717
##[[
1818
static_assert(traits.is_type(T), "invalid type '%s", T)
1919
static_assert(not T.is_comptime, "spans cannot be of type '%s'", T)
20-
static_assert(T.size ~= 0, "spans cannot be of empty type '%s'", T)
20+
static_assert(T.is_empty ~= true, "spans cannot be of empty type '%s'", T)
2121
]]
2222
local T: type = @#[T]#
2323

lualib/nelua/analyzer.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ function visitors.RecordType(context, node, opts)
893893
else
894894
recordtype = types.RecordType({}, node)
895895
recordtype.size = nil -- size is unknown yet
896+
recordtype.is_empty = nil
896897
end
897898
attr.type = primtypes.type
898899
attr.value = recordtype

lualib/nelua/cbuiltins.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ end
262262

263263
-- Used to take reference of literals (rvalues).
264264
function cbuiltins.NELUA_LITERAL_REF(context)
265+
if ccompiler.get_cc_info().is_cpp then --luacov:disable
266+
context:get_visiting_node():raisef('taking reference of a compound literal is not allowed in the C++ backend')
267+
end --luacov:enable
265268
context:define_builtin_macro('NELUA_LITERAL_REF', [[
266269
/* Macro used to take reference of literals. */
267270
#define NELUA_LITERAL_REF(T, x) (&((struct{T v;}){x}.v))
@@ -1519,11 +1522,8 @@ function cbuiltins.operators.bnot(_, _, emitter, argattr, argname)
15191522
end
15201523

15211524
-- Implementation of reference operator (`&`).
1522-
function cbuiltins.operators.ref(_, node, emitter, argattr, argname)
1525+
function cbuiltins.operators.ref(_, _, emitter, argattr, argname)
15231526
if not argattr.lvalue and argattr.type.is_aggregate then -- taking reference of a literal
1524-
if ccompiler.get_cc_info().is_cpp then --luacov:disable
1525-
node:raisef('taking reference of a compound literal is not allowed in the C++ backend')
1526-
end --luacov:enable
15271527
emitter:add_builtin('NELUA_LITERAL_REF')
15281528
emitter:add('(', argattr.type, ', (', argname, '))')
15291529
else

tests/gc_test.nelua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ do -- finalizers
5050
end
5151
end
5252

53-
local foo: *Foo <volatile> = gc_allocator:new(Foo{count=count})
54-
local foos: span(Foo) <volatile> = gc_allocator:new(Foo{count=count}, 2)
53+
local foo: *Foo = gc_allocator:new(Foo{count=count})
54+
local foos: span(Foo) = gc_allocator:new(Foo{count=count}, 2)
5555
foos = (@span(Foo)){}
5656
foo = nilptr
5757
end

0 commit comments

Comments
 (0)