[llvm-bugs] [Bug 31048] New: Improve "use of undeclared identifier x" diagnostic. Where x is a member of the templated base class.

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 17 15:25:42 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=31048

            Bug ID: 31048
           Summary: Improve "use of undeclared identifier x" diagnostic.
                    Where x is a member of the templated base class.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: peetlugen19 at yandex.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

template<typename T>
struct Base {
  int foo();
};

template<typename T>
struct Derived : Base<T> {
  void bar();
};

template <typename T>
void Derived<T>::bar() {
  foo();
}

Clang (-std=c++1z -fsyntax-only -Wall):

./test20.cpp:13:3: error: use of undeclared identifier 'foo'
  foo();
  ^
1 error generated.

GCC (v6.2.1):

./test20.cpp: In member function ‘void Derived<T>::bar()’:
./test20.cpp:13:7: error: there are no arguments to ‘foo’ that depend on a
template parameter, so a declaration of ‘foo’ must be available [-fpermissive]
   foo();
       ^
Perhaps clang should be able to print some hints that foo can be called through
"this->foo" or by explicitly using the base class scope ("Base<T>::foo()").

-- 
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/20161117/63448caa/attachment.html>


More information about the llvm-bugs mailing list