Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small example that generate errors. #79

Closed
christian-blanvillain opened this issue Oct 6, 2022 · 0 comments · Fixed by #101
Closed

Small example that generate errors. #79

christian-blanvillain opened this issue Oct 6, 2022 · 0 comments · Fixed by #101
Labels
Bug Something isn't working

Comments

@christian-blanvillain
Copy link

christian-blanvillain commented Oct 6, 2022

This generate an unhandled errror:

int static inline quot( int x, int y ) {
	if( x == 0 || y == 0 )
		return	0;
	if( x > y )
		return	x%y ? 0 : x/y;
	else	
		return	y%x ? 0 : y/x;
}
int main() {
	quot(2,2);
}

Instead, I had to rewrite using this:

int static inline quot( int x, int y )  { return ( x == 0 || y == 0 ) ? 0 : (( x > y ) ? ( x%y ? 0 : x/y ) : ( y%x ? 0 : y/x )); } 

Here is the error message:

C to V translator 0.3.1
  translating bug.c           ... 

Unhandled expr() node {ReturnStmt} (ast line nr node.ast_line_nr "bug.c"):
{ReturnStmt} name:"" value:"" loc:Loc{
    offset: 0
    file: ''
    line: 0
    col: 0
    tok_len: 0
    included_from: IncludedFrom{
        file: ''
    }
    spelling_loc: IncludedFrom{
        file: ''
    }
    range: Range{
        begin: Begin{
            spelling_loc: IncludedFrom{
                file: ''
            }
        }
    }
}  #c: 1 typ:""
0   c2v-master                          0x000000010293d5bc main__C2V_if_statement + 700
1   c2v-master                          0x000000010293b74d main__C2V_statement + 301
2   c2v-master                          0x0000000102939105 main__C2V_statements + 133
3   c2v-master                          0x0000000102935686 main__C2V_fn_decl + 3926
4   c2v-master                          0x000000010294448a main__C2V_top_level + 154
5   c2v-master                          0x0000000102943a70 main__C2V_translate_file + 3744
6   c2v-master                          0x0000000102942aa3 main__main + 1475
7   c2v-master                          0x00000001029487f7 main + 71
8   c2v-master                          0x00000001028ae034 start + 52
9   ???                                 0x0000000000000002 0x0 + 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants