poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[COMMITTED] pkl: make computed field setters and getters optional


From: Jose E. Marchesi
Subject: [COMMITTED] pkl: make computed field setters and getters optional
Date: Sun, 22 Jan 2023 20:27:13 +0100
User-agent: Gnus/5.13 (Gnus v5.13)


2023-01-22  Jose E. Marchesi  <jemarch@gnu.org>

        * libpoke/pkl-ast.h: Prototype for pkl_asm_struct_type_method_p.
        Prototype for pkl_asm_get_struct_type_field.
        * libpoke/pkl-ast.c (pkl_asm_get_struct_type_method): New
        function.
        (pkl_asm_get_struct_type_field): Likewise.
        * libpoke/pkl-anal.c (pkl_anal2_ps_struct_ref): New handler.
        (pkl_anal2_ps_ass_stmt): Likewise.
        (pkl_phase_anal2): Register handlers.
        * libpoke/pkl-typify.c (pkl_typify1_ps_type_struct): Do no force
        to define getter and setter methods for computer fields.
        * libpoke/pkl-gen.c (pkl_gen_ps_struct_ref): Raise an exception
        when referring to a computed field with no getter.
        (pkl_gen_pr_ass_stmt): Likewise for the setter.
        * testsuite/poke.pkl/sref-diag-3.pk: New test.
        * testsuite/poke.pkl/computed-19.pk: Likewise.
        * testsuite/poke.pkl/computed-diag-5.pk: Remove.
        * testsuite/poke.pkl/computed-diag-6.pk: Likewise.
        * testsuite/poke.pkl/computed-diag-7.pk: Likewise.
        * testsuite/poke.pkl/ass-diag-10.pk: Likewise.
---
 ChangeLog                             | 22 +++++++
 libpoke/pkl-anal.c                    | 82 ++++++++++++++++++++++++++-
 libpoke/pkl-ast.c                     | 49 ++++++++++++++++
 libpoke/pkl-ast.h                     | 14 +++++
 libpoke/pkl-gen.c                     | 57 ++++++++++++++-----
 libpoke/pkl-typify.c                  | 26 +--------
 testsuite/Makefile.am                 |  6 +-
 testsuite/poke.pkl/ass-diag-10.pk     |  6 ++
 testsuite/poke.pkl/computed-19.pk     | 12 ++++
 testsuite/poke.pkl/computed-diag-5.pk | 11 ----
 testsuite/poke.pkl/computed-diag-6.pk | 11 ----
 testsuite/poke.pkl/computed-diag-7.pk | 14 -----
 testsuite/poke.pkl/sref-diag-3.pk     |  5 ++
 13 files changed, 236 insertions(+), 79 deletions(-)
 create mode 100644 testsuite/poke.pkl/ass-diag-10.pk
 create mode 100644 testsuite/poke.pkl/computed-19.pk
 delete mode 100644 testsuite/poke.pkl/computed-diag-5.pk
 delete mode 100644 testsuite/poke.pkl/computed-diag-6.pk
 delete mode 100644 testsuite/poke.pkl/computed-diag-7.pk
 create mode 100644 testsuite/poke.pkl/sref-diag-3.pk

diff --git a/ChangeLog b/ChangeLog
index 58f0df2c..f92e3797 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2023-01-22  Jose E. Marchesi  <jemarch@gnu.org>
+
+       * libpoke/pkl-ast.h: Prototype for pkl_asm_struct_type_method_p.
+       Prototype for pkl_asm_get_struct_type_field.
+       * libpoke/pkl-ast.c (pkl_asm_get_struct_type_method): New
+       function.
+       (pkl_asm_get_struct_type_field): Likewise.
+       * libpoke/pkl-anal.c (pkl_anal2_ps_struct_ref): New handler.
+       (pkl_anal2_ps_ass_stmt): Likewise.
+       (pkl_phase_anal2): Register handlers.
+       * libpoke/pkl-typify.c (pkl_typify1_ps_type_struct): Do no force
+       to define getter and setter methods for computer fields.
+       * libpoke/pkl-gen.c (pkl_gen_ps_struct_ref): Raise an exception
+       when referring to a computed field with no getter.
+       (pkl_gen_pr_ass_stmt): Likewise for the setter.
+       * testsuite/poke.pkl/sref-diag-3.pk: New test.
+       * testsuite/poke.pkl/computed-19.pk: Likewise.
+       * testsuite/poke.pkl/computed-diag-5.pk: Remove.
+       * testsuite/poke.pkl/computed-diag-6.pk: Likewise.
+       * testsuite/poke.pkl/computed-diag-7.pk: Likewise.
+       * testsuite/poke.pkl/ass-diag-10.pk: Likewise.
+
 2023-01-22  Jose E. Marchesi  <jemarch@gnu.org>
 
        * testsuite/poke.pkl/acons-20.pk: New test.
diff --git a/libpoke/pkl-anal.c b/libpoke/pkl-anal.c
index 80f0eebe..dac71b31 100644
--- a/libpoke/pkl-anal.c
+++ b/libpoke/pkl-anal.c
@@ -607,7 +607,10 @@ PKL_PHASE_BEGIN_HANDLER (pkl_anal1_ps_var)
 PKL_PHASE_END_HANDLER
 
 /* It is an error to set a struct field as a variable if we are not in
-   a method.  */
+   a method.
+
+   Assigning to a computed fild that lacks a setter is a compile-time
+   error.  */
 
 PKL_PHASE_BEGIN_HANDLER (pkl_anal1_ps_ass_stmt)
 {
@@ -1030,6 +1033,81 @@ PKL_PHASE_BEGIN_HANDLER (pkl_anal2_ps_asm_exp)
 }
 PKL_PHASE_END_HANDLER
 
+/* Referring to a computed field that lacks a getter is a compile-time
+   error.  */
+
+PKL_PHASE_BEGIN_HANDLER (pkl_anal2_ps_struct_ref)
+{
+  pkl_ast_node struct_ref = PKL_PASS_NODE;
+  pkl_ast_node struct_ref_identifier = PKL_AST_STRUCT_REF_IDENTIFIER 
(struct_ref);
+  const char *struct_ref_identifier_str = PKL_AST_IDENTIFIER_POINTER 
(struct_ref_identifier);
+  pkl_ast_node struct_ref_struct = PKL_AST_STRUCT_REF_STRUCT (struct_ref);
+  pkl_ast_node struct_type = PKL_AST_TYPE (struct_ref_struct);
+  pkl_ast_node field = pkl_ast_get_struct_type_field (struct_type,
+                                                      
struct_ref_identifier_str);
+
+  if (PKL_PASS_PARENT
+      && PKL_AST_CODE (PKL_PASS_PARENT) != PKL_AST_ASS_STMT
+      && field
+      && PKL_AST_STRUCT_TYPE_FIELD_COMPUTED_P (field))
+    {
+      char *getter = pk_str_concat ("get_", struct_ref_identifier_str, NULL);
+
+      if (!pkl_ast_get_struct_type_method (struct_type, getter))
+        {
+          char *struct_type_str = pkl_type_str (struct_type, 1);
+
+          PKL_ERROR (PKL_AST_LOC (struct_ref_identifier),
+                     "method %s for computed field in struct type %s is not 
defined",
+                     getter, struct_type_str);
+          free (struct_type_str);
+          PKL_ANAL_PAYLOAD->errors ++;
+          PKL_PASS_ERROR;
+        }
+
+      free (getter);
+    }
+}
+PKL_PHASE_END_HANDLER
+
+/* Assigning to a computed fild that lacks a setter is a compile-time
+   error.  */
+
+PKL_PHASE_BEGIN_HANDLER (pkl_anal2_ps_ass_stmt)
+{
+  pkl_ast_node ass_stmt = PKL_PASS_NODE;
+  pkl_ast_node ass_stmt_lvalue = PKL_AST_ASS_STMT_LVALUE (ass_stmt);
+
+  if (PKL_AST_CODE (ass_stmt_lvalue) == PKL_AST_STRUCT_REF)
+    {
+      pkl_ast_node sct = PKL_AST_STRUCT_REF_STRUCT (ass_stmt_lvalue);
+      pkl_ast_node struct_type = PKL_AST_TYPE (sct);
+      pkl_ast_node field_name = PKL_AST_STRUCT_REF_IDENTIFIER 
(ass_stmt_lvalue);
+      const char *field_name_str = PKL_AST_IDENTIFIER_POINTER (field_name);
+      pkl_ast_node field = pkl_ast_get_struct_type_field (struct_type, 
field_name_str);
+
+      if (field
+          && PKL_AST_STRUCT_TYPE_FIELD_COMPUTED_P (field))
+        {
+          char *setter = pk_str_concat ("set_", field_name_str, NULL);
+
+          if (!pkl_ast_get_struct_type_method (struct_type, setter))
+            {
+              char *struct_type_str = pkl_type_str (struct_type, 1);
+
+              PKL_ERROR (PKL_AST_LOC (field_name),
+                         "method %s for computed field in struct type %s is 
not defined",
+                         setter, struct_type_str);
+              free (struct_type_str);
+              PKL_ANAL_PAYLOAD->errors ++;
+              PKL_PASS_ERROR;
+            }
+
+          free (setter);
+        }
+    }
+}
+PKL_PHASE_END_HANDLER
 
 struct pkl_phase pkl_phase_anal2 =
   {
@@ -1045,6 +1123,8 @@ struct pkl_phase pkl_phase_anal2 =
    PKL_PHASE_PS_HANDLER (PKL_AST_STRUCT_TYPE_FIELD, 
pkl_anal2_ps_struct_type_field),
    PKL_PHASE_PS_HANDLER (PKL_AST_ASM_STMT, pkl_anal2_ps_asm_stmt),
    PKL_PHASE_PS_HANDLER (PKL_AST_ASM_EXP, pkl_anal2_ps_asm_exp),
+   PKL_PHASE_PS_HANDLER (PKL_AST_STRUCT_REF, pkl_anal2_ps_struct_ref),
+   PKL_PHASE_PS_HANDLER (PKL_AST_ASS_STMT, pkl_anal2_ps_ass_stmt),
    PKL_PHASE_PS_TYPE_HANDLER (PKL_TYPE_STRUCT, pkl_anal2_ps_type_struct),
   };
 
diff --git a/libpoke/pkl-ast.c b/libpoke/pkl-ast.c
index 7956c96e..e93eb6cd 100644
--- a/libpoke/pkl-ast.c
+++ b/libpoke/pkl-ast.c
@@ -2783,6 +2783,55 @@ pkl_ast_reverse (pkl_ast_node ast)
   return prev;
 }
 
+pkl_ast_node
+pkl_ast_get_struct_type_field (pkl_ast_node struct_type,
+                               const char *field_name)
+{
+  pkl_ast_node field = PKL_AST_TYPE_S_ELEMS (struct_type);
+
+  for (field = PKL_AST_TYPE_S_ELEMS (struct_type);
+       field;
+       field = PKL_AST_CHAIN (field))
+    {
+      if (PKL_AST_CODE (field) == PKL_AST_STRUCT_TYPE_FIELD)
+        {
+          pkl_ast_node fname = PKL_AST_STRUCT_TYPE_FIELD_NAME (field);
+
+          if (fname && STREQ (PKL_AST_IDENTIFIER_POINTER (fname),
+                              field_name))
+            return field;
+        }
+    }
+
+  return NULL;
+
+}
+
+pkl_ast_node
+pkl_ast_get_struct_type_method (pkl_ast_node struct_type,
+                                const char *method_name)
+{
+  pkl_ast_node decl = PKL_AST_TYPE_S_ELEMS (struct_type);
+
+  for (decl = PKL_AST_TYPE_S_ELEMS (struct_type);
+       decl;
+       decl = PKL_AST_CHAIN (decl))
+    {
+      if (PKL_AST_CODE (decl) == PKL_AST_DECL
+          && PKL_AST_FUNC_METHOD_P (PKL_AST_DECL_INITIAL (decl)))
+        {
+          pkl_ast_node decl_name = PKL_AST_DECL_NAME (decl);
+
+          if (decl_name
+              && STREQ (PKL_AST_IDENTIFIER_POINTER (decl_name),
+                        method_name))
+            return decl;
+        }
+    }
+
+  return NULL;
+}
+
 pkl_ast_node
 pkl_ast_type_incr_step (pkl_ast ast, pkl_ast_node type)
 {
diff --git a/libpoke/pkl-ast.h b/libpoke/pkl-ast.h
index 1f27e738..b1d12638 100644
--- a/libpoke/pkl-ast.h
+++ b/libpoke/pkl-ast.h
@@ -1087,6 +1087,20 @@ pkl_ast_node pkl_type_integral_promote (pkl_ast ast,
                                         pkl_ast_node type1,
                                         pkl_ast_node type2);
 
+/* Return the PKL_AST_STRUCT_TYPE_FIELD with the given FIELD_NAME in
+   the given STRUCT_TYPE.  If no such a field exists in the struct
+   type, return NULL.  */
+
+pkl_ast_node pkl_ast_get_struct_type_field (pkl_ast_node struct_type,
+                                            const char *field_name);
+
+/* Return the PKL_AST_DECL node node corresponding to the method named
+   METHOD_NAME in the given STRUCT_TYPE.  If no such method exists
+   then return NULL.  */
+
+pkl_ast_node pkl_ast_get_struct_type_method (pkl_ast_node struct_type,
+                                             const char *method_name);
+
 /* Return an expression that evaluates to an increment step for the
    given TYPE.  If the provided type doesn't support the notion of
    increment step this function returns NULL.  */
diff --git a/libpoke/pkl-gen.c b/libpoke/pkl-gen.c
index 8ea8bd18..bbdfd7d2 100644
--- a/libpoke/pkl-gen.c
+++ b/libpoke/pkl-gen.c
@@ -1013,6 +1013,9 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_ass_stmt)
       }
     case PKL_AST_STRUCT_REF:
       {
+        pkl_ast_node sct = PKL_AST_STRUCT_REF_STRUCT (lvalue);
+        pkl_ast_node struct_type = PKL_AST_TYPE (sct);
+
         if (assigning_computed_field_p)
           {
             /* Assigning to a computed field.
@@ -1027,14 +1030,27 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_ass_stmt)
             char *setter = pk_str_concat ("set_",
                                           computed_field_name,
                                           NULL);
+            pkl_ast_node setter_decl
+              = pkl_ast_get_struct_type_method (struct_type, setter);
 
-            pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP); /* VAL SCT */
-            pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
-                          pvm_make_string (setter));   /* VAL SCT SETTER_NAME 
*/
-            pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_SREFMNT);
-            pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NIP);   /* VAL SCT CLS */
-            pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_CALL);  /* NULL */
-            pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP);  /* _ */
+            if (setter_decl)
+              {
+                pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP); /* VAL SCT */
+                pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
+                              pvm_make_string (setter));   /* VAL SCT 
SETTER_NAME */
+                pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_SREFMNT);
+                pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NIP);   /* VAL SCT CLS */
+                pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_CALL);  /* NULL */
+                pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP);  /* _ */
+              }
+            else
+              {
+                /* No setter defined for this computer field.  */
+                pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
+                              pvm_make_exception (PVM_E_ELEM, PVM_E_ELEM_NAME,
+                                                  PVM_E_ELEM_ESTATUS, NULL, 
NULL));
+                pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_RAISE);
+              }
 
             free (setter);
           }
@@ -1043,8 +1059,6 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_ass_stmt)
             /* Assigning to a regular struct field.  */
             /* Stack: VAL SCT ID */
 
-            pkl_ast_node sct = PKL_AST_INDEXER_ENTITY (lvalue);
-            pkl_ast_node struct_type = PKL_AST_TYPE (sct);
             pvm_program_label label1 = pkl_asm_fresh_label (PKL_GEN_ASM);
             pvm_program_label label2 = pkl_asm_fresh_label (PKL_GEN_ASM);
 
@@ -2888,13 +2902,26 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_struct_ref)
           char *getter = pk_str_concat ("get_",
                                         PKL_AST_IDENTIFIER_POINTER 
(computed_field_name),
                                         NULL);
+          pkl_ast_node getter_decl
+            = pkl_ast_get_struct_type_method (struct_ref_struct_type, getter);
 
-          pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP);  /* STRUCT */
-          pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
-                        pvm_make_string (getter));   /* STRUCT GETTER_NAME */
-          pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_SREFMNT); /* STRUCT GETTER_NAME 
CLS */
-          pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NIP);  /* STRUCT CLS */
-          pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_CALL); /* VAL */
+          if (getter_decl)
+            {
+              pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP);  /* STRUCT */
+              pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
+                            pvm_make_string (getter));   /* STRUCT GETTER_NAME 
*/
+              pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_SREFMNT); /* STRUCT 
GETTER_NAME CLS */
+              pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NIP);  /* STRUCT CLS */
+              pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_CALL); /* VAL */
+            }
+          else
+            {
+              /* No getter defined for this computer field.  */
+              pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
+                            pvm_make_exception (PVM_E_ELEM, PVM_E_ELEM_NAME,
+                                                PVM_E_ELEM_ESTATUS, NULL, 
NULL));
+              pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_RAISE);
+            }
 
           free (getter);
         }
diff --git a/libpoke/pkl-typify.c b/libpoke/pkl-typify.c
index a33efe90..e4173386 100644
--- a/libpoke/pkl-typify.c
+++ b/libpoke/pkl-typify.c
@@ -1722,8 +1722,8 @@ PKL_PHASE_END_HANDLER
    Labels are not allowed in integral structs or unions, pinned structs and
    unions.  Optional fields are not allowed in integral structs or unions.
 
-   Computed fields should have getter and setter methods defined for
-   them, and they should handle values of the right type.  */
+   If computed fields have getter and setter methods defined for them,
+   they should handle values of the right type.  */
 
 PKL_PHASE_BEGIN_HANDLER (pkl_typify1_ps_type_struct)
 {
@@ -1878,7 +1878,6 @@ PKL_PHASE_BEGIN_HANDLER (pkl_typify1_ps_type_struct)
              signature (TYPE)void.  */
 
           pkl_ast_node decl;
-          int found_setter_p = 0, found_getter_p = 0;
           char *getter_name, *setter_name;
 
           pkl_ast_node field_name = PKL_AST_STRUCT_TYPE_FIELD_NAME (field);
@@ -1929,8 +1928,6 @@ PKL_PHASE_BEGIN_HANDLER (pkl_typify1_ps_type_struct)
                           PKL_TYPIFY_PAYLOAD->errors++;
                           PKL_PASS_ERROR;
                         }
-
-                      found_getter_p = 1;
                     }
 
                   if (STREQ (PKL_AST_IDENTIFIER_POINTER (method_name),
@@ -1960,29 +1957,10 @@ PKL_PHASE_BEGIN_HANDLER (pkl_typify1_ps_type_struct)
                           PKL_TYPIFY_PAYLOAD->errors++;
                           PKL_PASS_ERROR;
                         }
-
-                      found_setter_p = 1;
                     }
                 }
             }
 
-          if (!found_getter_p)
-            {
-              PKL_ERROR (PKL_AST_LOC (field),
-                         "computed field requires a getter method");
-              PKL_TYPIFY_PAYLOAD->errors++;
-            }
-
-          if (!found_setter_p)
-            {
-              PKL_ERROR (PKL_AST_LOC (field),
-                         "computed field requires a setter method");
-              PKL_TYPIFY_PAYLOAD->errors++;
-            }
-
-          if (!found_getter_p || !found_setter_p)
-            PKL_PASS_ERROR;
-
           free (getter_name);
           free (setter_name);
         }
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index f32046cd..813a1e35 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -876,6 +876,7 @@ EXTRA_DIST = \
   poke.pkl/ass-diag-7.pk \
   poke.pkl/ass-diag-8.pk \
   poke.pkl/ass-diag-9.pk \
+  poke.pkl/ass-diag-10.pk \
   poke.pkl/ass-function-1.pk \
   poke.pkl/ass-offset-1.pk \
   poke.pkl/ass-struct-int-1.pk \
@@ -1148,9 +1149,6 @@ EXTRA_DIST = \
   poke.pkl/computed-diag-2.pk \
   poke.pkl/computed-diag-3.pk \
   poke.pkl/computed-diag-4.pk \
-  poke.pkl/computed-diag-5.pk \
-  poke.pkl/computed-diag-6.pk \
-  poke.pkl/computed-diag-7.pk \
   poke.pkl/computed-diag-8.pk \
   poke.pkl/computed-diag-9.pk \
   poke.pkl/computed-diag-10.pk \
@@ -1176,6 +1174,7 @@ EXTRA_DIST = \
   poke.pkl/computed-16.pk \
   poke.pkl/computed-17.pk \
   poke.pkl/computed-18.pk \
+  poke.pkl/computed-19.pk \
   poke.pkl/cond-exp-diag-1.pk \
   poke.pkl/cond-exp-diag-2.pk \
   poke.pkl/cond-exp-diag-3.pk \
@@ -2358,6 +2357,7 @@ EXTRA_DIST = \
   poke.pkl/sref-5.pk \
   poke.pkl/sref-diag-1.pk \
   poke.pkl/sref-diag-2.pk \
+  poke.pkl/sref-diag-3.pk \
   poke.pkl/string-diag-1.pk \
   poke.pkl/string-diag-2.pk \
   poke.pkl/string-multiline-1.pk \
diff --git a/testsuite/poke.pkl/ass-diag-10.pk 
b/testsuite/poke.pkl/ass-diag-10.pk
new file mode 100644
index 00000000..5ce1de42
--- /dev/null
+++ b/testsuite/poke.pkl/ass-diag-10.pk
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+
+type Foo = struct { computed int i; };
+
+var f = Foo {};
+f.i = 10; /* { dg-error "set_i.*not defined" } */
diff --git a/testsuite/poke.pkl/computed-19.pk 
b/testsuite/poke.pkl/computed-19.pk
new file mode 100644
index 00000000..d15d844e
--- /dev/null
+++ b/testsuite/poke.pkl/computed-19.pk
@@ -0,0 +1,12 @@
+/* { dg-do run } */
+
+type Foo =
+  struct
+  {
+    int j;
+    computed int i;
+    method get_i = int: { return j + 1; }
+  };
+
+/* { dg-command {Foo{ j = 3 }.i} } */
+/* { dg-output "4" } */
diff --git a/testsuite/poke.pkl/computed-diag-5.pk 
b/testsuite/poke.pkl/computed-diag-5.pk
deleted file mode 100644
index b214358c..00000000
--- a/testsuite/poke.pkl/computed-diag-5.pk
+++ /dev/null
@@ -1,11 +0,0 @@
-/* { dg-do compile } */
-
-type Foo =
-  struct
-  {
-    int i;
-    computed string blah; /* { dg-error "getter" } */
-    int j;
-
-    method set_blah = (string s) void: { }
-  };
diff --git a/testsuite/poke.pkl/computed-diag-6.pk 
b/testsuite/poke.pkl/computed-diag-6.pk
deleted file mode 100644
index d4d1f774..00000000
--- a/testsuite/poke.pkl/computed-diag-6.pk
+++ /dev/null
@@ -1,11 +0,0 @@
-/* { dg-do compile } */
-
-type Foo =
-  struct
-  {
-    int i;
-    computed string blah; /* { dg-error "setter" } */
-    int j;
-
-    method get_blah = string: { }
-  };
diff --git a/testsuite/poke.pkl/computed-diag-7.pk 
b/testsuite/poke.pkl/computed-diag-7.pk
deleted file mode 100644
index 9d6abaf5..00000000
--- a/testsuite/poke.pkl/computed-diag-7.pk
+++ /dev/null
@@ -1,14 +0,0 @@
-/* { dg-do compile } */
-
-/* Functions are no methods.  */
-
-type Foo =
-  struct
-  {
-    int i;
-    computed string blah; /* { dg-error "setter" } */
-    int j;
-
-    method get_blah = string: { }
-    fun set_blah = (string s) void: { }
-  };
diff --git a/testsuite/poke.pkl/sref-diag-3.pk 
b/testsuite/poke.pkl/sref-diag-3.pk
new file mode 100644
index 00000000..6bd05dbf
--- /dev/null
+++ b/testsuite/poke.pkl/sref-diag-3.pk
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+type Foo = struct { computed int i; };
+
+Foo{}.i; /* { dg-error "get_i.*not defined" } */
-- 
2.30.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]