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
This commit is contained in:
Kaveh R. Ghazi 2000-08-23 16:13:47 +00:00 committed by Kaveh Ghazi
parent 23d168774e
commit 8a45161343
11 changed files with 233 additions and 0 deletions

View File

@ -1,3 +1,11 @@
2000-08-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* 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 <jsm28@cam.ac.uk>
* gcc.dg/c90-strftime-2.c, gcc.dg/c99-strftime-1.c,

View File

@ -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 <ghazi@caip.rutgers.edu> 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

View File

@ -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 <ghazi@caip.rutgers.edu> 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

View File

@ -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 <ghazi@caip.rutgers.edu> 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;
}

View File

@ -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 <ghazi@caip.rutgers.edu> 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';
}

View File

@ -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 <ghazi@caip.rutgers.edu> 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" } */
}

View File

@ -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 <ghazi@caip.rutgers.edu> 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) {}

View File

@ -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 <ghazi@caip.rutgers.edu> 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";
}

View File

@ -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 <ghazi@caip.rutgers.edu> 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;
}
}

View File

@ -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 <ghazi@caip.rutgers.edu> 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;
}

View File

@ -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 <ghazi@caip.rutgers.edu> 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 };
}