[llvm-bugs] [Bug 33919] New: Error recovery loses type inheritance relationship?

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 24 17:42:45 PDT 2017


            Bug ID: 33919
           Summary: Error recovery loses type inheritance relationship?
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jmgao at google.com
                CC: llvm-bugs at lists.llvm.org

Minimized test case:

    namespace ns {
      typedef int type;

    struct base {

    struct derived : public base {
      ns:;type foo() { return 0; }

    int foo(base& b) {
      return 0;

    int main() {
      derived x;

Clang (r4053586) is smart enough to notice that I probably meant ns::type:

    test.cpp:9:3: error: unknown type name 'ns'
      ns:;type foo() { return 0; }
    test.cpp:9:6: error: expected expression
      ns:;type foo() { return 0; }
    test.cpp:9:7: error: unknown type name 'type'; did you mean 'ns::type'?
      ns:;type foo() { return 0; }
    test.cpp:2:15: note: 'ns::type' declared here
      typedef int type;

but seems to have forgotten the relationship between base and derived?

    test.cpp:18:3: error: no matching function for call to 'foo'
    test.cpp:12:5: note: candidate function not viable: no known conversion
                         from 'derived' to 'base &' for 1st argument
    int foo(base& b) {

The actual code that this was minimized from triggered a pretty catastrophic
failure, because the type in which this typo happened inherited a type which
had an overload for std::ostream operator <<, resulting in a helpful 111-line
list of every overload of std::ostream operator <<, per use of <<.

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/20170725/9ef19685/attachment-0001.html>

More information about the llvm-bugs mailing list