QualType VoidPtrTy, NullPtrTy;
QualType OverloadTy;
QualType DependentTy;
+ QualType UndeducedAutoTy;
ASTContext(const LangOptions& LOpts, SourceManager &SM, TargetInfo &t,
IdentifierTable &idents, SelectorTable &sels,
NullPtr, // This is the type of C++0x 'nullptr'.
Overload, // This represents the type of an overloaded function declaration.
- Dependent // This represents the type of a type-dependent expression.
+ Dependent, // This represents the type of a type-dependent expression.
+
+ UndeducedAuto // In C++0x, this represents the type of an auto variable
+ // that has not been deduced yet.
};
private:
Kind TypeKind;
TST_typeofType,
TST_typeofExpr,
TST_decltype, // C++0x decltype
+ TST_auto, // C++0x auto
TST_error // erroneous type
};
// expressions.
InitBuiltinType(DependentTy, BuiltinType::Dependent);
+ // Placeholder type for C++0x auto declarations whose real type has
+ // not yet been deduced.
+ InitBuiltinType(UndeducedAutoTy, BuiltinType::UndeducedAuto);
+
// C99 6.2.5p11.
FloatComplexTy = getComplexType(FloatTy);
DoubleComplexTy = getComplexType(DoubleTy);
assert(false &&
"Overloaded and dependent types shouldn't get to name mangling");
break;
+ case BuiltinType::UndeducedAuto:
+ assert(0 && "Should not see undeduced auto here");
+ break;
}
}
case BuiltinType::NullPtr: ID = pch::PREDEF_TYPE_NULLPTR_ID; break;
case BuiltinType::Overload: ID = pch::PREDEF_TYPE_OVERLOAD_ID; break;
case BuiltinType::Dependent: ID = pch::PREDEF_TYPE_DEPENDENT_ID; break;
+ case BuiltinType::UndeducedAuto:
+ assert(0 && "Should not see undeduced auto here");
+ break;
}
Record.push_back((ID << 3) | T.getCVRQualifiers());
case DeclSpec::TST_typename: return "type-name";
case DeclSpec::TST_typeofType:
case DeclSpec::TST_typeofExpr: return "typeof";
+ case DeclSpec::TST_auto: return "auto";
}
}
isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_static, Loc, PrevSpec);
break;
case tok::kw_auto:
- isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_auto, Loc, PrevSpec);
+ if (getLang().CPlusPlus0x)
+ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_auto, Loc, PrevSpec);
+ else
+ isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_auto, Loc, PrevSpec);
break;
case tok::kw_register:
isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_register, Loc, PrevSpec);
Result = Context.getDecltypeType(E);
break;
}
+ case DeclSpec::TST_auto: {
+ // TypeQuals handled by caller.
+ Result = Context.UndeducedAutoTy;
+ break;
+ }
case DeclSpec::TST_error:
Result = Context.IntTy;
--- /dev/null
+// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x
+void f() {
+ auto int a; // expected-error{{cannot combine with previous 'auto' declaration specifier}}
+ int auto b; // expected-error{{cannot combine with previous 'int' declaration specifier}}
+}
--- /dev/null
+// RUN: clang-cc -fsyntax-only -verify %s -std=c++98
+void f() {
+ auto int a;
+ int auto b;
+}