From: Artem Belevich Date: Fri, 21 Sep 2018 17:46:28 +0000 (+0000) Subject: [CUDA] Fixed parsing of optional template-argument-list. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=057446eb82b598d2737d23c70ed91a33cf9012a0;p=clang [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 --- diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index 5af543702c..26709a5aaa 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/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) { diff --git a/test/Parser/cuda-kernel-call-c++11.cu b/test/Parser/cuda-kernel-call-c++11.cu index 8f833f79af..1870b201ad 100644 --- a/test/Parser/cuda-kernel-call-c++11.cu +++ b/test/Parser/cuda-kernel-call-c++11.cu @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -template struct S {}; +template struct S {}; template void f(); @@ -11,10 +11,14 @@ void foo(void) { // expected-no-diagnostics S>> s3; + S>> s30; S>>> s4; + S>>> s40; S>>>> s5; + S>>>> s50; (void)(&f>>==0); + (void)(&f>>==0); } diff --git a/test/Parser/cuda-kernel-call.cu b/test/Parser/cuda-kernel-call.cu index 1970c558c5..2a409aa377 100644 --- a/test/Parser/cuda-kernel-call.cu +++ b/test/Parser/cuda-kernel-call.cu @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -template struct S {}; +template struct S {}; template 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; // expected-error 2{{use '> >'}} + S>> s1; // expected-error 2{{use '> >'}} (void)(&f>>==0); // expected-error 2{{use '> >'}} + (void)(&f>>==0); // expected-error 2{{use '> >'}} }