Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unqualified enum literal from different package undetected #530

Closed
senier opened this issue Dec 29, 2020 · 0 comments · Fixed by #539
Closed

Unqualified enum literal from different package undetected #530

senier opened this issue Dec 29, 2020 · 0 comments · Fixed by #539
Assignees
Labels
bug generator Related to generator package (SPARK code generation) model Related to model package (e.g., model verification)

Comments

@senier
Copy link
Member

senier commented Dec 29, 2020

When using an unqualified enumeration literal in the condition of a refinement and the respective enumeration is specified in a separate package, the refinement is accepted as correct, but the generated SPARK code does not compile. Example:

package Numbers is
   type Protocol is (PROTO_OUTER) with Size => 8;
end Numbers;
with Numbers;
package Proto is
   type Packet is
      message
         Protocol : Numbers::Protocol
            then Data
               with Size => 128;
         Data  : Opaque;
      end message;
end Proto;
package Inner is
   type Value is mod 2**8;
   type Packet is
      message
         Data : Value;
      end message;
end Inner;
with Proto;
with Inner;
package In_Proto is
   for Proto::Packet use (Data => Inner::Packet)
      if Protocol = PROTO_OUTER;
end In_Proto;
$ rflx generate -d build in_proto.rflx 
Parsing in_proto.rflx
Parsing proto.rflx
Parsing numbers.rflx
Parsing inner.rflx
Processing Inner
Processing Numbers
Processing Proto
Processing In_Proto
Creating build/rflx-inner.ads
Creating build/rflx-inner-generic_packet.ads
Creating build/rflx-inner-generic_packet.adb
Creating build/rflx-inner-packet.ads
Creating build/rflx-numbers.ads
Creating build/rflx-proto.ads
Creating build/rflx-proto-generic_packet.ads
Creating build/rflx-proto-generic_packet.adb
Creating build/rflx-proto-packet.ads
Creating build/rflx-in_proto.ads
Creating build/rflx-in_proto-generic_contains.ads
Creating build/rflx-in_proto-generic_contains.adb
Creating build/rflx-in_proto-contains.ads
Creating build/rflx-rflx_arithmetic.ads
Creating build/rflx-rflx_builtin_types-conversions.ads
Creating build/rflx-rflx_builtin_types.ads
Creating build/rflx-rflx_generic_types.ads
Creating build/rflx-rflx_message_sequence.ads
Creating build/rflx-rflx_scalar_sequence.ads
Creating build/rflx-rflx_types.ads
Creating build/rflx-rflx_arithmetic.adb
Creating build/rflx-rflx_generic_types.adb
Creating build/rflx-rflx_message_sequence.adb
Creating build/rflx-rflx_scalar_sequence.adb
Creating build/rflx.ads
$ gprbuild -P build
Compile
   [Ada]          rflx-numbers.ads
   [Ada]          rflx-proto-packet.ads
   [Ada]          rflx-rflx_types.ads
   [Ada]          rflx-rflx_builtin_types.ads
   [Ada]          rflx-rflx_generic_types.adb
   [Ada]          rflx-in_proto-generic_contains.adb
rflx-in_proto-generic_contains.ads:33:50: "PROTO_OUTER" is not visible
rflx-in_proto-generic_contains.ads:33:50: non-visible declaration at rflx-numbers.ads:18
gprbuild: *** compilation phase failed

Importing the Numbers package and prefixing the literal with Numbers:: yields

rflx-in_proto-generic_contains.ads:33:50: "Numbers" is not visible
rflx-in_proto-generic_contains.ads:33:50: non-visible declaration at rflx-numbers.ads:12

The unprefixed literal should be reject in the spec and the SPARK package containing the definition should be withed in the generated code.

@senier senier created this issue from a note in RecordFlux 0.5 (To do) Dec 29, 2020
@senier senier added bug generator Related to generator package (SPARK code generation) specification Related to specification package (e.g., specification parsing) labels Dec 29, 2020
senier pushed a commit to Componolit/RecordFlux-specifications that referenced this issue Dec 29, 2020
External protocol numbers break compilation:
AdaCore/RecordFlux#530
senier pushed a commit to Componolit/RecordFlux-specifications that referenced this issue Dec 30, 2020
External protocol numbers break compilation:
AdaCore/RecordFlux#530
@treiher treiher self-assigned this Jan 4, 2021
@treiher treiher moved this from To do to In progress in RecordFlux 0.5 Jan 4, 2021
@treiher treiher added model Related to model package (e.g., model verification) and removed specification Related to specification package (e.g., specification parsing) labels Jan 6, 2021
@treiher treiher moved this from In progress to Done in RecordFlux 0.5 Jan 6, 2021
RecordFlux 0.5 automation moved this from Done to Merged Jan 11, 2021
@treiher treiher mentioned this issue Aug 4, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug generator Related to generator package (SPARK code generation) model Related to model package (e.g., model verification)
Projects
No open projects
RecordFlux 0.5
  
Merged
Development

Successfully merging a pull request may close this issue.

2 participants