diff options
author | Gaius Mulley <gaiusmod2@gmail.com> | 2024-01-26 19:04:48 +0000 |
---|---|---|
committer | Gaius Mulley <gaiusmod2@gmail.com> | 2024-01-26 19:04:48 +0000 |
commit | eb619490b01baa2fc2b5ee98d15516c4a2372e74 (patch) | |
tree | 64dc8c96889ed992daf2b2beb9bc6986832fc463 /gcc/testsuite/gm2 | |
parent | c34ab549d88da13ae16edccedd4218807afefb65 (diff) | |
download | gcc-eb619490b01baa2fc2b5ee98d15516c4a2372e74.zip gcc-eb619490b01baa2fc2b5ee98d15516c4a2372e74.tar.gz gcc-eb619490b01baa2fc2b5ee98d15516c4a2372e74.tar.bz2 |
modula2: detect string and pointer formal and actual parameter incompatibility
This patch improves the location accuracy of parameters and fixes bugs
in parameter checking in M2Check. It also corrects the location
of constant declarations.
gcc/m2/ChangeLog:
* gm2-compiler/M2Check.mod (dumpIndice): New procedure.
(dumpIndex): New procedure.
(dumptInfo): New procedure.
(buildError4): Add comment and pass formal and actual to
MetaError4. Improve text describing error.
(buildError2): Generate different error descriptions for
the three error kinds.
(checkConstMeta): Add block comment. Add more meta checks
and call doCheckPair to complete string const checking.
Add tinfo parameter.
(checkConstEquivalence): Add tinfo parameter.
* gm2-compiler/M2GCCDeclare.mod (PrintVerboseFromList):
Print the length of a const string.
* gm2-compiler/M2GenGCC.mod (CodeParam): Remove parameters
op1, op2 and op3.
(doParam): Add paramtok parameter. Use paramtok instead rather
than CurrentQuadToken.
(CodeParam): Rewrite.
* gm2-compiler/M2Quads.mod (CheckProcedureParameters):
Add comments explaining that const strings are not checked
in M2Quads.mod.
(FailParameter): Use MetaErrorT2 with tokpos rather than
MetaError2.
(doBuildBinaryOp): Assign OldPos and OperatorPos before the
IF block.
* gm2-compiler/SymbolTable.mod (PutConstString): Add call to
InitWhereDeclaredTok.
gcc/testsuite/ChangeLog:
* gm2/pim/fail/badpointer4.mod: New test.
* gm2/pim/fail/strconst.def: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc/testsuite/gm2')
-rw-r--r-- | gcc/testsuite/gm2/pim/fail/badpointer4.mod | 20 | ||||
-rw-r--r-- | gcc/testsuite/gm2/pim/fail/strconst.def | 6 |
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/testsuite/gm2/pim/fail/badpointer4.mod b/gcc/testsuite/gm2/pim/fail/badpointer4.mod new file mode 100644 index 0000000..b5fb8ad --- /dev/null +++ b/gcc/testsuite/gm2/pim/fail/badpointer4.mod @@ -0,0 +1,20 @@ +MODULE badpointer4 ; + +FROM DynamicStrings IMPORT String ; +FROM strconst IMPORT Hello ; + + +PROCEDURE testproc (s: String) ; +BEGIN +END testproc ; + + +PROCEDURE foo ; +BEGIN + testproc (Hello) +END foo ; + + +BEGIN + foo +END badpointer4. diff --git a/gcc/testsuite/gm2/pim/fail/strconst.def b/gcc/testsuite/gm2/pim/fail/strconst.def new file mode 100644 index 0000000..867e006 --- /dev/null +++ b/gcc/testsuite/gm2/pim/fail/strconst.def @@ -0,0 +1,6 @@ +DEFINITION MODULE strconst ; + +CONST + Hello = "hello world" ; + +END strconst. |