#This script is designed to run with Understand - CodeCheck #Robert Gempeler - 7/19/2010 use base ("Understand::Codecheck"); use strict; use constant ERR1 => 'Use of "setjmp" macro or "longjmp" function.'; sub register_tr_text() { my $check = shift; $check->add_tr_text(ERR1); } sub name { return "20.7 No \"setjmp\" macro or \"longjmp\" function allowed";} sub description { return "20.7 (Required) The \"setjmp\" macro and the \"longjmp\" function shall not be used.";} sub detailed_description { return <<"END_DESC" "setjmp" and "longjmp" allow the normal function call mechanisms to be bypassed, and shall not be used. END_DESC } sub test_language { my $language = shift; return $language =~ /C\+\+/; #Handles C and C++ } sub test_entity { return 1;} sub test_global { return 0;} sub define_options{} sub check { my $check = shift; my $file = shift; return unless $file->kind->check("file"); my @refs = $file->filerefs("call","function, macro",0); foreach my $ref (@refs){ if ($ref->ent->name =~ /^setjmp$|^longjmp$/){ $check->violation($ref->ent(),$file,$ref->line(),$ref->column(),ERR1); } } }