From 9a67abdb5cdaf8c25f3ecbe66e1d9d171260d3ce Mon Sep 17 00:00:00 2001 From: Michael Liao Date: Wed, 8 May 2019 00:52:33 +0000 Subject: [PATCH] [hip] Fix ambiguity from `>>>` of CUDA. Summary: - For template arguments ending with `>>>`, we should cease lookahead and treat it as type-id firstly, so that deduction could work properly. Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61396 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360214 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseTentative.cpp | 4 +++- test/Parser/cuda-kernel-call-c++11.cu | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp index de9391cddd..0504f0ddcb 100644 --- a/lib/Parse/ParseTentative.cpp +++ b/lib/Parse/ParseTentative.cpp @@ -590,9 +590,11 @@ bool Parser::isCXXTypeId(TentativeCXXTypeIdContext Context, bool &isAmbiguous) { } else if (Context == TypeIdAsTemplateArgument && (Tok.isOneOf(tok::greater, tok::comma) || (getLangOpts().CPlusPlus11 && - (Tok.is(tok::greatergreater) || + (Tok.isOneOf(tok::greatergreater, + tok::greatergreatergreater) || (Tok.is(tok::ellipsis) && NextToken().isOneOf(tok::greater, tok::greatergreater, + tok::greatergreatergreater, tok::comma)))))) { TPR = TPResult::True; isAmbiguous = true; diff --git a/test/Parser/cuda-kernel-call-c++11.cu b/test/Parser/cuda-kernel-call-c++11.cu index 1870b201ad..ef71e2a9ac 100644 --- a/test/Parser/cuda-kernel-call-c++11.cu +++ b/test/Parser/cuda-kernel-call-c++11.cu @@ -3,6 +3,10 @@ template struct S {}; template void f(); +template struct S {}; + +template struct V {}; +template struct V {}; void foo(void) { // In C++11 mode, all of these are expected to parse correctly, and the CUDA @@ -21,4 +25,11 @@ void foo(void) { (void)(&f>>==0); (void)(&f>>==0); + + S>> s6; +} + +template +void bar(T... args) { + S>> s7; } -- 2.40.0