mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Fix Linux constant in posix.c3. Address issue #1009. Sanitizes the module name in generated project.
This commit is contained in:
@@ -4,10 +4,10 @@ def Pid_t = int;
|
||||
def Uid_t = uint;
|
||||
def Gid_t = uint;
|
||||
|
||||
const CInt SA_ONSTACK = env::LINUX ? 0x08000000 : 0x0001;
|
||||
const CInt SA_RESTART = env::LINUX ? 0x10000000 : 0x0002;
|
||||
const CInt SA_RESETHAND = env::LINUX ? 0x80000000 : 0x0004;
|
||||
const CInt SA_SIGINFO = env::LINUX ? 0x00000004 : 0x0040;
|
||||
const CUInt SA_ONSTACK = env::LINUX ? 0x08000000 : 0x0001;
|
||||
const CUInt SA_RESTART = env::LINUX ? 0x10000000 : 0x0002;
|
||||
const CUInt SA_RESETHAND = env::LINUX ? 0x80000000 : 0x0004;
|
||||
const CUInt SA_SIGINFO = env::LINUX ? 0x00000004 : 0x0040;
|
||||
|
||||
def Sigset_t = uint @if(!env::LINUX);
|
||||
def Sigset_t = ulong[16] @if(env::LINUX);
|
||||
@@ -20,18 +20,25 @@ struct Sigaction
|
||||
SignalFunction sa_handler;
|
||||
SigActionFunction sa_sigaction;
|
||||
}
|
||||
CInt sa_flags @if(env::FREEBSD);
|
||||
Sigset_t sa_mask; // 128
|
||||
CInt sa_flags @if(!env::FREEBSD);
|
||||
void* sa_restorer @if(env::LINUX);
|
||||
CInt sa_flags @if(env::FREEBSD);
|
||||
Sigset_t sa_mask; // 128
|
||||
CInt sa_flags @if(!env::FREEBSD);
|
||||
void* sa_restorer @if(env::LINUX);
|
||||
}
|
||||
|
||||
struct Stack_t
|
||||
{
|
||||
void* ss_sp;
|
||||
usz ss_size @if(!env::LINUX);
|
||||
CInt ss_flags;
|
||||
usz ss_size @if(env::LINUX);
|
||||
struct @if(!env::LINUX)
|
||||
{
|
||||
usz ss_size;
|
||||
CInt ss_flags;
|
||||
}
|
||||
struct @if(env::LINUX)
|
||||
{
|
||||
CInt ss_flags;
|
||||
usz ss_size;
|
||||
}
|
||||
}
|
||||
|
||||
extern fn CInt sigaltstack(Stack_t* ss, Stack_t* old_ss);
|
||||
|
||||
@@ -209,7 +209,30 @@ void create_project(BuildOptions *build_options)
|
||||
|
||||
file = fopen("main.c3", "w");
|
||||
if (!file) goto ERROR;
|
||||
(void) fprintf(file, MAIN_TEMPLATE, build_options->project_name);
|
||||
|
||||
scratch_buffer_clear();
|
||||
size_t len = strlen(build_options->project_name);
|
||||
bool has_char = false;
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
char c = build_options->project_name[i];
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
if (!has_char) scratch_buffer_append("m_");
|
||||
has_char = true;
|
||||
scratch_buffer_append_char(c);
|
||||
continue;
|
||||
}
|
||||
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
|
||||
{
|
||||
scratch_buffer_append_char(c | 0x20);
|
||||
has_char = true;
|
||||
continue;
|
||||
}
|
||||
scratch_buffer_append_char('_');
|
||||
}
|
||||
if (!has_char) scratch_buffer_append("module");
|
||||
(void) fprintf(file, MAIN_TEMPLATE, scratch_buffer_to_string());
|
||||
if (fclose(file)) goto ERROR;
|
||||
|
||||
if (!dir_change("..")) goto ERROR;
|
||||
|
||||
@@ -3191,6 +3191,10 @@ static bool sema_append_generate_parameterized_name(SemaContext *c, Module *modu
|
||||
if (type->type_kind == TYPE_OPTIONAL) RETURN_SEMA_ERROR(type_info, "Expected a non-optional type.");
|
||||
if (type == type_void) RETURN_SEMA_ERROR(type_info, "A 'void' type cannot be used as a parameter type.");
|
||||
if (type_is_invalid_storage_type(type)) RETURN_SEMA_ERROR(type_info, "Expected a runtime type.");
|
||||
if (type_is_func_ptr(type))
|
||||
{
|
||||
if (!sema_resolve_type_decl(c, type->pointer)) return false;
|
||||
}
|
||||
if (mangled)
|
||||
{
|
||||
type_mangle_introspect_name_to_buffer(type);
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define COMPILER_VERSION "0.4.655"
|
||||
#define COMPILER_VERSION "0.4.656"
|
||||
14
test/test_suite/functions/recursive_through_generic.c3
Normal file
14
test/test_suite/functions/recursive_through_generic.c3
Normal file
@@ -0,0 +1,14 @@
|
||||
module oups;
|
||||
import std::collections::map;
|
||||
|
||||
fn void! main()
|
||||
{
|
||||
}
|
||||
|
||||
def FooFunc = fn void! (Bar*); // #error: Recursive definition
|
||||
def Foo = HashMap(<String, FooFunc>);
|
||||
|
||||
struct Bar
|
||||
{
|
||||
Foo foo;
|
||||
}
|
||||
Reference in New Issue
Block a user