This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

make #sccs do something useful


GCC has, since time immemorial, accepted and ignored the #sccs
preprocessor directive.  It's accepted because it appears in some
(old) system headers, and it's ignored because I was never able to
find any documentation of its syntax or effects.

Someone - I forget who, sorry - posted a query a few weeks ago, in the
course of which they revealed the syntax and effects of this
mysterious directive.  It turns out to be synonymous with #ident,
which GCC accepts and does something useful with.  If it hadn't been
synonymous, I might not have bothered changing anything, but since it
is, the patch is trivial.

It's not possible to put a test case for this in the test suite,
because not all targets define ASM_OUTPUT_IDENT, and even if they did,
we don't have a good way of checking the object file for the string.

Bootstrapped i686-linux, and object contents of a trivial test case
verified manually.

zw

libcpp:
        * directives.c (#sccs table entry): Mark IN_I, consistent with #ident.
        (do_sccs): Delete function definition, #define to do_ident.
        (do_ident): Don't hardwire directive name.
gcc:
        * doc/cpp.texi: Document that #sccs is a synonym for #ident.

===================================================================
Index: libcpp/directives.c
--- libcpp/directives.c	12 Mar 2005 10:44:02 -0000	1.14
+++ libcpp/directives.c	12 May 2005 18:23:14 -0000
@@ -157,7 +157,10 @@ D(ident,	T_IDENT,	EXTENSION, IN_I)	   /*
 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, 0)		   /* 0 SVR4? */
+D(sccs,		T_SCCS,		EXTENSION, IN_I)	   /* 0 SVR4? */
+
+/* #sccs is synonymous with #ident.  */
+#define do_sccs do_ident
 
 /* Use the table to generate a series of prototypes, an enum for the
    directive names, and an array of directive handlers.  */
@@ -953,7 +956,8 @@ do_ident (cpp_reader *pfile)
   const cpp_token *str = cpp_get_token (pfile);
 
   if (str->type != CPP_STRING)
-    cpp_error (pfile, CPP_DL_ERROR, "invalid #ident directive");
+    cpp_error (pfile, CPP_DL_ERROR, "invalid #%s directive",
+	       pfile->directive->name);
   else if (pfile->cb.ident)
     pfile->cb.ident (pfile, pfile->directive_line, &str->val.str);
 
@@ -1474,12 +1478,6 @@ cpp_handle_deferred_pragma (cpp_reader *
   CPP_OPTION (pfile, defer_pragmas) = saved_defer_pragmas;
 }
 
-/* Ignore #sccs on all systems.  */
-static void
-do_sccs (cpp_reader *pfile ATTRIBUTE_UNUSED)
-{
-}
-
 /* Handle #ifdef.  */
 static void
 do_ifdef (cpp_reader *pfile)
===================================================================
Index: gcc/doc/cpp.texi
--- gcc/doc/cpp.texi	1 May 2005 20:30:28 -0000	1.82
+++ gcc/doc/cpp.texi	12 May 2005 18:22:53 -0000
@@ -3372,18 +3372,15 @@ current file to be treated as if it came
 @chapter Other Directives
 
 @findex #ident
+@findex #sccs
 The @samp{#ident} directive takes one argument, a string constant.  On
 some systems, that string constant is copied into a special segment of
-the object file.  On other systems, the directive is ignored.
-
-This directive is not part of the C standard, but it is not an official
-GNU extension either.  We believe it came from System V@.
+the object file.  On other systems, the directive is ignored.  The
+@samp{#sccs} directive is a synonym for @samp{#ident}.
 
-@findex #sccs
-The @samp{#sccs} directive is recognized, because it appears in the
-header files of some systems.  It is a very old, obscure, extension
-which we did not invent, and we have been unable to find any
-documentation of what it should do, so GCC simply ignores it.
+These directives are not part of the C standard, but they are not
+official GNU extensions either.  What historical information we have
+been able to find, suggests they originated with System V@.
 
 @cindex null directive
 The @dfn{null directive} consists of a @samp{#} followed by a newline,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]