[cfe-commits] r134271 - in /cfe/trunk: include/clang/Sema/DeclSpec.h lib/Parse/ParseObjc.cpp lib/Sema/SemaType.cpp test/SemaObjCXX/arc-0x.mm
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Jul 1 15:22:40 PDT 2011
Author: akirtzidis
Date: Fri Jul 1 17:22:40 2011
New Revision: 134271
URL: http://llvm.org/viewvc/llvm-project?rev=134271&view=rev
Log:
Introduce Declarator::ObjCCatchContext, this will result in correct error for 'auto' in obj-c catch.
Modified:
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjCXX/arc-0x.mm
Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=134271&r1=134270&r2=134271&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Fri Jul 1 17:22:40 2011
@@ -1351,6 +1351,7 @@
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 @@
case TemplateParamContext:
case CXXNewContext:
case CXXCatchContext:
+ case ObjCCatchContext:
case BlockLiteralContext:
case TemplateTypeArgContext:
return true;
@@ -1523,6 +1525,7 @@
case PrototypeContext:
case TemplateParamContext:
case CXXCatchContext:
+ case ObjCCatchContext:
return true;
case TypeNameContext:
@@ -1555,6 +1558,7 @@
case ObjCPrototypeContext:
case TemplateParamContext:
case CXXCatchContext:
+ case ObjCCatchContext:
case TypeNameContext:
case CXXNewContext:
case AliasDeclContext:
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=134271&r1=134270&r2=134271&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Fri Jul 1 17:22:40 2011
@@ -1633,10 +1633,7 @@
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
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=134271&r1=134270&r2=134271&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Jul 1 17:22:40 2011
@@ -1803,6 +1803,7 @@
}
break;
case Declarator::CXXCatchContext:
+ case Declarator::ObjCCatchContext:
Error = 4; // Exception declaration
break;
case Declarator::TemplateParamContext:
@@ -2441,6 +2442,7 @@
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 @@
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);
Modified: cfe/trunk/test/SemaObjCXX/arc-0x.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/arc-0x.mm?rev=134271&r1=134270&r2=134271&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/arc-0x.mm (original)
+++ cfe/trunk/test/SemaObjCXX/arc-0x.mm Fri Jul 1 17:22:40 2011
@@ -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 @@
for (auto x : array) {
__strong id *xPtr = &x;
}
+
+ @try {
+ } @catch (auto e) { // expected-error {{'auto' not allowed in exception declaration}}
+ }
}
More information about the cfe-commits
mailing list