aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-18 17:45:20 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-18 17:45:20 +0000
commit809070a886684cb5b92eb0e00a6581ab1fa6b17a (patch)
treec3e6242279c488480f00bd966c7c46fcd7371eb3 /lib/Sema/SemaType.cpp
parente53f8206ebb36a17e95e64270704e2608d1796f4 (diff)
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
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index a385a13f4c..677f994cac 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -29,7 +29,6 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS) {
QualType Result;
switch (DS.getTypeSpecType()) {
- default: assert(0 && "Unknown TypeSpecType!");
case DeclSpec::TST_void:
Result = Context.VoidTy;
break;
@@ -169,6 +168,8 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS) {
Result = Context.getTypeOfExpr(E);
break;
}
+ case DeclSpec::TST_error:
+ return QualType();
}
// Handle complex types.
@@ -277,8 +278,11 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip) {
// 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 @@ Sema::TypeResult Sema::ActOnTypeName(Scope *S, Declarator &D) {
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();
}