Rationalise some tests.

Neil Booth neilb@earthling.net
Mon Dec 4 14:52:00 GMT 2000


I've added some other tests for excess tokens at the end of
directives, like the case Jason found, and moved all existing cases
under a new file extratokens.c.

Also, moved the 2 template C++ tests to g++.pt as Jason requested.

Neil.

	* g++.old-deja/g++.other/instan1.C, instan2.C: Move to...
	* g++.old-deja/g++.pt/instantiate1.C, instantiate2.C: ...here.
	* gcc.dg/cpp/19960224-2.c, endif.c, if-6.c: Move into...
	* gcc.dg/cpp/extratokens.c: ...here.

Index: g++.old-deja/g++.other/instan2.C
===================================================================
RCS file: instan2.C
diff -N instan2.C
--- /sourceware/cvs-tmp/cvsgRkBwe	Mon Dec  4 14:48:55 2000
+++ /dev/null	Tue May  5 13:32:27 1998
@@ -1,15 +0,0 @@
-// Build don't link:
-// Origin: Neil Booth, from bug report #44
-
-#include <iterator>
-
-template<class T>
-struct X
-{
-};
-
-template<class T>
-X<T> operator+(const X<T>&, const X<T>&);
-
-template<>
-X<int> operator+<int>(const X<int>&, const X<int>&);
Index: g++.old-deja/g++.other/instan3.C
===================================================================
RCS file: instan3.C
diff -N instan3.C
--- /sourceware/cvs-tmp/cvsY10dyi	Mon Dec  4 14:48:55 2000
+++ /dev/null	Tue May  5 13:32:27 1998
@@ -1,65 +0,0 @@
-// Build don't link:
-// Origin: Neil Booth, from bug report #36
-
-template <typename t> class vect;
-template <typename t> vect<t> operator-( const vect<t>&, const vect<t>& );
-
-template <typename t>
-class vect
-{
-public:
-  vect( t a );
-
-  vect( const vect<t>& v );
-  ~vect();
-
-  vect<t>& operator=( const vect<t>& v );
-  vect<t>  operator-( void ) const;
-  friend vect<t> operator- <>( const vect<t>&, const vect<t>& );
-
-private:
-  t a_;
-};
-
-template <typename t> inline
-vect<t>::vect( t a )
-: a_(a)
-{
-}
-
-template <typename t> inline
-vect<t>::vect( const vect<t>& v )
-: a_(v.a_)
-{
-}
-
-template <typename t> inline
-vect<t>::~vect()
-{
-}
-
-template <typename t> inline vect<t>& 
-vect<t>::operator=( const vect<t>& v )
-{
-   a_ = v.a_;
-   return *this;
-}
-
-template <typename t> inline vect<t>
-vect<t>::operator-( void ) const
-{
-  return vect<t>( -a_ );
-}
-
-template <typename t> inline vect<t>
-operator-( const vect<t>& u, const vect<t>& v )
-{
-  return vect<t>( u.a_ - v.a_ );
-}
-
-int
-main( void )
-{
-  vect<double> a( 1.0 ), b( 0.0 );
-  b = -a;
-}
Index: g++.old-deja/g++.pt/instantiate10.C
===================================================================
RCS file: instantiate10.C
diff -N instantiate10.C
--- /dev/null	Tue May  5 13:32:27 1998
+++ instantiate10.C	Mon Dec  4 14:48:49 2000
@@ -0,0 +1,15 @@
+// Build don't link:
+// Origin: Neil Booth, from bug report #44
+
+#include <iterator>
+
+template<class T>
+struct X
+{
+};
+
+template<class T>
+X<T> operator+(const X<T>&, const X<T>&);
+
+template<>
+X<int> operator+<int>(const X<int>&, const X<int>&);
Index: g++.old-deja/g++.pt/instantiate11.C
===================================================================
RCS file: instantiate11.C
diff -N instantiate11.C
--- /dev/null	Tue May  5 13:32:27 1998
+++ instantiate11.C	Mon Dec  4 14:48:49 2000
@@ -0,0 +1,65 @@
+// Build don't link:
+// Origin: Neil Booth, from bug report #36
+
+template <typename t> class vect;
+template <typename t> vect<t> operator-( const vect<t>&, const vect<t>& );
+
+template <typename t>
+class vect
+{
+public:
+  vect( t a );
+
+  vect( const vect<t>& v );
+  ~vect();
+
+  vect<t>& operator=( const vect<t>& v );
+  vect<t>  operator-( void ) const;
+  friend vect<t> operator- <>( const vect<t>&, const vect<t>& );
+
+private:
+  t a_;
+};
+
+template <typename t> inline
+vect<t>::vect( t a )
+: a_(a)
+{
+}
+
+template <typename t> inline
+vect<t>::vect( const vect<t>& v )
+: a_(v.a_)
+{
+}
+
+template <typename t> inline
+vect<t>::~vect()
+{
+}
+
+template <typename t> inline vect<t>& 
+vect<t>::operator=( const vect<t>& v )
+{
+   a_ = v.a_;
+   return *this;
+}
+
+template <typename t> inline vect<t>
+vect<t>::operator-( void ) const
+{
+  return vect<t>( -a_ );
+}
+
+template <typename t> inline vect<t>
+operator-( const vect<t>& u, const vect<t>& v )
+{
+  return vect<t>( u.a_ - v.a_ );
+}
+
+int
+main( void )
+{
+  vect<double> a( 1.0 ), b( 0.0 );
+  b = -a;
+}
Index: gcc.dg/cpp/19960224-2.c
===================================================================
RCS file: 19960224-2.c
diff -N 19960224-2.c
--- /sourceware/cvs-tmp/cvsYgI0yx	Mon Dec  4 14:48:57 2000
+++ /dev/null	Tue May  5 13:32:27 1998
@@ -1,6 +0,0 @@
-/* { dg-do preprocess } */
-
-#if 0
-#if 0
-#endif /	/* { dg-warning "extra tokens" "extra tokens after #endif" } */
-#endif
Index: gcc.dg/cpp/endif.c
===================================================================
RCS file: endif.c
diff -N endif.c
--- /sourceware/cvs-tmp/cvsOUWa7L	Mon Dec  4 14:48:57 2000
+++ /dev/null	Tue May  5 13:32:27 1998
@@ -1,15 +0,0 @@
-/* { dg-do preprocess } */
-/* { dg-options "-pedantic -Wall" } */
-
-/* You can't get away with this in your own code... */
-#ifdef KERNEL
-#define foo
-#endif KERNEL  /* { dg-warning "extra tokens" "good warning" } */
-
-/* This will provoke a warning because the '3' is an extension.  */
-#line 10 "endif-label.c" 3 /* { dg-warning "extra tokens" "#line extension" } */
-
-/* ... but in a system header, it's acceptable.  */
-#ifdef KERNEL
-#define foo
-#endif KERNEL  /* { dg-bogus "extra tokens" "bad warning" } */
Index: gcc.dg/cpp/extratokens.c
===================================================================
RCS file: extratokens.c
diff -N extratokens.c
--- /dev/null	Tue May  5 13:32:27 1998
+++ extratokens.c	Mon Dec  4 14:48:55 2000
@@ -0,0 +1,38 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.  */
+
+/* { dg-do preprocess } */
+/* { dg-options "-fno-show-column" } */
+
+/* Tests all directives that do not permit excess tokens at the end of
+   the line.  */
+
+/* Source: Neil Booth, 4 Dec 2000.  The combination of separate test
+   cases.  */
+
+#ifdef foo bar  /* { dg-error "extra tokens" "tokens after #ifdef" } */
+#endif
+
+#ifndef foo bar  /* { dg-error "extra tokens" "tokens after #ifndef" } */
+#endif
+
+#if 0
+#if 0
+#else foo	/* { dg-warning "extra tokens" "tokens after #else" } */
+#endif /	/* { dg-warning "extra tokens" "tokens after #endif" } */
+#endif
+
+#undef foo bar  /* { dg-error "extra tokens" "tokens after #undef" } */
+
+#assert foo(bar) bar /* { dg-error "extra tokens" "tokens after #assert" } */
+
+#unassert foo(bar) b /* { dg-error "extra tokens" "tokens after #unassert" } */
+
+#include "mi1c.h" bar /* { dg-error "extra tokens" "tokens after #include" } */
+
+#ident "something" bar /* { dg-error "extra tokens" "tokens after #ident" } */
+
+#line 36 "file.c" 3
+
+/* ... but in a system header, it's acceptable.  */
+#ifdef KERNEL
+#endif KERNEL  /* { dg-bogus "extra tokens" "bad warning" } */
Index: gcc.dg/cpp/if-6.c
===================================================================
RCS file: if-6.c
diff -N if-6.c
--- /sourceware/cvs-tmp/cvsUOnzi2	Mon Dec  4 14:48:57 2000
+++ /dev/null	Tue May  5 13:32:27 1998
@@ -1,3 +0,0 @@
-/* { dg-do preprocess } */
-#ifdef foo bar  /* { dg-error "extra tokens" "tokens after #ifdef" } */
-#endif


More information about the Gcc-patches mailing list