30f4339635e0 — Leonard Ritter 2 months ago
* fixed `store` not moving when dereferencing arguments
3 files changed, 20 insertions(+), 2 deletions(-)

M genie.lua
M src/prover.cpp
M testing/test_borrowing.sc
M genie.lua +2 -1
@@ 152,6 152,7 @@ project "gensyms"
 
     configuration { "linux" }
         buildoptions_cpp {
+            "-std=c++14",
             "-ferror-limit=1",
         }
 

          
@@ 271,7 272,7 @@ project "scopesrt"
             "-Wno-keyword-macro",
             "-Wno-gnu-redeclared-enum",
             "-Werror=switch",
-            "-fdiagnostics-absolute-paths"
+            "-fdiagnostics-absolute-paths",
         }
 
         if USE_ASAN_UBSAN then

          
M src/prover.cpp +5 -1
@@ 456,6 456,7 @@ void map_arguments_to_block(const ASTCon
     }
 }
 
+#if SCOPES_ANNOTATE_TRACKING
 static void write_annotation(const ASTContext &ctx,
     const Anchor *anchor, const String *msg, Values values) {
     values.insert(values.begin(),

          
@@ 470,6 471,7 @@ static void write_annotation(const ASTCo
         assert(false && "error while annotating");
     }
 }
+#endif
 
 static SCOPES_RESULT(void) verify_valid(const ASTContext &ctx, int id, const char *by) {
     SCOPES_RESULT_TYPE(void);

          
@@ 691,7 693,9 @@ static SCOPES_RESULT(void) drop_values(c
     IDs drop_ids;
     drop_ids.reserve(todrop.size());
     sort_drop_ids(todrop, drop_ids);
+    #if SCOPES_ANNOTATE_TRACKING
     auto anchor = mover.anchor();
+    #endif
     for (auto &&id : drop_ids) {
         if (!ctx.block->is_valid(id)) // already moved
             continue;

          
@@ 3077,7 3081,7 @@ repeat:
         case FN_VolatileStore:
         case FN_Store: {
             CHECKARGS(2, 2);
-            READ_STORAGETYPEOF(ElemT);
+            READ_MOVE_STORAGETYPEOF(ElemT);
             READ_STORAGETYPEOF(DestT);
             SCOPES_CHECK_RESULT(verify_kind<TK_Pointer>(DestT));
             SCOPES_CHECK_RESULT(verify_writable(DestT));

          
M testing/test_borrowing.sc +13 -0
@@ 582,4 582,17 @@ fn testfunc ()
 testfunc;
 One.test-refcount-balanced;
 
+do
+    using import Map
+    using import struct
+
+    struct A
+        a : i32
+    local a : A
+    local m : (Map i32 A)
+
+    # this used to fail because `store` did not move-dereference arguments
+    'set m 10 a
+    ;
+
 ;
  No newline at end of file