|
| 1 | +// RUN: rm -rf %t* |
| 2 | +// RUN: 3c -base-dir=%S -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s |
| 3 | +// RUN: 3c -base-dir=%S -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s |
| 4 | +// RUN: 3c -base-dir=%S -alltypes -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null - |
| 5 | +// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s -- |
| 6 | +// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/macro_itype.c -- | diff %t.checked/macro_itype.c - |
| 7 | + |
| 8 | +// Example encountered while converting libjpeg. This triggered an assertion |
| 9 | +// fail because the ItypeStr extracted from the source was empty. |
| 10 | +#define macro0 int *a : itype(_Ptr<int>); |
| 11 | +struct s { macro0 }; |
| 12 | +//CHECK: struct s { macro0 }; |
| 13 | + |
| 14 | +// Example from issue correctcomputation/checkedc-clang#594. |
| 15 | +#define PARAM_DECL_WITH_ITYPE int *p : itype(_Ptr<int>) |
| 16 | +void foo(PARAM_DECL_WITH_ITYPE); |
| 17 | +//CHECK: void foo(PARAM_DECL_WITH_ITYPE); |
| 18 | + |
| 19 | +// Just removing the assertion that failed on the above example caused this to |
| 20 | +// rewrite incorrectly. The ItypeStr would be left empty, so first parameter |
| 21 | +// would be rewritten to `int *b` even though the rewriter intended to give it |
| 22 | +// an itype. If the parameter was then passed a checked pointer, there would be |
| 23 | +// a Checked C compiler error. Ideally, 3C wouldn't need to change the |
| 24 | +// declaration of `b` at all (see issue correctcomputation/checkedc-clang#694). |
| 25 | +#define macro1 : itype(_Ptr<int>) |
| 26 | +void fn(int *b macro1, int *c) { |
| 27 | +//CHECK: void fn(int *b : itype(_Ptr<int>), _Ptr<int> c) { |
| 28 | + b = 1; |
| 29 | +} |
| 30 | +void caller() { |
| 31 | + int *e; |
| 32 | + //CHECK: _Ptr<int> e = ((void *)0); |
| 33 | + fn(e, 0); |
| 34 | +} |
0 commit comments