PR16090: C++1y: treat undeduced 'auto' as a literal type, so that constexpr

function templates can use it as a return type.

llvm-svn: 182433
This commit is contained in:
Richard Smith 2013-05-21 22:29:20 +00:00
parent f44d2a8a3e
commit f9a458047a
2 changed files with 12 additions and 0 deletions

View File

@ -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<AutoType>(BaseTy->getCanonicalTypeInternal()))
return true;
return false;
}

View File

@ -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<typename T> constexpr auto g(T t) { return t; }
static_assert(f() == 0, "");
static_assert(g(true), "");
}