[LLVMbugs] [Bug 12538] New: really poor error recovery for missing typename

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 12 11:39:57 PDT 2012


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

             Bug #: 12538
           Summary: really poor error recovery for missing typename
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: clattner at apple.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


As pointed out on the GCC mailing list:

A missing "typename" keyword is a very common, very easy to make
mistake when using C++ templates.  It isn't usually obvious what the
problem is, so it's exactly where compilers could help, but both get
zero marks here:

$ cat missing-typename.cc
template<class T> void f(T::type) { }

struct A { };

void g()
{
   A a;
   f<A>(a);
}
$ g++-4.7 missing-typename.cc
missing-typename.cc:1:33: error: variable or field 'f' declared void
missing-typename.cc: In function 'void g()':
missing-typename.cc:8:5: error: 'f' was not declared in this scope
missing-typename.cc:8:8: error: expected primary-expression before '>' token

$ clang++-3.1 missing-typename.cc
missing-typename.cc:1:24: error: variable 'f' declared as a template
template<class T> void f(T::type) { }
~~~~~~~~~~~~~~~~~      ^
missing-typename.cc:1:34: error: expected ';' at end of declaration
template<class T> void f(T::type) { }
                                ^
                                ;
missing-typename.cc:1:35: error: expected unqualified-id
template<class T> void f(T::type) { }
                                 ^
missing-typename.cc:7:5: error: use of undeclared identifier 'A'
   A a;
   ^
missing-typename.cc:8:5: error: use of undeclared identifier 'f'
   f<A>(a);
   ^
missing-typename.cc:8:7: error: use of undeclared identifier 'A'
   f<A>(a);
     ^
missing-typename.cc:8:10: error: use of undeclared identifier 'a'
   f<A>(a);
        ^
7 errors generated.


Clang's carets and range highlighting don't help in the slightest, and
the poor error recovery that means "A" is reported as unidentified
doesn't help either.

-- 
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