Commit 00722508 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

add basic checks for method modifiers, fixes bug 435853 include

2007-05-09  Jürg Billeter  <j@bitron.ch>

	* vala/parser.y: add basic checks for method modifiers, fixes bug 435853
	* vala/vala.h: include valaflagsvalue.h

svn path=/trunk/; revision=312
parent fe8d0698
2007-05-09 Jürg Billeter <j@bitron.ch>
* vala/parser.y: add basic checks for method modifiers, fixes bug 435853
* vala/vala.h: include valaflagsvalue.h
2007-05-09 Jürg Billeter <j@bitron.ch> 2007-05-09 Jürg Billeter <j@bitron.ch>
* vala/valanamespace.vala: iterate correctly over string in * vala/valanamespace.vala: iterate correctly over string in
......
...@@ -2317,7 +2317,9 @@ modifiers ...@@ -2317,7 +2317,9 @@ modifiers
| modifiers modifier | modifiers modifier
{ {
if (($1 & $2) == $2) { if (($1 & $2) == $2) {
/* modifier specified twice, signal error */ ValaSourceReference *src = src(@2);
vala_report_error (src, "Modifier may only be specified once.");
g_object_unref (src);
} }
$$ = $1 | $2; $$ = $1 | $2;
} }
...@@ -2577,6 +2579,7 @@ method_header ...@@ -2577,6 +2579,7 @@ method_header
{ {
GList *l; GList *l;
ValaSourceReference *src; ValaSourceReference *src;
ValaModifier vmodifiers;
if (!vala_type_reference_get_is_weak ($5)) { if (!vala_type_reference_get_is_weak ($5)) {
vala_type_reference_set_transfers_ownership ($5, TRUE); vala_type_reference_set_transfers_ownership ($5, TRUE);
...@@ -2591,14 +2594,17 @@ method_header ...@@ -2591,14 +2594,17 @@ method_header
if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) { if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) {
vala_method_set_instance ($$, FALSE); vala_method_set_instance ($$, FALSE);
} }
if (($4 & VALA_MODIFIER_ABSTRACT) == VALA_MODIFIER_ABSTRACT) { vmodifiers = $4 & (VALA_MODIFIER_ABSTRACT | VALA_MODIFIER_VIRTUAL | VALA_MODIFIER_OVERRIDE);
if (vmodifiers == 0) {
} else if (vmodifiers == VALA_MODIFIER_ABSTRACT) {
vala_method_set_is_abstract ($$, TRUE); vala_method_set_is_abstract ($$, TRUE);
} } else if (vmodifiers == VALA_MODIFIER_VIRTUAL) {
if (($4 & VALA_MODIFIER_VIRTUAL) == VALA_MODIFIER_VIRTUAL) {
vala_method_set_is_virtual ($$, TRUE); vala_method_set_is_virtual ($$, TRUE);
} } else if (vmodifiers == VALA_MODIFIER_OVERRIDE) {
if (($4 & VALA_MODIFIER_OVERRIDE) == VALA_MODIFIER_OVERRIDE) {
vala_method_set_overrides ($$, TRUE); vala_method_set_overrides ($$, TRUE);
} else {
vala_report_error (vala_code_node_get_source_reference (VALA_CODE_NODE ($$)), "Only one of `abstract', `virtual', and `override' may be specified.");
vala_code_node_set_error (VALA_CODE_NODE ($$), TRUE);
} }
VALA_CODE_NODE($$)->attributes = $2; VALA_CODE_NODE($$)->attributes = $2;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <vala/valaexpressionstatement.h> #include <vala/valaexpressionstatement.h>
#include <vala/valafield.h> #include <vala/valafield.h>
#include <vala/valaflags.h> #include <vala/valaflags.h>
#include <vala/valaflagsvalue.h>
#include <vala/valaforeachstatement.h> #include <vala/valaforeachstatement.h>
#include <vala/valaformalparameter.h> #include <vala/valaformalparameter.h>
#include <vala/valaforstatement.h> #include <vala/valaforstatement.h>
......
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