[PATCH] D134475: Add C++11 attribute msvc::constexpr

Richard Dzenis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 1 13:56:10 PDT 2022


RIscRIpt updated this revision to Diff 464522.
RIscRIpt retitled this revision from "[AST] Add C++11 attribute msvc::constexpr" to "Add C++11 attribute msvc::constexpr".
RIscRIpt added a comment.

Add more tests, don't alter constexprKind of `[[msvc::constexpr]]` functions - instead change implementation of `isConstexpr`

In D134475#3827712 <https://reviews.llvm.org/D134475#3827712>, @aaron.ballman wrote:

> ... we're missing some significant test coverage for it. I had some suggestions for specific things we should be thinking about, but another useful test would be to modify an existing constexpr test to add a RUN line enabling ms extensions, and use a macro to switch between `constexpr` and `[[msvc::constexpr]]` based on those RUN lines. Basically, ensure that `[[msvc::constexpr]]` gives the same behavior (both in terms of evaluation and in terms of semantic checking) as `constexpr`. WDYT?

That's a good idea. Based on my experiments with MSVC, I am more convinced that `constexpr` and `[[msvc::constexpr]]` are synonyms (with some extra undocumented (yet?) features by MSFT). I added more tests as per your suggestion.
Regarding existing tests, I was able to find only `clang/test/AST/Interp/functions.cpp` which uses `constexpr` only with functions (otherwise `-Dconstexpr=[[msvc::constexpr]]` would break code in case there are `constexpr` variables) - I added `RUN` lines there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134475

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/Interp/functions.cpp
  clang/test/AST/msvc-attrs-invalid.cpp
  clang/test/AST/msvc-attrs.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134475.464522.patch
Type: text/x-patch
Size: 7691 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221001/d40323ee/attachment-0001.bin>


More information about the cfe-commits mailing list