public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug objc++/49070] New: ObjC++ compiler fails to compile ObjC method invocations without keyword arguments
@ 2011-05-19 19:11 nicola at gcc dot gnu.org
  2011-05-19 19:14 ` [Bug objc++/49070] " nicola at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-05-19 19:11 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: ObjC++ compiler fails to compile ObjC method
                    invocations without keyword arguments
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: objc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: nicola@gcc.gnu.org


The following testcase

/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, May 2011.  */
#include <objc/objc.h>

@interface A
- (id) method:(id)arg0 :(id)arg1;
@end

id function (A *x)
{
  return [x method:x :x];
}

fails to compile as Objective-C++ with GCC 4.7.0:

[nicola@lampone ~]$ gcc test.mm -c
test.mm: In function ‘objc_object* function(A*)’:
test.mm:10:22: error: found ‘:’ in nested-name-specifier, expected ‘::’
test.mm:10:20: error: ‘x’ is not a class or namespace
test.mm:10:24: warning: ‘A’ may not respond to ‘-method:’ [enabled by default]
test.mm:10:24: warning: (Messages without a matching method signature [enabled
by default]
test.mm:10:24: warning: will be assumed to return ‘id’ and accept [enabled by
default]
test.mm:10:24: warning: ‘...’ as arguments.) [enabled by default]
[nicola@lampone ~]$

It compiles as Objective-C (ie, if you rename the file as test.m).  It also
compiles with much older compilers, such as GCC 4.1.2.

This testcase was distilled from a bug reported by Banlu Kemiyatorn.

I'd consider this slightly higher priority than the usual Objective-C++ 
testcase because what is broken is actually part of the basic Objective-C 
language syntax.

Thanks


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

* [Bug objc++/49070] ObjC++ compiler fails to compile ObjC method invocations without keyword arguments
  2011-05-19 19:11 [Bug objc++/49070] New: ObjC++ compiler fails to compile ObjC method invocations without keyword arguments nicola at gcc dot gnu.org
@ 2011-05-19 19:14 ` nicola at gcc dot gnu.org
  2021-02-26 21:42 ` [Bug objc++/49070] [8/9/10/11 regression] " iains at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-05-19 19:14 UTC (permalink / raw)
  To: gcc-bugs

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

Nicola Pero <nicola at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.05.19 18:36:55
     Ever Confirmed|0                           |1

--- Comment #1 from Nicola Pero <nicola at gcc dot gnu.org> 2011-05-19 18:36:55 UTC ---
Confirmed.  The testcase fails to compile with

  gcc (GCC) 4.7.0 20110519 (experimental).

Thanks


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

* [Bug objc++/49070] [8/9/10/11 regression] ObjC++ compiler fails to compile ObjC method invocations without keyword arguments
  2011-05-19 19:11 [Bug objc++/49070] New: ObjC++ compiler fails to compile ObjC method invocations without keyword arguments nicola at gcc dot gnu.org
  2011-05-19 19:14 ` [Bug objc++/49070] " nicola at gcc dot gnu.org
@ 2021-02-26 21:42 ` iains at gcc dot gnu.org
  2021-03-18 11:50 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: iains at gcc dot gnu.org @ 2021-02-26 21:42 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.4                         |8.6

--- Comment #5 from Iain Sandoe <iains at gcc dot gnu.org> ---
patch posted :
https://gcc.gnu.org/pipermail/gcc-patches/2021-February/565952.html

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

* [Bug objc++/49070] [8/9/10/11 regression] ObjC++ compiler fails to compile ObjC method invocations without keyword arguments
  2011-05-19 19:11 [Bug objc++/49070] New: ObjC++ compiler fails to compile ObjC method invocations without keyword arguments nicola at gcc dot gnu.org
  2011-05-19 19:14 ` [Bug objc++/49070] " nicola at gcc dot gnu.org
  2021-02-26 21:42 ` [Bug objc++/49070] [8/9/10/11 regression] " iains at gcc dot gnu.org
@ 2021-03-18 11:50 ` cvs-commit at gcc dot gnu.org
  2021-03-24 22:07 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-18 11:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:0cc218d42c241ed286cc5af9fb7d2e45386f7a24

commit r11-7714-g0cc218d42c241ed286cc5af9fb7d2e45386f7a24
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Fri Feb 26 10:21:02 2021 +0000

    Objective-C++ : Fix handling of unnamed message parms [PR49070].

    When we are parsing an Objective-C++ message, a colon is a valid
    terminator for a assignment-expression.  That is:

    [receiver meth:x:x:x:x];

    Is a valid, if somewhat unreadable, construction; corresponding
    to a method declaration like:

    - (id) meth:(id)arg0 :(id)arg1 :(id)arg2 :(id)arg3;

    Where three of the message params have no selector name.

    If fact, although it might be unintentional, Objective-C/C++ can
    accept message selectors with all the parms unnamed (this applies
    to the clang implementation too, which is taken as the reference
    for the language).

    For regular C++, the pattern x:x is not valid in that position an
    an error is emitted with a fixit for the expected scope token.

    If we simply made that error conditional on !c_dialect_objc()
    that would regress Objective-C++ diagnostics for cases outside a
    message selector, so we add a state flag for this.

    gcc/cp/ChangeLog:

            PR objc++/49070
            * parser.c (cp_debug_parser): Add Objective-C++ message
            state flag.
            (cp_parser_nested_name_specifier_opt): Allow colon to
            terminate an assignment-expression when parsing Objective-
            C++ messages.
            (cp_parser_objc_message_expression): Set and clear message
            parsing state on entry and exit.
            * parser.h (struct cp_parser): Add a context flag for
            Objective-C++ message state.

    gcc/testsuite/ChangeLog:

            PR objc++/49070
            * obj-c++.dg/pr49070.mm: New test.
            * objc.dg/unnamed-parms.m: New test.

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

* [Bug objc++/49070] [8/9/10/11 regression] ObjC++ compiler fails to compile ObjC method invocations without keyword arguments
  2011-05-19 19:11 [Bug objc++/49070] New: ObjC++ compiler fails to compile ObjC method invocations without keyword arguments nicola at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-03-18 11:50 ` cvs-commit at gcc dot gnu.org
@ 2021-03-24 22:07 ` cvs-commit at gcc dot gnu.org
  2021-05-14 14:05 ` [Bug objc++/49070] [9/10/11/12 " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-24 22:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain D Sandoe
<iains@gcc.gnu.org>:

https://gcc.gnu.org/g:e3cac00975a1de879dc8356285a8908c25026ec4

commit r10-9536-ge3cac00975a1de879dc8356285a8908c25026ec4
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Fri Feb 26 10:21:02 2021 +0000

    Objective-C++ : Fix handling of unnamed message parms [PR49070].

    When we are parsing an Objective-C++ message, a colon is a valid
    terminator for a assignment-expression.  That is:

    [receiver meth:x:x:x:x];

    Is a valid, if somewhat unreadable, construction; corresponding
    to a method declaration like:

    - (id) meth:(id)arg0 :(id)arg1 :(id)arg2 :(id)arg3;

    Where three of the message params have no selector name.

    If fact, although it might be unintentional, Objective-C/C++ can
    accept message selectors with all the parms unnamed (this applies
    to the clang implementation too, which is taken as the reference
    for the language).

    For regular C++, the pattern x:x is not valid in that position an
    an error is emitted with a fixit for the expected scope token.

    If we simply made that error conditional on !c_dialect_objc()
    that would regress Objective-C++ diagnostics for cases outside a
    message selector, so we add a state flag for this.

    gcc/cp/ChangeLog:

            PR objc++/49070
            * parser.c (cp_debug_parser): Add Objective-C++ message
            state flag.
            (cp_parser_nested_name_specifier_opt): Allow colon to
            terminate an assignment-expression when parsing Objective-
            C++ messages.
            (cp_parser_objc_message_expression): Set and clear message
            parsing state on entry and exit.
            * parser.h (struct cp_parser): Add a context flag for
            Objective-C++ message state.

    gcc/testsuite/ChangeLog:

            PR objc++/49070
            * obj-c++.dg/pr49070.mm: New test.
            * objc.dg/unnamed-parms.m: New test.

    (cherry picked from commit 0cc218d42c241ed286cc5af9fb7d2e45386f7a24)

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

* [Bug objc++/49070] [9/10/11/12 regression] ObjC++ compiler fails to compile ObjC method invocations without keyword arguments
  2011-05-19 19:11 [Bug objc++/49070] New: ObjC++ compiler fails to compile ObjC method invocations without keyword arguments nicola at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-03-24 22:07 ` cvs-commit at gcc dot gnu.org
@ 2021-05-14 14:05 ` jakub at gcc dot gnu.org
  2021-06-01  8:05 ` rguenth at gcc dot gnu.org
  2022-05-27  9:11 ` [Bug objc++/49070] [9 " rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14 14:05 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|8.6                         |9.4
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The GCC 8 branch is being closed, retargeting at 9.4

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

* [Bug objc++/49070] [9/10/11/12 regression] ObjC++ compiler fails to compile ObjC method invocations without keyword arguments
  2011-05-19 19:11 [Bug objc++/49070] New: ObjC++ compiler fails to compile ObjC method invocations without keyword arguments nicola at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-05-14 14:05 ` [Bug objc++/49070] [9/10/11/12 " jakub at gcc dot gnu.org
@ 2021-06-01  8:05 ` rguenth at gcc dot gnu.org
  2022-05-27  9:11 ` [Bug objc++/49070] [9 " rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

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

* [Bug objc++/49070] [9 regression] ObjC++ compiler fails to compile ObjC method invocations without keyword arguments
  2011-05-19 19:11 [Bug objc++/49070] New: ObjC++ compiler fails to compile ObjC method invocations without keyword arguments nicola at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-06-01  8:05 ` rguenth at gcc dot gnu.org
@ 2022-05-27  9:11 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.0
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC 10.

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

end of thread, other threads:[~2022-05-27  9:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-19 19:11 [Bug objc++/49070] New: ObjC++ compiler fails to compile ObjC method invocations without keyword arguments nicola at gcc dot gnu.org
2011-05-19 19:14 ` [Bug objc++/49070] " nicola at gcc dot gnu.org
2021-02-26 21:42 ` [Bug objc++/49070] [8/9/10/11 regression] " iains at gcc dot gnu.org
2021-03-18 11:50 ` cvs-commit at gcc dot gnu.org
2021-03-24 22:07 ` cvs-commit at gcc dot gnu.org
2021-05-14 14:05 ` [Bug objc++/49070] [9/10/11/12 " jakub at gcc dot gnu.org
2021-06-01  8:05 ` rguenth at gcc dot gnu.org
2022-05-27  9:11 ` [Bug objc++/49070] [9 " rguenth 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).