| Bug#: 15317 | Product: gcc | Version: 3.4.0 | |
| Host: sparc-sun-solaris2.8 | Target: sparc-sun-solaris2.8 | Build: sparc-sun-solaris2.8 | |
| Status: RESOLVED | Severity: minor | Priority: P1 | |
| Resolution: FIXED | Assigned To: mark@codesourcery.com | Reported By: mb@apissoft.com | |
| Component: c++ | Target Milestone: 3.4.1 | ||
| Summary: [3.4/4.0 Regression] __attribute__ unused in first parameter of constructor gives error | |||
| Keywords: rejects-valid | |||
| Opened: 2004-05-06 14:14 | |||
| Description: | Last confirmed: 2004-05-06 14:43 | Opened: 2004-05-06 14:14 |
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
Can you give us a small testcase? Thanks Wolfgang
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
Confirmed, reduced example:
struct A
{
A(char);
};
A::A(__attribute__((unused)) char i2)
{}
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)))
{}
Subject: Bug 15317 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-05-24 02:22:19 Modified files: gcc/testsuite : ChangeLog gcc/cp : ChangeLog parser.c typeck.c Added files: gcc/testsuite/g++.dg/ext: attrib14.C gcc/testsuite/g++.dg/template: error12.C ptrmem9.C Log message: PR c++/15044 * parser.c (cp_parser_class_head): Robustify. PR c++/15317 * parser.c (cp_parser_decl_specifier_seq): Correct error in comment. (cp_parser_constructor_declarator_p): Treat attributes as decl-specifiers. PR c++/15329 * typeck.c (build_unary_op): Do not attempt to resolve casts to base classes in templates. PR c++/15044 * g++.dg/template/error12.C: New test. PR c++/15317 * g++.dg/ext/attrib14.C: New test. PR c++/15329 * g++.dg/template/ptrmem9.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.182&r2=1.3389.2.183 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.105&r2=1.3892.2.106 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.27&r2=1.157.2.28 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.519.2.15&r2=1.519.2.16 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib14.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.2.16.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error12.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem9.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Subject: Bug 15317 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-05-24 02:29:35 Modified files: gcc/testsuite : ChangeLog gcc/cp : ChangeLog parser.c typeck.c Added files: gcc/testsuite/g++.dg/ext: attrib15.C gcc/testsuite/g++.dg/template: error12.C ptrmem9.C Log message: PR c++/15044 * parser.c (cp_parser_class_head): Robustify. PR c++/15317 * parser.c (cp_parser_decl_specifier_seq): Correct error in comment. (cp_parser_constructor_declarator_p): Treat attributes as decl-specifiers. PR c++/15329 * typeck.c (build_unary_op): Do not attempt to resolve casts to base classes in templates. PR c++/15044 * g++.dg/template/error12.C: New test. PR c++/15317 * g++.dg/ext/attrib15.C: New test. PR c++/15329 * g++.dg/template/ptrmem9.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3777&r2=1.3778 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4056&r2=1.4057 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.194&r2=1.195 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.543&r2=1.544 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib15.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error12.C.diff?cvsroot=gcc&r1=1.1&r2=1.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem9.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
Subject: Bug 15317 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-05-24 02:30:28 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/ext: attrib15.C Log message: PR c++/15044 * parser.c (cp_parser_class_head): Robustify. PR c++/15317 * parser.c (cp_parser_decl_specifier_seq): Correct error in comment. (cp_parser_constructor_declarator_p): Treat attributes as decl-specifiers. PR c++/15329 * typeck.c (build_unary_op): Do not attempt to resolve casts to base classes in templates. PR c++/15044 * g++.dg/template/error12.C: New test. PR c++/15317 * g++.dg/ext/attrib15.C: New test. PR c++/15329 * g++.dg/template/ptrmem9.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.183&r2=1.3389.2.184 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib15.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1