From 99737dee776f8b60436c2b944b2ca3ae69f2efde Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <divverent@xonotic.org>
Date: Wed, 2 May 2012 10:27:31 +0200
Subject: [PATCH] work around QCC STORE_V bug

---
 misc/tools/progs-analyzer.pl | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/misc/tools/progs-analyzer.pl b/misc/tools/progs-analyzer.pl
index a6528d2b..95a66132 100644
--- a/misc/tools/progs-analyzer.pl
+++ b/misc/tools/progs-analyzer.pl
@@ -661,8 +661,18 @@ sub find_uninitialized_locals($$)
 			my ($ip, $state, $s, $c) = @_;
 			my $op = $s->{op};
 
+			# QCVM BUG: RETURN always takes vector, there is no float equivalent
 			my $return_hack = $c->{isreturn} // 0;
 
+			if($op eq 'STORE_V')
+			{
+				# COMPILER BUG of QCC: params are always copied using STORE_V
+				if($s->{b} >= 4 && $s->{b} < 28) # parameter range
+				{
+					$return_hack = 1;
+				}
+			}
+
 			for(qw(a b c))
 			{
 				my $type = $c->{$_};
@@ -681,7 +691,8 @@ sub find_uninitialized_locals($$)
 					my $valid = $state->{$ofs}{valid};
 					if($valid->[0] == 0)
 					{
-						if($return_hack <= 2 and ($op ne 'OR' && $op ne 'AND' || $_ ne 'b')) # fteqcc logicops cause this
+						# COMPILER BUG of FTEQCC: AND and OR may take uninitialized as second argument (logicops)
+						if($return_hack <= 2 and ($op ne 'OR' && $op ne 'AND' || $_ ne 'b'))
 						{
 							print "; Use of uninitialized value $ofs in $func->{debugname} at $ip.$_\n";
 							++$warned{$ip}{$_};
@@ -689,7 +700,8 @@ sub find_uninitialized_locals($$)
 					}
 					elsif($valid->[0] < 0)
 					{
-						if($return_hack <= 2 and ($op ne 'OR' && $op ne 'AND' || $_ ne 'b')) # fteqcc logicops cause this
+						# COMPILER BUG of FTEQCC: AND and OR may take uninitialized as second argument (logicops)
+						if($return_hack <= 2 and ($op ne 'OR' && $op ne 'AND' || $_ ne 'b'))
 						{
 							print "; Use of temporary $ofs across CALL in $func->{debugname} at $ip.$_\n";
 							++$warned{$ip}{$_};
-- 
2.39.5