[clang] [Clang] Improve support for expression messages in `static_assert` (PR #73234)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 27 07:24:44 PST 2023


================
@@ -179,18 +179,20 @@ static_assert(false, Message{}); // expected-error {{static assertion failed: He
 }
 
 struct MessageInvalidSize {
-    constexpr auto size(int) const; // expected-note {{candidate function not viable: requires 1 argument, but 0 were provided}}
-    constexpr auto data() const;
+    constexpr unsigned long size(int) const; // expected-note {{'size' declared here}}
+    constexpr const char* data() const;
 };
 struct MessageInvalidData {
-    constexpr auto size() const;
-    constexpr auto data(int) const; // expected-note {{candidate function not viable: requires 1 argument, but 0 were provided}}
+    constexpr unsigned long size() const;
+    constexpr const char* data(int) const; // expected-note {{'data' declared here}}
 };
 
 static_assert(false, MessageInvalidSize{});  // expected-error {{static assertion failed}} \
-                                             // expected-error {{the message in a static assertion must have a 'size()' member function returning an object convertible to 'std::size_t'}}
+                                             // expected-error {{the message in a static assertion must have a 'size()' member function returning an object convertible to 'std::size_t'}} \
----------------
cor3ntin wrote:

The only thing that change is that the note previously attached to the  declaration of size() is now an error attached to the call site (L195) and the declaration gets a 'declared here' note.

I don't see how we could preserve the previous diagnostics, they all come from deep in overload resolution.

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


More information about the cfe-commits mailing list