[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

Bill Wendling via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 12 09:05:45 PDT 2024


================
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define __counted_by(f)  __attribute__((counted_by(f)))
+
+struct size_unknown;
+
+struct at_pointer {
+  int count;
+  struct size_unknown *__counted_by(count) buf; // expected-error{{'counted_by' cannot be applied to an sized type}}
----------------
bwendling wrote:

This should be fine, because `count` is declared before use—unless I'm getting type attributes confused with field attributes.. Also, there's a grammar-o in the message: `to _an_ sized type`.

https://github.com/llvm/llvm-project/pull/87596


More information about the cfe-commits mailing list