[PATCH] D145861: [clang][Interp] Ignore more non-VarDecl declarations

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 14 07:40:27 PDT 2023


tbaeder updated this revision to Diff 505092.

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

https://reviews.llvm.org/D145861

Files:
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/test/AST/Interp/literals.cpp


Index: clang/test/AST/Interp/literals.cpp
===================================================================
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -768,3 +768,16 @@
   static_assert(S3<U>{}.foo(), "");
   static_assert(!S3<T>{}.foo(), "");
 }
+
+#if __cplusplus >= 201402L
+constexpr int ignoredDecls() {
+  static_assert(true);
+  struct F { int a; };
+  enum E { b };
+  using A = int;
+  typedef int Z;
+
+  return F{12}.a;
+}
+static_assert(ignoredDecls() == 12, "");
+#endif
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -221,7 +221,7 @@
 template <class Emitter>
 bool ByteCodeStmtGen<Emitter>::visitDeclStmt(const DeclStmt *DS) {
   for (auto *D : DS->decls()) {
-    if (isa<StaticAssertDecl>(D))
+    if (isa<StaticAssertDecl, TagDecl, TypedefNameDecl>(D))
       continue;
 
     const auto *VD = dyn_cast<VarDecl>(D);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145861.505092.patch
Type: text/x-patch
Size: 1036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230314/0d494018/attachment.bin>


More information about the cfe-commits mailing list