diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-01-04 04:53:10 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2015-01-04 04:53:10 +0000 |
commit | a17629290b6157dad843001e1cdeb4fe353f2e0f (patch) | |
tree | 0124e2d289ab3d5401932fda7a648f08c73d40ee /lib/Sema | |
parent | 952b0616d5b6370e84b2c108238259e0af39ff72 (diff) |
Crash less enthusiasticially on _Atomic or __restrict__ on invalid types.
Many places in Sema cannot handle isNull() types. This is fine, because in
most places the type building code recovers by falling back to IntTy. In
GetFullTypeForDeclarator(), this is done at the end of the getNumTypeObjects()
loop body. This function calls BuildQualifiedType() before this fallback is
done though, so it explicitly needs to check for isNull() types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225124 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaType.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 4582406065..95c3698bf1 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1188,6 +1188,9 @@ static std::string getPrintableNameForEntity(DeclarationName Entity) { QualType Sema::BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS) { + if (T.isNull()) + return QualType(); + // Enforce C99 6.7.3p2: "Types other than pointer types derived from // object or incomplete types shall not be restrict-qualified." if (Qs.hasRestrict()) { @@ -1226,6 +1229,9 @@ QualType Sema::BuildQualifiedType(QualType T, SourceLocation Loc, QualType Sema::BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVRA, const DeclSpec *DS) { + if (T.isNull()) + return QualType(); + // Convert from DeclSpec::TQ to Qualifiers::TQ by just dropping TQ_atomic. unsigned CVR = CVRA & ~DeclSpec::TQ_atomic; |