r212421 - Add parser support for __leave (sema and onward still missing).
Nico Weber
nicolasweber at gmx.de
Sun Jul 6 15:33:01 PDT 2014
Author: nico
Date: Sun Jul 6 17:32:59 2014
New Revision: 212421
URL: http://llvm.org/viewvc/llvm-project?rev=212421&view=rev
Log:
Add parser support for __leave (sema and onward still missing).
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/Sema/__try.c
cfe/trunk/test/SemaCXX/__try.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=212421&r1=212420&r2=212421&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Jul 6 17:32:59 2014
@@ -5153,6 +5153,8 @@ def err_need_header_before_typeid : Erro
"you need to include <typeinfo> before using the 'typeid' operator">;
def err_need_header_before_ms_uuidof : Error<
"you need to include <guiddef.h> before using the '__uuidof' operator">;
+def err_ms___leave_unimplemented : Error<
+ "__leave support not implemented yet">;
def err_uuidof_without_guid : Error<
"cannot call operator __uuidof on a type with no GUID">;
def err_uuidof_with_multiple_guids : Error<
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=212421&r1=212420&r2=212421&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Sun Jul 6 17:32:59 2014
@@ -1668,6 +1668,7 @@ private:
StmtResult ParseSEHTryBlockCommon(SourceLocation Loc);
StmtResult ParseSEHExceptBlock(SourceLocation Loc);
StmtResult ParseSEHFinallyBlock(SourceLocation Loc);
+ StmtResult ParseSEHLeaveStatement();
//===--------------------------------------------------------------------===//
// Objective-C Statements
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=212421&r1=212420&r2=212421&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sun Jul 6 17:32:59 2014
@@ -3158,13 +3158,11 @@ public:
StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
SourceLocation TryLoc, Stmt *TryBlock,
Stmt *Handler);
-
StmtResult ActOnSEHExceptBlock(SourceLocation Loc,
Expr *FilterExpr,
Stmt *Block);
-
- StmtResult ActOnSEHFinallyBlock(SourceLocation Loc,
- Stmt *Block);
+ StmtResult ActOnSEHFinallyBlock(SourceLocation Loc, Stmt *Block);
+ StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope);
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock);
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=212421&r1=212420&r2=212421&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Sun Jul 6 17:32:59 2014
@@ -288,6 +288,11 @@ Retry:
ProhibitAttributes(Attrs); // TODO: is it correct?
return ParseSEHTryBlock();
+ case tok::kw___leave:
+ Res = ParseSEHLeaveStatement();
+ SemiError = "__leave";
+ break;
+
case tok::annot_pragma_vis:
ProhibitAttributes(Attrs);
HandlePragmaVisibility();
@@ -506,6 +511,16 @@ StmtResult Parser::ParseSEHFinallyBlock(
return Actions.ActOnSEHFinallyBlock(FinallyBlock,Block.get());
}
+/// Handle __leave
+///
+/// seh-leave-statement:
+/// '__leave' ';'
+///
+StmtResult Parser::ParseSEHLeaveStatement() {
+ SourceLocation LeaveLoc = ConsumeToken(); // eat the '__leave'.
+ return Actions.ActOnSEHLeaveStmt(LeaveLoc, getCurScope());
+}
+
/// ParseLabeledStatement - We have an identifier and a ':' after it.
///
/// labeled-statement:
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=212421&r1=212420&r2=212421&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Sun Jul 6 17:32:59 2014
@@ -3277,6 +3277,11 @@ Sema::ActOnSEHFinallyBlock(SourceLocatio
return SEHFinallyStmt::Create(Context,Loc,Block);
}
+StmtResult
+Sema::ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope) {
+ return StmtError(Diag(Loc, diag::err_ms___leave_unimplemented));
+}
+
StmtResult Sema::BuildMSDependentExistsStmt(SourceLocation KeywordLoc,
bool IsIfExists,
NestedNameSpecifierLoc QualifierLoc,
Modified: cfe/trunk/test/Sema/__try.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/__try.c?rev=212421&r1=212420&r2=212421&view=diff
==============================================================================
--- cfe/trunk/test/Sema/__try.c (original)
+++ cfe/trunk/test/Sema/__try.c Sun Jul 6 17:32:59 2014
@@ -170,3 +170,28 @@ void TEST() {
(void)GetExceptionInformation(); // expected-error{{only allowed in __except filter expression}}
(void)AbnormalTermination(); // expected-error{{only allowed in __finally block}}
}
+
+void test___leave() {
+ // FIXME: should say "__leave stmt not in __try block":
+ __leave; // expected-error{{not implemented yet}}
+ __try {
+ // FIXME: should be fine
+ __leave; // expected-error{{not implemented yet}}
+ // FIXME: should say "expected ';' after __leave statement"
+ __leave 4; // expected-error{{not implemented yet}} expected-warning{{expression result unused}}
+ } __except(1) {
+ // FIXME: should say "__leave stmt not in __try block":
+ __leave; // expected-error{{not implemented yet}}
+ }
+
+ __try {
+ // FIXME: should be fine
+ __leave; // expected-error{{not implemented yet}}
+ } __finally {
+ // FIXME: should say "__leave stmt not in __try block":
+ __leave; // expected-error{{not implemented yet}}
+ }
+ // FIXME: should say "__leave stmt not in __try block":
+ __leave; // expected-error{{not implemented yet}}
+}
+
Modified: cfe/trunk/test/SemaCXX/__try.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/__try.cpp?rev=212421&r1=212420&r2=212421&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/__try.cpp (original)
+++ cfe/trunk/test/SemaCXX/__try.cpp Sun Jul 6 17:32:59 2014
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify -fborland-extensions -fcxx-exceptions %s
-// expected-no-diagnostics
// This test is from http://docwiki.embarcadero.com/RADStudio/en/Try
@@ -77,3 +76,15 @@ template void Except<void>();
template void Finally<void>();
}
+
+void test___leave() {
+ // Most tests are in __try.c.
+
+ // Clang accepts try with __finally. MSVC doesn't. (Maybe a Borland thing?)
+ // __leave in mixed blocks isn't supported.
+ try {
+ // FIXME: should say "__leave stmt not in __try block":
+ __leave; // expected-error{{not implemented yet}}
+ } __finally {
+ }
+}
More information about the cfe-commits
mailing list