Commit f5a4c935 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2016 from jdemeyer/libc_limits

Fix types of values in libc.limits
parents 2fc2cba0 e9126671
......@@ -2074,7 +2074,11 @@ class NameNode(AtomicExprNode):
def check_const(self):
entry = self.entry
if entry is not None and not (entry.is_const or entry.is_cfunction or entry.is_builtin):
if entry is not None and not (
entry.is_const or
entry.is_cfunction or
entry.is_builtin or
entry.type.is_const):
self.not_const()
return False
return True
......
# 5.2.4.2.1 Sizes of integer types <limits.h>
cdef extern from "<limits.h>":
const int CHAR_BIT
const int MB_LEN_MAX
enum: CHAR_BIT
enum: MB_LEN_MAX
const char CHAR_MIN
const char CHAR_MAX
enum: CHAR_MIN
enum: CHAR_MAX
const signed char SCHAR_MIN
const signed char SCHAR_MAX
const unsigned char UCHAR_MAX
enum: SCHAR_MIN
enum: SCHAR_MAX
enum: UCHAR_MAX
const short SHRT_MIN
const short SHRT_MAX
const unsigned short USHRT_MAX
enum: SHRT_MIN
enum: SHRT_MAX
enum: USHRT_MAX
const int INT_MIN
const int INT_MAX
const unsigned int UINT_MAX
enum: INT_MIN
enum: INT_MAX
enum: UINT_MAX
const long LONG_MIN
const long LONG_MAX
const unsigned long ULONG_MAX
enum: LONG_MIN
enum: LONG_MAX
enum: ULONG_MAX
enum: LLONG_MIN
enum: LLONG_MAX
enum: ULLONG_MAX
const long long LLONG_MIN
const long long LLONG_MAX
const unsigned long long ULLONG_MAX
......@@ -10,10 +10,7 @@ cimport cython
import sys
IS_PYPY = hasattr(sys, 'pypy_version_info')
cdef extern from *:
int INT_MAX
long LONG_MAX
long LONG_MIN
from libc.limits cimport INT_MAX, LONG_MAX, LONG_MIN
max_int = INT_MAX
max_long = LONG_MAX
......@@ -149,6 +146,15 @@ def format_c_numbers_max(int n, long l):
return s1, s2
def format_c_number_const():
"""
>>> s = format_c_number_const()
>>> s == '{0}'.format(max_long) or s
True
"""
return f"{LONG_MAX}"
def format_c_number_range(int n):
"""
>>> for i in range(-1000, 1000):
......
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