[PATCH] D151720: [clang][ExprConstant] Fix display of syntactically-invalid note for member function calls
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 1 00:35:01 PDT 2023
tbaeder added a comment.
The only additional test I could come up with is one where the `->` is in the middle of an lvalue designator, like:
struct A {
constexpr int foo() { (void)(1/0); return 1;}
};
struct B {
A aa;
A *a = &aa;
};
struct C {
B b;
};
struct D {
C cc;
C *c = &cc;
};
constexpr D d{};
static_assert(d.c->b.a->foo() == 1);
but this is printed correctly. The rest of the output LGTM but I'll wait for some of the others to maybe chime in.
================
Comment at: clang/lib/AST/ExprConstant.cpp:1931
+ else
+ Out << ".";
+ } else if (const auto *OCE =
----------------
Did you `clang-format` these changes? The two if/else body here seems indented 4 spaces instead of 2.
================
Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:995
+static_assert(sptr->f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'sptr->f()'}}
+static_assert(slref.f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'slref.f()'}}
+static_assert(srref.f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'srref.f()'}}
----------------
================
Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:996
+static_assert(slref.f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'slref.f()'}}
+static_assert(srref.f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'srref.f()'}}
static_assert(T(3).f() == 3, "");
----------------
================
Comment at: clang/test/SemaCXX/constexpr-frame-describe.cpp:5
+struct Foo {
+ constexpr void zomg() const { (void)(1 / 0); } // expected-error {{constant expression}} expected-warning {{division by zero}} expected-note 2{{division by zero}}
+};
----------------
================
Comment at: clang/test/SemaCXX/constexpr-frame-describe.cpp:11
+ constexpr bool operator==(const S&) const { // expected-error {{never produces a constant expression}}
+ return 1 / 0; // expected-warning {{division by zero}} expected-note 3{{division by zero}}
+ }
----------------
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151720/new/
https://reviews.llvm.org/D151720
More information about the cfe-commits
mailing list