[PATCH] D134475: [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 18 14:28:49 PDT 2023
rsmith added inline comments.
================
Comment at: clang/lib/AST/ExprConstant.cpp:5615-5627
+ if (canEvalMSConstexpr || isMSConstexpr) {
+ // Diagnose invalid usage of [[msvc::constexpr]] function
+ bool isConstructor = isa<CXXConstructorDecl>(Definition);
+ if (canEvalMSConstexpr) { // !isMSConstexpr
+ Info.FFDiag(CallLoc, diag::note_constexpr_invalid_function, 1)
+ << /*IsConstexpr*/ 0 << isConstructor << Definition;
+ Info.Note(Definition->getLocation(), diag::note_declared_at);
----------------
Given that the intended use case is for usage behind the scenes in the standard library, I don't think we should be changing our diagnostic output at all here. If the library, as an implementation detail, marks a non-`constexpr` function as `[[msvc::constexpr]]`, we shouldn't tell the user to add `[[msvc::constexpr]]` to their code to allow it to be called, after all, the annotation is an implementation detail of the MS standard library.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134475/new/
https://reviews.llvm.org/D134475
More information about the cfe-commits
mailing list