iASL: Mark Return() and Return as "Null" return statements.

Since the parser stuffs a "zero" as the return value for these
statements (due to the AML grammar), they were seen as "return with
value" by the semantic checking. They are now seen correctly as
"null" return statements.
This commit is contained in:
Robert Moore 2011-03-22 09:34:11 -07:00
parent 8b3f242f8d
commit a35e8b2438
3 changed files with 13 additions and 5 deletions

View File

@ -1556,7 +1556,7 @@ ReturnTerm
: PARSEOP_RETURN '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RETURN);}
OptionalReturnArg
')' {$$ = TrLinkChildren ($<n>3,1,$4);}
| PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrCreateLeafNode (PARSEOP_ZERO));}
| PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN));}
| PARSEOP_RETURN '('
error ')' {$$ = AslDoError(); yyclearin;}
;
@ -3133,7 +3133,7 @@ OptionalTermArg
;
OptionalReturnArg
: {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */
: {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN);} /* Placeholder is a ZeroOp object */
| TermArg {$$ = $1;}
;

View File

@ -148,6 +148,7 @@
#define NODE_COMPILER_EMITTED 0x00020000
#define NODE_IS_DUPLICATE 0x00040000
#define NODE_IS_RESOURCE_DATA 0x00080000
#define NODE_IS_NULL_RETURN 0x00100000
/* Keeps information about individual control methods */

View File

@ -374,10 +374,17 @@ AnMethodAnalysisWalkBegin (
return (AE_ERROR);
}
/* Child indicates a return value */
/*
* A child indicates a possible return value. A simple Return or
* Return() is marked with NODE_IS_NULL_RETURN by the parser so
* that it is not counted as a "real" return-with-value, although
* the AML code that is actually emitted is Return(0). The AML
* definition of Return has a required parameter, so we are
* forced to convert a null return to Return(0).
*/
if ((Op->Asl.Child) &&
(Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
(Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(!(Op->Asl.Child->Asl.CompileFlags & NODE_IS_NULL_RETURN)))
{
MethodInfo->NumReturnWithValue++;
}