summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-09-29 07:57:14 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-09-30 13:38:59 +0200
commitcd9b22bf2b57d626f87e4239f847775e2fb11a84 (patch)
treef0d391b24de8f430b90e07881da9bb9e5fadbc3b /tests
parentd941d208deb172af157505913c98d5b49d95e5d5 (diff)
downloadcython-cd9b22bf2b57d626f87e4239f847775e2fb11a84.tar.gz
Join '*' and '**' parsing in declarators to avoid differences for 'const' parsing etc.
Diffstat (limited to 'tests')
-rw-r--r--tests/compile/const_decl.pyx15
-rw-r--r--tests/errors/const_decl_errors.pyx14
2 files changed, 21 insertions, 8 deletions
diff --git a/tests/compile/const_decl.pyx b/tests/compile/const_decl.pyx
index 5424c8f90..c47f952df 100644
--- a/tests/compile/const_decl.pyx
+++ b/tests/compile/const_decl.pyx
@@ -1,12 +1,17 @@
# mode: compile
-cdef const_args(const int a, const int *b, const (int*) c, int *const d):
+cdef const_args(const int a, const int *b, const (int*) c, int *const d, int **const e, int *const *f):
print a
print b[0]
- b = NULL # OK, the pointer itself is not const
- c[0] = 4 # OK, the value is not const
- d[0] = 7 # OK, the value is not const
+ b = NULL # OK, the pointer itself is not const
+ c[0] = 4 # OK, the value is not const
+ d[0] = 7 # OK, the value is not const
+ e[0][0] = 1 # OK, the value is not const
+ e[0] = NULL # OK, the pointed pointer is not const
+ f[0][0] = 1 # OK, the value is not const
+ f = NULL # OK, the pointer is not const
def call_const_args(x):
cdef int k = x
- const_args(x, &k, &k, &k)
+ cdef int* arr = [x]
+ const_args(x, &k, &k, &k, &arr, &arr)
diff --git a/tests/errors/const_decl_errors.pyx b/tests/errors/const_decl_errors.pyx
index 184cdc60c..29c9896ea 100644
--- a/tests/errors/const_decl_errors.pyx
+++ b/tests/errors/const_decl_errors.pyx
@@ -10,13 +10,19 @@ cdef const int x = 10
cdef struct S:
int member
-cdef func(const int a, const int* b, const (int*) c, const S s, int *const d,
+cdef func(const int a, const int* b, const (int*) c, const S s, int *const d, int **const e, int *const *f,
const S *const t):
a = 10
c = NULL
b[0] = 100
s.member = 1000
d = NULL
+ e[0][0] = 1 # ok
+ e[0] = NULL # ok
+ e = NULL # nok
+ f[0][0] = 1 # ok
+ f[0] = NULL # nok
+ f = NULL # ok
t = &s
cdef volatile object v
@@ -30,6 +36,8 @@ _ERRORS = """
17:5: Assignment to const dereference
18:5: Assignment to const attribute 'member'
19:4: Assignment to const 'd'
-20:4: Assignment to const 't'
-22:5: Const/volatile base type cannot be a Python object
+22:4: Assignment to const 'e'
+24:5: Assignment to const dereference
+26:4: Assignment to const 't'
+28:5: Const/volatile base type cannot be a Python object
"""