re PR preprocessor/22168 (#if #A == #B should have a diagnostic in ISO C mode)

libcpp
	PR preprocessor/22168:
	* include/cpplib.h (struct cpp_options) <objc>: Update
	documentation.
	* expr.c (eval_token): Warn for use of assertions.
	* directives.c (directive_diagnostics): Warn about extensions.
	(DEPRECATED): New define.
	(DIRECTIVE_TABLE): Use it.
gcc
	PR preprocessor/22168:
	* doc/cpp.texi (Top): Update menu.
	(Alternatives to Wrapper #ifndef): New node.
	(Other Directives): Document deprecation.
	(Obsolete Features): Remove menu.
	(Assertions): Merge node into Obsolete Features.
	(Obsolete once-only headers): Move earlier; rename to Alternatives
	to Wrapper #ifndef.
	* doc/cppopts.texi: Update.
	* c.opt (Wdeprecated): Enable for C and ObjC.
	* doc/invoke.texi (Option Summary): Move -Wno-deprecated.
	(C++ Dialect Options): Move -Wno-deprecated from here to...
	(Warning Options): ... here.
gcc/testsuite
	PR preprocessor/22168:
	* gcc.dg/pch/import-2.hs: Add -Wno-deprecated.
	* gcc.dg/pch/import-1.hs: Add -Wno-deprecated.
	* gcc.dg/pch/import-2.c: Add -Wno-deprecated.
	* gcc.dg/pch/import-1.c: Add -Wno-deprecated.
	* gcc.dg/cpp/import2.c: Add -Wno-deprecated.
	* gcc.dg/cpp/import1.c: Add -Wno-deprecated.
	* gcc.dg/cpp/trad/assert3.c: Add -Wno-deprecated.
	* gcc.dg/cpp/trad/assert2.c: Add -Wno-deprecated.
	* gcc.dg/cpp/trad/assert1.c: Add -Wno-deprecated.
	* gcc.dg/cpp/ident.c: Add -Wno-deprecated.
	* gcc.dg/cpp/ident-1.c: Add -Wno-deprecated.
	* gcc.dg/cpp/extratokens.c: Add -Wno-deprecated.
	* gcc.dg/cpp/assert3.c: Add -Wno-deprecated.
	* gcc.dg/cpp/assert2.c: Add -Wno-deprecated.
	* gcc.dg/cpp/assert1.c: Add -Wno-deprecated.
	* gcc.dg/cpp/assert4.c: Compile with -ansi and not -pedantic.  Add
	-Wno-deprecated.
	* gcc.dg/cpp/pr22168.c: New file.
	* gcc.dg/cpp/pr22168-2.c: New file.

From-SVN: r135264
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index b86e22e..fc226b4 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,13 @@
+2008-05-13  Tom Tromey  <tromey@redhat.com>
+
+	PR preprocessor/22168:
+	* include/cpplib.h (struct cpp_options) <objc>: Update
+	documentation.
+	* expr.c (eval_token): Warn for use of assertions.
+	* directives.c (directive_diagnostics): Warn about extensions.
+	(DEPRECATED): New define.
+	(DIRECTIVE_TABLE): Use it.
+
 2008-05-06  Tom Tromey  <tromey@redhat.com>
 
 	PR preprocessor/35313, PR preprocessor/36088:
diff --git a/libcpp/directives.c b/libcpp/directives.c
index bac08ad..9954796 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -75,6 +75,7 @@
 #define INCL		(1 << 2)
 #define IN_I		(1 << 3)
 #define EXPAND		(1 << 4)
+#define DEPRECATED	(1 << 5)
 
 /* Defines one #-directive, including how to handle it.  */
 typedef void (*directive_handler) (cpp_reader *);
@@ -130,9 +131,9 @@
    counts from all the source code I have lying around (egcs and libc
    CVS as of 1999-05-18, plus grub-0.5.91, linux-2.2.9, and
    pcmcia-cs-3.0.9).  This is no longer important as directive lookup
-   is now O(1).  All extensions other than #warning and #include_next
-   are deprecated.  The name is where the extension appears to have
-   come from.  */
+   is now O(1).  All extensions other than #warning, #include_next,
+   and #import are deprecated.  The name is where the extension
+   appears to have come from.  */
 
 #define DIRECTIVE_TABLE							\
 D(define,	T_DEFINE = 0,	KANDR,     IN_I)	   /* 270554 */ \
@@ -149,11 +150,11 @@
 D(pragma,	T_PRAGMA,	STDC89,    IN_I)	   /*    195 */ \
 D(warning,	T_WARNING,	EXTENSION, 0)		   /*     22 */ \
 D(include_next,	T_INCLUDE_NEXT,	EXTENSION, INCL | EXPAND)  /*     19 */ \
-D(ident,	T_IDENT,	EXTENSION, IN_I)	   /*     11 */ \
+D(ident,	T_IDENT,	EXTENSION, IN_I | DEPRECATED) /*     11 */ \
 D(import,	T_IMPORT,	EXTENSION, INCL | EXPAND)  /* 0 ObjC */	\
-D(assert,	T_ASSERT,	EXTENSION, 0)		   /* 0 SVR4 */	\
-D(unassert,	T_UNASSERT,	EXTENSION, 0)		   /* 0 SVR4 */	\
-D(sccs,		T_SCCS,		EXTENSION, IN_I)	   /* 0 SVR4? */
+D(assert,	T_ASSERT,	EXTENSION, DEPRECATED)	   /* 0 SVR4 */	\
+D(unassert,	T_UNASSERT,	EXTENSION, DEPRECATED)	   /* 0 SVR4 */	\
+D(sccs,		T_SCCS,		EXTENSION, IN_I | DEPRECATED) /* 0 SVR4? */
 
 /* #sccs is synonymous with #ident.  */
 #define do_sccs do_ident
@@ -337,11 +338,20 @@
 static void
 directive_diagnostics (cpp_reader *pfile, const directive *dir, int indented)
 {
-  /* Issue -pedantic warnings for extensions.  */
-  if (CPP_PEDANTIC (pfile)
-      && ! pfile->state.skipping
-      && dir->origin == EXTENSION)
-    cpp_error (pfile, CPP_DL_PEDWARN, "#%s is a GCC extension", dir->name);
+  /* Issue -pedantic or deprecated warnings for extensions.  We let
+     -pedantic take precedence if both are applicable.  */
+  if (! pfile->state.skipping)
+    {
+      if (dir->origin == EXTENSION
+	  && !(dir == &dtable[T_IMPORT] && CPP_OPTION (pfile, objc))
+	  && CPP_PEDANTIC (pfile))
+	cpp_error (pfile, CPP_DL_PEDWARN, "#%s is a GCC extension", dir->name);
+      else if (((dir->flags & DEPRECATED) != 0
+		|| (dir == &dtable[T_IMPORT] && !CPP_OPTION (pfile, objc)))
+	       && CPP_OPTION (pfile, warn_deprecated))
+	cpp_error (pfile, CPP_DL_WARNING, "#%s is a deprecated GCC extension",
+		   dir->name);
+    }
 
   /* Traditionally, a directive is ignored unless its # is in
      column 1.  Therefore in code intended to work with K+R
diff --git a/libcpp/expr.c b/libcpp/expr.c
index af0e259..2e52617 100644
--- a/libcpp/expr.c
+++ b/libcpp/expr.c
@@ -745,10 +745,25 @@
 	}
       break;
 
-    default: /* CPP_HASH */
+    case CPP_HASH:
+      if (!pfile->state.skipping)
+	{
+	  /* A pedantic warning takes precedence over a deprecated
+	     warning here.  */
+	  if (CPP_PEDANTIC (pfile))
+	    cpp_error (pfile, CPP_DL_PEDWARN,
+		       "assertions are a GCC extension");
+	  else if (CPP_OPTION (pfile, warn_deprecated))
+	    cpp_error (pfile, CPP_DL_WARNING,
+		       "assertions are a deprecated extension");
+	}
       _cpp_test_assertion (pfile, &temp);
       result.high = 0;
       result.low = temp;
+      break;
+
+    default:
+      abort ();
     }
 
   result.unsignedp = !!unsignedp;
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 46ab146..6b3f761 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -1,6 +1,6 @@
 /* Definitions for CPP library.
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2007
+   2004, 2005, 2007, 2008
    Free Software Foundation, Inc.
    Written by Per Bothner, 1994-95.
 
@@ -275,8 +275,9 @@
   /* Nonzero means handle cplusplus style comments.  */
   unsigned char cplusplus_comments;
 
-  /* Nonzero means define __OBJC__, treat @ as a special token, and
-     use the OBJC[PLUS]_INCLUDE_PATH environment variable.  */
+  /* Nonzero means define __OBJC__, treat @ as a special token, use
+     the OBJC[PLUS]_INCLUDE_PATH environment variable, and allow
+     "#import".  */
   unsigned char objc;
 
   /* Nonzero means don't copy comments into the output file.  */