This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/86601] New: g++ accepts 'friend' at ill-formed positions in the decl-specifier-seq


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

            Bug ID: 86601
           Summary: g++ accepts 'friend' at ill-formed positions in the
                    decl-specifier-seq
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

g++ accepts this:

  struct S {
    class T friend;
    unsigned friend char;
  };

Both of these are illegal by [class.friend]p3, which requires the 'friend'
decl-specifier to be the first in the decl-specifier-seq for non-function
declarations.

BTW, clang++ rejects it:

code0.cpp:2:10: error: 'friend' must appear first in a non-function declaration
 class T friend;
         ^
code0.cpp:3:11: error: 'friend' must appear first in a non-function declaration
 unsigned friend char;
          ^
2 errors generated.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]