r342752 - [CUDA] Fixed parsing of optional template-argument-list.
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 21 10:46:29 PDT 2018
Author: tra
Date: Fri Sep 21 10:46:28 2018
New Revision: 342752
URL: http://llvm.org/viewvc/llvm-project?rev=342752&view=rev
Log:
[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
Modified:
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/test/Parser/cuda-kernel-call-c++11.cu
cfe/trunk/test/Parser/cuda-kernel-call.cu
Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=342752&r1=342751&r2=342752&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Fri Sep 21 10:46:28 2018
@@ -946,7 +946,9 @@ Parser::ParseTemplateIdAfterTemplateName
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) {
Modified: cfe/trunk/test/Parser/cuda-kernel-call-c++11.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cuda-kernel-call-c%2B%2B11.cu?rev=342752&r1=342751&r2=342752&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cuda-kernel-call-c++11.cu (original)
+++ cfe/trunk/test/Parser/cuda-kernel-call-c++11.cu Fri Sep 21 10:46:28 2018
@@ -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);
}
Modified: cfe/trunk/test/Parser/cuda-kernel-call.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cuda-kernel-call.cu?rev=342752&r1=342751&r2=342752&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cuda-kernel-call.cu (original)
+++ cfe/trunk/test/Parser/cuda-kernel-call.cu Fri Sep 21 10:46:28 2018
@@ -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 '> >'}}
}
More information about the cfe-commits
mailing list