Topic: Why is the decl-specifier-seq optional in simple-declaration.


Author: Theodore Norvell <theo@cs.ubc.ca>
Date: Tue, 18 Sep 2001 21:02:45 GMT
Raw View
Is there any case where error free code contains a simple-declaration
that consists only of an init-declarator-list?

In the ISO spec, simple-declaration is defined as
 simple-declaration:
  decl-specifier-seq(opt) init-declarator-list(opt) ;
It also says that the decl-specifier-seq can only be omitted in the
case of constructors, destructors, and type converstions.  However,
I can't think of a case where you can use a simple-declaration
to declare these kinds of functions.


For example, the following program is syntactically valid:
 class C {
  C() ;  // Not a simple-declaration.
 } ;
 C::C() ; // A simple-declaration
But it is not error free, as you can not declare a constructor outside of its class.
(Note that the declaration within the class is a member-declaration,
not a simple-declaration.)

If I change simple-declaration to
 simple-declaration:
  decl-specifier-seq init-declarator-list(opt) ;
  ;
would I fail to parse any valid programs?

Cheers,
Theodore Norvell

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]