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

            Bug ID: 107178
           Summary: Diagnosis for colon vs semi-colon in a member function
                    declaration
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: llvm at rifkin dot dev
  Target Milestone: ---

The following code emits a poor diagnosis:

struct T {};

struct S {
    T foo():
};

<source>:4:7: error: bit-field 'T S::foo()' has non-integral type 'T (S::)()'
    4 |     T foo():
      |       ^~~

https://godbolt.org/z/39ME3K6TE

At least for the case of a member function declaration, a better diagnosis
would probably be ideal.


For T foo():, clang emits:

<source>:5:1: error: expected '(' or '{'
};
^


For T foo:, clang emits:

<source>:5:1: error: expected expression
};
^
<source>:5:3: error: expected '}'
};
  ^
<source>:3:10: note: to match this '{'
struct S {
         ^
<source>:5:3: error: expected ';' after struct
};
  ^
  ;

Reply via email to