Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeStmtGen.cpp +++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp @@ -210,6 +210,9 @@ template bool ByteCodeStmtGen::visitDeclStmt(const DeclStmt *DS) { for (auto *D : DS->decls()) { + if (isa(D)) + continue; + const auto *VD = dyn_cast(D); if (!VD) return false; Index: clang/test/AST/Interp/functions.cpp =================================================================== --- clang/test/AST/Interp/functions.cpp +++ clang/test/AST/Interp/functions.cpp @@ -9,11 +9,28 @@ static_assert(gimme5() == 5, ""); -template constexpr T identity(T t) { return t; } +template constexpr T identity(T t) { + static_assert(true); + return t; +} static_assert(identity(true), ""); static_assert(identity(true), ""); /// Compiled bytecode should be cached static_assert(!identity(false), ""); +template +constexpr bool sameSize() { + static_assert(sizeof(A) == sizeof(B), ""); // expected-error {{static assertion failed}} \ + // ref-error {{static assertion failed}} \ + // expected-note {{evaluates to}} \ + // ref-note {{evaluates to}} + return true; +} +static_assert(sameSize(), ""); +static_assert(sameSize(), ""); +static_assert(sameSize(), ""); // expected-note {{in instantiation of function template specialization}} \ + // ref-note {{in instantiation of function template specialization}} + + constexpr auto add(int a, int b) -> int { return identity(a) + identity(b); }