From 8a451613436b38938d577b0f2d0b8896b3141893 Mon Sep 17 00:00:00 2001 From: "Kaveh R. Ghazi" Date: Wed, 23 Aug 2000 16:13:47 +0000 Subject: [PATCH] tr-warn4.c, [...]: New tests. * gcc.dg/cpp/tr-warn4.c, gcc.dg/cpp/tr-warn5.c, gcc.dg/wtr-aggr-init-1.c, gcc.dg/wtr-escape-1.c, gcc.dg/wtr-int-type-1.c, gcc.dg/wtr-static-1.c, gcc.dg/wtr-strcat-1.c, gcc.dg/wtr-switch-1.c, gcc.dg/wtr-unary-plus-1.c, gcc.dg/wtr-union-init-1.c: New tests. From-SVN: r35913 --- gcc/testsuite/ChangeLog | 8 ++++++ gcc/testsuite/gcc.dg/cpp/tr-warn4.c | 26 +++++++++++++++++ gcc/testsuite/gcc.dg/cpp/tr-warn5.c | 14 +++++++++ gcc/testsuite/gcc.dg/wtr-aggr-init-1.c | 38 +++++++++++++++++++++++++ gcc/testsuite/gcc.dg/wtr-escape-1.c | 22 ++++++++++++++ gcc/testsuite/gcc.dg/wtr-int-type-1.c | 24 ++++++++++++++++ gcc/testsuite/gcc.dg/wtr-static-1.c | 14 +++++++++ gcc/testsuite/gcc.dg/wtr-strcat-1.c | 18 ++++++++++++ gcc/testsuite/gcc.dg/wtr-switch-1.c | 24 ++++++++++++++++ gcc/testsuite/gcc.dg/wtr-unary-plus-1.c | 20 +++++++++++++ gcc/testsuite/gcc.dg/wtr-union-init-1.c | 25 ++++++++++++++++ 11 files changed, 233 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/cpp/tr-warn4.c create mode 100644 gcc/testsuite/gcc.dg/cpp/tr-warn5.c create mode 100644 gcc/testsuite/gcc.dg/wtr-aggr-init-1.c create mode 100644 gcc/testsuite/gcc.dg/wtr-escape-1.c create mode 100644 gcc/testsuite/gcc.dg/wtr-int-type-1.c create mode 100644 gcc/testsuite/gcc.dg/wtr-static-1.c create mode 100644 gcc/testsuite/gcc.dg/wtr-strcat-1.c create mode 100644 gcc/testsuite/gcc.dg/wtr-switch-1.c create mode 100644 gcc/testsuite/gcc.dg/wtr-unary-plus-1.c create mode 100644 gcc/testsuite/gcc.dg/wtr-union-init-1.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 45221fb5c7d..3eb6b803d42 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2000-08-23 Kaveh R. Ghazi + + * gcc.dg/cpp/tr-warn4.c, gcc.dg/cpp/tr-warn5.c, + gcc.dg/wtr-aggr-init-1.c, gcc.dg/wtr-escape-1.c, + gcc.dg/wtr-int-type-1.c, gcc.dg/wtr-static-1.c, + gcc.dg/wtr-strcat-1.c, gcc.dg/wtr-switch-1.c, + gcc.dg/wtr-unary-plus-1.c, gcc.dg/wtr-union-init-1.c: New tests. + 2000-08-22 Joseph S. Myers * gcc.dg/c90-strftime-2.c, gcc.dg/c99-strftime-1.c, diff --git a/gcc/testsuite/gcc.dg/cpp/tr-warn4.c b/gcc/testsuite/gcc.dg/cpp/tr-warn4.c new file mode 100644 index 00000000000..108397761d9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/tr-warn4.c @@ -0,0 +1,26 @@ +/* Test for -Wtraditional warnings on integer constant suffixes. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do preprocess } */ +/* { dg-options "-Wtraditional -fno-show-column" } */ + +#if 1U /* { dg-warning "traditional C rejects.*suffix" "numeric constant suffix" } */ +#endif +#if 1u /* { dg-warning "traditional C rejects.*suffix" "numeric constant suffix" } */ +#endif +#if 1L +#endif +#if 1l +#endif + +#line 17 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + +#if 1U +#endif +#if 1u +#endif +#if 1L +#endif +#if 1l +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/tr-warn5.c b/gcc/testsuite/gcc.dg/cpp/tr-warn5.c new file mode 100644 index 00000000000..ab301b3aa07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/tr-warn5.c @@ -0,0 +1,14 @@ +/* Test for -Wtraditional warnings on the unary plus operator. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do preprocess } */ +/* { dg-options "-Wtraditional -fno-show-column" } */ + +#if +1 /* { dg-warning "unary plus operator" "unary plus operator" } */ +#endif + +#line 11 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + +#if +1 +#endif diff --git a/gcc/testsuite/gcc.dg/wtr-aggr-init-1.c b/gcc/testsuite/gcc.dg/wtr-aggr-init-1.c new file mode 100644 index 00000000000..259716e5e42 --- /dev/null +++ b/gcc/testsuite/gcc.dg/wtr-aggr-init-1.c @@ -0,0 +1,38 @@ +/* Test for -Wtraditional warnings on automatic aggregate initialization. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +struct foo +{ + int i; + long l; +}; + +struct foo f0 = { 0, 0 }; +static struct foo f1 = { 0, 0 }; + +void +testfunc1 (void) +{ + struct foo f3 = { 0, 0 }; /* { dg-warning "traditional C rejects automatic" "automatic aggregate initialization" } */ + static struct foo f4 = { 0, 0 }; + + f3 = f4; +} + +#line 26 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + +struct foo f5 = { 0, 0 }; +static struct foo f6 = { 0, 0 }; + +void +testfunc2 (void) +{ + struct foo f7 = { 0, 0 }; + static struct foo f8 = { 0, 0 }; + + f7 = f8; +} diff --git a/gcc/testsuite/gcc.dg/wtr-escape-1.c b/gcc/testsuite/gcc.dg/wtr-escape-1.c new file mode 100644 index 00000000000..a83bdc5117a --- /dev/null +++ b/gcc/testsuite/gcc.dg/wtr-escape-1.c @@ -0,0 +1,22 @@ +/* Test for -Wtraditional warnings on escape characters. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +void +testfunc (void) +{ + char c; + + c = '\a'; /* { dg-warning "the meaning of" "escaped character warning " } */ + c = '\x2'; /* { dg-warning "the meaning of" "escaped character warning " } */ + c = '\n'; + +#line 17 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + c = '\a'; + c = '\x2'; + c = '\n'; +} diff --git a/gcc/testsuite/gcc.dg/wtr-int-type-1.c b/gcc/testsuite/gcc.dg/wtr-int-type-1.c new file mode 100644 index 00000000000..27ab1441001 --- /dev/null +++ b/gcc/testsuite/gcc.dg/wtr-int-type-1.c @@ -0,0 +1,24 @@ +/* Test for -Wtraditional warnings on integer constant types. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +void +testfunc (void) +{ + long long i; + + i = 0x80000000; + i = 0x8000000000000000; + i = 9223372036854775807; /* { dg-warning "integer constant.*with -traditional" "integer constant" } */ + i = 4294967295; /* { dg-warning "decimal constant|integer constant.*with -traditional" "integer constant" } */ + +#line 18 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + i = 0x80000000; + i = 0x8000000000000000; + i = 9223372036854775807; + i = 4294967295; /* { dg-warning "decimal constant" "decimal constant" } */ +} diff --git a/gcc/testsuite/gcc.dg/wtr-static-1.c b/gcc/testsuite/gcc.dg/wtr-static-1.c new file mode 100644 index 00000000000..676b48231e4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/wtr-static-1.c @@ -0,0 +1,14 @@ +/* Test for -Wtraditional warnings on static/non-static mismatches. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +static void testfunc1(void); +void testfunc1(void) {} /* { dg-warning "non-static.*follows static" "non-static follows static" } */ + +#line 11 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + +static void testfunc2(void); +void testfunc2(void) {} diff --git a/gcc/testsuite/gcc.dg/wtr-strcat-1.c b/gcc/testsuite/gcc.dg/wtr-strcat-1.c new file mode 100644 index 00000000000..06806b13347 --- /dev/null +++ b/gcc/testsuite/gcc.dg/wtr-strcat-1.c @@ -0,0 +1,18 @@ +/* Test for -Wtraditional warnings on string concatenation. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +void +testfunc (void) +{ + const char *foo; + + foo = "hello" "hello"; /* { dg-warning "string concatenation" "string concatenation" } */ + +#line 15 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + foo = "hello" "hello"; +} diff --git a/gcc/testsuite/gcc.dg/wtr-switch-1.c b/gcc/testsuite/gcc.dg/wtr-switch-1.c new file mode 100644 index 00000000000..c42cdb11031 --- /dev/null +++ b/gcc/testsuite/gcc.dg/wtr-switch-1.c @@ -0,0 +1,24 @@ +/* Test for -Wtraditional warnings on switch operands of type long. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +void +testfunc (long l) +{ + switch (l) /* { dg-warning "switch expression" "switch expression" } */ + { + default: + break; + } + +#line 17 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + switch (l) + { + default: + break; + } +} diff --git a/gcc/testsuite/gcc.dg/wtr-unary-plus-1.c b/gcc/testsuite/gcc.dg/wtr-unary-plus-1.c new file mode 100644 index 00000000000..ec3cd19fa19 --- /dev/null +++ b/gcc/testsuite/gcc.dg/wtr-unary-plus-1.c @@ -0,0 +1,20 @@ +/* Test for -Wtraditional warnings on the unary plus operator. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +void +testfunc (void) +{ + int i; + + i = +1; /* { dg-warning "unary plus operator" "unary plus operator" } */ + i = +i; /* { dg-warning "unary plus operator" "unary plus operator" } */ + +#line 16 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + i = +1; + i = +i; +} diff --git a/gcc/testsuite/gcc.dg/wtr-union-init-1.c b/gcc/testsuite/gcc.dg/wtr-union-init-1.c new file mode 100644 index 00000000000..1f00069d510 --- /dev/null +++ b/gcc/testsuite/gcc.dg/wtr-union-init-1.c @@ -0,0 +1,25 @@ +/* Test for -Wtraditional warnings on union initialization. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +union foo +{ + int i; + long l; +}; + +void +testfunc (void) +{ + /* Note we only warn for non-zero initializers. */ + static union foo f1 = { 0 }; + static union foo f2 = { 1 }; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */ + +#line 21 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + static union foo f3 = { 0 }; + static union foo f4 = { 1 }; +}