[LLVMbugs] [Bug 8119] New: missing typename in function prototype is parsed as variable declaration

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Sep 8 17:43:37 PDT 2010


           Summary: missing typename in function prototype is parsed as
                    variable declaration
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

This code snippet is invalid and is rejected by both gcc and clang:

  template <typename A>
  class Map {
    class Iterator {

  template <typename S>
  void f1(Map<S>::Iterator v) {

but what's wrong? Let's ask clang:

  test.cc:9:6: error: variable 'f1' declared as a template
  void f1(Map<S>::Iterator v) {
  test.cc:9:27: error: expected ')'
  void f1(Map<S>::Iterator v) {
  test.cc:9:8: note: to match this '('
  void f1(Map<S>::Iterator v) {
  test.cc:9:29: error: expected ';' at end of declaration
  void f1(Map<S>::Iterator v) {
  test.cc:9:30: error: expected unqualified-id
  void f1(Map<S>::Iterator v) {
  4 errors generated.

This is a terrible diagnostic. It sounds like things go wrong when clang
decides that f1 is a variable instead of a function. The desired diagnostic is
the fixit that says where to insert 'typename' before Map.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list