c++/1825: parse error results in Tree check: expected class 't', have 'x' (error_mark)

schmid@snake.iap.physik.tu-darmstadt.de schmid@snake.iap.physik.tu-darmstadt.de
Wed Jan 31 23:36:00 GMT 2001


>Number:         1825
>Category:       c++
>Synopsis:       parse error results in Tree check: expected class 't', have 'x' (error_mark)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-illegal-code
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 31 23:36:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Peter Schmid
>Release:        2.97 20010129 (experimental)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.0 #25 Tue Jan 16 01:22:25 CET 2001 i686 unknown
Architecture: i686
glibc 2.1.3
GNU assembler version 2.10.91 (i686-pc-linux-gnu) using BFD version 2.10.1.0.4
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-nls --enable-shared
>Description:
The following illegal source code, a semicolon is missing after using
namespace std, generates Tree check: expected class 't', have 'x'
(error_mark). 

>How-To-Repeat:
tbug3.C

typedef struct
{
  int count;	
  int value;	
} mbstate_t;

namespace std {

  typedef long  	streamoff;
  typedef long	        streamsize; 

}

namespace std {

    template<typename _StateT>
    class fpos
    {
    public:
      typedef _StateT __state_type;

    private:
      __state_type 	_M_st;
      streamoff 	_M_off;

    public:
      __state_type
      state() const  { return _M_st; }

      fpos(): _M_st(__state_type()), _M_off(streamoff()) { }
    };

}  // namespace std


namespace std {
    typedef fpos<mbstate_t> 	streampos;

    template<class _CharT>
    struct char_traits
    {
      typedef streampos 	pos_type;
      typedef mbstate_t 	state_type;
      
      static state_type 
      _S_get_state(const pos_type& __pos) { return __pos.state(); }
    };

  template<>
    struct char_traits<char>
    {
      typedef streampos 	pos_type;
      typedef mbstate_t 	state_type;

      static state_type 
      _S_get_state(const pos_type& __pos) { return __pos.state(); }

  };

} // namespace std

using namespace std


int main (){ }

Compiling the source file tbug3.C
g++ -v -o tbug3 tbug3.C -W -Wall
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/specs
Configured with: ../gcc/configure --disable-nls --enable-shared --enable-threads=posix
gcc version 2.97 20010129 (experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/cc1plus -v -D__GNUC__=2 -D__GNUC_MINOR__=97 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -W -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tbug3.C -D__GNUG__=2 -D_GNU_SOURCE -D__GXX_ABI_VERSION=100 -quiet -dumpbase tbug3.C -W -Wall -version -o /tmp/ccqo5yzw.s
GNU CPP version 2.97 20010129 (experimental) (cpplib) (i386 Linux/ELF)
GNU CPP version 2.97 20010129 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 2.97 20010129 (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 2.97 20010129 (experimental).
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/i686-pc-linux-gnu/include/g++-v3
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/include
 /usr/local/i686-pc-linux-gnu/include
 /usr/include
End of search list.
tbug3.C:65: parse error before `int'
tbug3.C: In member function `_StateT std::fpos<_StateT>::state() const [with 
   _StateT = mbstate_t]':
tbug3.C:56:   instantiated from here
tbug3.C:28: `this' undeclared (first use this function)
tbug3.C:28: (Each undeclared identifier is reported only once for each function 
   it appears in.)
tbug3.C:28: Tree check: expected class 't', have 'x' (error_mark)
confused by earlier errors, bailing out

Preprocessor source file: tbug3.ii

# 1 "tbug3.C"
typedef struct
{
  int count;
  int value;
} mbstate_t;

namespace std {

  typedef long streamoff;
  typedef long streamsize;

}

namespace std {

    template<typename _StateT>
    class fpos
    {
    public:
      typedef _StateT __state_type;

    private:
      __state_type _M_st;
      streamoff _M_off;

    public:
      __state_type
      state() const { return _M_st; }

      fpos(): _M_st(__state_type()), _M_off(streamoff()) { }
    };

}


namespace std {
    typedef fpos<mbstate_t> streampos;

    template<class _CharT>
    struct char_traits
    {
      typedef streampos pos_type;
      typedef mbstate_t state_type;

      static state_type
      _S_get_state(const pos_type& __pos) { return __pos.state(); }
    };

  template<>
    struct char_traits<char>
    {
      typedef streampos pos_type;
      typedef mbstate_t state_type;

      static state_type
      _S_get_state(const pos_type& __pos) { return __pos.state(); }

  };

}

using namespace std


int main (){ }


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


More information about the Gcc-bugs mailing list