[LLVMbugs] [Bug 20081] New: Clang fails to parse some template code when running with -x cuda -std=c++11

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 19 08:14:05 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20081

            Bug ID: 20081
           Summary: Clang fails to parse some template code when running
                    with -x cuda -std=c++11
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eliben at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Background: r209824 fixed a bug that made -std options mask out -x cuda. Prior
to that, when "-std=c++11 -x cuda" were specified together, CUDA mode was not
activated.

Now that both CUDA mode and C++11 mode can be active together, we run into a
problem parsing certain C++11 code in CUDA mode. Here's a simple reproducer:

  template <typename T>
  struct K1 {
    T member;
  };

  template <typename T>
  struct K2 {
    T member;
  };

  template <typename T>
  struct K3 {
    T member;
  };

  K3<K2<K1<int>>> var;

Compiled just with -std=c++11 this works fine. With "-std=c++11 -x cuda",
however, we get:

error: a space is required between consecutive right angle brackets (use '> >')
K3<K2<K1<int>>> var;
            ^~
            > >

Running -cc1 -dump-tokens clarifies what's going on. In the absence of "-x
cuda", the ">>>" on the last line is taken as '>>' followed by '>', which the
template parser knows how to handle.

In CUDA mode, it's read as a single token - '>>>', which the parser does not
know how to handle.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140619/64be50c7/attachment.html>


More information about the llvm-bugs mailing list