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]

c++/9014: unnamed classes cannot have base classes


>Number:         9014
>Category:       c++
>Synopsis:       unnamed classes cannot have base classes
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 19 19:56:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     martin@xemacs.org
>Release:        gcc-3.2.1
>Organization:
>Environment:
Linux x86
>Description:
C++ classes can be unnamed.
C++ classes can have base classes.
Orthogonality suggests they can do both.

The following should compile (and indeed does under
Intel's icc and Comeau C++'s test drive):

class A {};
class {} x;              // OK
class B : public A {} y; // OK
class : public A {} z;   // parse error


(martin@wobble) ~/src/toy $ gcc -c unnamed-inheritor.cc
unnamed-inheritor.cc:4: parse error before `:' token
unnamed-inheritor.cc:4: ISO C++ forbids declaration of `z' with no type

This grammar production

class-head:
    class-key identifieropt base-clauseopt

suggests that both the class name and the base clause are
independently optional.
>How-To-Repeat:
See description
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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