[cfe-commits] r122292 - in /cfe/trunk: lib/Parse/ParseDeclCXX.cpp test/CXX/temp/temp.decls/temp.variadic/p4.cpp

Douglas Gregor dgregor at apple.com
Mon Dec 20 15:57:46 PST 2010


Author: dgregor
Date: Mon Dec 20 17:57:46 2010
New Revision: 122292

URL: http://llvm.org/viewvc/llvm-project?rev=122292&view=rev
Log:
Extend the parser to support pack expansions within exception
specifications. We can't yet instantiate them, however, since I
tripped over PR8835.

Modified:
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p4.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=122292&r1=122291&r2=122292&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Dec 20 17:57:46 2010
@@ -1875,8 +1875,8 @@
 /// [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<ParsedType>
@@ -1908,10 +1908,21 @@
   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

Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p4.cpp?rev=122292&r1=122291&r2=122292&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p4.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p4.cpp Mon Dec 20 17:57:46 2010
@@ -26,3 +26,21 @@
 tuple<int, float> *t_int_float;
 extract_nested_types<identity<int>, identity<float> >::types *t_int_float_2 
   = t_int_float;
+
+// In a dynamic-exception-specification (15.4); the pattern is a type-id.
+template<typename ...Types>
+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<int, float> {
+  virtual void f() throw(int, float);
+};
+
+struct check_f_with_except_2 : f_with_except<int, float> {
+  virtual void f() throw(int);
+};
+#endif





More information about the cfe-commits mailing list