Rob Shearman : widl: Check that attributes applied to typedefs and fields are applicable and issue an error otherwise .

Alexandre Julliard julliard at winehq.org
Mon Apr 14 07:14:28 CDT 2008


Module: wine
Branch: master
Commit: e9afe272be36c4a8c0f10b0484eacb17d6d78e19
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e9afe272be36c4a8c0f10b0484eacb17d6d78e19

Author: Rob Shearman <rob at codeweavers.com>
Date:   Mon Apr 14 10:59:27 2008 +0100

widl: Check that attributes applied to typedefs and fields are applicable and issue an error otherwise.

---

 tools/widl/parser.y |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 49f7633..24bcd36 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -132,6 +132,8 @@ static void check_arg(var_t *arg);
 static void check_all_user_types(ifref_list_t *ifaces);
 static const attr_list_t *check_iface_attrs(const char *name, const attr_list_t *attrs);
 static attr_list_t *check_function_attrs(const char *name, attr_list_t *attrs);
+static attr_list_t *check_typedef_attrs(attr_list_t *attrs);
+static attr_list_t *check_field_attrs(const char *name, attr_list_t *attrs);
 
 #define tsENUM   1
 #define tsSTRUCT 2
@@ -655,7 +657,7 @@ field:	  s_field ';'				{ $$ = $1; }
 	;
 
 s_field:  m_attributes type pident array	{ $$ = $3->var;
-						  $$->attrs = $1;
+						  $$->attrs = check_field_attrs($$->name, $1);
 						  set_type($$, $2, $3, $4, FALSE);
 						  free($3);
 						}
@@ -928,7 +930,7 @@ type:	  tVOID					{ $$ = duptype(find_type("void", 0), 1); }
 	| tSAFEARRAY '(' type ')'		{ $$ = make_safearray($3); }
 	;
 
-typedef: tTYPEDEF m_attributes type pident_list	{ reg_typedefs($3, $4, $2);
+typedef: tTYPEDEF m_attributes type pident_list	{ reg_typedefs($3, $4, check_typedef_attrs($2));
 						  process_typedefs($4);
 						}
 	;
@@ -2249,6 +2251,32 @@ static void check_arg(var_t *arg)
   }
 }
 
+static attr_list_t *check_typedef_attrs(attr_list_t *attrs)
+{
+  const attr_t *attr;
+  if (!attrs) return attrs;
+  LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry)
+  {
+    if (!allowed_attr[attr->type].on_type)
+      error_loc("inapplicable attribute %s for typedef\n",
+                allowed_attr[attr->type].display_name);
+  }
+  return attrs;
+}
+
+static attr_list_t *check_field_attrs(const char *name, attr_list_t *attrs)
+{
+  const attr_t *attr;
+  if (!attrs) return attrs;
+  LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry)
+  {
+    if (!allowed_attr[attr->type].on_field)
+      error_loc("inapplicable attribute %s for field %s\n",
+                allowed_attr[attr->type].display_name, name);
+  }
+  return attrs;
+}
+
 static void check_all_user_types(ifref_list_t *ifrefs)
 {
   const ifref_t *ifref;




More information about the wine-cvs mailing list