Bug 27884 - [4.1 regression] bogus error: invalid use of 'register' in linkage specification
Summary: [4.1 regression] bogus error: invalid use of 'register' in linkage specification
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P1 blocker
Target Milestone: 4.1.2
Assignee: Mark Mitchell
URL:
Keywords: rejects-valid
Depends on: 26068
Blocks:
  Show dependency treegraph
 
Reported: 2006-06-03 17:12 UTC by Martin Michlmayr
Modified: 2006-06-16 23:09 UTC (History)
8 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-06-04 15:35:07


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Michlmayr 2006-06-03 17:12:42 UTC
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: ~]
Comment 1 Andrew Pinski 2006-06-03 17:18:55 UTC
I want to say the patch for PR 26068 caused this.
Comment 2 Richard Biener 2006-06-04 10:04:44 UTC
It's certainly a questionable use of 'register'.  What is the expected effect of this parameter declaration from perls point of view?
Comment 3 Martin Michlmayr 2006-06-04 10:24:06 UTC
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?
Comment 4 Richard Biener 2006-06-04 10:48:39 UTC
I agree that the code is valid from a standards perspective.  Just not very clever ;)
Comment 5 Martin Michlmayr 2006-06-04 10:52:28 UTC
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.
Comment 6 Richard Biener 2006-06-04 15:35:07 UTC
Confirmed.  Breaking perl is not nice.
Comment 7 Mark Mitchell 2006-06-16 18:46:06 UTC
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

Comment 8 Mark Mitchell 2006-06-16 18:53:38 UTC
Fixed in 4.2.0.
Comment 9 Mark Mitchell 2006-06-16 23:09:36 UTC
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

Comment 10 Mark Mitchell 2006-06-16 23:09:51 UTC
Fixed in 4.1.2.