tbaeder created this revision. tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik. Herald added a subscriber: kristof.beyls. Herald added a project: All. tbaeder requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
They are harmless and handled by other means, but we used to return false from visitDeclStmt. Repository: rG LLVM Github Monorepo 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,14 @@ 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 }; + + 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, RecordDecl, EnumDecl>(D)) continue; const auto *VD = dyn_cast<VarDecl>(D);
Index: clang/test/AST/Interp/literals.cpp =================================================================== --- clang/test/AST/Interp/literals.cpp +++ clang/test/AST/Interp/literals.cpp @@ -768,3 +768,14 @@ 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 }; + + 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, RecordDecl, EnumDecl>(D)) continue; const auto *VD = dyn_cast<VarDecl>(D);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits