public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/113862] New: error: "others" choice not allowed here
@ 2024-02-10 10:18 p.p11 at orange dot fr
  2024-02-14 17:44 ` [Bug ada/113862] " ebotcazou at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: p.p11 at orange dot fr @ 2024-02-10 10:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113862
           Summary: error: "others" choice not allowed here
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: p.p11 at orange dot fr
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 57376
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57376&action=edit
Reproducer.

$ gcc -c -gnatl test34b.adb
GNAT 13.2.0
Compiling: test34b.adb
     1. procedure Test34b is
     2.
     3.    type NTCT is new Natural;
     4.    TBD_Error, Not_Valid_Error : exception;
     5.    function Is_Valid (P : NTCT) return Boolean is (False);
     6.    Param : NTCT;
     7.    type Some_Tagged is tagged null record;
     8.    type A_Tagged is new Some_Tagged with  record Comp : Character; end
record;
     9.    type Some_Array is array (Positive range <>) of NTCT;
    10.    function Func (Val : Integer) return Natural is (0);
    11.
    12.    --    Section_11_3_Paragraph_2a
    13.    Pre : Boolean  := (if not Is_Valid(Param) then raise
Not_Valid_Error);
    14.    A : A_Tagged   := (Some_Tagged'(raise TBD_Error) with Comp => 'A');
    15.    B : Some_Array := (1, 2, 3, others => raise Not_Valid_Error);
                                       |
        >>> error: "others" choice not allowed here
        >>> error: qualify the aggregate with a constrained subtype to provide
bounds for it

    16.    C : Natural    := Func (Val => raise TBD_Error);
    17.    D : A_Tagged   := ((raise TBD_Error) with Comp => 'A');
    18.
    19. begin
    20.    null;
    21. end;

It is weird as this code comes from AARM 2022 Section_11_3_Paragraph_2a.
See full source code in attachement.

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

* [Bug ada/113862] error: "others" choice not allowed here
  2024-02-10 10:18 [Bug ada/113862] New: error: "others" choice not allowed here p.p11 at orange dot fr
@ 2024-02-14 17:44 ` ebotcazou at gcc dot gnu.org
  2024-02-14 17:46 ` ebotcazou at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-02-14 17:44 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-02-14
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Not clear if there is much value in creating a PR for such a pathological case
if it happens to be legal.

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

* [Bug ada/113862] error: "others" choice not allowed here
  2024-02-10 10:18 [Bug ada/113862] New: error: "others" choice not allowed here p.p11 at orange dot fr
  2024-02-14 17:44 ` [Bug ada/113862] " ebotcazou at gcc dot gnu.org
@ 2024-02-14 17:46 ` ebotcazou at gcc dot gnu.org
  2024-02-17 18:22 ` p.p11 at orange dot fr
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-02-14 17:46 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |SUSPENDED

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

* [Bug ada/113862] error: "others" choice not allowed here
  2024-02-10 10:18 [Bug ada/113862] New: error: "others" choice not allowed here p.p11 at orange dot fr
  2024-02-14 17:44 ` [Bug ada/113862] " ebotcazou at gcc dot gnu.org
  2024-02-14 17:46 ` ebotcazou at gcc dot gnu.org
@ 2024-02-17 18:22 ` p.p11 at orange dot fr
  2024-02-17 22:47 ` ebotcazou at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: p.p11 at orange dot fr @ 2024-02-17 18:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Pascal Pignard <p.p11 at orange dot fr> ---
Nevertheless, theses examples of code come from AARM Ada 2022:
11.3 Raise Statements and Raise Expressions
...
All of the following are legal, no additional parens are needed:

2.a.10/4        Pre : Boolean  := (if not Is_Valid(Param) then raise
Not_Valid_Error);
                A : A_Tagged   := (Some_Tagged'(raise TBD_Error) with Comp =>
'A');
                B : Some_Array := (1, 2, 3, others => raise Not_Valid_Error);
                C : Natural    := Func (Val => raise TBD_Error);

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

* [Bug ada/113862] error: "others" choice not allowed here
  2024-02-10 10:18 [Bug ada/113862] New: error: "others" choice not allowed here p.p11 at orange dot fr
                   ` (2 preceding siblings ...)
  2024-02-17 18:22 ` p.p11 at orange dot fr
@ 2024-02-17 22:47 ` ebotcazou at gcc dot gnu.org
  2024-02-19 10:56 ` charlet at gcc dot gnu.org
  2024-02-25 10:42 ` p.p11 at orange dot fr
  5 siblings, 0 replies; 7+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-02-17 22:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Well, this is very irregular if it happens to be legal, since it would be
illegal if the raise was replaced by anything else.  More of a bug in the
language than in the compiler if you ask me...

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

* [Bug ada/113862] error: "others" choice not allowed here
  2024-02-10 10:18 [Bug ada/113862] New: error: "others" choice not allowed here p.p11 at orange dot fr
                   ` (3 preceding siblings ...)
  2024-02-17 22:47 ` ebotcazou at gcc dot gnu.org
@ 2024-02-19 10:56 ` charlet at gcc dot gnu.org
  2024-02-25 10:42 ` p.p11 at orange dot fr
  5 siblings, 0 replies; 7+ messages in thread
From: charlet at gcc dot gnu.org @ 2024-02-19 10:56 UTC (permalink / raw)
  To: gcc-bugs

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

Arnaud Charlet <charlet at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |charlet at gcc dot gnu.org
             Status|SUSPENDED                   |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from Arnaud Charlet <charlet at gcc dot gnu.org> ---
The AARM example is just wrong, the syntax isn't valid.
The point of this section is to clarify when extra parens are not needed, it
doesn't change the fact that you can't declare an unconstrained array like that
without specifying the bounds, so GNAT's error message is correct.

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

* [Bug ada/113862] error: "others" choice not allowed here
  2024-02-10 10:18 [Bug ada/113862] New: error: "others" choice not allowed here p.p11 at orange dot fr
                   ` (4 preceding siblings ...)
  2024-02-19 10:56 ` charlet at gcc dot gnu.org
@ 2024-02-25 10:42 ` p.p11 at orange dot fr
  5 siblings, 0 replies; 7+ messages in thread
From: p.p11 at orange dot fr @ 2024-02-25 10:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Pascal Pignard <p.p11 at orange dot fr> ---
Created attachment 57522
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57522&action=edit
Reproducer updated (no more error)

I apologize the reproducer was wrong, I assumed Some_Array unconstrained
whereas it should have been constrained:
   type Some_Array is array (Positive range 1 .. 10) of NTCT;
Then no more error issue.
I've updated the reproducer.
Sorry for that, Pascal.

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

end of thread, other threads:[~2024-02-25 10:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-10 10:18 [Bug ada/113862] New: error: "others" choice not allowed here p.p11 at orange dot fr
2024-02-14 17:44 ` [Bug ada/113862] " ebotcazou at gcc dot gnu.org
2024-02-14 17:46 ` ebotcazou at gcc dot gnu.org
2024-02-17 18:22 ` p.p11 at orange dot fr
2024-02-17 22:47 ` ebotcazou at gcc dot gnu.org
2024-02-19 10:56 ` charlet at gcc dot gnu.org
2024-02-25 10:42 ` p.p11 at orange dot fr

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).