forked from qt-creator/qt-creator
Set and propagate the `auto' specifier.
This commit is contained in:
@@ -231,6 +231,8 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
|
||||
|
||||
if (ty.isFriend())
|
||||
symbol->setStorage(Symbol::Friend);
|
||||
else if (ty.isAuto())
|
||||
symbol->setStorage(Symbol::Auto);
|
||||
else if (ty.isRegister())
|
||||
symbol->setStorage(Symbol::Register);
|
||||
else if (ty.isStatic())
|
||||
@@ -241,7 +243,8 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
|
||||
symbol->setStorage(Symbol::Mutable);
|
||||
else if (ty.isTypedef())
|
||||
symbol->setStorage(Symbol::Typedef);
|
||||
else if (ty.isDeprecated())
|
||||
|
||||
if (ty.isDeprecated())
|
||||
symbol->setDeprecated(true);
|
||||
|
||||
if (it->value && it->value->initializer) {
|
||||
|
||||
@@ -140,6 +140,13 @@ bool CheckSpecifier::visit(SimpleSpecifierAST *ast)
|
||||
_fullySpecifiedType.setFriend(true);
|
||||
break;
|
||||
|
||||
case T_AUTO:
|
||||
if (_fullySpecifiedType.isAuto())
|
||||
translationUnit()->error(ast->specifier_token,
|
||||
"duplicate `%s'", spell(ast->specifier_token));
|
||||
_fullySpecifiedType.setAuto(true);
|
||||
break;
|
||||
|
||||
case T_REGISTER:
|
||||
if (_fullySpecifiedType.isRegister())
|
||||
translationUnit()->error(ast->specifier_token,
|
||||
|
||||
@@ -75,6 +75,7 @@ FullySpecifiedType FullySpecifiedType::qualifiedType() const
|
||||
{
|
||||
FullySpecifiedType ty = *this;
|
||||
ty.setFriend(false);
|
||||
ty.setAuto(false);
|
||||
ty.setRegister(false);
|
||||
ty.setStatic(false);
|
||||
ty.setExtern(false);
|
||||
@@ -119,6 +120,12 @@ bool FullySpecifiedType::isFriend() const
|
||||
void FullySpecifiedType::setFriend(bool isFriend)
|
||||
{ f._isFriend = isFriend; }
|
||||
|
||||
bool FullySpecifiedType::isAuto() const
|
||||
{ return f._isAuto; }
|
||||
|
||||
void FullySpecifiedType::setAuto(bool isAuto)
|
||||
{ f._isAuto = isAuto; }
|
||||
|
||||
bool FullySpecifiedType::isRegister() const
|
||||
{ return f._isRegister; }
|
||||
|
||||
@@ -225,6 +232,7 @@ void FullySpecifiedType::copySpecifiers(const FullySpecifiedType &type)
|
||||
{
|
||||
// class storage specifiers
|
||||
f._isFriend = type.f._isFriend;
|
||||
f._isAuto = type.f._isAuto;
|
||||
f._isRegister = type.f._isRegister;
|
||||
f._isStatic = type.f._isStatic;
|
||||
f._isExtern = type.f._isExtern;
|
||||
|
||||
@@ -83,6 +83,9 @@ public:
|
||||
bool isFriend() const;
|
||||
void setFriend(bool isFriend);
|
||||
|
||||
bool isAuto() const;
|
||||
void setAuto(bool isAuto);
|
||||
|
||||
bool isRegister() const;
|
||||
void setRegister(bool isRegister);
|
||||
|
||||
@@ -141,6 +144,7 @@ private:
|
||||
|
||||
// storage class specifiers
|
||||
unsigned _isFriend: 1;
|
||||
unsigned _isAuto: 1;
|
||||
unsigned _isRegister: 1;
|
||||
unsigned _isStatic: 1;
|
||||
unsigned _isExtern: 1;
|
||||
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
enum Storage {
|
||||
NoStorage = 0,
|
||||
Friend,
|
||||
Auto,
|
||||
Register,
|
||||
Static,
|
||||
Extern,
|
||||
|
||||
Reference in New Issue
Block a user