Skip to content

Commit

Permalink
Fix some warnings when compiling with clang and tcc
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Nov 9, 2023
1 parent 20adeab commit 077ab20
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/detail/strpatt.nelua
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ function StrPatt.create(source: string, pattern: string, plain: boolean): StrPat
return (@StrPatt) {
source = source,
pattern = pattern,
depth = MAX_MATCH_CALLS,
plain = plain,
anchor = anchor,
depth = MAX_MATCH_CALLS,
}
end

Expand Down
13 changes: 10 additions & 3 deletions lualib/nelua/cdefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ compilers_flags.cc = {
cflags_release = "-O2 -DNDEBUG",
cflags_maximum_performance = "-O3 -DNDEBUG",
cflags_shared_lib = "-shared",
cflags_shared_lib_windows = "",
cflags_assembly = "-S",
cflags_object = "-c",
cmd_compile = '$(cc) "$(cfile)" $(cflags) -o "$(binfile)"',
Expand Down Expand Up @@ -113,7 +112,11 @@ compilers_flags.emcc = tabler.updatecopy(compilers_flags.gcc, {
cflags_maximum_performance = "-O3 -ffast-math -DNDEBUG -fno-plt -flto",
})
-- Clang
compilers_flags.clang = tabler.copy(compilers_flags.gcc)
compilers_flags.clang = tabler.updatecopy(compilers_flags.gcc, {
cmd_compile = '$(cc) -x c "$(cfile)" -x none -Wno-unused-command-line-argument $(cflags) -o "$(binfile)"',
cmd_info = '$(cc) -E -x c "$(cfile)" -x none -Wno-unused-command-line-argument $(cflags)',
cmd_defines = '$(cc) -E -dM -x c "$(cfile)" -x none -Wno-unused-command-line-argument $(cflags)',
})
-- TCC
compilers_flags.tcc = tabler.updatecopy(compilers_flags.cc, {
cflags_base = "-w",
Expand All @@ -133,7 +136,11 @@ compilers_flags['g++'] = tabler.updatecopy(compilers_flags.gcc, {
ext = '.cpp',
})
-- Clang (C++)
compilers_flags['clang++'] = tabler.copy(compilers_flags['g++'])
compilers_flags['clang++'] = tabler.updatecopy(compilers_flags['g++'], {
cmd_compile = '$(cc) -x c++ "$(cfile)" -x none -Wno-unused-command-line-argument $(cflags) -o "$(binfile)"',
cmd_info = '$(cc) -E -x c++ "$(cfile)" -x none -Wno-unused-command-line-argument $(cflags)',
cmd_defines = '$(cc) -E -dM -x c++ "$(cfile)" -x none -Wno-unused-command-line-argument $(cflags)',
})
-- NVCC (CUDA C++)
compilers_flags['nvcc'] = tabler.updatecopy(compilers_flags.gcc, {
cflags_base = "",
Expand Down
3 changes: 2 additions & 1 deletion lualib/nelua/cgenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1617,13 +1617,14 @@ function cgenerator.emit_warning_pragmas(context)
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
#pragma clang diagnostic ignored "-Wparentheses-equality"
#pragma clang diagnostic ignored "-Wtautological-compare"
#pragma clang diagnostic ignored "-Wmissing-braces"
#ifndef __cplusplus
#pragma clang diagnostic ignored "-Wmissing-braces"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#pragma clang diagnostic error "-Wimplicit-function-declaration"
#pragma clang diagnostic error "-Wimplicit-int"
#else
#pragma clang diagnostic ignored "-Wnarrowing"
#pragma clang diagnostic ignored "-Wc99-designator"
#endif
#elif defined(__GNUC__) && __GNUC__ >= 5
#pragma GCC diagnostic ignored "-Wtype-limits"
Expand Down
6 changes: 3 additions & 3 deletions spec/cgenerator_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2403,9 +2403,9 @@ it("record methods", function()
function vec2pointer:len() return self.x + self.y end
assert(v:len() == 3)
local Math = @record{}
function Math.abs(x: number): number <cimport'fabs',cinclude'<math.h>'> end
assert(Math.abs(-1) == 1)
local Str = @record{}
function Str.len(x: cstring): cint <cimport'strlen',cinclude'<string.h>'> end
assert(Str.len('hello') == 5)
local Foo = @record{x: integer, f: function(*Foo): integer}
local foo: Foo = {1}
Expand Down

0 comments on commit 077ab20

Please sign in to comment.