Bug 15317 - [3.4/4.0 Regression] __attribute__ unused in first parameter of constructor gives error
Summary: [3.4/4.0 Regression] __attribute__ unused in first parameter of constructor g...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P1 minor
Target Milestone: 3.4.1
Assignee: Mark Mitchell
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2004-05-06 14:14 UTC by mb
Modified: 2004-10-30 21:11 UTC (History)
1 user (show)

See Also:
Host: sparc-sun-solaris2.8
Target: sparc-sun-solaris2.8
Build: sparc-sun-solaris2.8
Known to work: 3.3.3
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-05-06 14:43:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mb 2004-05-06 14:14:52 UTC
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 Andrew 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?
Comment 3 mb 2004-05-06 14:36:21 UTC
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 Andrew Pinski 2004-05-06 14:43:09 UTC
Confirmed, reduced example:
struct A
{
  A(char);
};
A::A(__attribute__((unused)) char i2)
{}
Comment 5 Andrew 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 6 CVS Commits 2004-05-24 02:23:49 UTC
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

Comment 7 CVS Commits 2004-05-24 02:29:48 UTC
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

Comment 8 CVS Commits 2004-05-24 02:30:47 UTC
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

Comment 9 Mark Mitchell 2004-05-24 02:34:43 UTC
Fixed in GCC 3.4.1.