Author: eliben Date: Fri Jun 20 08:09:59 2014 New Revision: 211357 URL: http://llvm.org/viewvc/llvm-project?rev=211357&view=rev Log: Fix PR20081: Parsing templates in the presence of -x cuda -std=c++11
http://reviews.llvm.org/D4222 Added: cfe/trunk/test/Parser/cuda-kernel-call-c++11.cu Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp 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=211357&r1=211356&r2=211357&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseTemplate.cpp (original) +++ cfe/trunk/lib/Parse/ParseTemplate.cpp Fri Jun 20 08:09:59 2014 @@ -751,7 +751,9 @@ bool Parser::ParseGreaterThanInTemplateL // This template-id is terminated by a token which starts with a '>'. Outside // C++11, this is now error recovery, and in C++11, this is error recovery if - // the token isn't '>>'. + // the token isn't '>>' or '>>>'. + // '>>>' is for CUDA, where this sequence of characters is parsed into + // tok::greatergreatergreater, rather than two separate tokens. RAngleLoc = Tok.getLocation(); @@ -781,7 +783,8 @@ bool Parser::ParseGreaterThanInTemplateL Hint2 = FixItHint::CreateInsertion(Next.getLocation(), " "); unsigned DiagId = diag::err_two_right_angle_brackets_need_space; - if (getLangOpts().CPlusPlus11 && Tok.is(tok::greatergreater)) + if (getLangOpts().CPlusPlus11 && + (Tok.is(tok::greatergreater) || Tok.is(tok::greatergreatergreater))) DiagId = diag::warn_cxx98_compat_two_right_angle_brackets; else if (Tok.is(tok::greaterequal)) DiagId = diag::err_right_angle_bracket_equal_needs_space; Added: 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=211357&view=auto ============================================================================== --- cfe/trunk/test/Parser/cuda-kernel-call-c++11.cu (added) +++ cfe/trunk/test/Parser/cuda-kernel-call-c++11.cu Fri Jun 20 08:09:59 2014 @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s + +template<typename> struct S {}; +template<typename> void f(); + + +void foo(void) { + // In C++11 mode, all of these are expected to parse correctly, and the CUDA + // language should not interfere with that. + + // expected-no-diagnostics + + S<S<S<int>>> s3; + + S<S<S<S<int>>>> s4; + + S<S<S<S<S<int>>>>> s5; + + (void)(&f<S<S<int>>>==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=211357&r1=211356&r2=211357&view=diff ============================================================================== --- cfe/trunk/test/Parser/cuda-kernel-call.cu (original) +++ cfe/trunk/test/Parser/cuda-kernel-call.cu Fri Jun 20 08:09:59 2014 @@ -10,7 +10,8 @@ void foo(void) { foo<<<>>>(); // expected-error {{expected expression}} - S<S<S<int>>> s; // expected-error 2{{use '> >'}} + // The following two are parse errors because -std=c++11 is not enabled. + S<S<S<int>>> s; // expected-error 2{{use '> >'}} (void)(&f<S<S<int>>>==0); // expected-error 2{{use '> >'}} } _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
