================
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -std=c++2c -fcontracts -fsyntax-only -verify %s
+
+// This test intentionally exercises parser-only support. Contract predicates
+// are parsed as ordinary expressions, but are not retained in the AST yet.
+
+int pre = 42;
+int post(int value) { return value; }
+
+int divide(int a, int b) pre(b != 0);
+int square(int x) post(result: result >= x);
+int clamp(int x) pre(x >= 0) pre(x <= 100)
+    post(result: x >= 0) post(other_result: x <= 100);
+
+struct OuterResult {};
+OuterResult shadowed_result;
+int result_shadowing(int x)
+    post(shadowed_result: shadowed_result >= x);
+
+template <typename T>
+concept C = true;
+
+template <typename T>
+int constrained(T value) requires C<T> pre(value > T{});
+
+struct S {
+  int member(int value) pre(value > 0) post(result: result > value);
----------------
cor3ntin wrote:

no https://eel.is/c++draft/dcl.contract.func#nt:function-contract-specifier-seq 
(but we can test it)

https://github.com/llvm/llvm-project/pull/221139
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to