15317 – [3.4/4.0 Regression] attribute unused in first parameter of constructor gives error (original) (raw)
If the first parameter of a constructor is marked as unused i always get the error:
x25.cpp:26: error: expected unqualified-id before "const"
x25.cpp:26: error: expected )' before "const" x25.cpp:26: error: expected ,' or `;' before "const
where the line is
x25.cpp:26: CommonX25::CommonX25(UNUSED const char *lName, UNUSED const char
*rName, UNUSED const char *source, UNUSED const char *dest)
Michael
Comment 1 Wolfgang Bangerth 2004-05-06 14:29:23 UTC
Can you give us a small testcase? Thanks Wolfgang
Comment 2 Drea Pinski 2004-05-06 14:33:12 UTC
With a simple testcase I cannot verify it: struct A { void f(const int *, const int *); };
void A::f(attribute((unused)) const int *i, attribute((unused)) const int *i2) { }
Are sure that UNUSED is defined to be the attribute?
small testcase:
class CommonX25 { private: #if defined AIX && !defined AIX43 ... #endif /* AIX */
public: CommonX25(const char *, const char *, const char *, const char *); ~CommonX25(); };
CommonX25::CommonX25(attribute ((unused)) const char *lName, attribute ( (unused)) const char *rName, attribute ((unused)) const char *source, attr ibute ((unused)) const char *dest) { #if defined AIX && !defined AIX43 ... #else cerr << "CommonX25 not implemented" << endl; exit(-1); #endif }
compiled with: g++ -c -o test.o test.cpp
Comment 4 Drea Pinski 2004-05-06 14:43:09 UTC
Confirmed, reduced example: struct A { A(char); }; A::A(attribute((unused)) char i2) {}
Comment 5 Drea Pinski 2004-05-06 14:44:52 UTC
A work around is to place the attribute after the variable name but this works only on 3.4.0 and above: struct A { A(char); }; A::A(char i2 attribute((unused))) {}
Comment 9 Mark Mitchell 2004-05-24 02:34:43 UTC
Fixed in GCC 3.4.1.