This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Parser failure with optimiser output code when using templates.
- To: bug-gcc at gnu dot org
- Subject: Parser failure with optimiser output code when using templates.
- From: Chris Leishman <masklin at debian dot org>
- Date: Tue, 1 Aug 2000 21:36:28 +1000
/*
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