Commit 21311e6f authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Fixed usage of local template before its definition (bug 525458)



Change-Id: I1dec30a80fa0a869a35d070c154928b579dd1243
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent 992ff1a8
......@@ -5023,7 +5023,10 @@ compile_time:
// the parameterized template's default values must also be generated
// (this only generates their value assignments, their declarations will
// be generated when the template's definition is reached)
if (ass->get_my_scope()->get_scope_mod_gen() == usage_mod) {
if (ass->get_my_scope()->get_scope_mod_gen() == usage_mod &&
my_scope->get_statementblock_scope() == NULL) {
// only if the template reference is global and is in the same module
// as the referenced parameterized template
str = formal_parlist->generate_code_defval(str);
}
} else {
......
......@@ -346,6 +346,27 @@ testcase templateIntReverseOrderImported2() runs on templateInt_mycomp {
}
}
type record of integer RoI;
// same as the previous test, but the usage is in a local template
testcase templateIntReverseOrderLocal() runs on templateInt_mycomp {
template integer t1 := tPard4;
template RoI t2 := { tPard4 };
var template integer vtExp1 := 19;
var template RoI vtExp2 := { 19 };
if (log2str(t1) == log2str(vtExp1) and
log2str(t2) == log2str(vtExp2)) {
setverdict(pass);
}
else {
setverdict(fail, "Expected: ", vtExp1, " and ", vtExp2,
", got: ", t1, " and ", t2);
}
}
template integer tPard4(integer p := 19) := p;
template integer IntTemplateParam(template integer i := 3) := i;
testcase templateIntParam() runs on templateInt_mycomp {
......@@ -392,6 +413,7 @@ control {
execute(templateIntReverseOrder());
execute(templateIntReverseOrderImported());
execute(templateIntReverseOrderImported2());
execute(templateIntReverseOrderLocal());
execute(templateIntParam());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment