r173766 - PR15017: A '>' can appear after a type-specifier in a template-argument-list.

Richard Smith richard-llvm at metafoo.co.uk
Mon Jan 28 20:13:32 PST 2013


Author: rsmith
Date: Mon Jan 28 22:13:32 2013
New Revision: 173766

URL: http://llvm.org/viewvc/llvm-project?rev=173766&view=rev
Log:
PR15017: A '>' can appear after a type-specifier in a template-argument-list.
It turns out that there's no correctness bug here (because we can't have a type
definition in this location), but there was a diagnostic bug.

Modified:
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/test/Parser/cxx-decl.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=173766&r1=173765&r2=173766&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Jan 28 22:13:32 2013
@@ -1015,6 +1015,9 @@ bool Parser::isValidAfterTypeSpecifier(b
   case tok::l_square: // enum E [[]] x
     // Note, no tok::kw_alignas here; alignas cannot appertain to a type.
     return getLangOpts().CPlusPlus11 && NextToken().is(tok::l_square);
+  case tok::greater:
+    // template<class T = class X>
+    return getLangOpts().CPlusPlus;
   }
   return false;
 }

Modified: cfe/trunk/test/Parser/cxx-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=173766&r1=173765&r2=173766&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Mon Jan 28 22:13:32 2013
@@ -180,6 +180,10 @@ void test (DIE die, DIE *Die, DIE INT, D
   FLOAT->foo();
 }
 
+namespace PR15017 {
+  template<typename T = struct X { int i; }> struct S {}; // expected-error {{'PR15017::X' can not be defined in a type specifier}}
+}
+
 // PR8380
 extern ""      // expected-error {{unknown linkage language}}
 test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \





More information about the cfe-commits mailing list