mirror of
https://github.com/vlang/v.git
synced 2025-09-10 07:47:20 -04:00
bootstrap: cleanup code checking for overflowing int literals, ease forwards compatibility with V versions before ef758a7
This commit is contained in:
parent
5407dbbde7
commit
ccfa65aa14
@ -1038,7 +1038,7 @@ pub fn last_error() IError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Magic constant because zero is used explicitly at times
|
// Magic constant because zero is used explicitly at times
|
||||||
pub const error_code_not_set = 0x7EFEFEFE
|
pub const error_code_not_set = int(0x7EFEFEFE)
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct SystemError {
|
pub struct SystemError {
|
||||||
|
@ -169,7 +169,7 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
|
|||||||
if v.pref.os == .macos && os.exists('/opt/procursus') {
|
if v.pref.os == .macos && os.exists('/opt/procursus') {
|
||||||
ccoptions.linker_flags << '-Wl,-rpath,/opt/procursus/lib'
|
ccoptions.linker_flags << '-Wl,-rpath,/opt/procursus/lib'
|
||||||
}
|
}
|
||||||
mut user_darwin_version := 999_999_999
|
mut user_darwin_version := 999_999
|
||||||
mut user_darwin_ppc := false
|
mut user_darwin_ppc := false
|
||||||
$if macos {
|
$if macos {
|
||||||
user_darwin_version = os.uname().release.split('.')[0].int()
|
user_darwin_version = os.uname().release.split('.')[0].int()
|
||||||
|
@ -211,12 +211,8 @@ fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
|
|||||||
}
|
}
|
||||||
if left_type == ast.int_type {
|
if left_type == ast.int_type {
|
||||||
if mut right is ast.IntegerLiteral {
|
if mut right is ast.IntegerLiteral {
|
||||||
mut is_large := right.val.len > 13
|
val := right.val.i64()
|
||||||
if !is_large && right.val.len > 9 {
|
if overflows_i32(val) {
|
||||||
val := right.val.i64()
|
|
||||||
is_large = overflows_i32(val)
|
|
||||||
}
|
|
||||||
if is_large {
|
|
||||||
c.error('overflow in implicit type `int`, use explicit type casting instead',
|
c.error('overflow in implicit type `int`, use explicit type casting instead',
|
||||||
right.pos)
|
right.pos)
|
||||||
}
|
}
|
||||||
|
@ -1789,12 +1789,8 @@ fn (mut c Checker) const_decl(mut node ast.ConstDecl) {
|
|||||||
// Check for int overflow
|
// Check for int overflow
|
||||||
if field.typ == ast.int_type {
|
if field.typ == ast.int_type {
|
||||||
if mut field.expr is ast.IntegerLiteral {
|
if mut field.expr is ast.IntegerLiteral {
|
||||||
mut is_large := field.expr.val.len > 13
|
val := field.expr.val.i64()
|
||||||
if !is_large && field.expr.val.len > 9 {
|
if overflows_i32(val) {
|
||||||
val := field.expr.val.i64()
|
|
||||||
is_large = overflows_i32(val)
|
|
||||||
}
|
|
||||||
if is_large {
|
|
||||||
c.error('overflow in implicit type `int`, use explicit type casting instead',
|
c.error('overflow in implicit type `int`, use explicit type casting instead',
|
||||||
field.expr.pos)
|
field.expr.pos)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user