[kaffe] CVS kaffe (doogie): Rewrote again, moving the warning/description definitions themselves into

Kaffe CVS cvs-commits at kaffe.org
Fri Dec 10 12:52:17 PST 2004


PatchSet 5593 
Date: 2004/12/10 20:47:47
Author: doogie
Branch: HEAD
Tag: (none) 
Log:
Rewrote again, moving the warning/description definitions themselves into
their respective files.

Members: 
	ChangeLog:1.3138->1.3139 
	scripts/GCCWarning.pm:1.1->1.2 
	scripts/JikesWarning.pm:1.1->1.2 
	scripts/LogWarning.pm:1.2->1.3 
	scripts/Registry.pm:INITIAL->1.1 
	scripts/sort-warnings.pl:1.9->1.10 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3138 kaffe/ChangeLog:1.3139
--- kaffe/ChangeLog:1.3138	Fri Dec 10 06:20:16 2004
+++ kaffe/ChangeLog	Fri Dec 10 20:47:47 2004
@@ -1,7 +1,15 @@
 2004-12-10  Adam Heath  <doogie at brainfood.com>
 
-	* scripts/sort-warnings.pl, scripts/LogWarning.pl,
-	  scripts/WarningDescription.pl:
+	* scripts/sort-warnings.pl, scripts/LogWarning.pm,
+	  scripts/WarningDescription.pm, scripts/JikesWarning.pm,
+	  scripts/GCCWarning.pm, scripts/Registry.pm:
+	  Rewrote again, moving the warning/description definitions themselves
+	  into their respective files.
+
+2004-12-10  Adam Heath  <doogie at brainfood.com>
+
+	* scripts/sort-warnings.pl, scripts/LogWarning.pm,
+	  scripts/WarningDescription.pm:
 	  Start adding description support to the various detected
 	  warnings.  Currently, only -Wmissing-braces has a description;
 	  this was copied from the gcc info docs.
Index: kaffe/scripts/GCCWarning.pm
diff -u kaffe/scripts/GCCWarning.pm:1.1 kaffe/scripts/GCCWarning.pm:1.2
--- kaffe/scripts/GCCWarning.pm:1.1	Fri Dec 10 05:07:03 2004
+++ kaffe/scripts/GCCWarning.pm	Fri Dec 10 20:47:51 2004
@@ -4,16 +4,133 @@
 use strict;
 use warnings;
 
-use base qw( LogWarning );
-use vars qw( $prefix_regex $prefix_regex_noparam $prefix_regex2 );
+use LogWarning;
+use Registry;
 
-$prefix_regex = qr/^([^:\n]+):(\d+):(?:\d+:)? warning: /m;
-$prefix_regex_noparam = qr/^(?:[^:\n]+):(?:\d+): warning: /m;
+use vars qw( @ISA $prefix_regex $prefix_regex_noparam $prefix_regex2 );
+BEGIN {
+    @ISA = qw( LogWarning );
+    $prefix_regex = qr/^([^:\n]+):(\d+):(?:\d+:)? warning: /m;
+    $prefix_regex_noparam = qr/^(?:[^:\n]+):(?:\d+): warning: /m;
+}
 
 sub new {
     my $class = shift;
 	my ( $name, $regex, $description ) = @_;
-    return $class->SUPER::new( 'gcc', $name, qr/${prefix_regex}$regex/, $description );
+    my $warning = $class->SUPER::new( 'gcc', $name, qr/${prefix_regex}$regex/, $description );
+    Registry::add_warning($warning);
+    return $warning;
+}
+
+sub register_description {
+    Registry::register_description( 'gcc', @_ );
 }
 
+sub register_warning {
+    GCCWarning->new( @_ );
+}
+
+BEGIN {
+    #--
+    register_description( '-Wmissing-braces', "Warn if an aggregate or union initializer is not fully bracketed.
+In the following example, the initializer for `a' is not fully
+bracketed, but that for `b' is fully bracketed.
+
+int a[2][2] = { 0, 1, 2, 3 };
+int b[2][2] = { { 0, 1 }, { 2, 3 } };" );
+    register_warning( '-Wmissing-braces', qr/missing initializer\n${GCCWarning::prefix_regex_noparam}\(near initialization for `([^']+)'\)$/m ),
+    #--
+    register_description( '-Wfloat-equal', "Warn if floating point values are used in equality comparisons.
+
+The idea behind this is that sometimes it is convenient (for the
+programmer) to consider floating-point values as approximations to
+infinitely precise real numbers.  If you are doing this, then you
+need to compute (by analysing the code, or in some other way) the
+maximum or likely maximum error that the computation introduces,
+and allow for it when performing comparisons (and when producing
+output, but that's a different problem).  In particular, instead
+of testing for equality, you would check to see whether the two
+values have ranges that overlap; and this is done with the
+relational operators, so equality comparisons are probably
+mistaken." ),
+    register_warning( '-Wfloat-equal', qr/comparing floating point with == or != is unsafe$/m ),
+    #--
+    register_description( '-Wbad-function-cast', "Warn whenever a function call is cast to a non-matching type.  For
+example, warn if `int malloc()' is cast to `anything *'" );
+    register_warning( '-Wbad-function-cast', qr/cast does not match function type$/m ),
+    #--
+    register_description( '-Wmissing-prototypes', "Warn if a global function is defined without a previous prototype
+declaration.  This warning is issued even if the definition itself
+provides a prototype.  The aim is to detect global functions that
+fail to be declared in header files." );
+    register_warning( '-Wmissing-prototypes', qr/no previous prototype for `([^']+)'$/m ),
+    #--
+    register_description( '-Wredundant-decls', "Warn if anything is declared more than once in the same scope,
+even in cases where multiple declaration is valid and changes
+nothing." );
+    register_warning( '-Wredundant-decls', qr/redundant redeclaration of `([^']+)' in same scope\n${GCCWarning::prefix_regex}previous declaration of `[^']+'$/m ),
+    #--
+    register_description( '-Winline', "Warn if a function can not be inlined and it was declared as
+inline." );
+    register_warning( '-Winline', qr/inlining failed in call to `([^']+)'\n${GCCWarning::prefix_regex}called from here$/m ),
+    #--
+    register_warning( 'missing-prototypes-mismatch', qr/no previous prototype for `([^']+)'\n${GCCWarning::prefix_regex_noparam}type mismatch with previous implicit declaration\n${GCCWarning::prefix_regex}previous implicit declaration of `[^']+'\n${GCCWarning::prefix_regex_noparam}`[^']+' was previously implicitly declared to return `([^']+)'$/m ),
+
+    register_warning( '-Wformat-nonliteral', qr/format not a string literal, argument types not checked$/m ),
+    register_warning( '-Wformat-nonliteral', qr/format not a string literal and no format arguments$/m ),
+    register_warning( '-Wimplicit-func-decl', qr/implicit declaration of function `([^']+)'$/m ),
+    register_warning( '-Wunused-parameter', qr/unused parameter `([^']+)'$/m ),
+    register_warning( '-Wunused-variable', qr/unused variable `([^']+)'$/m ),
+
+
+    register_warning( '-Wshadow', qr/declaration of `([^']+)' shadows a global declaration\n${GCCWarning::prefix_regex}shadowed declaration is here$/m ),
+    register_warning( '-Wshadow', qr/declaration of `([^']+)' shadows a previous local\n${GCCWarning::prefix_regex}shadowed declaration is here$/m ),
+    register_warning( '-Wpointer-arith', qr/pointer of type `([^']+)' used in arithmetic$/m ),
+
+    register_warning( '-Wpointer-arith', qr/pointer of type `([^']+)' used in subtraction$/m ),
+    register_warning( '-Wcast-qual', qr/cast discards qualifiers from pointer target type$/m ),
+    register_warning( '-Wcast-qual', qr/initialization discards qualifiers from pointer target type$/m ),
+    register_warning( '-Wcast-qual', qr/passing arg (\d+) of `([^']+)' discards qualifiers from pointer target type$/m ),
+    register_warning( '-Wcast-qual', qr/return discards qualifiers from pointer target type$/m ),
+    register_warning( '-Wcast-qual', qr/assignment discards qualifiers from pointer target type$/m ),
+    register_warning( '-Wcast-qual', qr/assignment makes qualified function pointer from unqualified$/m ),
+    register_warning( '-Wcast-align', qr/padding struct size to alignment boundary$/m ),
+    register_warning( '-Wconversion', qr/negative integer implicitly converted to unsigned type$/m ),
+    register_warning( '-Wconversion', qr/passing arg (\d+) of `([^']+)' makes (integer|pointer) from (integer|pointer) without a cast$/m ),
+    register_warning( '-Wsign-compare', qr/comparison of unsigned expression < 0 is always false$/m ),
+    register_warning( '-Wsign-compare', qr/comparison between signed and unsigned$/m ),
+    register_warning( '-Wsign-compare', qr/signed and unsigned type in conditional expression$/m ),
+    register_warning( '-Waggregate-return', qr/function call has aggregate value$/m ),
+    register_warning( '-Waggregate-return', qr/function returns an aggregate$/m ),
+    register_warning( '-Wstrict-prototypes', qr/non-static declaration for `([^']+)' follows static$/m ),
+    register_warning( '-Wstrict-prototypes', qr/function declaration isn't a prototype$/m ),
+    register_warning( '-Wmissing-declarations'    => qr/"([^"]+)" is not defined\s*$/m ),
+    register_warning( '-Wmissing-declarations'    => qr/`([^']+)' is not defined\s*$/m ),
+    register_warning( '-Wmissing-noreturn', qr/function might be possible candidate for attribute `(noreturn)'$/m ),
+    register_warning( '-Wmissing-noreturn', qr/`([^']+)' function does return$/m ),
+    register_warning( '-Wmissing-format-attribute', qr/function might be possible candidate for `printf' format attribute$/m ),
+    register_warning( '-Wpadded', qr/padding struct to align `([^']+)'$/m ),
+    register_warning( '-Wnested-externs', qr/nested extern declaration of `([^']+)'$/m ),
+    register_warning( '-Wunreachable-code', qr/will never be executed$/m ),
+
+
+
+
+
+    register_warning( 'traditional', qr/passing arg (\d+) of (?:`([^']+)'|(pointer to function)) with different width due to prototype$/m ),
+    register_warning( 'traditional', qr/passing arg (\d+) of (?:`([^']+)'|(pointer to function)) as (unsigned|signed) due to prototype$/m ),
+    register_warning( 'traditional', qr/passing arg (\d+) of `([^']+)' as `([^']+)' rather than `([^']+)' due to prototype$/m ),
+    register_warning( 'traditional', qr/macro arg `([^']+)' would be stringified with -traditional\.$/m ),
+    register_warning( 'traditional', qr/passing arg (\d+) of `([^']+)' as (floating|integer) rather than (floating|integer) due to prototype$/m ),
+    register_warning( 'traditional', qr/passing arg (\d+) of (?:`([^']+)'|(pointer to function)) as `([^']+)' rather than `([^']+)' due to prototype$/m ),
+    register_warning( 'traditional', qr/passing arg (\d+) of (?:`([^']+)'|(pointer to function)) from incompatible pointer type$/m ),
+
+
+    register_warning( 'deprecated-lvalue', qr/use of (compound|conditional|cast) expressions as lvalues is deprecated$/m ),
+
+    register_warning( 'foo', qr/`([^']+)' declared inside parameter list$/m ),
+    register_warning( 'foo', qr/(assignment|initialization) from incompatible pointer type$/m ),
+    register_warning( 'foo', qr/integer constant is too large for "([^"]+)" type$/m ),
+
+}
 1;
Index: kaffe/scripts/JikesWarning.pm
diff -u kaffe/scripts/JikesWarning.pm:1.1 kaffe/scripts/JikesWarning.pm:1.2
--- kaffe/scripts/JikesWarning.pm:1.1	Fri Dec 10 05:07:03 2004
+++ kaffe/scripts/JikesWarning.pm	Fri Dec 10 20:47:51 2004
@@ -5,14 +5,48 @@
 use strict;
 use warnings;
 
-use base qw( LogWarning );
-use vars qw( $jikes_prefix );
-$jikes_prefix = qr/([^:\n]+):(\d+):\d+:\d+:\d+: (?:Lexical|Semantic) (?:Caution|Warning): /m;
+use LogWarning;
+use Registry;
+use vars qw( @ISA $jikes_prefix );
+
+BEGIN {
+    @ISA = qw( LogWarning );
+    $jikes_prefix = qr/([^:\n]+):(\d+):\d+:\d+:\d+: (?:Lexical|Semantic) (?:Caution|Warning): /m;
+}
 
 sub new {
     my $class = shift;
 	my ( $name, $regex, $description ) = @_;
-    return $class->SUPER::new( 'jikes', $name, qr/${jikes_prefix}$regex/, $description );
+    my $warning = $class->SUPER::new( 'jikes', $name, qr/${jikes_prefix}$regex/, $description );
+    Registry::add_warning($warning);
+    return $warning;
+}
+
+sub register_description {
+    Registry::register_description( 'jikes', @_ );
+}
+
+sub register_warning {
+    JikesWarning->new( @_ );
+}
+
+BEGIN {
+    register_warning( 'throws-uncheck', qr/Since type "([^"]+)" is an unchecked exception, it does not need to be listed in the throws clause.$/m, '' ),
+    register_warning( 'throws-unchecked', qr/Since type "([^"]+)" is an unchecked exception, it does not need to be listed in the throws clause.$/m ),
+    register_warning( 'modifier-order', qr/The modifier "([^"]+)" did not appear in the recommended order public\/protected\/private, abstract, static, final, synchronized, transient, volatile, strictfp.$/m ),
+    register_warning( 'public-in-interface', qr/The use of the "([^"]+)" modifier in this context is redundant and strongly discouraged as a matter of style.$/m ),
+    register_warning( 'exception-superclass', qr/The listing of type "([^"]+)" in the throws clause is not necessary, since its superclass, "([^"]+)", is also listed.$/m ),
+    register_warning( 'override-default', qr/Method "([^"]+)" in class "([^"]+)" does not override or hide the corresponding method with default access in class "([^"]+)".$/m ),
+    register_warning( 'invalid-zip', qr/The file "([^"]+)" does not exist or else is not a valid zip file.$/m ),
+    register_warning( 'invalid-zip', qr/I\/O warning: "No such file or directory" while trying to open (.*)\.$/m ),
+    register_warning( 'negative-shift-count', qr/The shift count (-\d+) is negative; it will be masked to the appropriate width and behave as a positive shift count.$/m ),
+    register_warning( 'large-shift-count', qr/The shift count of (\d+) is >= the (\d+-bit) width of the type.$/m ),
+    register_warning( 'method-is-constructor', qr/The name of this method "([^"]+)" matches the name of the containing class. However, the method is not a constructor since its declarator is qualified with a type.$/m ),
+    register_warning( 'use-parens', qr/Suggest parentheses around assignment used as truth value.$/m ),
+    register_warning( 'instance-static-access', qr/Invoking the class method "([^"]+)" via an instance is discouraged because the method invoked will be the one in the variable's declared type, not the instance's dynamic type.$/m ),
+    register_warning( 'instance-static-access', qr/Accessing the class field "([^"]+)" via an instance is discouraged because the field accessed will be the one in the variable's declared type, not the instance's dynamic type.$/m ),
+    register_warning( 'static-variable-init', qr/Final field "([^"]+)" is initialized with a constant expression and could be made static to save space.$/m ),
+    register_warning( 'lexical:invalid-char', qr/The use of "([^"]+)" in an identifier, while legal, is strongly discouraged, since it can conflict with compiler-generated names. If you are trying to access a nested type, use "([^"]+)" instead of "(?:[^"]+)".$/m ),
 }
 
 1;
Index: kaffe/scripts/LogWarning.pm
diff -u kaffe/scripts/LogWarning.pm:1.2 kaffe/scripts/LogWarning.pm:1.3
--- kaffe/scripts/LogWarning.pm:1.2	Fri Dec 10 06:20:18 2004
+++ kaffe/scripts/LogWarning.pm	Fri Dec 10 20:47:51 2004
@@ -59,4 +59,13 @@
 	return $self->{ 'description' }->description();
 }
 
+sub get_description {
+    my $self = shift;
+    my $description = $self->description_text();
+    if ( !$description ) {
+        $description = Registry::lookup_description( $self->compiler(), $self->shortName() );
+        $description = $description->description() if ( $description );
+    }
+    return $description;
+}
 1;
===================================================================
Checking out kaffe/scripts/Registry.pm
RCS:  /home/cvs/kaffe/kaffe/scripts/Registry.pm,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/scripts/Registry.pm	Fri Dec 10 20:52:16 2004
@@ -0,0 +1,60 @@
+#!/usr/bin/perl -w
+package Registry;
+
+use strict;
+use warnings;
+
+use Data::Dumper;
+use vars qw( %description_registry @warnings %warning_map );
+
+sub register_description {
+    my ( $compiler, $shortName, $description );
+    if ( ref( $_[ 0 ] ) ) {
+        my $compiler = $_[ 0 ]->compiler();
+        my $shortName = $_[ 0 ]->shortName();
+    } else {
+        $compiler = shift;
+        $shortName = shift;
+        $description = shift;
+    }
+    my $existing = $description_registry{ $compiler }{ $shortName };
+    print STDERR "Duplicate description for: compiler[$compiler] name[$shortName]!\n" if ( $existing );
+    $description_registry{ $compiler }{ $shortName } = $description;
+}
+
+sub lookup_description($$) {
+    return $description_registry{ $_[ 0 ] }{ $_[ 0 ] };
+}
+
+sub add_warning {
+    push( @warnings, @_ );
+}
+
+sub analyze_warnings {
+    my %duplicated_warnings;
+    for ( my $i = 0; $i < @warnings; $i++ ) {
+        my $warning = $warnings[ $i ];
+        my $warning_group = $duplicated_warnings{ $warning->compiler() } ||= {};
+        my $warning_name = $warning->name();
+        if ( !$warning_group->{ $warning_name } ) {
+            $warning_group->{ $warning_name } = $warning;
+        } else {
+            if ( ref( $warning_group->{ $warning_name } ) ) {
+                $warning_group->{ $warning_name }->index( 1 );
+                $warning_group->{ $warning_name } = 2;
+            }
+            $warning->index( $warning_group->{ $warning_name }++ );
+        }
+    }
+
+    for ( my $i = 0; $i < @warnings; $i++ ) {
+        $warning_map{ $warnings[ $i ]->name() } = $warnings[ $i ];
+    }
+}
+
+sub get_warning {
+    return $warning_map{ $_[ 0 ] };
+}
+
+1;
+
Index: kaffe/scripts/sort-warnings.pl
diff -u kaffe/scripts/sort-warnings.pl:1.9 kaffe/scripts/sort-warnings.pl:1.10
--- kaffe/scripts/sort-warnings.pl:1.9	Fri Dec 10 06:20:18 2004
+++ kaffe/scripts/sort-warnings.pl	Fri Dec 10 20:47:51 2004
@@ -11,6 +11,8 @@
 use LogWarning;
 use JikesWarning;
 use GCCWarning;
+use Registry;
+Registry::analyze_warnings();
 
 #<robilad> guilhem: ~3000 unique ones with -Wall -W -Wtraditional -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual
 #          -Wcast-align -Wwrite-strings -Wconversion -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes
@@ -50,136 +52,12 @@
     ),x;
 
 
-my @descriptions = (
-    new WarningDescription( 'gcc', '-Wmissing-braces', "Warn if an aggregate or union initializer is not fully bracketed.
-In the following example, the initializer for `a' is not fully
-bracketed, but that for `b' is fully bracketed.
-
-int a[2][2] = { 0, 1, 2, 3 };
-int b[2][2] = { { 0, 1 }, { 2, 3 } };" ),
-);
-
-my @warning_types = (
-	new JikesWarning( 'throws-uncheck', qr/Since type "([^"]+)" is an unchecked exception, it does not need to be listed in the throws clause.$/m, '' ),
-	new JikesWarning( 'throws-unchecked', qr/Since type "([^"]+)" is an unchecked exception, it does not need to be listed in the throws clause.$/m ),
-	new JikesWarning( 'modifier-order', qr/The modifier "([^"]+)" did not appear in the recommended order public\/protected\/private, abstract, static, final, synchronized, transient, volatile, strictfp.$/m ),
-	new JikesWarning( 'public-in-interface', qr/The use of the "([^"]+)" modifier in this context is redundant and strongly discouraged as a matter of style.$/m ),
-	new JikesWarning( 'exception-superclass', qr/The listing of type "([^"]+)" in the throws clause is not necessary, since its superclass, "([^"]+)", is also listed.$/m ),
-	new JikesWarning( 'override-default', qr/Method "([^"]+)" in class "([^"]+)" does not override or hide the corresponding method with default access in class "([^"]+)".$/m ),
-	new JikesWarning( 'invalid-zip', qr/The file "([^"]+)" does not exist or else is not a valid zip file.$/m ),
-	new JikesWarning( 'invalid-zip', qr/I\/O warning: "No such file or directory" while trying to open (.*)\.$/m ),
-	new JikesWarning( 'negative-shift-count', qr/The shift count (-\d+) is negative; it will be masked to the appropriate width and behave as a positive shift count.$/m ),
-	new JikesWarning( 'large-shift-count', qr/The shift count of (\d+) is >= the (\d+-bit) width of the type.$/m ),
-	new JikesWarning( 'method-is-constructor', qr/The name of this method "([^"]+)" matches the name of the containing class. However, the method is not a constructor since its declarator is qualified with a type.$/m ),
-	new JikesWarning( 'use-parens', qr/Suggest parentheses around assignment used as truth value.$/m ),
-	new JikesWarning( 'instance-static-access', qr/Invoking the class method "([^"]+)" via an instance is discouraged because the method invoked will be the one in the variable's declared type, not the instance's dynamic type.$/m ),
-	new JikesWarning( 'instance-static-access', qr/Accessing the class field "([^"]+)" via an instance is discouraged because the field accessed will be the one in the variable's declared type, not the instance's dynamic type.$/m ),
-	new JikesWarning( 'static-variable-init', qr/Final field "([^"]+)" is initialized with a constant expression and could be made static to save space.$/m ),
-	new JikesWarning( 'lexical:invalid-char', qr/The use of "([^"]+)" in an identifier, while legal, is strongly discouraged, since it can conflict with compiler-generated names. If you are trying to access a nested type, use "([^"]+)" instead of "(?:[^"]+)".$/m ),
-
-	new GCCWarning( 'missing-prototypes-mismatch', qr/no previous prototype for `([^']+)'\n${GCCWarning::prefix_regex_noparam}type mismatch with previous implicit declaration\n${GCCWarning::prefix_regex}previous implicit declaration of `[^']+'\n${GCCWarning::prefix_regex_noparam}`[^']+' was previously implicitly declared to return `([^']+)'$/m ),
-
-	new GCCWarning( '-Wformat-nonliteral', qr/format not a string literal, argument types not checked$/m ),
-	new GCCWarning( '-Wformat-nonliteral', qr/format not a string literal and no format arguments$/m ),
-	new GCCWarning( '-Wimplicit-func-decl', qr/implicit declaration of function `([^']+)'$/m ),
-	new GCCWarning( '-Wmissing-braces', qr/missing initializer\n${GCCWarning::prefix_regex_noparam}\(near initialization for `([^']+)'\)$/m ),
-	new GCCWarning( '-Wunused-parameter', qr/unused parameter `([^']+)'$/m ),
-	new GCCWarning( '-Wunused-variable', qr/unused variable `([^']+)'$/m ),
-
-	new GCCWarning( '-Wfloat-equal', qr/comparing floating point with == or != is unsafe$/m ),
-
-	new GCCWarning( '-Wshadow', qr/declaration of `([^']+)' shadows a global declaration\n${GCCWarning::prefix_regex}shadowed declaration is here$/m ),
-	new GCCWarning( '-Wshadow', qr/declaration of `([^']+)' shadows a previous local\n${GCCWarning::prefix_regex}shadowed declaration is here$/m ),
-	new GCCWarning( '-Wpointer-arith', qr/pointer of type `([^']+)' used in arithmetic$/m ),
-	new GCCWarning( '-Wpointer-arith', qr/pointer of type `([^']+)' used in subtraction$/m ),
-	new GCCWarning( '-Wbad-function-cast', qr/cast does not match function type$/m ),
-	new GCCWarning( '-Wcast-qual', qr/cast discards qualifiers from pointer target type$/m ),
-	new GCCWarning( '-Wcast-qual', qr/initialization discards qualifiers from pointer target type$/m ),
-	new GCCWarning( '-Wcast-qual', qr/passing arg (\d+) of `([^']+)' discards qualifiers from pointer target type$/m ),
-	new GCCWarning( '-Wcast-qual', qr/return discards qualifiers from pointer target type$/m ),
-	new GCCWarning( '-Wcast-qual', qr/assignment discards qualifiers from pointer target type$/m ),
-	new GCCWarning( '-Wcast-qual', qr/assignment makes qualified function pointer from unqualified$/m ),
-	new GCCWarning( '-Wcast-align', qr/padding struct size to alignment boundary$/m ),
-	new GCCWarning( '-Wconversion', qr/negative integer implicitly converted to unsigned type$/m ),
-	new GCCWarning( '-Wconversion', qr/passing arg (\d+) of `([^']+)' makes (integer|pointer) from (integer|pointer) without a cast$/m ),
-	new GCCWarning( '-Wsign-compare', qr/comparison of unsigned expression < 0 is always false$/m ),
-	new GCCWarning( '-Wsign-compare', qr/comparison between signed and unsigned$/m ),
-	new GCCWarning( '-Wsign-compare', qr/signed and unsigned type in conditional expression$/m ),
-	new GCCWarning( '-Waggregate-return', qr/function call has aggregate value$/m ),
-	new GCCWarning( '-Waggregate-return', qr/function returns an aggregate$/m ),
-	new GCCWarning( '-Wstrict-prototypes', qr/non-static declaration for `([^']+)' follows static$/m ),
-	new GCCWarning( '-Wstrict-prototypes', qr/function declaration isn't a prototype$/m ),
-	new GCCWarning( '-Wmissing-prototypes', qr/no previous prototype for `([^']+)'$/m ),
-	new GCCWarning( '-Wmissing-declarations'	=> qr/"([^"]+)" is not defined\s*$/m ),
-	new GCCWarning( '-Wmissing-declarations'	=> qr/`([^']+)' is not defined\s*$/m ),
-	new GCCWarning( '-Wmissing-noreturn', qr/function might be possible candidate for attribute `(noreturn)'$/m ),
-	new GCCWarning( '-Wmissing-noreturn', qr/`([^']+)' function does return$/m ),
-	new GCCWarning( '-Wmissing-format-attribute', qr/function might be possible candidate for `printf' format attribute$/m ),
-	new GCCWarning( '-Wpadded', qr/padding struct to align `([^']+)'$/m ),
-	new GCCWarning( '-Wredundant-decls', qr/redundant redeclaration of `([^']+)' in same scope\n${GCCWarning::prefix_regex}previous declaration of `[^']+'$/m ),
-	new GCCWarning( '-Wnested-externs', qr/nested extern declaration of `([^']+)'$/m ),
-	new GCCWarning( '-Wunreachable-code', qr/will never be executed$/m ),
-	new GCCWarning( '-Winline', qr/inlining failed in call to `([^']+)'\n${GCCWarning::prefix_regex}called from here$/m ),
-
-
-
-
-
-	new GCCWarning( 'traditional', qr/passing arg (\d+) of (?:`([^']+)'|(pointer to function)) with different width due to prototype$/m ),
-	new GCCWarning( 'traditional', qr/passing arg (\d+) of (?:`([^']+)'|(pointer to function)) as (unsigned|signed) due to prototype$/m ),
-	new GCCWarning( 'traditional', qr/passing arg (\d+) of `([^']+)' as `([^']+)' rather than `([^']+)' due to prototype$/m ),
-	new GCCWarning( 'traditional', qr/macro arg `([^']+)' would be stringified with -traditional\.$/m ),
-	new GCCWarning( 'traditional', qr/passing arg (\d+) of `([^']+)' as (floating|integer) rather than (floating|integer) due to prototype$/m ),
-	new GCCWarning( 'traditional', qr/passing arg (\d+) of (?:`([^']+)'|(pointer to function)) as `([^']+)' rather than `([^']+)' due to prototype$/m ),
-	new GCCWarning( 'traditional', qr/passing arg (\d+) of (?:`([^']+)'|(pointer to function)) from incompatible pointer type$/m ),
-
-
-	new GCCWarning( 'deprecated-lvalue', qr/use of (compound|conditional|cast) expressions as lvalues is deprecated$/m ),
-
-	new GCCWarning( 'foo', qr/`([^']+)' declared inside parameter list$/m ),
-	new GCCWarning( 'foo', qr/(assignment|initialization) from incompatible pointer type$/m ),
-	new GCCWarning( 'foo', qr/integer constant is too large for "([^"]+)" type$/m ),
-
-);
-
 # No User Servicable Parts Below
 
 my %disabled;
 
-# <auto-number duplicate entries>
-my %duplicated_warnings;
-for ( my $i = 0; $i < @warning_types; $i++ ) {
-	my $warning = $warning_types[ $i ];
-    my $warning_group = $duplicated_warnings{ $warning->compiler() } ||= {};
-    my $warning_name = $warning->name();
-    if ( !$warning_group->{ $warning_name } ) {
-        $warning_group->{ $warning_name } = $warning;
-    } else {
-        if ( ref( $warning_group->{ $warning_name } ) ) {
-            $warning_group->{ $warning_name }->index( 1 );
-            $warning_group->{ $warning_name } = 2;
-        }
-        $warning->index( $warning_group->{ $warning_name }++ );
-    }
-}
-# </auto-number duplicate entries>
-
-# <create name warning map>
-my %warning_map;
-for ( my $i = 0; $i < @warning_types; $i++ ) {
-    $warning_map{ $warning_types[ $i ]->name() } = $warning_types[ $i ];
-}
-# </create name warning map>
-
-# <create description name map>
-my %description_map;
-for ( my $i = 0; $i < @descriptions; $i++ ) {
-    $description_map{ $descriptions[ $i ]->name() } = $descriptions[ $i ];
-}
-# </create description name map>
-print STDERR Dumper( \%description_map );
-
 #print( STDERR join(',', keys( %warning_types ) )."\n" );
+# <read lines into a single text var>
 my $text;
 my $removeNext = 0;
 while (<>) {
@@ -199,19 +77,24 @@
 	$text .= $_;
 }
 print( STDERR "done loading: " . length( $text ) . "\n" );
+# </read lines into a single text var>
 
 my %file_errors;
 my %error_counts;
 my %errors;
 my $total_errors = 0;
 
-for ( my $i = 0; $i < @warning_types; $i++ ) {
-	my $warning = $warning_types[ $i ];
+for ( my $i = 0; $i < @Registry::warnings; $i++ ) {
+	my $warning = $Registry::warnings[ $i ];
     my $compiler = $warning->compiler();
     my $type = $warning->name();
     my $regex = $warning->regex();
 
-print( STDERR "\t$type\t\t" ) if ( !$disabled{ $compiler } );
+    if ( !$disabled{ $compiler } ) {
+        print( STDERR "\t$type" );
+        print( STDERR '*' ) if ( $warning->get_description() );
+        print( STDERR "\t\t" );
+    }
 	my @matches;
 	my $scanned = '';
 	my $count = 0;
@@ -245,13 +128,9 @@
 print( "\n" );
 foreach my $type ( sort( { $error_counts{ $b } <=> $error_counts{ $a } } keys( %errors ) ) ) {
 	my $h1 = $errors{ $type };
-    my $warning = $warning_map{ $type };
+    my $warning = Registry::get_warning( $type );
 	print( "Type: $type\n" );
-    my $description = $warning->description_text();
-    if ( !$description ) {
-        $description = $description_map{ $warning->shortName() };
-        $description = $description->description() if ( $description );
-    }
+    my $description = $warning->get_description();
     print( "Description:\n" . join( "", map( { "\t$_\n" } split( "\n", $description ) ) ) ) if ( $description );
     print( "Count: $error_counts{ $type }\n" );
 	foreach my $file ( sort( keys( %$h1 ) ) ) {



More information about the kaffe mailing list