diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index eacf3678189c..004e31af178d 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -1196,6 +1196,11 @@ bool Type::isLiteralType(ASTContext &Ctx) const { return true; } + // If this type hasn't been deduced yet, then conservatively assume that + // it'll work out to be a literal type. + if (isa(BaseTy->getCanonicalTypeInternal())) + return true; + return false; } diff --git a/clang/test/SemaCXX/constant-expression-cxx1y.cpp b/clang/test/SemaCXX/constant-expression-cxx1y.cpp index ea0c9e652683..23b5d0b460f5 100644 --- a/clang/test/SemaCXX/constant-expression-cxx1y.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx1y.cpp @@ -708,3 +708,10 @@ namespace switch_stmt { static_assert(test_copy("hello world", 10), ""); static_assert(test_copy("hello world", 10), ""); } + +namespace deduced_return_type { + constexpr auto f() { return 0; } + template constexpr auto g(T t) { return t; } + static_assert(f() == 0, ""); + static_assert(g(true), ""); +}