Skip to content

Commit 4da7b00

Browse files
authored
Add four missing attributes to the builtin_attrs table. (#1898)
1 parent 2129967 commit 4da7b00

File tree

4 files changed

+396
-0
lines changed

4 files changed

+396
-0
lines changed

ocaml/parsing/builtin_attributes.ml

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ let builtin_attrs =
104104
; "loop"; "ocaml.loop"
105105
; "tail_mod_cons"; "ocaml.tail_mod_cons"
106106
; "unaliasable"; "ocaml.unaliasable"
107+
; "builtin"; "ocaml.builtin"
108+
; "no_effects"; "ocaml.no_effects"
109+
; "no_coeffects"; "ocaml.no_coeffects"
110+
; "only_generative_effects"; "ocaml.only_generative_effects";
107111
]
108112

109113
(* nroberts: When we upstream the builtin-attribute whitelisting, we shouldn't

ocaml/testsuite/tests/warnings/w53.compilers.reference

+160
Original file line numberDiff line numberDiff line change
@@ -582,3 +582,163 @@ File "w53.ml", line 356, characters 17-22:
582582
356 | let f2 = fun [@boxed] (type a) (x : a) -> x (* rejected *)
583583
^^^^^
584584
Warning 53 [misplaced-attribute]: the "boxed" attribute cannot appear in this context
585+
File "w53.ml", line 360, characters 21-28:
586+
360 | type 'a t1 = 'a [@@builtin] (* rejected *)
587+
^^^^^^^
588+
Warning 53 [misplaced-attribute]: the "builtin" attribute cannot appear in this context
589+
File "w53.ml", line 361, characters 19-26:
590+
361 | type s1 = Foo1 [@builtin] (* rejected *)
591+
^^^^^^^
592+
Warning 53 [misplaced-attribute]: the "builtin" attribute cannot appear in this context
593+
File "w53.ml", line 362, characters 17-24:
594+
362 | val x : int [@@builtin] (* rejected *)
595+
^^^^^^^
596+
Warning 53 [misplaced-attribute]: the "builtin" attribute cannot appear in this context
597+
File "w53.ml", line 364, characters 22-29:
598+
364 | external y : (int [@builtin]) -> (int [@builtin]) = "x" "y" (* rejected *)
599+
^^^^^^^
600+
Warning 53 [misplaced-attribute]: the "builtin" attribute cannot appear in this context
601+
File "w53.ml", line 364, characters 42-49:
602+
364 | external y : (int [@builtin]) -> (int [@builtin]) = "x" "y" (* rejected *)
603+
^^^^^^^
604+
Warning 53 [misplaced-attribute]: the "builtin" attribute cannot appear in this context
605+
File "w53.ml", line 369, characters 21-28:
606+
369 | type 'a t1 = 'a [@@builtin] (* rejected *)
607+
^^^^^^^
608+
Warning 53 [misplaced-attribute]: the "builtin" attribute cannot appear in this context
609+
File "w53.ml", line 370, characters 19-26:
610+
370 | type s1 = Foo1 [@builtin] (* rejected *)
611+
^^^^^^^
612+
Warning 53 [misplaced-attribute]: the "builtin" attribute cannot appear in this context
613+
File "w53.ml", line 371, characters 22-29:
614+
371 | let x : int = 42 [@@builtin] (* rejected *)
615+
^^^^^^^
616+
Warning 53 [misplaced-attribute]: the "builtin" attribute cannot appear in this context
617+
File "w53.ml", line 373, characters 22-29:
618+
373 | external y : (int [@builtin]) -> (int [@builtin]) = "x" "y" (* rejected *)
619+
^^^^^^^
620+
Warning 53 [misplaced-attribute]: the "builtin" attribute cannot appear in this context
621+
File "w53.ml", line 373, characters 42-49:
622+
373 | external y : (int [@builtin]) -> (int [@builtin]) = "x" "y" (* rejected *)
623+
^^^^^^^
624+
Warning 53 [misplaced-attribute]: the "builtin" attribute cannot appear in this context
625+
File "w53.ml", line 378, characters 21-31:
626+
378 | type 'a t1 = 'a [@@no_effects] (* rejected *)
627+
^^^^^^^^^^
628+
Warning 53 [misplaced-attribute]: the "no_effects" attribute cannot appear in this context
629+
File "w53.ml", line 379, characters 19-29:
630+
379 | type s1 = Foo1 [@no_effects] (* rejected *)
631+
^^^^^^^^^^
632+
Warning 53 [misplaced-attribute]: the "no_effects" attribute cannot appear in this context
633+
File "w53.ml", line 380, characters 17-27:
634+
380 | val x : int [@@no_effects] (* rejected *)
635+
^^^^^^^^^^
636+
Warning 53 [misplaced-attribute]: the "no_effects" attribute cannot appear in this context
637+
File "w53.ml", line 382, characters 22-32:
638+
382 | external y : (int [@no_effects]) -> (int [@no_effects]) = "x" "y" (* rejected *)
639+
^^^^^^^^^^
640+
Warning 53 [misplaced-attribute]: the "no_effects" attribute cannot appear in this context
641+
File "w53.ml", line 382, characters 45-55:
642+
382 | external y : (int [@no_effects]) -> (int [@no_effects]) = "x" "y" (* rejected *)
643+
^^^^^^^^^^
644+
Warning 53 [misplaced-attribute]: the "no_effects" attribute cannot appear in this context
645+
File "w53.ml", line 387, characters 21-31:
646+
387 | type 'a t1 = 'a [@@no_effects] (* rejected *)
647+
^^^^^^^^^^
648+
Warning 53 [misplaced-attribute]: the "no_effects" attribute cannot appear in this context
649+
File "w53.ml", line 388, characters 19-29:
650+
388 | type s1 = Foo1 [@no_effects] (* rejected *)
651+
^^^^^^^^^^
652+
Warning 53 [misplaced-attribute]: the "no_effects" attribute cannot appear in this context
653+
File "w53.ml", line 389, characters 22-32:
654+
389 | let x : int = 42 [@@no_effects] (* rejected *)
655+
^^^^^^^^^^
656+
Warning 53 [misplaced-attribute]: the "no_effects" attribute cannot appear in this context
657+
File "w53.ml", line 391, characters 22-32:
658+
391 | external y : (int [@no_effects]) -> (int [@no_effects]) = "x" "y" (* rejected *)
659+
^^^^^^^^^^
660+
Warning 53 [misplaced-attribute]: the "no_effects" attribute cannot appear in this context
661+
File "w53.ml", line 391, characters 45-55:
662+
391 | external y : (int [@no_effects]) -> (int [@no_effects]) = "x" "y" (* rejected *)
663+
^^^^^^^^^^
664+
Warning 53 [misplaced-attribute]: the "no_effects" attribute cannot appear in this context
665+
File "w53.ml", line 396, characters 21-33:
666+
396 | type 'a t1 = 'a [@@no_coeffects] (* rejected *)
667+
^^^^^^^^^^^^
668+
Warning 53 [misplaced-attribute]: the "no_coeffects" attribute cannot appear in this context
669+
File "w53.ml", line 397, characters 19-31:
670+
397 | type s1 = Foo1 [@no_coeffects] (* rejected *)
671+
^^^^^^^^^^^^
672+
Warning 53 [misplaced-attribute]: the "no_coeffects" attribute cannot appear in this context
673+
File "w53.ml", line 398, characters 17-29:
674+
398 | val x : int [@@no_coeffects] (* rejected *)
675+
^^^^^^^^^^^^
676+
Warning 53 [misplaced-attribute]: the "no_coeffects" attribute cannot appear in this context
677+
File "w53.ml", line 400, characters 22-34:
678+
400 | external y : (int [@no_coeffects]) -> (int [@no_coeffects]) = "x" "y" (* rejected *)
679+
^^^^^^^^^^^^
680+
Warning 53 [misplaced-attribute]: the "no_coeffects" attribute cannot appear in this context
681+
File "w53.ml", line 400, characters 47-59:
682+
400 | external y : (int [@no_coeffects]) -> (int [@no_coeffects]) = "x" "y" (* rejected *)
683+
^^^^^^^^^^^^
684+
Warning 53 [misplaced-attribute]: the "no_coeffects" attribute cannot appear in this context
685+
File "w53.ml", line 405, characters 21-33:
686+
405 | type 'a t1 = 'a [@@no_coeffects] (* rejected *)
687+
^^^^^^^^^^^^
688+
Warning 53 [misplaced-attribute]: the "no_coeffects" attribute cannot appear in this context
689+
File "w53.ml", line 406, characters 19-31:
690+
406 | type s1 = Foo1 [@no_coeffects] (* rejected *)
691+
^^^^^^^^^^^^
692+
Warning 53 [misplaced-attribute]: the "no_coeffects" attribute cannot appear in this context
693+
File "w53.ml", line 407, characters 22-34:
694+
407 | let x : int = 42 [@@no_coeffects] (* rejected *)
695+
^^^^^^^^^^^^
696+
Warning 53 [misplaced-attribute]: the "no_coeffects" attribute cannot appear in this context
697+
File "w53.ml", line 409, characters 22-34:
698+
409 | external y : (int [@no_coeffects]) -> (int [@no_coeffects]) = "x" "y" (* rejected *)
699+
^^^^^^^^^^^^
700+
Warning 53 [misplaced-attribute]: the "no_coeffects" attribute cannot appear in this context
701+
File "w53.ml", line 409, characters 47-59:
702+
409 | external y : (int [@no_coeffects]) -> (int [@no_coeffects]) = "x" "y" (* rejected *)
703+
^^^^^^^^^^^^
704+
Warning 53 [misplaced-attribute]: the "no_coeffects" attribute cannot appear in this context
705+
File "w53.ml", line 414, characters 21-44:
706+
414 | type 'a t1 = 'a [@@only_generative_effects] (* rejected *)
707+
^^^^^^^^^^^^^^^^^^^^^^^
708+
Warning 53 [misplaced-attribute]: the "only_generative_effects" attribute cannot appear in this context
709+
File "w53.ml", line 415, characters 19-42:
710+
415 | type s1 = Foo1 [@only_generative_effects] (* rejected *)
711+
^^^^^^^^^^^^^^^^^^^^^^^
712+
Warning 53 [misplaced-attribute]: the "only_generative_effects" attribute cannot appear in this context
713+
File "w53.ml", line 416, characters 17-40:
714+
416 | val x : int [@@only_generative_effects] (* rejected *)
715+
^^^^^^^^^^^^^^^^^^^^^^^
716+
Warning 53 [misplaced-attribute]: the "only_generative_effects" attribute cannot appear in this context
717+
File "w53.ml", line 418, characters 22-45:
718+
418 | external y : (int [@only_generative_effects]) -> (int [@only_generative_effects]) = "x" "y" (* rejected *)
719+
^^^^^^^^^^^^^^^^^^^^^^^
720+
Warning 53 [misplaced-attribute]: the "only_generative_effects" attribute cannot appear in this context
721+
File "w53.ml", line 418, characters 58-81:
722+
418 | external y : (int [@only_generative_effects]) -> (int [@only_generative_effects]) = "x" "y" (* rejected *)
723+
^^^^^^^^^^^^^^^^^^^^^^^
724+
Warning 53 [misplaced-attribute]: the "only_generative_effects" attribute cannot appear in this context
725+
File "w53.ml", line 423, characters 21-44:
726+
423 | type 'a t1 = 'a [@@only_generative_effects] (* rejected *)
727+
^^^^^^^^^^^^^^^^^^^^^^^
728+
Warning 53 [misplaced-attribute]: the "only_generative_effects" attribute cannot appear in this context
729+
File "w53.ml", line 424, characters 19-42:
730+
424 | type s1 = Foo1 [@only_generative_effects] (* rejected *)
731+
^^^^^^^^^^^^^^^^^^^^^^^
732+
Warning 53 [misplaced-attribute]: the "only_generative_effects" attribute cannot appear in this context
733+
File "w53.ml", line 425, characters 22-45:
734+
425 | let x : int = 42 [@@only_generative_effects] (* rejected *)
735+
^^^^^^^^^^^^^^^^^^^^^^^
736+
Warning 53 [misplaced-attribute]: the "only_generative_effects" attribute cannot appear in this context
737+
File "w53.ml", line 427, characters 22-45:
738+
427 | external y : (int [@only_generative_effects]) -> (int [@only_generative_effects]) = "x" "y" (* rejected *)
739+
^^^^^^^^^^^^^^^^^^^^^^^
740+
Warning 53 [misplaced-attribute]: the "only_generative_effects" attribute cannot appear in this context
741+
File "w53.ml", line 427, characters 58-81:
742+
427 | external y : (int [@only_generative_effects]) -> (int [@only_generative_effects]) = "x" "y" (* rejected *)
743+
^^^^^^^^^^^^^^^^^^^^^^^
744+
Warning 53 [misplaced-attribute]: the "only_generative_effects" attribute cannot appear in this context

ocaml/testsuite/tests/warnings/w53.ml

+72
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,75 @@ module TestNewtypeAttr = struct
355355

356356
let f2 = fun [@boxed] (type a) (x : a) -> x (* rejected *)
357357
end
358+
359+
module type TestBuiltinSig = sig
360+
type 'a t1 = 'a [@@builtin] (* rejected *)
361+
type s1 = Foo1 [@builtin] (* rejected *)
362+
val x : int [@@builtin] (* rejected *)
363+
364+
external y : (int [@builtin]) -> (int [@builtin]) = "x" "y" (* rejected *)
365+
external z : int -> int = "x" "y" [@@builtin] (* accepted *)
366+
end
367+
368+
module TestBuiltinStruct = struct
369+
type 'a t1 = 'a [@@builtin] (* rejected *)
370+
type s1 = Foo1 [@builtin] (* rejected *)
371+
let x : int = 42 [@@builtin] (* rejected *)
372+
373+
external y : (int [@builtin]) -> (int [@builtin]) = "x" "y" (* rejected *)
374+
external z : int -> int = "x" "y" [@@builtin] (* accepted *)
375+
end
376+
377+
module type TestNoEffectsSig = sig
378+
type 'a t1 = 'a [@@no_effects] (* rejected *)
379+
type s1 = Foo1 [@no_effects] (* rejected *)
380+
val x : int [@@no_effects] (* rejected *)
381+
382+
external y : (int [@no_effects]) -> (int [@no_effects]) = "x" "y" (* rejected *)
383+
external z : int -> int = "x" "y" [@@no_effects] (* accepted *)
384+
end
385+
386+
module TestNoEffectsStruct = struct
387+
type 'a t1 = 'a [@@no_effects] (* rejected *)
388+
type s1 = Foo1 [@no_effects] (* rejected *)
389+
let x : int = 42 [@@no_effects] (* rejected *)
390+
391+
external y : (int [@no_effects]) -> (int [@no_effects]) = "x" "y" (* rejected *)
392+
external z : int -> int = "x" "y" [@@no_effects] (* accepted *)
393+
end
394+
395+
module type TestNoCoeffectsSig = sig
396+
type 'a t1 = 'a [@@no_coeffects] (* rejected *)
397+
type s1 = Foo1 [@no_coeffects] (* rejected *)
398+
val x : int [@@no_coeffects] (* rejected *)
399+
400+
external y : (int [@no_coeffects]) -> (int [@no_coeffects]) = "x" "y" (* rejected *)
401+
external z : int -> int = "x" "y" [@@no_coeffects] (* accepted *)
402+
end
403+
404+
module TestNoCoeffectsStruct = struct
405+
type 'a t1 = 'a [@@no_coeffects] (* rejected *)
406+
type s1 = Foo1 [@no_coeffects] (* rejected *)
407+
let x : int = 42 [@@no_coeffects] (* rejected *)
408+
409+
external y : (int [@no_coeffects]) -> (int [@no_coeffects]) = "x" "y" (* rejected *)
410+
external z : int -> int = "x" "y" [@@no_coeffects] (* accepted *)
411+
end
412+
413+
module type TestOnlyGenerativeEffectsSig = sig
414+
type 'a t1 = 'a [@@only_generative_effects] (* rejected *)
415+
type s1 = Foo1 [@only_generative_effects] (* rejected *)
416+
val x : int [@@only_generative_effects] (* rejected *)
417+
418+
external y : (int [@only_generative_effects]) -> (int [@only_generative_effects]) = "x" "y" (* rejected *)
419+
external z : int -> int = "x" "y" [@@only_generative_effects] (* accepted *)
420+
end
421+
422+
module TestOnlyGenerativeEffectsStruct = struct
423+
type 'a t1 = 'a [@@only_generative_effects] (* rejected *)
424+
type s1 = Foo1 [@only_generative_effects] (* rejected *)
425+
let x : int = 42 [@@only_generative_effects] (* rejected *)
426+
427+
external y : (int [@only_generative_effects]) -> (int [@only_generative_effects]) = "x" "y" (* rejected *)
428+
external z : int -> int = "x" "y" [@@only_generative_effects] (* accepted *)
429+
end

0 commit comments

Comments
 (0)