Commit c93a2314 authored by Robert Bradshaw's avatar Robert Bradshaw

More warning suppression, formatting.

parent 1d552268
...@@ -407,13 +407,19 @@ class CTypedefType(BaseType): ...@@ -407,13 +407,19 @@ class CTypedefType(BaseType):
type = self.declaration_code("") type = self.declaration_code("")
name = self.specialization_name() name = self.specialization_name()
if binop == "lshift": if binop == "lshift":
env.use_utility_code(TempitaUtilityCode.load("LeftShift", "Overflow.c", context={'TYPE': type, 'NAME': name})) env.use_utility_code(TempitaUtilityCode.load(
"LeftShift", "Overflow.c",
context={'TYPE': type, 'NAME': name, 'SIGNED': self.signed}))
else: else:
if const_rhs: if const_rhs:
binop += "_const" binop += "_const"
_load_overflow_base(env) _load_overflow_base(env)
env.use_utility_code(TempitaUtilityCode.load("SizeCheck", "Overflow.c", context={'TYPE': type, 'NAME': name})) env.use_utility_code(TempitaUtilityCode.load(
env.use_utility_code(TempitaUtilityCode.load("Binop", "Overflow.c", context={'TYPE': type, 'NAME': name, 'BINOP': binop})) "SizeCheck", "Overflow.c",
context={'TYPE': type, 'NAME': name}))
env.use_utility_code(TempitaUtilityCode.load(
"Binop", "Overflow.c",
context={'TYPE': type, 'NAME': name, 'BINOP': binop}))
return "__Pyx_%s_%s_checking_overflow" % (binop, name) return "__Pyx_%s_%s_checking_overflow" % (binop, name)
def error_condition(self, result_code): def error_condition(self, result_code):
...@@ -1567,29 +1573,43 @@ class CIntType(CNumericType): ...@@ -1567,29 +1573,43 @@ class CIntType(CNumericType):
type = self.declaration_code("") type = self.declaration_code("")
name = self.specialization_name() name = self.specialization_name()
if binop == "lshift": if binop == "lshift":
env.use_utility_code(TempitaUtilityCode.load("LeftShift", "Overflow.c", context={'TYPE': type, 'NAME': name})) env.use_utility_code(TempitaUtilityCode.load(
"LeftShift", "Overflow.c",
context={'TYPE': type, 'NAME': name, 'SIGNED': not self.signed}))
else: else:
if const_rhs: if const_rhs:
binop += "_const" binop += "_const"
if type in ('int', 'long', 'long long'): if type in ('int', 'long', 'long long'):
env.use_utility_code(TempitaUtilityCode.load("BaseCaseSigned", "Overflow.c", context={'INT': type, 'NAME': name})) env.use_utility_code(TempitaUtilityCode.load(
"BaseCaseSigned", "Overflow.c",
context={'INT': type, 'NAME': name}))
elif type in ('unsigned int', 'unsigned long', 'unsigned long long'): elif type in ('unsigned int', 'unsigned long', 'unsigned long long'):
env.use_utility_code(TempitaUtilityCode.load("BaseCaseUnsigned", "Overflow.c", context={'UINT': type, 'NAME': name})) env.use_utility_code(TempitaUtilityCode.load(
"BaseCaseUnsigned", "Overflow.c",
context={'UINT': type, 'NAME': name}))
elif self.rank <= 1: elif self.rank <= 1:
# sizeof(short) < sizeof(int) # sizeof(short) < sizeof(int)
return "__Pyx_%s_%s_no_overflow" % (binop, name) return "__Pyx_%s_%s_no_overflow" % (binop, name)
else: else:
_load_overflow_base(env) _load_overflow_base(env)
env.use_utility_code(TempitaUtilityCode.load("SizeCheck", "Overflow.c", context={'TYPE': type, 'NAME': name})) env.use_utility_code(TempitaUtilityCode.load(
env.use_utility_code(TempitaUtilityCode.load("Binop", "Overflow.c", context={'TYPE': type, 'NAME': name, 'BINOP': binop})) "SizeCheck", "Overflow.c",
context={'TYPE': type, 'NAME': name}))
env.use_utility_code(TempitaUtilityCode.load(
"Binop", "Overflow.c",
context={'TYPE': type, 'NAME': name, 'BINOP': binop}))
return "__Pyx_%s_%s_checking_overflow" % (binop, name) return "__Pyx_%s_%s_checking_overflow" % (binop, name)
def _load_overflow_base(env): def _load_overflow_base(env):
env.use_utility_code(UtilityCode.load("Common", "Overflow.c")) env.use_utility_code(UtilityCode.load("Common", "Overflow.c"))
for type in ('int', 'long', 'long long'): for type in ('int', 'long', 'long long'):
env.use_utility_code(TempitaUtilityCode.load("BaseCaseSigned", "Overflow.c", context={'INT': type, 'NAME': type.replace(' ', '_')})) env.use_utility_code(TempitaUtilityCode.load(
"BaseCaseSigned", "Overflow.c",
context={'INT': type, 'NAME': type.replace(' ', '_')}))
for type in ('unsigned int', 'unsigned long', 'unsigned long long'): for type in ('unsigned int', 'unsigned long', 'unsigned long long'):
env.use_utility_code(TempitaUtilityCode.load("BaseCaseUnsigned", "Overflow.c", context={'UINT': type, 'NAME': type.replace(' ', '_')})) env.use_utility_code(TempitaUtilityCode.load(
"BaseCaseUnsigned", "Overflow.c",
context={'UINT': type, 'NAME': type.replace(' ', '_')}))
class CAnonEnumType(CIntType): class CAnonEnumType(CIntType):
......
...@@ -40,7 +40,7 @@ static int __Pyx_check_twos_complement() { ...@@ -40,7 +40,7 @@ static int __Pyx_check_twos_complement() {
#define __Pyx_add_no_overflow(a, b, overflow) ((a) + (b)) #define __Pyx_add_no_overflow(a, b, overflow) ((a) + (b))
#define __Pyx_add_const_no_overflow(a, b, overflow) ((a) + (b)) #define __Pyx_add_const_no_overflow(a, b, overflow) ((a) + (b))
#define __Pyx_sub_no_overflow(a, b, overflow) ((a) - (b)) #define __Pyx_sub_no_overflow(a, b, overflow) ((a) - (b))
#define __Pyx_sub_no_const_overflow(a, b, overflow) ((a) - (b)) #define __Pyx_sub_const_no_overflow(a, b, overflow) ((a) - (b))
#define __Pyx_mul_no_overflow(a, b, overflow) ((a) * (b)) #define __Pyx_mul_no_overflow(a, b, overflow) ((a) * (b))
#define __Pyx_mul_const_no_overflow(a, b, overflow) ((a) * (b)) #define __Pyx_mul_const_no_overflow(a, b, overflow) ((a) * (b))
#define __Pyx_div_no_overflow(a, b, overflow) ((a) / (b)) #define __Pyx_div_no_overflow(a, b, overflow) ((a) / (b))
...@@ -231,7 +231,7 @@ static int __Pyx_check_sane_{{NAME}}() { ...@@ -231,7 +231,7 @@ static int __Pyx_check_sane_{{NAME}}() {
sizeof({{TYPE}}) == sizeof(long long)) { sizeof({{TYPE}}) == sizeof(long long)) {
return 0; return 0;
} else { } else {
PyErr_Format(PyExc_RuntimeError, "Bad size for int type %s: %d", "{{TYPE}}", sizeof({{TYPE}})); PyErr_Format(PyExc_RuntimeError, "Bad size for int type %s: %d", "{{TYPE}}", (int) sizeof({{TYPE}}));
return 1; return 1;
} }
} }
...@@ -272,7 +272,11 @@ static CYTHON_INLINE {{TYPE}} __Pyx_{{BINOP}}_{{NAME}}_checking_overflow({{TYPE} ...@@ -272,7 +272,11 @@ static CYTHON_INLINE {{TYPE}} __Pyx_{{BINOP}}_{{NAME}}_checking_overflow({{TYPE}
/////////////// LeftShift.proto /////////////// /////////////// LeftShift.proto ///////////////
static CYTHON_INLINE {{TYPE}} __Pyx_lshift_{{NAME}}_checking_overflow({{TYPE}} a, {{TYPE}} b, int *overflow) { static CYTHON_INLINE {{TYPE}} __Pyx_lshift_{{NAME}}_checking_overflow({{TYPE}} a, {{TYPE}} b, int *overflow) {
*overflow |= (b < 0) | (b > (8 * sizeof({{TYPE}}))) | (a > (__PYX_MAX({{TYPE}}) >> b)); *overflow |=
#if {{SIGNED}}
(b < 0) |
#endif
(b > (8 * sizeof({{TYPE}}))) | (a > (__PYX_MAX({{TYPE}}) >> b));
return a << b; return a << b;
} }
#define __Pyx_lshift_const_{{NAME}}_checking_overflow __Pyx_lshift_{{NAME}}_checking_overflow #define __Pyx_lshift_const_{{NAME}}_checking_overflow __Pyx_lshift_{{NAME}}_checking_overflow
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment