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]

PATCH: Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998


[Sorry to have dropped this for over a week.  I had some additional
 bootstrap stability issues which I just waited out.]

In article <Pine.SOL.3.91.1010328161440.4287A-100000@cse.cygnus.com>,
Benjamin Kosnik <bkoz@redhat.com> writes:

> then there is a bit where it specifies, exactly, what names are macros. 
> setjmp is one of them.

OK, got it.  It appears to me that C99 only allows these reserved
identifiers to be macros or an identifier declared with external
linkage:

errno, setjmp, va_end and (not mentioned in note 154 but found in
later text and Annex J: Portability issues) math_errhandling

For now, I am ignoring math_errhandling since it is unclear that it
should be defined if any related C99-required macros are not also
found.

According to section 17.4.1.2 clause 5 of ISO 14882:1998 "Names which
are defined as macros in C shall be defined as macros in the C++
Standard Library, even if C grants license for implementation as
functions."

Assuming a liberal reading of this section, errno should be provided
as a macro even if the C implementation is something other than a
function or a macro (i.e. it is a global variable with external
linkage)...

> ok. but do all the required names. You'll see a set of 17_intro/*.cc 
> files that test for this stuff: do them all please

OK, all other macros tested must be macros according to ISO 9899:1999
thus this patch should do it:

[BTW, tested on i386-unknown-freebsd4.2 in already bootstrapped tree
by rebuilding libstdc++-v3 from scratch.  Fixes:

FAIL: 17_intro/header_csetjmp.cc (test for excess errors), static  
FAIL: 17_intro/header_csetjmp.cc (test for excess errors), shared

but similar logic paths in other two headers are not tested on this
platform.]

2001-04-06  Loren J. Rittle  <ljrittle@acm.org>

	* include/c_std/bits/std_cerrno.h (errno): Define macro from
	identifier declared with external linkage, if needed.
	* include/c_std/bits/std_csetjmp.h (setjmp): Likewise.
	* include/c_std/bits/std_cstdarg.h (va_end): Likewise.


Index: include/c_std/bits/std_cerrno.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/c_std/bits/std_cerrno.h,v
retrieving revision 1.6
diff -c -r1.6 std_cerrno.h
*** std_cerrno.h	2001/03/06 23:32:58	1.6
--- std_cerrno.h	2001/04/06 17:15:31
***************
*** 39,42 ****
--- 39,47 ----
  #pragma GCC system_header
  #include <errno.h>
  
+ // Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
+ #ifndef errno
+ #define errno errno
+ #endif
+ 
  #endif
Index: include/c_std/bits/std_csetjmp.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/c_std/bits/std_csetjmp.h,v
retrieving revision 1.5
diff -c -r1.5 std_csetjmp.h
*** std_csetjmp.h	2001/02/05 22:27:40	1.5
--- std_csetjmp.h	2001/04/06 17:15:31
***************
*** 42,47 ****
--- 42,52 ----
  // Get rid of those macros defined in <setjmp.h> in lieu of real functions.
  #undef longjmp
  
+ // Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
+ #ifndef setjmp
+ #define setjmp(env) setjmp (env)
+ #endif
+ 
  namespace std
  {
    using ::jmp_buf;
Index: include/c_std/bits/std_cstdarg.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/c_std/bits/std_cstdarg.h,v
retrieving revision 1.4
diff -c -r1.4 std_cstdarg.h
*** std_cstdarg.h	2001/02/05 22:27:40	1.4
--- std_cstdarg.h	2001/04/06 17:15:31
***************
*** 39,44 ****
--- 39,49 ----
  #pragma GCC system_header
  #include <stdarg.h>
  
+ // Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
+ #ifndef va_end
+ #define va_end(ap) va_end (ap)
+ #endif
+ 
  namespace std
  {
    using ::va_list;


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