public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60361] New: unexpected 'use of parameter outside function body' error
@ 2014-02-27 22:53 rogero at howzatt dot demon.co.uk
  2014-03-03  9:49 ` [Bug c++/60361] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rogero at howzatt dot demon.co.uk @ 2014-02-27 22:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60361

            Bug ID: 60361
           Summary: unexpected 'use of parameter outside function body'
                    error
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rogero at howzatt dot demon.co.uk

When declaring a variable with a bracketed constructor call, and using the same
external name for the first argument and a template instantiation used as the
second argument, the delaration can fail to compile.

----- registration.cpp -----
struct Helper
{
  Helper(int a, void (*pfunc)());
};

template <int I> void function();

const int A = 1;
const int B = 2;

Helper testOk(A, function<A>);

Helper testOk2(int(A), function<B>);

Helper testOk3((int(A)), function<A>);

// Why does (only) this one fail?
Helper testFail(int(A), function<A>);
----- ends -----

registration.cpp:18:34: error: use of parameter 'A' outside function body
 Helper testFail(int(A), function<A>);
                                  ^
registration.cpp:18:34: error: use of parameter 'A' outside function body
registration.cpp:18:34: error: use of parameter 'A' outside function body
registration.cpp:18:36: error: no matching function for call to
'Helper::Helper(int, <unresolved overloaded function type>)'
 Helper testFail(int(A), function<A>);
                                    ^
registration.cpp:18:36: note: candidates are:
registration.cpp:3:3: note: Helper::Helper(int, void (*)())
   Helper(int a, void (*pfunc)());
   ^
registration.cpp:3:3: note:   no known conversion for argument 2 from
'<unresolved overloaded function type>' to 'void (*)()'
registration.cpp:1:8: note: Helper::Helper(const Helper&)
 struct Helper
        ^
registration.cpp:1:8: note:   candidate expects 1 argument, 2 provided

----
Fails with g++ 4.9.0 and 4.8.1
Works with g++ 4.2.3, Clang 3.2, ICC 13.0 and MSVC 8 thru 12.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60361] [4.7/4.8/4.9 Regression] unexpected 'use of parameter outside function body' error
  2014-02-27 22:53 [Bug c++/60361] New: unexpected 'use of parameter outside function body' error rogero at howzatt dot demon.co.uk
@ 2014-03-03  9:49 ` redi at gcc dot gnu.org
  2014-03-03 20:42 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-03  9:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60361

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-03-03
      Known to work|                            |4.3.5
            Summary|unexpected 'use of          |[4.7/4.8/4.9 Regression]
                   |parameter outside function  |unexpected 'use of
                   |body' error                 |parameter outside function
                   |                            |body' error
     Ever confirmed|0                           |1
      Known to fail|                            |4.6.2, 4.7.4, 4.8.2, 4.9.0

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
4.4 and 4.5 say:

t.cc:18:34: error: 'A' cannot appear in a constant-expression
t.cc:18:36: error: no matching function for call to 'Helper::Helper(int,
<unresolved overloaded function type>)'
t.cc:3:3: note: candidates are: Helper::Helper(int, void (*)())
t.cc:2:1: note:                 Helper::Helper(const Helper&)

and 4.6 onwards give the "use of parameter 'A' outside function body" error, so
if the code is valid this is a regression.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60361] [4.7/4.8/4.9 Regression] unexpected 'use of parameter outside function body' error
  2014-02-27 22:53 [Bug c++/60361] New: unexpected 'use of parameter outside function body' error rogero at howzatt dot demon.co.uk
  2014-03-03  9:49 ` [Bug c++/60361] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org
@ 2014-03-03 20:42 ` jason at gcc dot gnu.org
  2014-03-05 17:54 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2014-03-03 20:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60361

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
   Target Milestone|---                         |4.7.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60361] [4.7/4.8/4.9 Regression] unexpected 'use of parameter outside function body' error
  2014-02-27 22:53 [Bug c++/60361] New: unexpected 'use of parameter outside function body' error rogero at howzatt dot demon.co.uk
  2014-03-03  9:49 ` [Bug c++/60361] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org
  2014-03-03 20:42 ` jason at gcc dot gnu.org
@ 2014-03-05 17:54 ` jason at gcc dot gnu.org
  2014-03-05 17:56 ` [Bug c++/60361] [4.7/4.8 " jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2014-03-05 17:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60361

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Wed Mar  5 17:53:28 2014
New Revision: 208351

URL: http://gcc.gnu.org/viewcvs?rev=208351&root=gcc&view=rev
Log:
    PR c++/60361
    * parser.c (cp_parser_template_id): Don't set up a CPP_TEMPLATE_ID
    if re-parsing might succeed.
    * semantics.c (finish_id_expression): Use of a parameter outside
    the function body is a parse error.

Added:
    trunk/gcc/testsuite/g++.dg/parse/ambig7.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/g++.dg/parse/parameter-declaration-2.C
    trunk/gcc/testsuite/g++.dg/parse/typename7.C


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60361] [4.7/4.8 Regression] unexpected 'use of parameter outside function body' error
  2014-02-27 22:53 [Bug c++/60361] New: unexpected 'use of parameter outside function body' error rogero at howzatt dot demon.co.uk
                   ` (2 preceding siblings ...)
  2014-03-05 17:54 ` jason at gcc dot gnu.org
@ 2014-03-05 17:56 ` jason at gcc dot gnu.org
  2014-06-12 13:49 ` rguenth at gcc dot gnu.org
  2014-08-01 18:34 ` [Bug c++/60361] [4.8 " jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2014-03-05 17:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60361

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.9.0
            Summary|[4.7/4.8/4.9 Regression]    |[4.7/4.8 Regression]
                   |unexpected 'use of          |unexpected 'use of
                   |parameter outside function  |parameter outside function
                   |body' error                 |body' error
      Known to fail|4.9.0                       |

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed in 4.9 for now.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60361] [4.7/4.8 Regression] unexpected 'use of parameter outside function body' error
  2014-02-27 22:53 [Bug c++/60361] New: unexpected 'use of parameter outside function body' error rogero at howzatt dot demon.co.uk
                   ` (3 preceding siblings ...)
  2014-03-05 17:56 ` [Bug c++/60361] [4.7/4.8 " jason at gcc dot gnu.org
@ 2014-06-12 13:49 ` rguenth at gcc dot gnu.org
  2014-08-01 18:34 ` [Bug c++/60361] [4.8 " jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-12 13:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60361

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.4                       |4.8.4

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
The 4.7 branch is being closed, moving target milestone to 4.8.4.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60361] [4.8 Regression] unexpected 'use of parameter outside function body' error
  2014-02-27 22:53 [Bug c++/60361] New: unexpected 'use of parameter outside function body' error rogero at howzatt dot demon.co.uk
                   ` (4 preceding siblings ...)
  2014-06-12 13:49 ` rguenth at gcc dot gnu.org
@ 2014-08-01 18:34 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2014-08-01 18:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60361

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 4.8.4.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-01 18:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-27 22:53 [Bug c++/60361] New: unexpected 'use of parameter outside function body' error rogero at howzatt dot demon.co.uk
2014-03-03  9:49 ` [Bug c++/60361] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org
2014-03-03 20:42 ` jason at gcc dot gnu.org
2014-03-05 17:54 ` jason at gcc dot gnu.org
2014-03-05 17:56 ` [Bug c++/60361] [4.7/4.8 " jason at gcc dot gnu.org
2014-06-12 13:49 ` rguenth at gcc dot gnu.org
2014-08-01 18:34 ` [Bug c++/60361] [4.8 " jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).