regen/embed.pl: Warn if have > 1 i, p, and s flags
authorKarl Williamson <public@khwilliamson.com>
Thu, 7 Feb 2013 17:31:22 +0000 (10:31 -0700)
committerKarl Williamson <public@khwilliamson.com>
Fri, 8 Feb 2013 21:44:23 +0000 (14:44 -0700)
These should be mutually exclusive

regen/embed.pl

index cbf421f..629bb84 100755 (executable)
@@ -79,6 +79,13 @@ my ($embed, $core, $ext, $api) = setup_embed();
        if (! $can_ignore && $retval eq 'void') {
            warn "It is nonsensical to require the return value of a void function ($plain_func) to be checked";
        }
+
+       my $scope_type_flag_count = 0;
+       $scope_type_flag_count++ if $flags =~ /s/;
+       $scope_type_flag_count++ if $flags =~ /i/;
+       $scope_type_flag_count++ if $flags =~ /p/;
+       warn "$plain_func: i, p, and s flags are all mutually exclusive"
+                                                  if $scope_type_flag_count > 1;
        my $splint_flags = "";
        if ( $SPLINT && !$commented_out ) {
            $splint_flags .= '/*@noreturn@*/ ' if $never_returns;
@@ -95,8 +102,6 @@ my ($embed, $core, $ext, $api) = setup_embed();
            else {
                $type = $1 eq 's' ? "STATIC" : "PERL_STATIC_INLINE";
            }
-           warn "$plain_func: i and s flags are mutually exclusive"
-                                           if $flags =~ /s/ && $flags =~ /i/;
            $retval = "$type $splint_flags$retval";
            $func = "S_$plain_func";
        }