From cea24134be6d4996322733862d327a3d40268d2d Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Wed, 18 Jan 2006 15:04:01 -0500 Subject: [PATCH] Werror-1.c, [...]: New. * gcc.dg/Werror-1.c, gcc.dg/Werror-2.c, gcc.dg/Werror-3.c, gcc.dg/Werror-4.c, gcc.dg/Werror-5.c, gcc.dg/Werror-6.c, gcc.dg/Werror-7.c, gcc.dg/Werror-8.c, gcc.dg/Werror-9.c, gcc.dg/Werror-10.c, gcc.dg/Werror-11.c, gcc.dg/Werror-12: New. From-SVN: r109908 --- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gcc.dg/Werror-1.c | 21 +++++++++++++++++++++ gcc/testsuite/gcc.dg/Werror-10.c | 18 ++++++++++++++++++ gcc/testsuite/gcc.dg/Werror-11.c | 18 ++++++++++++++++++ gcc/testsuite/gcc.dg/Werror-12.c | 17 +++++++++++++++++ gcc/testsuite/gcc.dg/Werror-2.c | 16 ++++++++++++++++ gcc/testsuite/gcc.dg/Werror-3.c | 15 +++++++++++++++ gcc/testsuite/gcc.dg/Werror-4.c | 17 +++++++++++++++++ gcc/testsuite/gcc.dg/Werror-5.c | 16 ++++++++++++++++ gcc/testsuite/gcc.dg/Werror-6.c | 15 +++++++++++++++ gcc/testsuite/gcc.dg/Werror-7.c | 16 ++++++++++++++++ gcc/testsuite/gcc.dg/Werror-8.c | 17 +++++++++++++++++ gcc/testsuite/gcc.dg/Werror-9.c | 17 +++++++++++++++++ 13 files changed, 210 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/Werror-1.c create mode 100644 gcc/testsuite/gcc.dg/Werror-10.c create mode 100644 gcc/testsuite/gcc.dg/Werror-11.c create mode 100644 gcc/testsuite/gcc.dg/Werror-12.c create mode 100644 gcc/testsuite/gcc.dg/Werror-2.c create mode 100644 gcc/testsuite/gcc.dg/Werror-3.c create mode 100644 gcc/testsuite/gcc.dg/Werror-4.c create mode 100644 gcc/testsuite/gcc.dg/Werror-5.c create mode 100644 gcc/testsuite/gcc.dg/Werror-6.c create mode 100644 gcc/testsuite/gcc.dg/Werror-7.c create mode 100644 gcc/testsuite/gcc.dg/Werror-8.c create mode 100644 gcc/testsuite/gcc.dg/Werror-9.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f7973945267..deca25d9850 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2006-01-18 DJ Delorie + + * gcc.dg/Werror-1.c, gcc.dg/Werror-2.c, gcc.dg/Werror-3.c, + gcc.dg/Werror-4.c, gcc.dg/Werror-5.c, gcc.dg/Werror-6.c, + gcc.dg/Werror-7.c, gcc.dg/Werror-8.c, gcc.dg/Werror-9.c, + gcc.dg/Werror-10.c, gcc.dg/Werror-11.c, gcc.dg/Werror-12: New. + 2006-01-18 Jeff Law * gcc.c-torture/execute/930529-1.x: Use -fwrapv as test depends diff --git a/gcc/testsuite/gcc.dg/Werror-1.c b/gcc/testsuite/gcc.dg/Werror-1.c new file mode 100644 index 00000000000..d50e07c45f2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Walways-true -Wattributes -Werror" } */ +/* { dg-warning "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +/* This is the first in a series of test cases that test the + interaction between -Wfoo, -Werror, -Werror=foo, and #pragma GCC + diagnostic error foo. This one has all the bits we're testing, the + others are subsets of this one. */ + +#pragma GCC diagnostic error "-Walways-true" + +void __attribute__((dj)) bar() { } /* { dg-warning "warning: .* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-error "error: .* will always evaluate as 'true'" } */ + grill (); +} diff --git a/gcc/testsuite/gcc.dg/Werror-10.c b/gcc/testsuite/gcc.dg/Werror-10.c new file mode 100644 index 00000000000..3e2c9dffa4f --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-10.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes -Werror" } */ +/* { dg-warning "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +/* Make sure #pragma can work with -Werror. */ + +#pragma GCC diagnostic error "-Walways-true" + +void __attribute__((dj)) bar() { } /* { dg-warning "warning: .* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-error "error: .* will always evaluate as 'true'" } */ + grill (); +} diff --git a/gcc/testsuite/gcc.dg/Werror-11.c b/gcc/testsuite/gcc.dg/Werror-11.c new file mode 100644 index 00000000000..14aae3129f8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-11.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes -Werror" } */ +/* { dg-warning "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +/* Make sure #pragma can override -Werror. */ + +#pragma GCC diagnostic warning "-Walways-true" + +void __attribute__((dj)) bar() { } /* { dg-warning "warning: .* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-warning "warning: .* will always evaluate as 'true'" } */ + grill (); +} diff --git a/gcc/testsuite/gcc.dg/Werror-12.c b/gcc/testsuite/gcc.dg/Werror-12.c new file mode 100644 index 00000000000..0cb1f78f805 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-12.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes -Walways-true" } */ + +/* Make sure #pragma can override -Wfoo. */ + +#pragma GCC diagnostic ignored "-Walways-true" + +void __attribute__((dj)) bar() { } /* { dg-warning "attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-bogus "true" } */ + grill (); +} diff --git a/gcc/testsuite/gcc.dg/Werror-2.c b/gcc/testsuite/gcc.dg/Werror-2.c new file mode 100644 index 00000000000..8e08ba0857e --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-2.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* This one is the baseline. Make sure with no option we get no + warnings. */ + +void __attribute__((dj)) bar() { } /* { dg-warning "warning: .* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) + grill (); +} diff --git a/gcc/testsuite/gcc.dg/Werror-3.c b/gcc/testsuite/gcc.dg/Werror-3.c new file mode 100644 index 00000000000..a994714446c --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-3.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Walways-true -Wattributes" } */ + +/* Make sure the command line option enables the warning. */ + +void __attribute__((dj)) bar() { } /* { dg-warning "warning: .* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-warning "warning: .* will always evaluate as 'true'" } */ + grill (); +} diff --git a/gcc/testsuite/gcc.dg/Werror-4.c b/gcc/testsuite/gcc.dg/Werror-4.c new file mode 100644 index 00000000000..45d217b3233 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-4.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes" } */ + +/* Make sure the pragma enables the error. */ + +#pragma GCC diagnostic error "-Walways-true" + +void __attribute__((dj)) bar() { } /* { dg-warning "warning: .* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-error "error: .* will always evaluate as 'true'" } */ + grill (); +} diff --git a/gcc/testsuite/gcc.dg/Werror-5.c b/gcc/testsuite/gcc.dg/Werror-5.c new file mode 100644 index 00000000000..39125904dfa --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-5.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Walways-true -Wattributes -Werror" } */ +/* { dg-warning "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +/* Make sure -Werror turns warnings in to errors. */ + +void __attribute__((dj)) bar() { } /* { dg-warning "warning: .* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-warning "warning: .* will always evaluate as 'true'" } */ + grill (); +} diff --git a/gcc/testsuite/gcc.dg/Werror-6.c b/gcc/testsuite/gcc.dg/Werror-6.c new file mode 100644 index 00000000000..11f28b0aa6a --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-6.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes -Werror=always-true" } */ + +/* Make sure -Werror-foo emits an error and not a warning */ + +void __attribute__((dj)) bar() { } /* { dg-warning "warning: .* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-error "error: .* will always evaluate as 'true'" } */ + grill (); +} diff --git a/gcc/testsuite/gcc.dg/Werror-7.c b/gcc/testsuite/gcc.dg/Werror-7.c new file mode 100644 index 00000000000..e6671991f5a --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-7.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Walways-true -Werror -Wno-error=always-true -Wattributes" } */ +/* { dg-warning "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +/* Make sure -Wno-error= overrides -Werror. */ + +void __attribute__((dj)) bar() { } /* { dg-warning "warning: .* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-warning "warning: .* will always evaluate as 'true'" } */ + grill (); +} diff --git a/gcc/testsuite/gcc.dg/Werror-8.c b/gcc/testsuite/gcc.dg/Werror-8.c new file mode 100644 index 00000000000..ec70a2e8eab --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-8.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes" } */ + +/* Make sure #pragma can enable a warning. */ + +#pragma GCC diagnostic warning "-Walways-true" + +void __attribute__((dj)) bar() { } /* { dg-warning "warning: .* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-warning "warning: .* will always evaluate as 'true'" } */ + grill (); +} diff --git a/gcc/testsuite/gcc.dg/Werror-9.c b/gcc/testsuite/gcc.dg/Werror-9.c new file mode 100644 index 00000000000..5b287793f55 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Werror-9.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes" } */ + +/* Make sure #pragma can enable a warning as an error. */ + +#pragma GCC diagnostic error "-Walways-true" + +void __attribute__((dj)) bar() { } /* { dg-warning "warning: .* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-error "error: .* will always evaluate as 'true'" } */ + grill (); +}