aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-08-21 17:02:28 +0000
committerChris Lattner <sabre@nondot.org>2007-08-21 17:02:28 +0000
commit3cbc38bd3569d37f53bd76fa89d24803f48f5036 (patch)
treebc4acee9a3ac7c6d253132fa060b11f17e2f4949
parent58dee10ed2eee34035f62d1c2d32b3639e9182f8 (diff)
add sema support for complex integer types
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41232 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Sema/SemaType.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/Sema/SemaType.cpp b/Sema/SemaType.cpp
index a1e9e1ccc2..cc37055c9a 100644
--- a/Sema/SemaType.cpp
+++ b/Sema/SemaType.cpp
@@ -38,36 +38,45 @@ static QualType ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) {
return Ctx.UnsignedCharTy;
}
case DeclSpec::TST_unspecified: // Unspecific typespec defaults to int.
- case DeclSpec::TST_int:
+ case DeclSpec::TST_int: {
+ QualType Result;
if (DS.getTypeSpecSign() != DeclSpec::TSS_unsigned) {
switch (DS.getTypeSpecWidth()) {
- case DeclSpec::TSW_unspecified: return Ctx.IntTy;
- case DeclSpec::TSW_short: return Ctx.ShortTy;
- case DeclSpec::TSW_long: return Ctx.LongTy;
- case DeclSpec::TSW_longlong: return Ctx.LongLongTy;
+ case DeclSpec::TSW_unspecified: Result = Ctx.IntTy; break;
+ case DeclSpec::TSW_short: Result = Ctx.ShortTy; break;
+ case DeclSpec::TSW_long: Result = Ctx.LongTy; break;
+ case DeclSpec::TSW_longlong: Result = Ctx.LongLongTy; break;
}
} else {
switch (DS.getTypeSpecWidth()) {
- case DeclSpec::TSW_unspecified: return Ctx.UnsignedIntTy;
- case DeclSpec::TSW_short: return Ctx.UnsignedShortTy;
- case DeclSpec::TSW_long: return Ctx.UnsignedLongTy;
- case DeclSpec::TSW_longlong: return Ctx.UnsignedLongLongTy;
+ case DeclSpec::TSW_unspecified: Result = Ctx.UnsignedIntTy; break;
+ case DeclSpec::TSW_short: Result = Ctx.UnsignedShortTy; break;
+ case DeclSpec::TSW_long: Result = Ctx.UnsignedLongTy; break;
+ case DeclSpec::TSW_longlong: Result = Ctx.UnsignedLongLongTy; break;
}
}
+ // Handle complex integer types.
+ if (DS.getTypeSpecComplex() == DeclSpec::TSC_unspecified)
+ return Result;
+ assert(DS.getTypeSpecComplex() == DeclSpec::TSC_complex &&
+ "FIXME: imaginary types not supported yet!");
+ return Ctx.getComplexType(Result);
+ }
case DeclSpec::TST_float:
if (DS.getTypeSpecComplex() == DeclSpec::TSC_unspecified)
return Ctx.FloatTy;
assert(DS.getTypeSpecComplex() == DeclSpec::TSC_complex &&
"FIXME: imaginary types not supported yet!");
- return Ctx.FloatComplexTy;
+ return Ctx.getComplexType(Ctx.FloatTy);
case DeclSpec::TST_double: {
bool isLong = DS.getTypeSpecWidth() == DeclSpec::TSW_long;
+ QualType T = isLong ? Ctx.LongDoubleTy : Ctx.DoubleTy;
if (DS.getTypeSpecComplex() == DeclSpec::TSC_unspecified)
- return isLong ? Ctx.LongDoubleTy : Ctx.DoubleTy;
+ return T;
assert(DS.getTypeSpecComplex() == DeclSpec::TSC_complex &&
"FIXME: imaginary types not supported yet!");
- return isLong ? Ctx.LongDoubleComplexTy : Ctx.DoubleComplexTy;
+ return Ctx.getComplexType(T);
}
case DeclSpec::TST_bool: // _Bool or bool
return Ctx.BoolTy;