소스 검색

[CUDA] Fixed parsing of optional template-argument-list.

We need to consider all tokens that start with '>' when
we're checking for the end of an empty template argument list.

Differential Revision: https://reviews.llvm.org/D52321

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342752 91177308-0d34-0410-b5e6-96231b3b80d8
Artem Belevich 7 년 전
부모
커밋
057446eb82
3개의 변경된 파일11개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 1
      lib/Parse/ParseTemplate.cpp
  2. 5 1
      test/Parser/cuda-kernel-call-c++11.cu
  3. 3 1
      test/Parser/cuda-kernel-call.cu

+ 3 - 1
lib/Parse/ParseTemplate.cpp

@@ -946,7 +946,9 @@ Parser::ParseTemplateIdAfterTemplateName(bool ConsumeLastToken,
   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) {

+ 5 - 1
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 @@ void foo(void) {
   // 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);
 }

+ 3 - 1
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 @@ void foo(void) {
   // 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 '> >'}}
 }