From 5ed6880b57498722babe6e69832a008f0ea42ecc Mon Sep 17 00:00:00 2001 From: R Date: Thu, 3 Dec 2026 05:23:10 -0300 Subject: [PATCH] crypto: the removed-name message tests hold on every clang the CI runs ph_removed, async_seal_removed and seal_removed_call failed on Clang 18 and Apple Clang 17 (webcpp run 47012218351): their -verify directives held what Clang 22 alone reports. - ph_removed: Clang 22 corrects ::begin to std::begin and adds the failed call of the correction; Clang 18 and Apple Clang 17 do not. That knock-on is now 0-1. - async_seal_removed: clang's "did you mean" after the removed name is its typo correction, which differs by version: Clang 18 and Apple Clang 17 offer secret_key_encryption::aead::async_seal and async_open, the right forms, and compile the corrected calls; Clang 22 offers the box forms and adds a failed call each. The test pins the missing name, the knock-on is 0-1, and the program links AES-GCM's default backend, as a program that calls it does: unlinked, the corrected calls instantiated the engine and stopped at its not-linked static_assert and the errors after it. - seal_removed_call: Clang 18 and Apple Clang 17 correct the calls to aead::seal and open, which instantiated ChaCha20-Poly1305's engine on an unlinked default; the program links it. The page's fix of async_seal_removed says which clang offers which form. generate.py reads a directive's range of counts (1+, 0-1), and generate_test.py runs the four cases it declared but did not list, the new one among them. --- doc/generated/messages.adoc | 8 +++---- doc/tables/crypto.json | 2 +- doc/tables/generate.py | 12 ++++++---- doc/tables/generate_test.py | 17 ++++++++++++++ test/messages/async_seal_removed/Jamfile | 14 ++++++----- .../async_seal_removed/async_seal_removed.cpp | 23 +++++++++---------- test/messages/ph_removed/ph_removed.cpp | 8 ++++--- test/messages/seal_removed_call/Jamfile | 6 +++-- .../seal_removed_call/seal_removed_call.cpp | 6 +++-- 9 files changed, 61 insertions(+), 35 deletions(-) diff --git a/doc/generated/messages.adoc b/doc/generated/messages.adoc index 8c64678..8f7353d 100644 --- a/doc/generated/messages.adoc +++ b/doc/generated/messages.adoc @@ -141,11 +141,11 @@ The fix: As `+async_seal_xchacha+`: name a native backend, such as `+backends::s |`+async_seal_removed+` |native, wasip2, wasip3 -|`+no member named 'async_seal' in namespace 'webcpp::crypto'; did you mean 'webcpp::crypto::secret_key_encryption::async_seal'?+` +|`+no member named 'async_seal' in namespace 'webcpp::crypto'+` -`+no member named 'async_open' in namespace 'webcpp::crypto'; did you mean 'webcpp::crypto::secret_key_encryption::async_open'?+` +`+no member named 'async_open' in namespace 'webcpp::crypto'+` -The fix: Call crypto::secret_key_encryption::aead::async_seal and async_open. clang's suggestion, `+secret_key_encryption::async_seal+` and `+async_open+`, is the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user. +The fix: Call crypto::secret_key_encryption::aead::async_seal and async_open. What clang suggests depends on its version: Clang 18 and Apple Clang 17 offer those; Clang 22 offers `+secret_key_encryption::async_seal+` and `+async_open+`, the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user. |`+async_seal_removed_declaration+` |native, wasip2, wasip3 @@ -1908,7 +1908,7 @@ On MSVC, each case of `test/msvc` is proven to stop the build, at compile or at |`+async_seal_removed+` |the compile -|Call crypto::secret_key_encryption::aead::async_seal and async_open. clang's suggestion, `+secret_key_encryption::async_seal+` and `+async_open+`, is the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user. +|Call crypto::secret_key_encryption::aead::async_seal and async_open. What clang suggests depends on its version: Clang 18 and Apple Clang 17 offer those; Clang 22 offers `+secret_key_encryption::async_seal+` and `+async_open+`, the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user. |`+async_seal_removed_declaration+` |the compile diff --git a/doc/tables/crypto.json b/doc/tables/crypto.json index a5b8b07..9d9ba46 100644 --- a/doc/tables/crypto.json +++ b/doc/tables/crypto.json @@ -1556,7 +1556,7 @@ "secretbox_removed": "Name `crypto::secret_key_encryption::secretbox` and `secretbox_xchacha20poly1305`, the secret boxes' namespace; `ciphers::secretbox` is gone, with no alias.", "secretbox_removed_call": "As `secretbox_removed`: name `crypto::secret_key_encryption::secretbox<>` and `secretbox_xchacha20poly1305<>`, the names clang offers.", "seal_removed_call": "As `seal_removed`: call crypto::secret_key_encryption::aead::seal and open, which the cipher's header brings.", - "async_seal_removed": "Call crypto::secret_key_encryption::aead::async_seal and async_open. clang's suggestion, `secret_key_encryption::async_seal` and `async_open`, is the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user.", + "async_seal_removed": "Call crypto::secret_key_encryption::aead::async_seal and async_open. What clang suggests depends on its version: Clang 18 and Apple Clang 17 offer those; Clang 22 offers `secret_key_encryption::async_seal` and `async_open`, the box form, which takes no associated data and is wrong for an AES-GCM or ChaCha20-Poly1305 user.", "async_seal_removed_declaration": "As `async_seal_removed`: call crypto::secret_key_encryption::aead::async_seal and async_open, in .", "async_seal_box_asynchronous_backend": "Name a native backend, such as `backends::sodium`, for the secret box: WebCrypto has no secret box, so no form of it runs on the browser's backend, where only AES-GCM seals and opens.", "async_open_box_asynchronous_backend": "Name a native backend, such as `backends::sodium`, for the crypto_box: WebCrypto has no crypto_box, so no form of it runs on the browser's backend, where only AES-GCM seals and opens.", diff --git a/doc/tables/generate.py b/doc/tables/generate.py index ecc4576..aaaa4af 100644 --- a/doc/tables/generate.py +++ b/doc/tables/generate.py @@ -94,11 +94,13 @@ 'webcpp.compile-diagnostic', 'webcpp.compile-fail', 'webcpp.link-fail', 'webcpp.example') # A message test's text: clang's -verify directive, with the count it takes when two calls raise -# the same text (`expected-error@:* 2 {{text}}`). A directive that ends with `(knock-on)` -# after its text pins an error clang adds because of another (an undeclared name the first error -# left, a call it corrected): the test checks it, and the page leaves it out. clang's -verify -# ignores the words after a directive. -EXPECTED_ERROR = re.compile(r'expected-error@\S+(?: \d+)? \{\{(.*)\}\}(\s*\(knock-on\))?') +# the same text (`expected-error@:* 2 {{text}}`), or a range of counts (`1+`, or `0-1` for a +# knock-on error that one clang version reports and another does not). A directive that ends with +# `(knock-on)` after its text pins an error clang adds because of another (an undeclared name the +# first error left, a call it corrected): the test checks it, and the page leaves it out. clang's +# -verify ignores the words after a directive. +EXPECTED_ERROR = re.compile( + r'expected-error@\S+(?: \d+(?:\+|-\d+)?)? \{\{(.*)\}\}(\s*\(knock-on\))?') SOURCE = re.compile(r'\{([a-z0-9-]+)\}') # A comparison table's cell that the data writes: {speed:}, the family's throughput from # doc/performance.json, or {constant_time:}, its measured constant time from crypto.json. diff --git a/doc/tables/generate_test.py b/doc/tables/generate_test.py index 7d23252..723fb12 100644 --- a/doc/tables/generate_test.py +++ b/doc/tables/generate_test.py @@ -101,6 +101,19 @@ def test_a_message_test_s_first_error_is_its_message(scratch: Path) -> None: assert found == {'alias': (["no template named 'old' in namespace 'n'"], ['native'])}, found +def test_a_directive_s_range_of_counts_is_read(scratch: Path) -> None: + # A text that a range of counts states is listed as any other (`1+`), and a knock-on error that + # one clang reports and another does not (`0-1`) is left out as any knock-on. + written(scratch, 'test/messages/ranges/Jamfile', + 'webcpp.compile-diagnostic ranges : ranges.cpp : : native : alone ;\n') + written(scratch, 'test/messages/ranges/ranges.cpp', ( + "// expected-error@+2 1+ {{no member named 'old' in namespace 'n'}}\n" + "// expected-error@+1 0-1 {{no matching function for call to 'old'}} (knock-on)\n" + 'n::old(1);\n')) + found = generate.messages(scratch) + assert found == {'ranges': (["no member named 'old' in namespace 'n'"], ['native'])}, found + + def test_a_test_of_several_removed_names_lists_each(scratch: Path) -> None: # A test that pins several removed names lists every one, in the source's order, each once. written(scratch, 'test/messages/names/Jamfile', @@ -1824,6 +1837,10 @@ def test_a_namespace_table_is_split_into_its_parts(_: Path) -> None: test_a_program_inside_an_if_is_a_fault, test_the_memory_option_s_tests_are_declared, test_a_message_expected_more_than_once_is_read, + test_a_message_test_s_first_error_is_its_message, + test_a_directive_s_range_of_counts_is_read, + test_a_test_of_several_removed_names_lists_each, + test_a_function_is_read_in_the_header_the_operation_maps_it_to, test_a_backend_says_why_it_is_missing_elsewhere, test_a_reason_elsewhere_is_openssl_s_alone, test_an_outcome_reads_each_directive, diff --git a/test/messages/async_seal_removed/Jamfile b/test/messages/async_seal_removed/Jamfile index 34ef0cd..dddbbf6 100644 --- a/test/messages/async_seal_removed/Jamfile +++ b/test/messages/async_seal_removed/Jamfile @@ -8,10 +8,12 @@ project : requirements /webcpp/crypto//crypto ; import webcpp ; -# alone: the two missing names and the corrected calls of the box forms are -# the compile's only errors, so a regression that puts another error before or -# after them fails the test. -# The pinned "did you mean" texts are clang's typo correction, which names the -# box forms and may drift with clang updates. +# alone: the two missing names, and on Clang 22 the corrected calls of the box +# forms, are the compile's only errors, so a regression that puts another error +# before or after them fails the test. clang's "did you mean" is its typo +# correction, which differs by version, and is not pinned. AES-GCM's default +# backend is linked, as a program that calls it links it: where clang corrects +# the calls to the AEAD forms (Clang 18, Apple Clang 17), they compile. webcpp.compile-diagnostic async_seal_removed : async_seal_removed.cpp - : /webcpp/asio//asio : native wasip2 wasip3 : alone ; + : /webcpp/asio//asio /webcpp/crypto//gcm-default + : native wasip2 wasip3 : alone ; diff --git a/test/messages/async_seal_removed/async_seal_removed.cpp b/test/messages/async_seal_removed/async_seal_removed.cpp index 14e317a..b663df8 100644 --- a/test/messages/async_seal_removed/async_seal_removed.cpp +++ b/test/messages/async_seal_removed/async_seal_removed.cpp @@ -6,10 +6,13 @@ // What a program that still calls crypto::async_seal and crypto::async_open as it did sees (design // D11): each call stops the build, although async.hpp, which brings -// secret_key_encryption::aead::async_seal and async_open, is included. clang offers the box forms, -// secret_key_encryption::async_seal and async_open, whose arity is one less, and the corrected call -// adds its own error: those four errors alone. The object is a parameter: the calls are compiled, -// never run. +// secret_key_encryption::aead::async_seal and async_open, is included: those two errors alone. +// What clang offers after each is its typo correction, which differs by version and is not pinned: +// Clang 18 and Apple Clang 17 offer secret_key_encryption::aead::async_seal and async_open, the +// right forms, and the corrected calls compile; Clang 22 offers the box forms, +// secret_key_encryption::async_seal and async_open, whose arity is one less, and each corrected +// call adds its own error, which may be absent (0-1). The program links AES-GCM's default backend, +// as a program that calls it does. The object is a parameter: the calls are compiled, never run. #include #include @@ -32,16 +35,12 @@ void sealed_and_opened(webcpp::crypto::ciphers::aes256_gcm& cipher) { std::array const tag{}; webcpp::asio::io_context context; auto const executor = context.get_executor(); - // clang-format off - // expected-error@+3 {{no member named 'async_seal' in namespace 'webcpp::crypto'; did you mean 'webcpp::crypto::secret_key_encryption::async_seal'?}} - // expected-error@+2 {{no matching function for call to 'async_seal'}} (knock-on) - // clang-format on + // expected-error@+2 {{no member named 'async_seal' in namespace 'webcpp::crypto'}} + // expected-error@+1 0-1 {{no matching function for call to 'async_seal'}} (knock-on) webcpp::crypto::async_seal(executor, cipher, nonce, associated_data, data, [](boost::system::error_code, boost::hash2::digest<16>) {}); - // clang-format off - // expected-error@+3 {{no member named 'async_open' in namespace 'webcpp::crypto'; did you mean 'webcpp::crypto::secret_key_encryption::async_open'?}} - // expected-error@+2 {{no matching function for call to 'async_open'}} (knock-on) - // clang-format on + // expected-error@+2 {{no member named 'async_open' in namespace 'webcpp::crypto'}} + // expected-error@+1 0-1 {{no matching function for call to 'async_open'}} (knock-on) webcpp::crypto::async_open(executor, cipher, nonce, associated_data, data, tag, [](boost::system::error_code) {}); } diff --git a/test/messages/ph_removed/ph_removed.cpp b/test/messages/ph_removed/ph_removed.cpp index 2f67b1b..534e529 100644 --- a/test/messages/ph_removed/ph_removed.cpp +++ b/test/messages/ph_removed/ph_removed.cpp @@ -13,11 +13,13 @@ int main() { // With the name unknown, clang reads `<` as a comparison, the hash's type where a value goes - // and `::begin` as a global name: four errors for the line, as a program that still names it - // sees them, the first the missing name. + // and `::begin` as a global name: three errors for the line, as a program that still names it + // sees them, the first the missing name. Clang 22 also offers std::begin for the global name + // and adds the failed call of its correction, a fourth error that Clang 18 and Apple Clang 17 + // do not report: that one may be absent (0-1). // expected-error@+4 {{no member named 'ph' in namespace}} // expected-error@+3 {{expected '(' for function-style cast or type construction}} (knock-on) // expected-error@+2 {{no member named 'begin' in the global namespace}} (knock-on) - // expected-error@+1 {{no matching function for call to 'begin'}} (knock-on) + // expected-error@+1 0-1 {{no matching function for call to 'begin'}} (knock-on) return webcpp::crypto::curves::ed25519::ph::begin() ? 0 : 1; } diff --git a/test/messages/seal_removed_call/Jamfile b/test/messages/seal_removed_call/Jamfile index 37be06e..5afd4af 100644 --- a/test/messages/seal_removed_call/Jamfile +++ b/test/messages/seal_removed_call/Jamfile @@ -10,6 +10,8 @@ import webcpp ; # alone: the two removed calls are the compile's only errors. Native only: on # WASI clang offers fopen for open and adds an error, which -# seal_removed_call_wasi pins. +# seal_removed_call_wasi pins. ChaCha20-Poly1305's default backend is linked, as +# a program that calls it links it: Clang 18 and Apple Clang 17 correct the +# calls to the AEAD forms, which then compile. webcpp.compile-diagnostic seal_removed_call : seal_removed_call.cpp - : : native : alone ; + : /webcpp/crypto//chacha20_poly1305-default : native : alone ; diff --git a/test/messages/seal_removed_call/seal_removed_call.cpp b/test/messages/seal_removed_call/seal_removed_call.cpp index 76c070f..a87684e 100644 --- a/test/messages/seal_removed_call/seal_removed_call.cpp +++ b/test/messages/seal_removed_call/seal_removed_call.cpp @@ -6,8 +6,10 @@ // What a program that still calls crypto::seal and crypto::open as it did sees, natively (design // D11): each call stops the build, with those two errors alone, although the cipher's header, -// which brings secret_key_encryption::aead::seal and open, is included. On WASI clang offers the C -// library's fopen for open: seal_removed_call_wasi. +// which brings secret_key_encryption::aead::seal and open, is included. Clang 18 and Apple Clang 17 +// offer those, and compile the corrected calls, which instantiate the cipher's engine: the program +// links ChaCha20-Poly1305's default backend, as a program that calls it does. On WASI clang offers +// the C library's fopen for open: seal_removed_call_wasi. #include