This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[TESTSUITE] new test directive dg-message, fixes to use it in C tests
- From: Janis Johnson <janis187 at us dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: lopezibanez at gmail dot com
- Date: Fri, 18 May 2007 17:16:34 -0700
- Subject: [TESTSUITE] new test directive dg-message, fixes to use it in C tests
This patch is part of the fix for PR 25241. It adds new test directive
dg-message, and a procedure that supports that as well as upcoming
overrides of dg-warning and dg-error. This patch also changes all of
the C tests that use dg-error or dg-warning for messages that aren't
really errors or warnings.
Full testing with all languages but Ada is underway on powerpc64-linux.
If that passes and there are no complaints, I'll check this in early
next week along with documentation for dg-message.
2007-05-18 Janis Johnson <janis187@us.ibm.com>
Manuel Lopez-Ibanez <manu@gcc.gnu.org>
* lib/gcc-dg.exp(process_message): New proc.
(dg-message): New test directive.
* gcc.dg/always_inline.c: Use dg-message.
* gcc.dg/always_inline2.c: Ditto.
* gcc.dg/always_inline3.c: Ditto.
* gcc.dg/invalid-call-1.c: Ditto.
* gcc.dg/pr17506.c: Ditto.
* gcc.dg/simd-5.c: Ditto.
* gcc.dg/simd-6.c: Ditto.
* gcc.dg/va-arg-2.c: Ditto.
* gcc.dg/cpp/syshdr.c: Ditto.
* gcc.dg/cpp/unc4.c: Ditto.
* gcc.dg/cpp/trad/mi1.c: Ditto.
* gcc.dg/cpp/trad/mi5.c: Ditto.
* gcc.dg/cpp/trad/mi7.c: Ditto.
Index: gcc/testsuite/lib/gcc-dg.exp
===================================================================
--- gcc/testsuite/lib/gcc-dg.exp (revision 124832)
+++ gcc/testsuite/lib/gcc-dg.exp (working copy)
@@ -559,4 +559,40 @@
}
}
+# Modify the regular expression saved by a DejaGnu message directive to
+# include a prefix and to force the expression to match a single line.
+# MSGPROC is the procedure to call.
+# MSGPREFIX is the prefix to prepend.
+# DGARGS is the original argument list.
+
+proc process-message { msgproc msgprefix dgargs } {
+ upvar dg-messages dg-messages
+
+ # Process the dg- directive, including adding the regular expression
+ # to the new message entry in dg-messages.
+ set msgcnt [llength ${dg-messages}]
+ catch { eval $msgproc $dgargs }
+
+ # If the target expression wasn't satisfied there is no new message.
+ if { [llength ${dg-messages}] == $msgcnt } {
+ return;
+ }
+
+ # Prepend the message prefix to the regular expression and make
+ # it match a single line.
+ set newentry [lindex ${dg-messages} end]
+ set expmsg [lindex $newentry 2]
+ set expmsg "$msgprefix\[^\n]*$expmsg"
+ set newentry [lreplace $newentry 2 2 $expmsg]
+ set dg-messages [lreplace ${dg-messages} end end $newentry]
+ verbose "process-message:\n${dg-messages}" 2
+}
+
+# Look for messages that don't have standard prefixes.
+
+proc dg-message { args } {
+ upvar dg-messages dg-messages
+ process-message dg-warning "" $args
+}
+
set additional_prunes ""
Index: gcc/testsuite/gcc.dg/always_inline.c
===================================================================
--- gcc/testsuite/gcc.dg/always_inline.c (revision 124832)
+++ gcc/testsuite/gcc.dg/always_inline.c (working copy)
@@ -3,7 +3,7 @@
#include <stdarg.h>
inline __attribute__ ((always_inline)) void
e(int t, ...)
-{ /* { dg-error "variable argument" "" } */
+{ /* { dg-message "variable argument" "" } */
va_list q;
va_start (q, t);
}
Index: gcc/testsuite/gcc.dg/always_inline2.c
===================================================================
--- gcc/testsuite/gcc.dg/always_inline2.c (revision 124832)
+++ gcc/testsuite/gcc.dg/always_inline2.c (working copy)
@@ -1,8 +1,8 @@
/* { dg-do compile } */
/* { dg-options "-Winline -O2" } */
-inline __attribute__ ((always_inline)) void t(void); /* { dg-error "body not available" "" } */
+inline __attribute__ ((always_inline)) void t(void); /* { dg-message "body not available" "" } */
void
q(void)
{
- t(); /* { dg-error "called from here" "" } */
+ t(); /* { dg-message "called from here" "" } */
}
Index: gcc/testsuite/gcc.dg/always_inline3.c
===================================================================
--- gcc/testsuite/gcc.dg/always_inline3.c (revision 124832)
+++ gcc/testsuite/gcc.dg/always_inline3.c (working copy)
@@ -3,9 +3,9 @@
int do_something_evil (void);
inline __attribute__ ((always_inline)) void
q2(void)
-{ /* { dg-error "recursive" "" } */
+{ /* { dg-message "recursive" "" } */
if (do_something_evil ())
return;
- q2(); /* { dg-error "called from here" "" } */
+ q2(); /* { dg-message "called from here" "" } */
q2(); /* With -O2 we don't warn here, it is eliminated by tail recursion. */
}
Index: gcc/testsuite/gcc.dg/invalid-call-1.c
===================================================================
--- gcc/testsuite/gcc.dg/invalid-call-1.c (revision 124832)
+++ gcc/testsuite/gcc.dg/invalid-call-1.c (working copy)
@@ -13,5 +13,5 @@
void foo()
{
cptr = mar(6);
- ((char *(*)(void *,int (*)(void *,unsigned char **),char**))((fp)bar))(0,0,(void*)(0)); /* { dg-warning "" "non-compatible type" } */
+ ((char *(*)(void *,int (*)(void *,unsigned char **),char**))((fp)bar))(0,0,(void*)(0)); /* { dg-message "" "non-compatible type" } */
}
Index: gcc/testsuite/gcc.dg/pr17506.c
===================================================================
--- gcc/testsuite/gcc.dg/pr17506.c (revision 124832)
+++ gcc/testsuite/gcc.dg/pr17506.c (working copy)
@@ -18,7 +18,7 @@
void
bar (void)
{
- int j; /* { dg-error "note: 'j' was declared here" } */
+ int j; /* { dg-message "note: 'j' was declared here" } */
for (; foo (j); ++j)
baz ();
}
Index: gcc/testsuite/gcc.dg/simd-5.c
===================================================================
--- gcc/testsuite/gcc.dg/simd-5.c (revision 124832)
+++ gcc/testsuite/gcc.dg/simd-5.c (working copy)
@@ -4,4 +4,5 @@
/* Ensure that we don't need a typedef to initialize a vector type. */
#define vector __attribute__ ((vector_size (8)))
vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" } */
-vector char y = (vector short) {1,2,3,4}; /* { dg-error "use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts.*incompatible types in initialization" } */
+vector char y = (vector short) {1,2,3,4}; /* { dg-message "use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts" } */
+ /* { dg-error "incompatible types in initialization" "" { target *-*-* } 7 } */
Index: gcc/testsuite/gcc.dg/simd-6.c
===================================================================
--- gcc/testsuite/gcc.dg/simd-6.c (revision 124832)
+++ gcc/testsuite/gcc.dg/simd-6.c (working copy)
@@ -4,4 +4,5 @@
/* Ensure that we don't need a typedef to initialize a vector type. */
#define vector __attribute__ ((vector_size (8)))
vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" } */
-vector char y = (vector short) {1,2,3,4}; /* { dg-error "use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts.*incompatible types in initialization" } */
+vector char y = (vector short) {1,2,3,4}; /* { dg-message "use -flax-vector-conversions to permit conversions between vectors with differing element types or numbers of subparts" } */
+ /* { dg-message "incompatible types in initialization" "" { target *-*-* } 7 } */
Index: gcc/testsuite/gcc.dg/va-arg-2.c
===================================================================
--- gcc/testsuite/gcc.dg/va-arg-2.c (revision 124832)
+++ gcc/testsuite/gcc.dg/va-arg-2.c (working copy)
@@ -5,7 +5,7 @@
#include <varargs.h> /* { dg-bogus "varargs.h" "missing file" } */
-/* { dg-error "" "In file included from" { target *-*-* } 6 } */
+/* { dg-message "" "In file included from" { target *-*-* } 6 } */
/* { dg-error "no longer implements" "#error 1" { target *-*-* } 4 } */
/* { dg-error "Revise your code" "#error 2" { target *-*-* } 5 } */
Index: gcc/testsuite/gcc.dg/cpp/syshdr.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/syshdr.c (revision 124832)
+++ gcc/testsuite/gcc.dg/cpp/syshdr.c (working copy)
@@ -8,5 +8,5 @@
/* { dg-do preprocess } */
/* { dg-error "include_next" "good error" { target *-*-* } 4 } */
-#include "syshdr1.h" /* { dg-error "" "In file included from:" } */
+#include "syshdr1.h" /* { dg-message "" "In file included from:" } */
#include "syshdr2.h"
Index: gcc/testsuite/gcc.dg/cpp/unc4.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/unc4.c (revision 124832)
+++ gcc/testsuite/gcc.dg/cpp/unc4.c (working copy)
@@ -32,7 +32,7 @@
message. */
#define FOO
#ifdef FOO /* { dg-bogus "unterminated" "nested unterm" } */
-#include "unc1.c" /* { dg-error "" } */
+#include "unc1.c" /* { dg-message "file included from" "" { target *-*-* } 0 } */
#endif
/* dg.exp doesn't read the included files for tags, so we have to
Index: gcc/testsuite/gcc.dg/cpp/trad/mi1.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/trad/mi1.c (revision 124832)
+++ gcc/testsuite/gcc.dg/cpp/trad/mi1.c (working copy)
@@ -13,7 +13,7 @@
/* { dg-do compile }
{ dg-options "-H -traditional-cpp" }
- { dg-error "mi1c\.h\n\[^\n\]*mi1nd\.h\n\[^\n\]*mi1ndp\.h\n\[^\n\]*mi1x\.h" "redundant include check" { target *-*-* } 0 } */
+ { dg-message "mi1c\.h\n\[^\n\]*mi1nd\.h\n\[^\n\]*mi1ndp\.h\n\[^\n\]*mi1x\.h" "redundant include check" { target *-*-* } 0 } */
#include "mi1c.h"
#include "mi1c.h"
Index: gcc/testsuite/gcc.dg/cpp/trad/mi5.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/trad/mi5.c (revision 124832)
+++ gcc/testsuite/gcc.dg/cpp/trad/mi5.c (working copy)
@@ -7,7 +7,7 @@
/* { dg-do preprocess }
{ dg-options "-H -C -traditional-cpp" }
- { dg-error "mi1c\.h" "redundant include check with -C" { target *-*-* } 0 } */
+ { dg-message "mi1c\.h" "redundant include check with -C" { target *-*-* } 0 } */
#include "mi1c.h"
#include "mi1c.h"
Index: gcc/testsuite/gcc.dg/cpp/trad/mi7.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/trad/mi7.c (revision 124832)
+++ gcc/testsuite/gcc.dg/cpp/trad/mi7.c (working copy)
@@ -11,7 +11,7 @@
/* { dg-do preprocess }
{ dg-options "-H -traditional-cpp" }
- { dg-error "mi7a\.h\n\[^\n\]*mi7a\.h\n\[^\n\]*mi7b\.h\n\[^\n\]*mi7b\.h" "redundant include check" { target *-*-* } 0 } */
+ { dg-message "mi7a\.h\n\[^\n\]*mi7a\.h\n\[^\n\]*mi7b\.h\n\[^\n\]*mi7b\.h" "redundant include check" { target *-*-* } 0 } */
#include "mi7a.h"
#include "mi7a.h"