Skip to content

Commit

Permalink
no return
Browse files Browse the repository at this point in the history
  • Loading branch information
thradams committed May 16, 2024
1 parent 34a942a commit 81e8f35
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 25 deletions.
32 changes: 9 additions & 23 deletions src/file.c
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
#pragma safety enable


struct X
{
char* _Owner _Opt text;
};

void free(void* _Owner _Opt p);
void* _Owner _Opt calloc(int n, int sz);


struct X* _Owner make();
char* _Owner _Opt strdup(const char* s);
[[noreturn]] void exit( int exit_code );

void f(int condition)
void f()
{
struct X* _Owner _Opt p = calloc(1, sizeof * p);
try
{
if (p == nullptr)
throw;


if (condition)
throw;
p->text = strdup("a");
}
catch
char * _Opt _Owner s = strdup("a");

if (s == nullptr)
{
exit(1);
}

static_state(s, "not-null");
free(s);
}
10 changes: 10 additions & 0 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -6089,6 +6089,16 @@ bool unlabeled_statement_ends_with_jump(struct unlabeled_statement* p_unlabeled_
p_unlabeled_statement->primary_block->compound_statement->block_item_list.tail &&
p_unlabeled_statement->primary_block->compound_statement->block_item_list.tail->unlabeled_statement)
{
if (p_unlabeled_statement->primary_block->compound_statement->block_item_list.tail->unlabeled_statement->expression_statement &&
p_unlabeled_statement->primary_block->compound_statement->block_item_list.tail->unlabeled_statement->expression_statement->expression_opt)
{
if (p_unlabeled_statement->primary_block->compound_statement->block_item_list.tail->unlabeled_statement->expression_statement->expression_opt->expression_type == POSTFIX_FUNCTION_CALL)
{
//calling a function declared with [[noreturn]]
return p_unlabeled_statement->primary_block->compound_statement->block_item_list.tail->unlabeled_statement->expression_statement->expression_opt->type.attributes_flags & STD_ATTRIBUTE_NORETURN;
}
}

return
p_unlabeled_statement->primary_block->compound_statement->block_item_list.tail->unlabeled_statement->jump_statement != NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions src/web/splitterbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const SplitterBar = function (container, leftContent, rightContent, is_vertical)
splitter.style.background = 'RGB(244,244,244)';
splitter.style.border = "1px solid #d2d3d4";

splitter.style.cursor = 'col-resize';
splitter.style.cursor = 'ew-resize';//'col-resize';

leftSide.style.position = 'absolute';
leftSide.style.left = 0;
Expand All @@ -58,7 +58,7 @@ const SplitterBar = function (container, leftContent, rightContent, is_vertical)
splitter.style.zIndex = 1;
splitter.style.background = 'RGB(244,244,244)';
splitter.style.border = "1px solid #d2d3d4";
splitter.style.cursor = 'row-resize';
splitter.style.cursor = 'ns-resize'; //'row-resize';


leftSide.style.top = 0;
Expand Down
18 changes: 18 additions & 0 deletions tests/unit-tests/test_19600.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma safety enable

void free(void* _Owner _Opt p);
char* _Owner _Opt strdup(const char* s);
[[noreturn]] void exit( int exit_code );

void f()
{
char * _Opt _Owner s = strdup("a");

if (s == nullptr)
{
exit(1);
}

static_state(s, "not-null");
free(s);
}

0 comments on commit 81e8f35

Please sign in to comment.