[clang] [Clang] Improve support for expression messages in `static_assert` (PR #73234)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 27 07:29:51 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'}} \
----------------
AaronBallman wrote:
Okay, I didn't think it would be easy to retain the previous behavior, but I still had to ask just in case.
https://github.com/llvm/llvm-project/pull/73234
More information about the cfe-commits
mailing list