@@ -44,7 +44,11 @@ Function: c_typecheck_baset::typecheck_code
44
44
void c_typecheck_baset::typecheck_code (codet &code)
45
45
{
46
46
if (code.id ()!=ID_code)
47
- throw " expected code, got " +code.pretty ();
47
+ {
48
+ err_location (code);
49
+ str << " expected code, got " << code.pretty ();
50
+ throw 0 ;
51
+ }
48
52
49
53
code.type ()=code_typet ();
50
54
@@ -205,7 +209,11 @@ Function: c_typecheck_baset::typecheck_assign
205
209
void c_typecheck_baset::typecheck_assign (codet &code)
206
210
{
207
211
if (code.operands ().size ()!=2 )
208
- throw " assignment statement expected to have two operands" ;
212
+ {
213
+ err_location (code);
214
+ str << " assignment statement expected to have two operands" ;
215
+ throw 0 ;
216
+ }
209
217
210
218
typecheck_expr (code.op0 ());
211
219
typecheck_expr (code.op1 ());
@@ -280,7 +288,8 @@ void c_typecheck_baset::typecheck_break(codet &code)
280
288
if (!break_is_allowed)
281
289
{
282
290
err_location (code);
283
- throw " break not allowed here" ;
291
+ str << " break not allowed here" ;
292
+ throw 0 ;
284
293
}
285
294
}
286
295
@@ -301,7 +310,8 @@ void c_typecheck_baset::typecheck_continue(codet &code)
301
310
if (!continue_is_allowed)
302
311
{
303
312
err_location (code);
304
- throw " continue not allowed here" ;
313
+ str << " continue not allowed here" ;
314
+ throw 0 ;
305
315
}
306
316
}
307
317
@@ -323,14 +333,16 @@ void c_typecheck_baset::typecheck_decl(codet &code)
323
333
if (code.operands ().size ()!=1 )
324
334
{
325
335
err_location (code);
326
- throw " decl expected to have 1 operand" ;
336
+ str << " decl expected to have 1 operand" ;
337
+ throw 0 ;
327
338
}
328
339
329
340
// op0 must be declaration
330
341
if (code.op0 ().id ()!=ID_declaration)
331
342
{
332
343
err_location (code);
333
- throw " decl statement expected to have declaration as operand" ;
344
+ str << " decl statement expected to have declaration as operand" ;
345
+ throw 0 ;
334
346
}
335
347
336
348
ansi_c_declarationt declaration;
@@ -381,7 +393,8 @@ void c_typecheck_baset::typecheck_decl(codet &code)
381
393
!is_complete_type (symbol.type ))
382
394
{
383
395
err_location (symbol.location );
384
- throw " incomplete type not permitted here" ;
396
+ str << " incomplete type not permitted here" ;
397
+ throw 0 ;
385
398
}
386
399
387
400
// see if it's a typedef
@@ -489,7 +502,11 @@ Function: c_typecheck_baset::typecheck_expression
489
502
void c_typecheck_baset::typecheck_expression (codet &code)
490
503
{
491
504
if (code.operands ().size ()!=1 )
492
- throw " expression statement expected to have one operand" ;
505
+ {
506
+ err_location (code);
507
+ str << " expression statement expected to have one operand" ;
508
+ throw 0 ;
509
+ }
493
510
494
511
exprt &op=code.op0 ();
495
512
typecheck_expr (op);
@@ -510,7 +527,11 @@ Function: c_typecheck_baset::typecheck_for
510
527
void c_typecheck_baset::typecheck_for (codet &code)
511
528
{
512
529
if (code.operands ().size ()!=4 )
513
- throw " for expected to have four operands" ;
530
+ {
531
+ err_location (code);
532
+ str << " for expected to have four operands" ;
533
+ throw 0 ;
534
+ }
514
535
515
536
// the "for" statement has an implicit block around it,
516
537
// since code.op0() may contain declarations
@@ -627,7 +648,8 @@ void c_typecheck_baset::typecheck_switch_case(code_switch_caset &code)
627
648
if (code.operands ().size ()!=2 )
628
649
{
629
650
err_location (code);
630
- throw " switch_case expected to have two operands" ;
651
+ str << " switch_case expected to have two operands" ;
652
+ throw 0 ;
631
653
}
632
654
633
655
typecheck_code (code.code ());
@@ -637,15 +659,17 @@ void c_typecheck_baset::typecheck_switch_case(code_switch_caset &code)
637
659
if (!case_is_allowed)
638
660
{
639
661
err_location (code);
640
- throw " did not expect default label here" ;
662
+ str << " did not expect default label here" ;
663
+ throw 0 ;
641
664
}
642
665
}
643
666
else
644
667
{
645
668
if (!case_is_allowed)
646
669
{
647
670
err_location (code);
648
- throw " did not expect `case' here" ;
671
+ str << " did not expect `case' here" ;
672
+ throw 0 ;
649
673
}
650
674
651
675
exprt &case_expr=code.case_op ();
@@ -671,15 +695,17 @@ void c_typecheck_baset::typecheck_gcc_switch_case_range(codet &code)
671
695
if (code.operands ().size ()!=3 )
672
696
{
673
697
err_location (code);
674
- throw " gcc_switch_case_range expected to have three operands" ;
698
+ str << " gcc_switch_case_range expected to have three operands" ;
699
+ throw 0 ;
675
700
}
676
701
677
702
typecheck_code (to_code (code.op2 ()));
678
703
679
704
if (!case_is_allowed)
680
705
{
681
706
err_location (code);
682
- throw " did not expect `case' here" ;
707
+ str << " did not expect `case' here" ;
708
+ throw 0 ;
683
709
}
684
710
685
711
typecheck_expr (code.op0 ());
@@ -741,15 +767,17 @@ void c_typecheck_baset::typecheck_gcc_computed_goto(codet &code)
741
767
if (code.operands ().size ()!=1 )
742
768
{
743
769
err_location (code);
744
- throw " computed-goto expected to have one operand" ;
770
+ str << " computed-goto expected to have one operand" ;
771
+ throw 0 ;
745
772
}
746
773
747
774
exprt &dest=code.op0 ();
748
775
749
776
if (dest.id ()!=ID_dereference)
750
777
{
751
778
err_location (dest);
752
- throw " computed-goto expected to have dereferencing operand" ;
779
+ str << " computed-goto expected to have dereferencing operand" ;
780
+ throw 0 ;
753
781
}
754
782
755
783
assert (dest.operands ().size ()==1 );
@@ -773,7 +801,11 @@ Function: c_typecheck_baset::typecheck_ifthenelse
773
801
void c_typecheck_baset::typecheck_ifthenelse (code_ifthenelset &code)
774
802
{
775
803
if (code.operands ().size ()!=3 )
776
- throw " ifthenelse expected to have three operands" ;
804
+ {
805
+ err_location (code);
806
+ str << " ifthenelse expected to have three operands" ;
807
+ throw 0 ;
808
+ }
777
809
778
810
exprt &cond=code.cond ();
779
811
@@ -831,7 +863,11 @@ Function: c_typecheck_baset::typecheck_start_thread
831
863
void c_typecheck_baset::typecheck_start_thread (codet &code)
832
864
{
833
865
if (code.operands ().size ()!=1 )
834
- throw " start_thread expected to have one operand" ;
866
+ {
867
+ err_location (code);
868
+ str << " start_thread expected to have one operand" ;
869
+ throw 0 ;
870
+ }
835
871
836
872
typecheck_code (to_code (code.op0 ()));
837
873
}
@@ -876,7 +912,8 @@ void c_typecheck_baset::typecheck_return(codet &code)
876
912
else
877
913
{
878
914
err_location (code);
879
- throw " return expected to have 0 or 1 operands" ;
915
+ str << " return expected to have 0 or 1 operands" ;
916
+ throw 0 ;
880
917
}
881
918
}
882
919
@@ -895,7 +932,11 @@ Function: c_typecheck_baset::typecheck_switch
895
932
void c_typecheck_baset::typecheck_switch (code_switcht &code)
896
933
{
897
934
if (code.operands ().size ()!=2 )
898
- throw " switch expects two operands" ;
935
+ {
936
+ err_location (code);
937
+ str << " switch expects two operands" ;
938
+ throw 0 ;
939
+ }
899
940
900
941
typecheck_expr (code.value ());
901
942
@@ -934,7 +975,11 @@ Function: c_typecheck_baset::typecheck_while
934
975
void c_typecheck_baset::typecheck_while (code_whilet &code)
935
976
{
936
977
if (code.operands ().size ()!=2 )
937
- throw " while expected to have two operands" ;
978
+ {
979
+ err_location (code);
980
+ str << " while expected to have two operands" ;
981
+ throw 0 ;
982
+ }
938
983
939
984
typecheck_expr (code.cond ());
940
985
implicit_typecast_bool (code.cond ());
@@ -977,7 +1022,11 @@ Function: c_typecheck_baset::typecheck_dowhile
977
1022
void c_typecheck_baset::typecheck_dowhile (code_dowhilet &code)
978
1023
{
979
1024
if (code.operands ().size ()!=2 )
980
- throw " do while expected to have two operands" ;
1025
+ {
1026
+ err_location (code);
1027
+ str << " do while expected to have two operands" ;
1028
+ throw 0 ;
1029
+ }
981
1030
982
1031
typecheck_expr (code.cond ());
983
1032
implicit_typecast_bool (code.cond ());
0 commit comments