File tree Expand file tree Collapse file tree 3 files changed +62
-2
lines changed 
regression/contracts-dfcc/array_struct_smt-02 Expand file tree Collapse file tree 3 files changed +62
-2
lines changed Original file line number Diff line number Diff line change 1+ typedef  struct 
2+ {
3+   int  coeffs [1 ];
4+ } mld_poly ;
5+ 
6+ typedef  struct 
7+ {
8+   mld_poly  vec [1 ];
9+ } mld_polyveck ;
10+ 
11+ int  main ()
12+ {
13+   mld_polyveck  h ;
14+ 
15+   // clang-format off 
16+   for (unsigned int   i  =  0 ; i  <  1 ; ++ i )
17+     __CPROVER_loop_invariant (i  <= 1 )
18+   {
19+     h .vec [i ].coeffs [0 ] =  1 ;
20+   }
21+   // clang-format on 
22+ 
23+   return  0 ;
24+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+ --dfcc main --apply-loop-contracts _ --cprover-smt2
4+ ^VERIFICATION SUCCESSFUL$
5+ ^EXIT=0$
6+ ^SIGNAL=0$
7+ --
8+ --
9+ Make sure the SMT back-end produces valid SMT2 when structs and arrays are
10+ nested in each other.
Original file line number Diff line number Diff line change @@ -1407,9 +1407,35 @@ void smt2_convt::convert_expr(const exprt &expr)
14071407    out << " (ite " 
14081408    convert_expr (if_expr.cond ());
14091409    out << "  " 
1410-     convert_expr (if_expr.true_case ());
1410+     if (
1411+       expr.type ().id () == ID_array && !use_array_theory (if_expr.true_case ()) &&
1412+       use_array_theory (if_expr.false_case ()))
1413+     {
1414+       unflatten (wheret::BEGIN, expr.type ());
1415+ 
1416+       convert_expr (if_expr.true_case ());
1417+ 
1418+       unflatten (wheret::END, expr.type ());
1419+     }
1420+     else 
1421+     {
1422+       convert_expr (if_expr.true_case ());
1423+     }
14111424    out << "  " 
1412-     convert_expr (if_expr.false_case ());
1425+     if (
1426+       expr.type ().id () == ID_array && use_array_theory (if_expr.true_case ()) &&
1427+       !use_array_theory (if_expr.false_case ()))
1428+     {
1429+       unflatten (wheret::BEGIN, expr.type ());
1430+ 
1431+       convert_expr (if_expr.false_case ());
1432+ 
1433+       unflatten (wheret::END, expr.type ());
1434+     }
1435+     else 
1436+     {
1437+       convert_expr (if_expr.false_case ());
1438+     }
14131439    out << " )" 
14141440  }
14151441  else  if (expr.id ()==ID_and ||
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments