[PATCH] D54903: [Sema] Improve static_assert diagnostics.

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 27 15:32:42 PST 2018


Quuxplusone added inline comments.


================
Comment at: test/SemaCXX/static-assert.cpp:111
+static_assert(std::is_same<ExampleTypes::T, ExampleTypes::U>::value, "message"); // expected-error{{static_assert failed due to requirement 'std::is_same<int, float>::value' "message"}}
+static_assert(std::is_const<ExampleTypes::T>::value, "message");                 // expected-error{{static_assert failed due to requirement 'std::is_const<int>::value' "message"}}
----------------
I would like to see some more realistic test cases. I suggest this test case for example:
```
struct BI_tag {};
struct RAI_tag : BI_tag {};
struct MyIterator {
    using tag = BI_tag;
};
struct MyContainer {
    using iterator = MyIterator;
};
template<class Container>
void foo() {
    static_assert(std::is_base_of_v<RAI_tag, typename Container::iterator::tag>);
}
```
This is an example where as a programmer I would not want to see //only// `failed due to requirement std::is_base_of_v<RAI_tag, BI_tag>` — that doesn't help me solve the issue. OTOH, since every diagnostic includes a cursor to the exact text of the `static_assert` already, I think it's fair to say that the current diagnostic message is redundant, and therefore it's okay to replace it (as you propose to do) with something that is not redundant.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54903/new/

https://reviews.llvm.org/D54903





More information about the cfe-commits mailing list