]> granicus.if.org Git - clang/commitdiff
Introduce Declarator::ObjCCatchContext, this will result in correct error for 'auto...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 1 Jul 2011 22:22:40 +0000 (22:22 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 1 Jul 2011 22:22:40 +0000 (22:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134271 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/DeclSpec.h
lib/Parse/ParseObjc.cpp
lib/Sema/SemaType.cpp
test/SemaObjCXX/arc-0x.mm

index af958f16dae8caa6efe309907f14b596b7fbbc74..db811d06f2e4b88779e540205e4d44ca63613f6e 100644 (file)
@@ -1351,6 +1351,7 @@ public:
     TemplateParamContext,// Within a template parameter list.
     CXXNewContext,       // C++ new-expression.
     CXXCatchContext,     // C++ catch exception-declaration
+    ObjCCatchContext,    // Objective-C catch exception-declaration
     BlockLiteralContext,  // Block literal declarator.
     TemplateTypeArgContext, // Template type argument.
     AliasDeclContext,    // C++0x alias-declaration.
@@ -1502,6 +1503,7 @@ public:
     case TemplateParamContext:
     case CXXNewContext:
     case CXXCatchContext:
+    case ObjCCatchContext:
     case BlockLiteralContext:
     case TemplateTypeArgContext:
       return true;
@@ -1523,6 +1525,7 @@ public:
     case PrototypeContext:
     case TemplateParamContext:
     case CXXCatchContext:
+    case ObjCCatchContext:
       return true;
 
     case TypeNameContext:
@@ -1555,6 +1558,7 @@ public:
     case ObjCPrototypeContext:
     case TemplateParamContext:
     case CXXCatchContext:
+    case ObjCCatchContext:
     case TypeNameContext:
     case CXXNewContext:
     case AliasDeclContext:
index 8a6c9642143552beee1a99e111af56e47b1dd9cc..7641565d1cc3017a839129462dad4a91ec9c040d 100644 (file)
@@ -1633,10 +1633,7 @@ StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
         if (Tok.isNot(tok::ellipsis)) {
           DeclSpec DS(AttrFactory);
           ParseDeclarationSpecifiers(DS);
-          // For some odd reason, the name of the exception variable is
-          // optional. As a result, we need to use "PrototypeContext", because
-          // we must accept either 'declarator' or 'abstract-declarator' here.
-          Declarator ParmDecl(DS, Declarator::PrototypeContext);
+          Declarator ParmDecl(DS, Declarator::ObjCCatchContext);
           ParseDeclarator(ParmDecl);
 
           // Inform the actions module about the declarator, so it
index fa18a32aaa647945de173e97830d6b8df37f35c5..2254821cb1085532132c045e5b7865861aab397c 100644 (file)
@@ -1803,6 +1803,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
       }
       break;
     case Declarator::CXXCatchContext:
+    case Declarator::ObjCCatchContext:
       Error = 4; // Exception declaration
       break;
     case Declarator::TemplateParamContext:
@@ -2441,6 +2442,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
     case Declarator::ForContext:
     case Declarator::ConditionContext:
     case Declarator::CXXCatchContext:
+    case Declarator::ObjCCatchContext:
     case Declarator::BlockLiteralContext:
     case Declarator::TemplateTypeArgContext:
       // 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::CXXNewContext:
     case Declarator::CXXCatchContext:
+    case Declarator::ObjCCatchContext:
     case Declarator::TemplateTypeArgContext:
       Diag(OwnedTagDecl->getLocation(),diag::err_type_defined_in_type_specifier)
         << Context.getTypeDeclType(OwnedTagDecl);
index 9b48da5a33f9e84ee9c8f1e11a2b375095f383b4..fa022af522e924914123b4883ea11c54caf8acb4 100644 (file)
@@ -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.
 void move_it(__strong id &&from) {
@@ -25,4 +25,8 @@ void deduction(id obj) {
   for (auto x : array) {
     __strong id *xPtr = &x;
   }
+
+  @try {
+  } @catch (auto e) { // expected-error {{'auto' not allowed in exception declaration}}
+  }
 }