From ee71cbddb77f8da9285657cac248b431928143b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Sun, 12 Mar 2023 08:32:07 +0100 Subject: [PATCH] [clang][Interp] Ignore more non-VarDecl declarations They are harmless and handled by other means, but we used to return false from visitDeclStmt. Differential Revision: https://reviews.llvm.org/D145861 --- clang/lib/AST/Interp/ByteCodeStmtGen.cpp | 2 +- clang/test/AST/Interp/literals.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp index 6faa3f9..2c53900 100644 --- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp @@ -224,7 +224,7 @@ bool ByteCodeStmtGen::visitCompoundStmt( template bool ByteCodeStmtGen::visitDeclStmt(const DeclStmt *DS) { for (auto *D : DS->decls()) { - if (isa(D)) + if (isa(D)) continue; const auto *VD = dyn_cast(D); diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp index 5883c18..f31a490 100644 --- a/clang/test/AST/Interp/literals.cpp +++ b/clang/test/AST/Interp/literals.cpp @@ -766,3 +766,16 @@ namespace TypeTraits { static_assert(S3{}.foo(), ""); static_assert(!S3{}.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 -- 2.7.4