Commit 9c4e086a authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Fixed has_defval and get_defval functions (bug 544632)



Change-Id: I4f8360e5254bb60dc5463164af49d3f8e1b8750d
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent 314b32dc
......@@ -4504,7 +4504,7 @@ namespace Ttcn {
FormalPar *local_fp = fp_list->get_fp_byIndex(i);
if (local_fp->has_notused_defval()) {
FormalPar *base_fp = base_fpl->get_fp_byIndex(i);
if (base_fp->has_defval()) {
if (base_fp->has_defval_checked()) {
local_fp->set_defval(base_fp->get_defval());
} else {
local_fp->error("Not used symbol (`-') doesn't have the "
......@@ -8530,9 +8530,14 @@ namespace Ttcn {
bool FormalPar::has_defval() const
{
if (checked) return defval.ap != 0;
if (checked) return has_defval_checked();
else return defval.ti != 0;
}
bool FormalPar::has_defval_checked() const
{
return checked && defval.ap != 0;
}
bool FormalPar::has_notused_defval() const
{
......@@ -9494,7 +9499,7 @@ namespace Ttcn {
const string& par_name = par->get_id().get_name();
if (par->get_asstype() != Definition::A_PAR_TIMER)
par->get_Type()->set_genname(p_prefix, par_name);
if (par->has_defval()) {
if (par->has_defval_checked()) {
string embedded_genname(p_prefix);
embedded_genname += '_';
embedded_genname += par_name;
......@@ -9877,7 +9882,7 @@ namespace Ttcn {
static_cast<unsigned long> (i + 1), fp->get_id().get_dispname().c_str());
if (!ti->get_Type() && !ti->get_DerivedRef() && ti->get_Template()
->get_templatetype() == Template::TEMPLATE_NOTUSED) {
if (fp->has_defval()) {
if (fp->has_defval_checked()) {
ActualPar *defval = fp->get_defval();
p_aplist->add(new ActualPar(defval));
if (defval->is_erroneous()) error_flag = true;
......@@ -9902,7 +9907,7 @@ namespace Ttcn {
// (which must exist).
for (size_t i = upper_limit; i < formal_pars; i++) {
FormalPar *fp = pars_v[i];
if (fp->has_defval()) {
if (fp->has_defval_checked()) {
ActualPar *defval = fp->get_defval();
p_aplist->add(new ActualPar(defval));
if (defval->is_erroneous()) error_flag = true;
......
......@@ -1769,7 +1769,12 @@ namespace Ttcn {
virtual bool is_local() const;
virtual Type *get_Type();
virtual void chk();
/** Returns true if the formal parameter has a default value (whether it's
* checked or not). Does not guarantee that usage of get_defval is safe! */
bool has_defval() const;
/** Returns true if the formal parameter is checked and has a default value.
* Guarantees that usage of get_defval is safe. */
bool has_defval_checked() const;
bool has_notused_defval() const;
/** Get the default value.
* \pre chk() has been called (checked==true) */
......
......@@ -8630,4 +8630,25 @@ template MyRecF t2 := { fnum := (-infinity..0.0) };
<END_TC>
:exmp.
*-----------------------------------------------------------*
:h3.Adhoc:: Bug 544632: Using same name for type and template with default value parameter
.*-----------------------------------------------------------*
:xmp tab=0.
<TC - Bug 544632: Using same name for type and template with default value parameter>
<COMPILE>
<VERDICT_LEAF FAIL>
<MODULE TTCN Temp Temp.ttcn>
module Temp {
template T T(template integer p := ?) := p;
}
<END_MODULE>
<RESULT IF_FAIL COUNT 1>
is not a reference to a type
<END_RESULT>
<END_TC>
:exmp.
:etext.
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