[PATCH] D61790: [C++20] add Basic consteval specifier

Tyker via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 7 07:03:48 PDT 2019


Tyker added inline comments.


================
Comment at: clang/lib/Parse/ParseDecl.cpp:2491
+  if (DS.hasConstexprSpecifier() && DSC != DeclSpecContext::DSC_condition) {
     Diag(DS.getConstexprSpecLoc(), diag::err_typename_invalid_constexpr);
     DS.ClearConstexprSpec();
----------------
rsmith wrote:
> Should this say which specifier was used? Or do we somehow reject eg. `sizeof(consteval int)` before we get here?
`sizeof(consteval int)` was rejected before this point but the diagnostics was bad. so i improved it.


================
Comment at: clang/lib/Parse/ParseExprCXX.cpp:1152-1154
     P.Diag(ConstexprLoc, !P.getLangOpts().CPlusPlus17
                              ? diag::ext_constexpr_on_lambda_cxx17
                              : diag::warn_cxx14_compat_constexpr_on_lambda);
----------------
rsmith wrote:
> We should produce a `-Wc++17-compat` diagnostic similar to this for uses of `consteval`.
a consteval keyword can only be lexed when we are in C++2a because it is a C++2a keyword so the warning would never fire.


================
Comment at: clang/lib/Sema/DeclSpec.cpp:1296-1297
       << (TypeSpecType == TST_char16 ? "char16_t" : "char32_t");
-  if (Constexpr_specified)
+  if (hasConstexprSpecifier())
     S.Diag(ConstexprLoc, diag::warn_cxx98_compat_constexpr);
 
----------------
rsmith wrote:
> For `consteval` we should produce an "incompatible with C++ standards before C++2a" diagnostic, not an "incompatible with C++98" diagnostic.
same as previous comment. the consteval keyword cannot be lexed unless we are in c++2a mode so the warning would never fire.


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

https://reviews.llvm.org/D61790





More information about the cfe-commits mailing list