diff options
author | Gaius Mulley <gaiusmod2@gmail.com> | 2023-09-14 21:00:45 +0100 |
---|---|---|
committer | Gaius Mulley <gaiusmod2@gmail.com> | 2023-09-14 21:00:45 +0100 |
commit | d8b4d6c9de8324dfa56933c2bc95694254cb736d (patch) | |
tree | 0159cd099aba72c931eb832baa0bb932a1c6cf32 /gcc | |
parent | fd948fd846c7de29150872e43b63bf9128da5b8f (diff) | |
download | gcc-d8b4d6c9de8324dfa56933c2bc95694254cb736d.zip gcc-d8b4d6c9de8324dfa56933c2bc95694254cb736d.tar.gz gcc-d8b4d6c9de8324dfa56933c2bc95694254cb736d.tar.bz2 |
modula2: Add missing comments to M2CaseList.mod and add testcases
This patch adds procedure block comments to M2CaseList.mod, changes
date values to use unique digits and add a new test case.
gcc/m2/ChangeLog:
* gm2-compiler/M2CaseList.mod (NewRanges): Add block
comment.
(NewSet): Add block comment.
(DisplayRanges): Add block comment.
(IncludeElement): Add block comment.
(IncludeElements): Add block comment.
(appendString): Add block comment.
(appendEnum): Add block comment.
(appendTree): Add block comment.
(SubrangeErrors): Add block comment.
gcc/testsuite/ChangeLog:
* gm2/switches/case/fail/subrangecase.mod: Replace 19
with 17.
* gm2/switches/case/fail/subrangecase2.mod: Ditto.
* gm2/switches/case/fail/subrangecase3.mod: Ditto.
* gm2/switches/case/fail/subrangecase4.mod: Ditto.
* gm2/switches/case/pass/subrangecase.mod: Ditto.
* gm2/switches/case/pass/subrangecase2.mod: Ditto.
* gm2/switches/case/pass/subrangecase3.mod: Ditto.
* gm2/switches/case/pass/subrangecase4.mod: Ditto.
* gm2/switches/case/fail/calendar.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc')
10 files changed, 58 insertions, 32 deletions
diff --git a/gcc/m2/gm2-compiler/M2CaseList.mod b/gcc/m2/gm2-compiler/M2CaseList.mod index 910fcc6..b7155e3 100644 --- a/gcc/m2/gm2-compiler/M2CaseList.mod +++ b/gcc/m2/gm2-compiler/M2CaseList.mod @@ -511,7 +511,7 @@ END OverlappingCaseBounds ; (* - NewRanges - + NewRanges - return a new range from the freelist or heap. *) PROCEDURE NewRanges () : SetRange ; @@ -531,7 +531,8 @@ END NewRanges ; (* - NewSet - + NewSet - returns a new set based on type with the low and high fields assigned + to the min and max values for the type. *) PROCEDURE NewSet (type: CARDINAL) : SetRange ; @@ -549,7 +550,7 @@ END NewSet ; (* - DisposeRanges - + DisposeRanges - place set and its list onto the free list. *) PROCEDURE DisposeRanges (set: SetRange) : SetRange ; @@ -737,7 +738,7 @@ VAR (* - IncludeElement - + IncludeElement - only include enumeration field into errorString if it lies between low..high. *) PROCEDURE IncludeElement (enumList: List; field: CARDINAL; low, high: Tree) ; @@ -756,7 +757,7 @@ END IncludeElement ; (* - IncludeElements - + IncludeElements - only include enumeration field values low..high in errorString. *) PROCEDURE IncludeElements (type: CARDINAL; enumList: List; low, high: Tree) ; @@ -776,7 +777,7 @@ END IncludeElements ; (* - ErrorRangeEnum + ErrorRangeEnum - include enumeration fields Low to High in errorString. *) PROCEDURE ErrorRangeEnum (type: CARDINAL; set: SetRange; enumList: List) ; @@ -824,7 +825,7 @@ END ErrorRanges ; (* - appendString - + appendString - appends str to errorString. *) PROCEDURE appendString (str: String) ; @@ -834,7 +835,7 @@ END appendString ; (* - appendEnum - + appendEnum - appends enum to errorString. *) PROCEDURE appendEnum (enum: CARDINAL) ; @@ -844,7 +845,7 @@ END appendEnum ; (* - appendStr - + appendStr - appends str to errorString. *) PROCEDURE appendStr (str: ARRAY OF CHAR) ; @@ -953,7 +954,8 @@ END isPrintableChar ; (* - appendTree - + appendTree - append tree value to the errorString. It attempts to pretty print + CHAR constants and will fall back to CHR (x) if necessary. *) PROCEDURE appendTree (value: Tree; type: CARDINAL) ; @@ -984,7 +986,7 @@ END appendTree ; (* - SubrangeErrors - + SubrangeErrors - create an errorString containing all set ranges. *) PROCEDURE SubrangeErrors (subrangetype: CARDINAL; set: SetRange) ; diff --git a/gcc/testsuite/gm2/switches/case/fail/calendar.mod b/gcc/testsuite/gm2/switches/case/fail/calendar.mod new file mode 100644 index 0000000..501cb2b --- /dev/null +++ b/gcc/testsuite/gm2/switches/case/fail/calendar.mod @@ -0,0 +1,24 @@ +MODULE calendar ; + + +TYPE + DayRange = [1..30] ; + + +PROCEDURE sept1752 (day: DayRange) : BOOLEAN ; +BEGIN + CASE day OF + + 1..2, + 14..30: RETURN TRUE + + END ; + RETURN FALSE +END sept1752 ; + + +BEGIN + IF sept1752 (4) + THEN + END +END calendar. diff --git a/gcc/testsuite/gm2/switches/case/fail/subrangecase.mod b/gcc/testsuite/gm2/switches/case/fail/subrangecase.mod index 2c3b56e..577dccb 100644 --- a/gcc/testsuite/gm2/switches/case/fail/subrangecase.mod +++ b/gcc/testsuite/gm2/switches/case/fail/subrangecase.mod @@ -2,16 +2,16 @@ MODULE subrangecase ; (*!m2iso+gm2*) TYPE - DateRange = [1910..1920] ; + DateRange = [1710..1720] ; PROCEDURE init (d: DateRange) ; BEGIN CASE d OF - (* 1910: | *) - 1911..1919: | - 1920: | + (* 1710: | *) + 1711..1719: | + 1720: | END END init ; diff --git a/gcc/testsuite/gm2/switches/case/fail/subrangecase2.mod b/gcc/testsuite/gm2/switches/case/fail/subrangecase2.mod index d0e3a3a..6361770 100644 --- a/gcc/testsuite/gm2/switches/case/fail/subrangecase2.mod +++ b/gcc/testsuite/gm2/switches/case/fail/subrangecase2.mod @@ -2,14 +2,14 @@ MODULE subrangecase2 ; (*!m2iso+gm2*) TYPE - DateRange = [1910..1920] ; + DateRange = [1710..1720] ; PROCEDURE init (d: DateRange) ; BEGIN CASE d OF - 1911..1920: | + 1711..1720: | END END init ; diff --git a/gcc/testsuite/gm2/switches/case/fail/subrangecase3.mod b/gcc/testsuite/gm2/switches/case/fail/subrangecase3.mod index 5a34c0b..8b123f6 100644 --- a/gcc/testsuite/gm2/switches/case/fail/subrangecase3.mod +++ b/gcc/testsuite/gm2/switches/case/fail/subrangecase3.mod @@ -2,15 +2,15 @@ MODULE subrangecase3 ; (*!m2iso+gm2*) TYPE - DateRange = [1910..1920] ; + DateRange = [1710..1720] ; PROCEDURE init (d: DateRange) ; BEGIN CASE d OF - 1910: | - 1912..1919: | + 1710: | + 1712..1719: | END END init ; diff --git a/gcc/testsuite/gm2/switches/case/fail/subrangecase4.mod b/gcc/testsuite/gm2/switches/case/fail/subrangecase4.mod index f8c4ae1..390d588 100644 --- a/gcc/testsuite/gm2/switches/case/fail/subrangecase4.mod +++ b/gcc/testsuite/gm2/switches/case/fail/subrangecase4.mod @@ -2,15 +2,15 @@ MODULE subrangecase4 ; (*!m2iso+gm2*) TYPE - DateRange = [1910..1920] ; + DateRange = [1710..1720] ; PROCEDURE init (d: DateRange) ; BEGIN CASE d OF - 1910: | - 1913..1918: | + 1710: | + 1713..1718: | END END init ; diff --git a/gcc/testsuite/gm2/switches/case/pass/subrangecase.mod b/gcc/testsuite/gm2/switches/case/pass/subrangecase.mod index 50bbf6a..a0a8e35 100644 --- a/gcc/testsuite/gm2/switches/case/pass/subrangecase.mod +++ b/gcc/testsuite/gm2/switches/case/pass/subrangecase.mod @@ -2,16 +2,16 @@ MODULE subrangecase ; (*!m2iso+gm2*) TYPE - DateRange = [1910..1920] ; + DateRange = [1710..1720] ; PROCEDURE init (d: DateRange) ; BEGIN CASE d OF - 1910: | - 1911..1919: | - 1920: | + 1710: | + 1711..1719: | + 1720: | END END init ; diff --git a/gcc/testsuite/gm2/switches/case/pass/subrangecase2.mod b/gcc/testsuite/gm2/switches/case/pass/subrangecase2.mod index cd14c0c..b2badc7 100644 --- a/gcc/testsuite/gm2/switches/case/pass/subrangecase2.mod +++ b/gcc/testsuite/gm2/switches/case/pass/subrangecase2.mod @@ -2,14 +2,14 @@ MODULE subrangecase2 ; (*!m2iso+gm2*) TYPE - DateRange = [1910..1920] ; + DateRange = [1710..1720] ; PROCEDURE init (d: DateRange) ; BEGIN CASE d OF - 1910..1920: | + 1710..1720: | END END init ; diff --git a/gcc/testsuite/gm2/switches/case/pass/subrangecase3.mod b/gcc/testsuite/gm2/switches/case/pass/subrangecase3.mod index 2f48373..3e15e7b 100644 --- a/gcc/testsuite/gm2/switches/case/pass/subrangecase3.mod +++ b/gcc/testsuite/gm2/switches/case/pass/subrangecase3.mod @@ -2,14 +2,14 @@ MODULE subrangecase3 ; (*!m2iso+gm2*) TYPE - DateRange = [1910..1920] ; + DateRange = [1710..1720] ; PROCEDURE init (d: DateRange) ; BEGIN CASE d OF - 1910..1919: | + 1710..1719: | ELSE END diff --git a/gcc/testsuite/gm2/switches/case/pass/subrangecase4.mod b/gcc/testsuite/gm2/switches/case/pass/subrangecase4.mod index 8a2a672..50978b9 100644 --- a/gcc/testsuite/gm2/switches/case/pass/subrangecase4.mod +++ b/gcc/testsuite/gm2/switches/case/pass/subrangecase4.mod @@ -2,7 +2,7 @@ MODULE subrangecase4 ; (*!m2iso+gm2*) TYPE - DateRange = [1910..1920] ; + DateRange = [1710..1720] ; PROCEDURE init (d: DateRange) ; |