Rob Shearman : widl: Output a warning if duplicate attributes are specified .

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


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

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

widl: Output a warning if duplicate attributes are specified.

---

 tools/widl/parser.y |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 9824634..929d95c 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -138,6 +138,7 @@ static const attr_list_t *check_library_attrs(const char *name, const attr_list_
 static attr_list_t *check_dispiface_attrs(const char *name, attr_list_t *attrs);
 static const attr_list_t *check_module_attrs(const char *name, const attr_list_t *attrs);
 static const attr_list_t *check_coclass_attrs(const char *name, const attr_list_t *attrs);
+const char *get_attr_display_name(enum attr_type type);
 
 #define tsENUM   1
 #define tsSTRUCT 2
@@ -1031,12 +1032,21 @@ static str_list_t *append_str(str_list_t *list, char *str)
 
 static attr_list_t *append_attr(attr_list_t *list, attr_t *attr)
 {
+    attr_t *attr_existing;
     if (!attr) return list;
     if (!list)
     {
         list = xmalloc( sizeof(*list) );
         list_init( list );
     }
+    LIST_FOR_EACH_ENTRY(attr_existing, list, attr_t, entry)
+        if (attr_existing->type == attr->type)
+        {
+            parser_warning("duplicate attribute %s\n", get_attr_display_name(attr->type));
+            /* use the last attribute, like MIDL does */
+            list_remove(&attr_existing->entry);
+            break;
+        }
     list_add_tail( list, &attr->entry );
     return list;
 }
@@ -2211,6 +2221,11 @@ struct allowed_attr allowed_attr[] =
     /* ATTR_WIREMARSHAL */      { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "wire_marshal" },
 };
 
+const char *get_attr_display_name(enum attr_type type)
+{
+    return allowed_attr[type].display_name;
+}
+
 static const attr_list_t *check_iface_attrs(const char *name, const attr_list_t *attrs)
 {
   const attr_t *attr;




More information about the wine-cvs mailing list