[cfe-dev] Clang and CUDA with C++11 features
Peter Colberg
peter at colberg.org
Thu Jun 14 07:53:33 PDT 2012
On Wed, Jun 13, 2012 at 09:35:10PM -0700, Sean Silva wrote:
> On Wed, Jun 13, 2012 at 8:28 PM, Peter Colberg <peter at colberg.org> wrote:
> > The parser interprets the compressed C++11 template parameter syntax
> > as a call to a CUDA kernel function. Is there a way to disable parsing
> > of the CUDA call syntax <<< >>>? I would be using a C++ wrapper around
> > cudaConfigureCall, cudaSetupArgument and cudaLaunch anyway.
>
> Try:
>
> find $HEADER_DIR | xargs sed --i.bak -e 's/>>>/> > >/'
>
> I don't think there are any syntactic dark corners where that will break
> otherwise valid C++.
>
> No guarantees though (that's what the -i.bak is for ;).
The other way around: CUDA violates the C++ standard with regard to
template parameter syntax, so I would like to disable the CUDA
execution syntax, and use cudaLaunch with a pointer instead.
The lexer of Clang is straight-forward :-).
--- lib/Lex/Lexer.cpp 2012-06-14 10:48:34.675569175 -0400
+++ lib/Lex/Lexer.cpp 2012-06-14 10:48:51.246645348 -0400
@@ -3054,10 +3054,6 @@
// If this is '<<<<' and we're in a Perforce-style conflict marker,
// ignore it.
goto LexNextToken;
- } else if (LangOpts.CUDA && After == '<') {
- Kind = tok::lesslessless;
- CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result),
- SizeTmp2, Result);
} else {
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
Kind = tok::lessless;
@@ -3110,10 +3106,6 @@
} else if (After == '>' && HandleEndOfConflictMarker(CurPtr-1)) {
// If this is '>>>>>>>' and we're in a conflict marker, ignore it.
goto LexNextToken;
- } else if (LangOpts.CUDA && After == '>') {
- Kind = tok::greatergreatergreater;
- CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result),
- SizeTmp2, Result);
} else {
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
Kind = tok::greatergreater;
Peter
More information about the cfe-dev
mailing list