https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116771

            Bug ID: 116771
           Summary: Missing suggestion on mispelled class name
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: easyhack
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

I made this typo in C++:

class layout_printer
{
    void print_newline ();
};

void
layout_pirnter::print_newline ()
{
}

and noticed that we don't yet issue a suggestion for the missppelled class
name:

<source>:7:1: error: 'layout_pirnter' has not been declared
    7 | layout_pirnter::print_newline ()
      | ^~~~~~~~~~~~~~
Compiler returned: 1

whereas clang does:

<source>:7:1: error: use of undeclared identifier 'layout_pirnter'; did you
mean 'layout_printer'?
    7 | layout_pirnter::print_newline ()
      | ^~~~~~~~~~~~~~
      | layout_printer
<source>:1:7: note: 'layout_printer' declared here
    1 | class layout_printer
      |       ^
<source>:7:1: error: use of undeclared identifier 'layout_pirnter'; did you
mean 'layout_printer'?
    7 | layout_pirnter::print_newline ()
      | ^~~~~~~~~~~~~~
      | layout_printer
<source>:1:7: note: 'layout_printer' declared here
    1 | class layout_printer
      |       ^
2 errors generated.
Compiler returned: 1

See https://godbolt.org/z/q968ePqq9

I'm not sure why clang emits two errors, but that's for them to fix.
In the meantime, we should provide a suggestion for the misspelling.

Reply via email to