tra updated this revision to Diff 166509.
tra added a comment.

Added '>=' and '>>=' to the list of tokens that may indicate the end of the
empty template argument list.


https://reviews.llvm.org/D52321

Files:
  clang/lib/Parse/ParseTemplate.cpp
  clang/test/Parser/cuda-kernel-call-c++11.cu
  clang/test/Parser/cuda-kernel-call.cu


Index: clang/test/Parser/cuda-kernel-call.cu
===================================================================
--- clang/test/Parser/cuda-kernel-call.cu
+++ clang/test/Parser/cuda-kernel-call.cu
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-template<typename> struct S {};
+template<typename T=int> struct S {};
 template<typename> void f();
 
 void foo(void) {
@@ -13,5 +13,7 @@
   // The following two are parse errors because -std=c++11 is not enabled.
 
   S<S<S<int>>> s; // expected-error 2{{use '> >'}}
+  S<S<S<>>> s1; // expected-error 2{{use '> >'}}
   (void)(&f<S<S<int>>>==0); // expected-error 2{{use '> >'}}
+  (void)(&f<S<S<>>>==0); // expected-error 2{{use '> >'}}
 }
Index: clang/test/Parser/cuda-kernel-call-c++11.cu
===================================================================
--- clang/test/Parser/cuda-kernel-call-c++11.cu
+++ clang/test/Parser/cuda-kernel-call-c++11.cu
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
 
-template<typename> struct S {};
+template<typename T=int> struct S {};
 template<typename> void f();
 
 
@@ -11,10 +11,14 @@
   // expected-no-diagnostics
 
   S<S<S<int>>> s3;
+  S<S<S<>>> s30;
 
   S<S<S<S<int>>>> s4;
+  S<S<S<S<>>>> s40;
 
   S<S<S<S<S<int>>>>> s5;
+  S<S<S<S<S<>>>>> s50;
 
   (void)(&f<S<S<int>>>==0);
+  (void)(&f<S<S<>>>==0);
 }
Index: clang/lib/Parse/ParseTemplate.cpp
===================================================================
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -946,7 +946,9 @@
   bool Invalid = false;
   {
     GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
-    if (Tok.isNot(tok::greater) && Tok.isNot(tok::greatergreater))
+    if (!Tok.isOneOf(tok::greater, tok::greatergreater,
+                     tok::greatergreatergreater, tok::greaterequal,
+                     tok::greatergreaterequal))
       Invalid = ParseTemplateArgumentList(TemplateArgs);
 
     if (Invalid) {


Index: clang/test/Parser/cuda-kernel-call.cu
===================================================================
--- clang/test/Parser/cuda-kernel-call.cu
+++ clang/test/Parser/cuda-kernel-call.cu
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-template<typename> struct S {};
+template<typename T=int> struct S {};
 template<typename> void f();
 
 void foo(void) {
@@ -13,5 +13,7 @@
   // The following two are parse errors because -std=c++11 is not enabled.
 
   S<S<S<int>>> s; // expected-error 2{{use '> >'}}
+  S<S<S<>>> s1; // expected-error 2{{use '> >'}}
   (void)(&f<S<S<int>>>==0); // expected-error 2{{use '> >'}}
+  (void)(&f<S<S<>>>==0); // expected-error 2{{use '> >'}}
 }
Index: clang/test/Parser/cuda-kernel-call-c++11.cu
===================================================================
--- clang/test/Parser/cuda-kernel-call-c++11.cu
+++ clang/test/Parser/cuda-kernel-call-c++11.cu
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
 
-template<typename> struct S {};
+template<typename T=int> struct S {};
 template<typename> void f();
 
 
@@ -11,10 +11,14 @@
   // expected-no-diagnostics
 
   S<S<S<int>>> s3;
+  S<S<S<>>> s30;
 
   S<S<S<S<int>>>> s4;
+  S<S<S<S<>>>> s40;
 
   S<S<S<S<S<int>>>>> s5;
+  S<S<S<S<S<>>>>> s50;
 
   (void)(&f<S<S<int>>>==0);
+  (void)(&f<S<S<>>>==0);
 }
Index: clang/lib/Parse/ParseTemplate.cpp
===================================================================
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -946,7 +946,9 @@
   bool Invalid = false;
   {
     GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
-    if (Tok.isNot(tok::greater) && Tok.isNot(tok::greatergreater))
+    if (!Tok.isOneOf(tok::greater, tok::greatergreater,
+                     tok::greatergreatergreater, tok::greaterequal,
+                     tok::greatergreaterequal))
       Invalid = ParseTemplateArgumentList(TemplateArgs);
 
     if (Invalid) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D52321: [... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D523... Artem Belevich via Phabricator via cfe-commits
    • [PATCH] D523... Artem Belevich via Phabricator via cfe-commits

Reply via email to