[LLVMbugs] [Bug 12776] New: Incorrect compile error for local class in out-of-class member function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 9 12:04:15 PDT 2012


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

             Bug #: 12776
           Summary: Incorrect compile error for local class in
                    out-of-class member function
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: sigmund_vik at yahoo.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


This code should compile without any errors:

template<class T>
class SomeType
{
};

template<class T>
class Test
{
public:
    Test();
};

template<class T>
Test<T>::Test()
{
    class Local
    {
    public:
        Local()
        {
            typedef SomeType<T> MyType;
        }
    };
    Local instance;
}


int main(int argc, const char **argv)
{
    Test<int> test;

    return 0;
}


However, clang produces the following compile error:

main.cpp:21:30: error: template argument for template type parameter must be a
type
            typedef SomeType<T> MyType;
                             ^
main.cpp:30:15: note: in instantiation of member function 'Test<int>::Test'
requested here
    Test<int> test;
              ^
main.cpp:1:16: note: template parameter is declared here
template<class T>
               ^
1 error generated.


This happens for clang version 3.1 trunk (svn revision 156484).  It also
happens for clang 3.0.

This code compiles fine if the class named "Local" is not local *or* if the
member function is not defined out-of-class.  However, in the latter case
compilation fails with a similar error when using clang 3.0.

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