]> granicus.if.org Git - clang/commitdiff
PR15017: A '>' can appear after a type-specifier in a template-argument-list.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 29 Jan 2013 04:13:32 +0000 (04:13 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 29 Jan 2013 04:13:32 +0000 (04:13 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173766 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDeclCXX.cpp
test/Parser/cxx-decl.cpp

index 2c5d142fd7fb9d97980ee6bed3ba75dde994b343..4f0c893b040388855dc86403f233d6271f207499 100644 (file)
@@ -1015,6 +1015,9 @@ bool Parser::isValidAfterTypeSpecifier(bool CouldBeBitfield) {
   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;
 }
index 71fd7aae18d8b47246d0b7c49dd23fa3cb12d8a2..24ba12751571813941eae21a56a2c4eddffde6f3 100644 (file)
@@ -180,6 +180,10 @@ void test (DIE die, DIE *Die, DIE INT, DIE *FLOAT) {
   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}} \