From 830837da534fa1620ec523903beb0e6d452c179d Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 20 Dec 2010 23:57:46 +0000 Subject: [PATCH] Extend the parser to support pack expansions within exception specifications. We can't yet instantiate them, however, since I tripped over PR8835. llvm-svn: 122292 --- clang/lib/Parse/ParseDeclCXX.cpp | 15 +++++++++++++-- .../CXX/temp/temp.decls/temp.variadic/p4.cpp | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index a2c87f85c304..e1f7f7bdc589 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1875,8 +1875,8 @@ Parser::MemInitResult Parser::ParseMemInitializer(Decl *ConstructorDecl) { /// [MS] 'throw' '(' '...' ')' /// /// type-id-list: -/// type-id -/// type-id-list ',' type-id +/// type-id ... [opt] +/// type-id-list ',' type-id ... [opt] /// bool Parser::ParseExceptionSpecification(SourceLocation &EndLoc, llvm::SmallVectorImpl @@ -1908,10 +1908,21 @@ bool Parser::ParseExceptionSpecification(SourceLocation &EndLoc, SourceRange Range; while (Tok.isNot(tok::r_paren)) { TypeResult Res(ParseTypeName(&Range)); + + if (Tok.is(tok::ellipsis)) { + // C++0x [temp.variadic]p5: + // - In a dynamic-exception-specification (15.4); the pattern is a + // type-id. + SourceLocation Ellipsis = ConsumeToken(); + if (!Res.isInvalid()) + Res = Actions.ActOnPackExpansion(Res.get(), Ellipsis); + } + if (!Res.isInvalid()) { Exceptions.push_back(Res.get()); Ranges.push_back(Range); } + if (Tok.is(tok::comma)) ConsumeToken(); else diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp index b4f7c09981ff..7d2fe850361d 100644 --- a/clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp +++ b/clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp @@ -26,3 +26,21 @@ struct identity { tuple *t_int_float; extract_nested_types, identity >::types *t_int_float_2 = t_int_float; + +// In a dynamic-exception-specification (15.4); the pattern is a type-id. +template +struct f_with_except { + virtual void f() throw(Types...); +}; + +// FIXME: the code below requires the ability to instantiate pack +// expansions whose pattern is a type-id. +#if 0 +struct check_f_with_except_1 : f_with_except { + virtual void f() throw(int, float); +}; + +struct check_f_with_except_2 : f_with_except { + virtual void f() throw(int); +}; +#endif