From 356513d7d005dc811657bf7413b6bfbed9632a1e Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 1 Dec 2008 18:00:20 +0000 Subject: [PATCH] Parse the exception-specification throw(...), a Microsoft extension llvm-svn: 60359 --- clang/include/clang/Basic/DiagnosticKinds.def | 2 ++ clang/lib/Parse/ParseDeclCXX.cpp | 21 ++++++++++++++----- clang/test/SemaCXX/ms-exception-spec.cpp | 3 +++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 clang/test/SemaCXX/ms-exception-spec.cpp diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index b935ff0f2980..d049b6c655eb 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -587,6 +587,8 @@ DIAG(warn_parens_disambiguated_as_function_decl, WARNING, "parentheses were disambiguated as a function declarator") DIAG(err_expected_member_or_base_name, ERROR, "expected class member or base class name") +DIAG(ext_ellipsis_exception_spec, EXTENSION, + "exception specification of '...' is a Microsoft extension") // Language specific pragmas diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 268de00bc362..78539abaadbb 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -763,12 +763,13 @@ Parser::MemInitResult Parser::ParseMemInitializer(DeclTy *ConstructorDecl) { /// ParseExceptionSpecification - Parse a C++ exception-specification /// (C++ [except.spec]). /// -/// exception-specification: -/// 'throw' '(' type-id-list [opt] ')' +/// exception-specification: +/// 'throw' '(' type-id-list [opt] ')' +/// [MS] 'throw' '(' '...' ')' /// -/// type-id-list: -/// type-id -/// type-id-list ',' type-id +/// type-id-list: +/// type-id +/// type-id-list ',' type-id /// bool Parser::ParseExceptionSpecification() { assert(Tok.is(tok::kw_throw) && "expected throw"); @@ -780,6 +781,16 @@ bool Parser::ParseExceptionSpecification() { } SourceLocation LParenLoc = ConsumeParen(); + // Parse throw(...), a Microsoft extension that means "this function + // can throw anything". + if (Tok.is(tok::ellipsis)) { + SourceLocation EllipsisLoc = ConsumeToken(); + if (!getLang().Microsoft) + Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec); + SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc); + return false; + } + // Parse the sequence of type-ids. while (Tok.isNot(tok::r_paren)) { ParseTypeName(); diff --git a/clang/test/SemaCXX/ms-exception-spec.cpp b/clang/test/SemaCXX/ms-exception-spec.cpp new file mode 100644 index 000000000000..ec4e29a89fd1 --- /dev/null +++ b/clang/test/SemaCXX/ms-exception-spec.cpp @@ -0,0 +1,3 @@ +// RUN: clang %s -fsyntax-only -verify -fms-extensions + +void f() throw(...) { }