aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-06-29 22:58:55 +0000
committerAnders Carlsson <andersca@mac.com>2009-06-29 22:58:55 +0000
commitaf017e682918f7a1a95ff08d9ab7ae3426436ca3 (patch)
tree6b0b254096cee59b6cfc1a3b61c0d1f5d05b8220 /lib/Sema/SemaType.cpp
parent43a3643eaf6d411b43b01cbbf85a197ffdaba204 (diff)
Improvements to decltype. We now don't crash anymore when the expr is an overloaded function decl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74472 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 1c67daece0..c0b4e9fbec 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -242,7 +242,11 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
Expr *E = static_cast<Expr *>(DS.getTypeRep());
assert(E && "Didn't get an expression for decltype?");
// TypeQuals handled by caller.
- Result = Context.getDecltypeType(E);
+ Result = BuildDecltypeType(E);
+ if (Result.isNull()) {
+ Result = Context.IntTy;
+ isInvalid = true;
+ }
break;
}
case DeclSpec::TST_auto: {
@@ -1463,3 +1467,16 @@ QualType Sema::getQualifiedNameType(const CXXScopeSpec &SS, QualType T) {
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
return Context.getQualifiedNameType(NNS, T);
}
+
+QualType Sema::BuildTypeofExprType(Expr *E) {
+ return Context.getTypeOfExprType(E);
+}
+
+QualType Sema::BuildDecltypeType(Expr *E) {
+ if (E->getType() == Context.OverloadTy) {
+ Diag(E->getLocStart(),
+ diag::err_cannot_determine_declared_type_of_overloaded_function);
+ return QualType();
+ }
+ return Context.getDecltypeType(E);
+}