Update Parser::ParseTypeName to return a TypeResult, which also tells
us whether there was an error in trying to parse a type-name (type-id
in C++). This allows propagation of errors further in the compiler,
suppressing more bogus error messages.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64922 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index a385a13..677f994 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -29,7 +29,6 @@
QualType Result;
switch (DS.getTypeSpecType()) {
- default: assert(0 && "Unknown TypeSpecType!");
case DeclSpec::TST_void:
Result = Context.VoidTy;
break;
@@ -169,6 +168,8 @@
Result = Context.getTypeOfExpr(E);
break;
}
+ case DeclSpec::TST_error:
+ return QualType();
}
// Handle complex types.
@@ -277,8 +278,11 @@
// We default to a dependent type initially. Can be modified by
// the first return statement.
T = Context.DependentTy;
- else
+ else {
T = ConvertDeclSpecToType(DS);
+ if (T.isNull())
+ return T;
+ }
break;
}
@@ -725,16 +729,13 @@
assert(D.getIdentifier() == 0 && "Type name should have no identifier!");
QualType T = GetTypeForDeclarator(D, S);
+ if (T.isNull())
+ return true;
- assert(!T.isNull() && "GetTypeForDeclarator() returned null type");
-
// Check that there are no default arguments (C++ only).
if (getLangOptions().CPlusPlus)
CheckExtraCXXDefaultArguments(D);
- // In this context, we *do not* check D.getInvalidType(). If the declarator
- // type was invalid, GetTypeForDeclarator() still returns a "valid" type,
- // though it will not reflect the user specified type.
return T.getAsOpaquePtr();
}