summaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gcc.dg/Wcxx-compat-7.c35
-rw-r--r--gcc/testsuite/gcc.dg/Wcxx-compat-8.c43
-rw-r--r--gcc/testsuite/gcc.dg/c99-tag-1.c6
-rw-r--r--gcc/testsuite/gcc.dg/pr17188-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/pr39084.c2
6 files changed, 96 insertions, 9 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e0e92ce27dc..ca5cf9f7cc9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2009-05-10 Ian Lance Taylor <iant@google.com>
+
+ * gcc.dg/Wcxx-compat-7.c: New testcase.
+ * gcc.dg/Wcxx-compat-8.c: New testcase.
+ * gcc.dg/c99-tag-1.c: Recognize new "originally defined here"
+ notes
+ * gcc.dg/pr17188-1.c: Likewise.
+ * gcc.dg/pr39084.c: Likewise.
+
2009-05-10 Michael Matz <matz@suse.de>
PR target/40031
diff --git a/gcc/testsuite/gcc.dg/Wcxx-compat-7.c b/gcc/testsuite/gcc.dg/Wcxx-compat-7.c
new file mode 100644
index 00000000000..bccbd1107b6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wcxx-compat-7.c
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+/* { dg-options "-Wc++-compat" } */
+
+struct s1
+{
+ enum e1 /* { dg-message "note: enum type defined here" } */
+ {
+ A, /* { dg-message "note: enum constant defined here" } */
+ B
+ } f1;
+ struct s2 /* { dg-message "note: struct defined here" } */
+ {
+ struct s3 /* { dg-message "note: struct defined here" } */
+ {
+ enum e1 f3;
+ struct s1 *p1;
+ struct s2 *p2;
+ struct s3 *p3;
+ } f2;
+ union u1 /* { dg-message "note: union defined here" } */
+ {
+ int f4;
+ } f5;
+ struct s3 f6;
+ } f7;
+ struct s2 f8;
+ enum e1 f9;
+};
+
+struct s1 v1;
+enum e1 v2; /* { dg-warning "not visible in C\[+\]\[+\]" } */
+struct s2 v3; /* { dg-warning "not visible in C\[+\]\[+\]" } */
+struct s3 v4; /* { dg-warning "not visible in C\[+\]\[+\]" } */
+union u1 v5; /* { dg-warning "not visible in C\[+\]\[+\]" } */
+int i = A; /* { dg-warning "not visible in C\[+\]\[+\]" } */
diff --git a/gcc/testsuite/gcc.dg/Wcxx-compat-8.c b/gcc/testsuite/gcc.dg/Wcxx-compat-8.c
new file mode 100644
index 00000000000..a7343ba91e6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wcxx-compat-8.c
@@ -0,0 +1,43 @@
+/* { dg-do compile } */
+/* { dg-options "-Wc++-compat" } */
+
+struct s1
+{
+ enum e1 /* { dg-message "note: enum type defined here" } */
+ {
+ A = sizeof (struct s2 { int i; }), /* { dg-warning "invalid in C\[+\]\[+\]" } */
+ B
+ } f1;
+};
+struct s2 v1; /* Don't issue another warning about s2. */
+enum e1 v2; /* { dg-warning "not visible in C\[+\]\[+\]" } */
+
+enum e2
+{
+ C = sizeof (struct s3 { int i; }), /* { dg-warning "invalid in C\[+\]\[+\]" } */
+ D = __alignof__ (struct s4 { int i; }), /* { dg-warning "invalid in C\[+\]\[+\]" } */
+ E
+};
+
+struct s3 v3;
+int v4 = C;
+
+__typeof__ (struct s5 { int i; }) v5; /* { dg-warning "invalid in C\[+\]\[+\]" } */
+
+int
+f1 (struct s1 *p)
+{
+ return ((struct s6 { int j; } *) p)->j; /* { dg-warning "invalid in C\[+\]\[+\]" } */
+}
+
+int
+f2 (struct s1 *p)
+{
+ return (__extension__ (struct s7 { int j; } *)p)->j;
+}
+
+int
+f3 ()
+{
+ return (struct s8 { int i; }) { 0 }.i; /* { dg-warning "invalid in C\[+\]\[+\]" } */
+}
diff --git a/gcc/testsuite/gcc.dg/c99-tag-1.c b/gcc/testsuite/gcc.dg/c99-tag-1.c
index e93d3bcf0b4..dd525317d03 100644
--- a/gcc/testsuite/gcc.dg/c99-tag-1.c
+++ b/gcc/testsuite/gcc.dg/c99-tag-1.c
@@ -24,7 +24,7 @@ foo (void)
/* A specific type shall have its content defined at most once. But we
may redeclare the tag in different scopes. */
{
- struct s0 { int i; };
+ struct s0 { int i; }; /* { dg-message "note: originally defined here" } */
{
struct s0 { long l; };
}
@@ -33,7 +33,7 @@ foo (void)
}
struct s0 { int i; }; /* { dg-bogus "warning" "warning in place of error" } */
/* { dg-error "rede" "struct redef" { target *-*-* } 34 } */
- union u0 { int i; };
+ union u0 { int i; }; /* { dg-message "note: originally defined here" } */
{
union u0 { long l; };
}
@@ -42,7 +42,7 @@ foo (void)
}
union u0 { int i; }; /* { dg-bogus "warning" "warning in place of error" } */
/* { dg-error "rede" "union redef" { target *-*-* } 43 } */
- enum e0 { E0A };
+ enum e0 { E0A }; /* { dg-message "note: originally defined here" } */
{
enum e0 { E0B };
}
diff --git a/gcc/testsuite/gcc.dg/pr17188-1.c b/gcc/testsuite/gcc.dg/pr17188-1.c
index 2cad0120fa4..522a14f7d75 100644
--- a/gcc/testsuite/gcc.dg/pr17188-1.c
+++ b/gcc/testsuite/gcc.dg/pr17188-1.c
@@ -5,20 +5,20 @@
/* { dg-do compile } */
/* { dg-options "" } */
-struct s0 { };
+struct s0 { }; /* { dg-message "note: originally defined here" } */
struct s0;
struct s0 { }; /* { dg-error "redefinition of 'struct s0'" } */
-struct s1 { };
+struct s1 { }; /* { dg-message "note: originally defined here" } */
struct s1 { }; /* { dg-error "redefinition of 'struct s1'" } */
-struct s2 { int a : 1; };
+struct s2 { int a : 1; }; /* { dg-message "note: originally defined here" } */
struct s2 { int a : 1; }; /* { dg-error "redefinition of 'struct s2'" } */
-struct s3 { };
+struct s3 { }; /* { dg-message "note: originally defined here" } */
struct s3 { int a : 1; }; /* { dg-error "redefinition of 'struct s3'" } */
-struct s4 { int a : 1; };
+struct s4 { int a : 1; }; /* { dg-message "note: originally defined here" } */
struct s4 { }; /* { dg-error "redefinition of 'struct s4'" } */
struct s5 { int a : 1; };
diff --git a/gcc/testsuite/gcc.dg/pr39084.c b/gcc/testsuite/gcc.dg/pr39084.c
index 6432841fb15..ff731492154 100644
--- a/gcc/testsuite/gcc.dg/pr39084.c
+++ b/gcc/testsuite/gcc.dg/pr39084.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
/* { dg-options "-O2" } */
-struct color { int i; };
+struct color { int i; }; /* { dg-message "note: originally defined here" } */
static const struct color col;
struct color * f(void)
{