Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4984,6 +4984,15 @@ bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS) {
return false;
if (!this->visitVarDecl(VD))
return false;

// Register decomposition decl holding vars.
if (const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
for (auto *BD : DD->bindings())
if (auto *KD = BD->getHoldingVar()) {
if (!this->visitVarDecl(KD))
return false;
}
}
}

return true;
Expand Down
20 changes: 20 additions & 0 deletions clang/test/AST/ByteCode/cxx17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,23 @@ constexpr S s = getS(); // both-error {{must be initialized by a constant expres
// both-note {{declared here}}
static_assert(s.a == 12, ""); // both-error {{not an integral constant expression}} \
// both-note {{initializer of 's' is not a constant expression}}

using size_t = decltype(sizeof(0));
namespace std { template<typename T> struct tuple_size; }
namespace std { template<size_t, typename> struct tuple_element; }

namespace constant {
struct Q {};
template<int N> constexpr int get(Q &&) { return N * N; }
}
template<> struct std::tuple_size<constant::Q> { static const int value = 3; };
template<int N> struct std::tuple_element<N, constant::Q> { typedef int type; };

namespace constant {
Q q;
constexpr bool f() {
auto [a, b, c] = q;
return a == 0 && b == 1 && c == 4;
}
static_assert(f());
}
Loading