Between 20060508 and 20060530 gcc 4.2 changed to now longer allow the following code. This error seems bogus to me. (sid)3733:tbm@test: ~] cat test.cc extern "C" void foo(register int *my_perl); (sid)3734:tbm@test: ~] c++ -c test.cc test.cc:1: error: invalid use of 'register' in linkage specification zsh: exit 1 c++ -c test.cc (sid)3735:tbm@test: ~]
I want to say the patch for PR 26068 caused this.
It's certainly a questionable use of 'register'. What is the expected effect of this parameter declaration from perls point of view?
I don't know why Perl uses it, I simply noticed that lots of packages in Debian now fail to build because its part of a Perl header... they do this: extern "C" SV* Perl_Gsv_placeholder_ptr(register PerlInterpreter *my_perl __attribute__((unused))); In an IRC discussion whether this is valid, the following comments were made: 18:11 < Womble2> "a linkage-specification directly containing a single declaration shall not specify a storage class" (7.5/8) 18:12 < Womble2> but I think it really means at the top-level of the declaration 18:12 < pinskia> Womble2: I think that means extern "C" static int t; is invalid 18:12 < Womble2> yes the example it gives has a function declared a static 18:13 < pinskia> but register allows to the argument and not to the declaration 18:13 < pinskia> s/allows/applies/ 18:14 < Womble2> indeed, though the statement could be (rather perversely) read as disallow specification of a storage class anywhere in the declaration, as the person who made the change may have done [Womble2 = Ben Hutchings, pinskia = Andrew Pinski] Do you disagree with that interpretation?
I agree that the code is valid from a standards perspective. Just not very clever ;)
OK, I'll let the Perl people know. It would be nice though to revert this error before 4.1.2/4.2.0 come out.
Confirmed. Breaking perl is not nice.
Subject: Bug 27884 Author: mmitchel Date: Fri Jun 16 18:45:50 2006 New Revision: 114727 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114727 Log: PR c++/27884 * decl.c (have_extern_spec): Remove. (start_decl): Do not check have_extern_spec. (start_function): Likewise. * cp-tree.h (have_extern_spec): Remove. * parser.c (cp_parser_linkage_specification): Don't set have_extern_spec. (cp_parser_init_declarator): Likewise. (cp_parser_parameter_declaration): Do not treat parameters as within the scope of an unbraced linkage specification. PR c++/27884 * g++.dg/parse/linkage2.C: New test Added: trunk/gcc/testsuite/g++.dg/parse/linkage2.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-tree.h trunk/gcc/cp/decl.c trunk/gcc/cp/parser.c trunk/gcc/testsuite/ChangeLog
Fixed in 4.2.0.
Subject: Bug 27884 Author: mmitchel Date: Fri Jun 16 23:09:23 2006 New Revision: 114731 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114731 Log: PR c++/27884 * decl.c (have_extern_spec): Remove. (start_decl): Do not check have_extern_spec. (start_function): Likewise. * cp-tree.h (have_extern_spec): Remove. * parser.c (cp_parser_linkage_specification): Don't set have_extern_spec. (cp_parser_init_declarator): Likewise. (cp_parser_parameter_declaration): Do not treat parameters as within the scope of an unbraced linkage specification. PR c++/27884 * g++.dg/parse/linkage2.C: New test Added: branches/gcc-4_1-branch/gcc/testsuite/g++.dg/parse/linkage2.C Modified: branches/gcc-4_1-branch/gcc/cp/ChangeLog branches/gcc-4_1-branch/gcc/cp/cp-tree.h branches/gcc-4_1-branch/gcc/cp/decl.c branches/gcc-4_1-branch/gcc/cp/parser.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Fixed in 4.1.2.