================
@@ -1,12 +1,57 @@
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify
%s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify
%s -falloc-token-mode=typehash -DMODE_TYPEHASH
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify
%s -falloc-token-max=2 -DTOKEN_MAX=2
#if !__has_builtin(__builtin_infer_alloc_token)
#error "missing __builtin_infer_alloc_token"
#endif
+#ifndef TOKEN_MAX
+#define TOKEN_MAX 0
+#endif
+
+struct NoPtr {
+ int x;
+ long y;
+};
+
+struct WithPtr {
+ int a;
+ char *buf;
+};
+
+// Check specific known values; these are guaranteed to be stable.
+#ifdef MODE_TYPEHASH
+static_assert(__builtin_infer_alloc_token(sizeof(int)) ==
2689373973731826898ULL);
+static_assert(__builtin_infer_alloc_token(sizeof(char*)) ==
2250492667400517147ULL);
+static_assert(__builtin_infer_alloc_token(sizeof(NoPtr)) ==
7465259095297095368ULL);
+static_assert(__builtin_infer_alloc_token(sizeof(WithPtr)) ==
11898882936532569145ULL);
+#elif TOKEN_MAX == 2
+static_assert(__builtin_infer_alloc_token(sizeof(int)) == 0);
+static_assert(__builtin_infer_alloc_token(sizeof(char*)) == 1);
+static_assert(__builtin_infer_alloc_token(sizeof(NoPtr)) == 0);
+static_assert(__builtin_infer_alloc_token(sizeof(WithPtr)) == 1);
----------------
fmayer wrote:
just in case:
```
#elif defined(TOKEN_MAX)
#error
```
https://github.com/llvm/llvm-project/pull/163639
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits