summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/AST/Type.cpp5
-rw-r--r--clang/test/SemaCXX/constant-expression-cxx1y.cpp7
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index eacf3678189..004e31af178 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<AutoType>(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 ea0c9e65268..23b5d0b460f 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<typename T> constexpr auto g(T t) { return t; }
+ static_assert(f() == 0, "");
+ static_assert(g(true), "");
+}
OpenPOWER on IntegriCloud