Files
swift-mirror/test/Interop/C/swiftify-import/Inputs/counted-by.h
Henrik G. Olsson 8db1ad6222 Cherry-pick [Swiftify] Don't import counted_by with suffixed integer literals (#82469) (#82594)
Integer literal expressions with types that are not of type `int` are
printed with a suffix to indicate the type (e.g. `123U` or `456L` for
`unsigned` and `long`). This is not valid syntax for integer literals in
Swift, so until we fully translate the count expr syntax to Swift we
need to avoid importing these count expressions.

Also fixes some -Werror related stuff in test cases.

rdar://154141719
(cherry picked from commit 374658a)
2025-06-30 11:58:55 -07:00

65 lines
1.9 KiB
C

#pragma once
#define __counted_by(x) __attribute__((__counted_by__(x)))
void simple(int len, int * __counted_by(len) p);
void simpleFlipped(int * __counted_by(len) p, int len);
void swiftAttr(int len, int *p) __attribute__((
swift_attr("@_SwiftifyImport(.countedBy(pointer: .param(2), count: \"len\"))")));
void shared(int len, int * __counted_by(len) p1, int * __counted_by(len) p2);
void complexExpr(int len, int offset, int * __counted_by(len - offset) p);
void nullUnspecified(int len, int * __counted_by(len) _Null_unspecified p);
void nonnull(int len, int * __counted_by(len) _Nonnull p);
void nullable(int len, int * __counted_by(len) _Nullable p);
int * __counted_by(len) returnPointer(int len);
void offByOne(int len, int * __counted_by(len + 1) p);
void offBySome(int len, int offset, int * __counted_by(len + (1 + offset)) p);
void scalar(int m, int n, int * __counted_by(m * n) p);
void bitwise(int m, int n, int o, int * __counted_by(m & n | ~o) p);
void bitshift(int m, int n, int o, int * __counted_by(m << (n >> o)) p);
void constInt(int * __counted_by(42 * 10) p);
void constFloatCastedToInt(int * __counted_by((int) (4.2 / 12)) p);
void sizeofType(int * __counted_by(sizeof(int *)) p);
void sizeofParam(int * __counted_by(sizeof(p)) p);
void derefLen(int * len, int * __counted_by(*len) p);
void lNot(int len, int * __counted_by(!len) p);
void lAnd(int len, int * __counted_by(len && len) p);
void lOr(int len, int * __counted_by(len || len) p);
void floatCastToInt(float meters, int * __counted_by((int) meters) p);
void pointerCastToInt(int *square, int * __counted_by((int) square) p);
void nanAsInt(int * __counted_by((int) (0 / 0)) p);
void unsignedLiteral(int * __counted_by(2u) p);
void longLiteral(int * __counted_by(2l) p);
void hexLiteral(int * __counted_by(0xfa) p);
void binaryLiteral(int * __counted_by(0b10) p);
void octalLiteral(int * __counted_by(0777) p);