[libcxx-commits] [PATCH] D155064: [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated
Corentin Jabot via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jul 23 01:30:37 PDT 2023
cor3ntin added inline comments.
================
Comment at: clang/test/SemaCXX/vartemplate-lambda.cpp:17
+ // expected-note{{cannot be used in a constant expression}} \
+ // expected-error 2{{a lambda expression may not appear inside of a constant expression}}
};
----------------
This also looks like a regression.
The current error is much clearer, can you investigate?
```
<source>:3:22: error: constexpr variable 't<int>' must be initialized by a constant expression
3 | static constexpr T t = [](int f = T(7)){return f;}();
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:6:12: note: in instantiation of static data member 'S::t<int>' requested here
6 | int a = S::t<int>;
| ^
<source>:3:26: note: non-literal type 'S::(lambda at <source>:3:26)' cannot be used in a constant expression
3 | static constexpr T t = [](int f = T(7)){return f;}();
| ^
```
Why do we emt 2 errors instead of a single note? Here the error is that the initializer is not a constant expression, everything else should be notes.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155064/new/
https://reviews.llvm.org/D155064
More information about the libcxx-commits
mailing list