Introduce Declarator::ObjCCatchContext, this will result in correct error for 'auto' in obj-c catch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134271 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Argyrios Kyrtzidis 2011-07-01 22:22:40 +00:00
Родитель 9864c7dc02
Коммит 17b6399f84
4 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@ -1351,6 +1351,7 @@ public:
TemplateParamContext,// Within a template parameter list. TemplateParamContext,// Within a template parameter list.
CXXNewContext, // C++ new-expression. CXXNewContext, // C++ new-expression.
CXXCatchContext, // C++ catch exception-declaration CXXCatchContext, // C++ catch exception-declaration
ObjCCatchContext, // Objective-C catch exception-declaration
BlockLiteralContext, // Block literal declarator. BlockLiteralContext, // Block literal declarator.
TemplateTypeArgContext, // Template type argument. TemplateTypeArgContext, // Template type argument.
AliasDeclContext, // C++0x alias-declaration. AliasDeclContext, // C++0x alias-declaration.
@ -1502,6 +1503,7 @@ public:
case TemplateParamContext: case TemplateParamContext:
case CXXNewContext: case CXXNewContext:
case CXXCatchContext: case CXXCatchContext:
case ObjCCatchContext:
case BlockLiteralContext: case BlockLiteralContext:
case TemplateTypeArgContext: case TemplateTypeArgContext:
return true; return true;
@ -1523,6 +1525,7 @@ public:
case PrototypeContext: case PrototypeContext:
case TemplateParamContext: case TemplateParamContext:
case CXXCatchContext: case CXXCatchContext:
case ObjCCatchContext:
return true; return true;
case TypeNameContext: case TypeNameContext:
@ -1555,6 +1558,7 @@ public:
case ObjCPrototypeContext: case ObjCPrototypeContext:
case TemplateParamContext: case TemplateParamContext:
case CXXCatchContext: case CXXCatchContext:
case ObjCCatchContext:
case TypeNameContext: case TypeNameContext:
case CXXNewContext: case CXXNewContext:
case AliasDeclContext: case AliasDeclContext:

Просмотреть файл

@ -1633,10 +1633,7 @@ StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
if (Tok.isNot(tok::ellipsis)) { if (Tok.isNot(tok::ellipsis)) {
DeclSpec DS(AttrFactory); DeclSpec DS(AttrFactory);
ParseDeclarationSpecifiers(DS); ParseDeclarationSpecifiers(DS);
// For some odd reason, the name of the exception variable is Declarator ParmDecl(DS, Declarator::ObjCCatchContext);
// optional. As a result, we need to use "PrototypeContext", because
// we must accept either 'declarator' or 'abstract-declarator' here.
Declarator ParmDecl(DS, Declarator::PrototypeContext);
ParseDeclarator(ParmDecl); ParseDeclarator(ParmDecl);
// Inform the actions module about the declarator, so it // Inform the actions module about the declarator, so it

Просмотреть файл

@ -1803,6 +1803,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
} }
break; break;
case Declarator::CXXCatchContext: case Declarator::CXXCatchContext:
case Declarator::ObjCCatchContext:
Error = 4; // Exception declaration Error = 4; // Exception declaration
break; break;
case Declarator::TemplateParamContext: case Declarator::TemplateParamContext:
@ -2441,6 +2442,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
case Declarator::ForContext: case Declarator::ForContext:
case Declarator::ConditionContext: case Declarator::ConditionContext:
case Declarator::CXXCatchContext: case Declarator::CXXCatchContext:
case Declarator::ObjCCatchContext:
case Declarator::BlockLiteralContext: case Declarator::BlockLiteralContext:
case Declarator::TemplateTypeArgContext: case Declarator::TemplateTypeArgContext:
// FIXME: We may want to allow parameter packs in block-literal contexts // FIXME: We may want to allow parameter packs in block-literal contexts
@ -2480,6 +2482,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
case Declarator::TemplateParamContext: case Declarator::TemplateParamContext:
case Declarator::CXXNewContext: case Declarator::CXXNewContext:
case Declarator::CXXCatchContext: case Declarator::CXXCatchContext:
case Declarator::ObjCCatchContext:
case Declarator::TemplateTypeArgContext: case Declarator::TemplateTypeArgContext:
Diag(OwnedTagDecl->getLocation(),diag::err_type_defined_in_type_specifier) Diag(OwnedTagDecl->getLocation(),diag::err_type_defined_in_type_specifier)
<< Context.getTypeDeclType(OwnedTagDecl); << Context.getTypeDeclType(OwnedTagDecl);

Просмотреть файл

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++0x -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -verify -fblocks %s // RUN: %clang_cc1 -std=c++0x -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -verify -fblocks -fobjc-exceptions %s
// "Move" semantics, trivial version. // "Move" semantics, trivial version.
void move_it(__strong id &&from) { void move_it(__strong id &&from) {
@ -25,4 +25,8 @@ void deduction(id obj) {
for (auto x : array) { for (auto x : array) {
__strong id *xPtr = &x; __strong id *xPtr = &x;
} }
@try {
} @catch (auto e) { // expected-error {{'auto' not allowed in exception declaration}}
}
} }