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]

Parser failure with optimiser output code when using templates.


/*

gcc version:    gcc version 2.95.2 20000220 (Debian GNU/Linux)
OS:             Debian GNU/Linux (woody)
kernel:         2.2.16 (SMP)

compiled with:  g++ -Wall gcc-bug.cc


The following code will build fine if NO_TEMPLATE is defined.  If, however,
templates are used then the following errors occur:

gcc-bug.cc: In method `void Tester<int>::test()':
gcc-bug.cc:43:   instantiated from here
gcc-bug.cc:32: `volatile' undeclared (first use this function)
gcc-bug.cc:32: (Each undeclared identifier is reported only once
gcc-bug.cc:32: for each function it appears in.)
gcc-bug.cc:32: warning:  qualifier ignored on asm


The code using asm was produced by gcc as an optimisation, which I striped out
from the preprocessed source to use in this example.

*/

//#define NO_TEMPLATE


#ifndef NO_TEMPLATE
template <class T>
#endif
class Tester
{
public:
	void test();
};


#ifndef NO_TEMPLATE
template <class T> void
Tester<T> :: test()
#else
void
Tester :: test()
#endif
{
	int port = 1;
	int port2;

	port2 = (__extension__   ({ register unsigned short int __v; if (__builtin_constant_p (  port  ))    __v = ((((   port   ) >> 8) & 0xff) | (((   port   ) & 0xff) << 8)) ;   else    __asm__ __volatile__ ("rorw $8, %w0"    : "=r" (__v)    : "0" ((unsigned short int) (  port  )) : "cc");    __v; }))  ;
}


int main()
{
#ifndef NO_TEMPLATE
	Tester<int> x;
#else
	Tester x;
#endif
	x.test();
	return 0;
}

PGP signature


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