diff --git a/dlls/oleaut32/tests/test_tlb.idl b/dlls/oleaut32/tests/test_tlb.idl index 53729dcee3b..ad35af40c39 100644 --- a/dlls/oleaut32/tests/test_tlb.idl +++ b/dlls/oleaut32/tests/test_tlb.idl @@ -24,6 +24,8 @@ import "oaidl.idl"; /* needed by widl */ +midl_pragma warning ( disable : 2368 ) + [uuid(8b05fe77-4a6c-4133-b9cd-8f81747af784)] library Test { diff --git a/tools/widl/parser.h b/tools/widl/parser.h index 1bcc3c182f2..f48cacc005c 100644 --- a/tools/widl/parser.h +++ b/tools/widl/parser.h @@ -45,6 +45,9 @@ void pop_import(void); int is_type(const char *name); +int do_warning(char *toggle, warning_list_t *wnum); +int is_warning_enabled(int warning); + extern char *temp_name; #endif diff --git a/tools/widl/parser.l b/tools/widl/parser.l index c0b2fcd7b36..6520ce72e6b 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -76,6 +76,8 @@ static int cbufalloc = 0; static int kw_token(const char *kw); static int attr_token(const char *kw); +static warning_list_t *disabled_warnings = NULL; + #define MAX_IMPORT_DEPTH 10 struct { YY_BUFFER_STATE state; @@ -556,3 +558,61 @@ void abort_import(void) for (ptr=0; ptrnum == warning) + return; + warning_entry = xmalloc( sizeof(*warning_entry) ); + warning_entry->num = warning; + list_add_tail(disabled_warnings, &warning_entry->entry); +} + +static void warning_enable(int warning) +{ + warning_t *warning_entry; + LIST_FOR_EACH_ENTRY(warning_entry, disabled_warnings, warning_t, entry) + if(warning_entry->num == warning) + { + list_remove(&warning_entry->entry); + free(warning_entry); + break; + } +} + +int do_warning(char *toggle, warning_list_t *wnum) +{ + warning_t *warning, *next; + int ret = 1; + if(!disabled_warnings) + { + disabled_warnings = xmalloc( sizeof(*disabled_warnings) ); + list_init( disabled_warnings ); + } + + if(!strcmp(toggle, "disable")) + LIST_FOR_EACH_ENTRY(warning, wnum, warning_t, entry) + warning_disable(warning->num); + else if(!strcmp(toggle, "enable")) + LIST_FOR_EACH_ENTRY(warning, wnum, warning_t, entry) + warning_enable(warning->num); + else + ret = 0; + + LIST_FOR_EACH_ENTRY_SAFE(warning, next, wnum, warning_t, entry) + free(warning); + return ret; +} + +int is_warning_enabled(int warning) +{ + warning_t *warning_entry; + if(!disabled_warnings) + return 1; + LIST_FOR_EACH_ENTRY(warning_entry, disabled_warnings, warning_t, entry) + if(warning_entry->num == warning) + return 0; + return 1; +} diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 3131e0ddd69..6551ea20b45 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -381,7 +381,14 @@ statement: | pragma_warning { $$ = NULL; } ; -pragma_warning: tPRAGMA_WARNING '(' aIDENTIFIER ':' warnings ')' { $$ = NULL; } +pragma_warning: tPRAGMA_WARNING '(' aIDENTIFIER ':' warnings ')' + { + int result; + $$ = NULL; + result = do_warning($3, $5); + if(!result) + error_loc("expected \"disable\" or \"enable\"\n"); + } ; warnings: diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index 8b65eadf0f3..137bb2db2ea 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -51,6 +51,7 @@ #include "header.h" #include "hash.h" #include "typetree.h" +#include "parser.h" enum MSFT_segment_index { MSFT_SEG_TYPEINFO = 0, /* type information */ @@ -504,7 +505,7 @@ static int ctl2_alloc_guid( offset = ctl2_find_guid(typelib, hash_key, &guid->guid); if (offset != -1) { - if (pedantic) + if (is_warning_enabled(2368)) warning("duplicate uuid {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n", guid->guid.Data1, guid->guid.Data2, guid->guid.Data3, guid->guid.Data4[0], guid->guid.Data4[1], guid->guid.Data4[2], guid->guid.Data4[3],