diff --git a/src/ID.cc b/src/ID.cc index 4216422225..a68abb6264 100644 --- a/src/ID.cc +++ b/src/ID.cc @@ -294,6 +294,22 @@ void ID::RemoveAttr(attr_tag a) } } +void ID::SetOption() + { + if ( is_option ) + return; + + is_option = true; + + // option implied redefinable + if ( ! IsRedefinable() ) + { + attr_list* attr = new attr_list; + attr->append(new Attr(ATTR_REDEF)); + AddAttrs(new Attributes(attr, Type(), false)); + } + } + void ID::EvalFunc(Expr* ef, Expr* ev) { Expr* arg1 = new ConstExpr(val->Ref()); diff --git a/src/ID.h b/src/ID.h index 442a13dfcc..18754584df 100644 --- a/src/ID.h +++ b/src/ID.h @@ -60,7 +60,7 @@ public: void SetConst() { is_const = true; } bool IsConst() const { return is_const; } - void SetOption() { is_option = true; } + void SetOption(); bool IsOption() const { return is_option; } void SetEnumConst() { is_enum_const = true; } diff --git a/testing/btest/Baseline/core.option-redef/.stdout b/testing/btest/Baseline/core.option-redef/.stdout index 1e8b314962..baf1966653 100644 --- a/testing/btest/Baseline/core.option-redef/.stdout +++ b/testing/btest/Baseline/core.option-redef/.stdout @@ -1 +1,2 @@ 6 +7 diff --git a/testing/btest/core/option-redef.bro b/testing/btest/core/option-redef.bro index 05706ab48b..3d67a9a755 100644 --- a/testing/btest/core/option-redef.bro +++ b/testing/btest/core/option-redef.bro @@ -2,11 +2,15 @@ # @TEST-EXEC: btest-diff .stdout # options are allowed to be redef-able. +# And they are even redef-able by default. option testopt = 5 &redef; redef testopt = 6; +option anotheropt = 6; +redef anotheropt = 7; event bro_init() { print testopt; + print anotheropt; }