You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2007/11/22 16:20:30 UTC

svn commit: r597425 - in /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar tests/strings/21.cwchar.cpp

Author: faridz
Date: Thu Nov 22 07:20:29 2007
New Revision: 597425

URL: http://svn.apache.org/viewvc?rev=597425&view=rev
Log:
2007-11-21 Farid Zaripov <fa...@epam.com>

	STDCXX-637
	* include/ansi/cwchar [_RWSTD_STRICT_ANSI]: #undefine getwc
	and putwc masking macros.
	* tests/strings/21.cwchar.cpp (test_macros): Issue rw_warn()
	instead of rw_assert() in non strict ANSI mode.
	(test_functions): Issue rw_warn() instead of rw_assert().

Modified:
    incubator/stdcxx/branches/4.2.x/include/ansi/cwchar
    incubator/stdcxx/branches/4.2.x/tests/strings/21.cwchar.cpp

Modified: incubator/stdcxx/branches/4.2.x/include/ansi/cwchar
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/include/ansi/cwchar?rev=597425&r1=597424&r2=597425&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.x/include/ansi/cwchar (original)
+++ incubator/stdcxx/branches/4.2.x/include/ansi/cwchar Thu Nov 22 07:20:29 2007
@@ -46,6 +46,13 @@
 #include _RWSTD_ANSI_C_WCHAR_H
 
 
+#ifdef _RWSTD_STRICT_ANSI
+// 17.4.1.2, p6 - masking macros are not allowed
+#  undef getwc
+#  undef putwc
+#endif   // _RWSTD_STRICT_ANSI
+
+
 #if _RWSTD_NAMESPACE_STD_OPEN == 17
 #undef _RWSTD_NAMESPACE_STD_OPEN
 

Modified: incubator/stdcxx/branches/4.2.x/tests/strings/21.cwchar.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/tests/strings/21.cwchar.cpp?rev=597425&r1=597424&r2=597425&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.x/tests/strings/21.cwchar.cpp (original)
+++ incubator/stdcxx/branches/4.2.x/tests/strings/21.cwchar.cpp Thu Nov 22 07:20:29 2007
@@ -509,9 +509,15 @@
     }
 
     for (unsigned i = 0; masking_macros [i]; ++i) {
+#ifdef _RWSTD_STRICT_ANSI
         rw_assert ('\0' == masking_macros [i][0], 0, __LINE__,
                    "masking macro %s unexpectedly defined",
                    masking_macros [i]);
+#else
+        rw_warn ('\0' == masking_macros [i][0], 0, __LINE__,
+                 "masking macro %s unexpectedly defined",
+                 masking_macros [i]);
+#endif
     }
 }
 
@@ -855,13 +861,13 @@
                  std_name, #fun, overload < 0, 0 == overload);          \
         const char* const return_type_name =                            \
             get_type_name ((T)0, std::fun args);                        \
-        rw_assert (0 == ncalls, 0, __LINE__,                            \
-                   "%s::%s("                                            \
-                   "%{?}%{:}/* %{?}non-%{;}const overload */%{;}) "     \
-                   "not declared (_RWSTD_NO_%s = %d, "                  \
-                   "_RWSTD_NO_%s_IN_LIBC = %d)",                        \
-                   std_name, #fun, overload < 0, 0 == overload,         \
-                   #macro, EVAL (macro), #macro, EVAL_IN_LIBC (macro)); \
+        rw_warn (0 == ncalls, 0, __LINE__,                              \
+                 "%s::%s("                                              \
+                 "%{?}%{:}/* %{?}non-%{;}const overload */%{;}) "       \
+                 "not declared (_RWSTD_NO_%s = %d, "                    \
+                 "_RWSTD_NO_%s_IN_LIBC = %d)",                          \
+                 std_name, #fun, overload < 0, 0 == overload,           \
+                 #macro, EVAL (macro), #macro, EVAL_IN_LIBC (macro));   \
         if (0 == ncalls)                                                \
             rw_assert (0 == return_type_name, 0, __LINE__, "%s::%s("    \
                        "%{?}%{:}/* %{?}non-%{;}const overload */%{;}) " \



Re: svn commit: r597425 - in /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar tests/strings/21.cwchar.cpp

Posted by Martin Sebor <se...@roguewave.com>.
Farid Zaripov wrote:
>> -----Original Message-----
>> From: Martin Sebor [mailto:sebor@roguewave.com] 
>> Sent: Friday, November 30, 2007 2:51 AM
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: svn commit: r597425 - in 
>> /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar 
>> tests/strings/21.cwchar.cpp
>>
>>>   Yes, potentially here might be a problems.
>> So maybe we need to rethink the original strategy of 
>> #undefining the macros only when _RWSTD_STRICT_ANSI is 
>> #defined. Or is there a way to prevent the expansion of the 
>> macros in the using declarations?
>>
>> Btw., it occurs to me that if they are defined as function 
>> macros (i.e., #define getwc() as opposed to #define getwc, 
>> without the parentheses), mentioning getwc w/o an argument 
>> list as is done in using declarations will not cause them to 
>> be expanded. So the problem only exists for object macros 
>> (i.e., those that aren't defined with parentheses).
> 
>   If the using directives are decorated by #ifndef _RWSTD_NO_funname
> there would be no problems in case the STDCXX-451 issue resolved.
> 
>>>   BTW in ansi/cctype and ansi/cmath headers the masking macros are 
>>> #undefined unconditionally.
>>>
>>>  I think first we need to collect information how these macros are 
>>> implemented on different platforms and then decide what 
>> should we do.
>>
>> I suppose we should do that. But either way we decide we 
>> should be consistent. So if there already are unconditional 
>> #undefs in several other headers we might as well follow suit 
>> with cwchar (and wchar.h) until we gather more information 
>> and decide to change all the other headers to #undef all the 
>> other macros conditionally.
> 
>   Agreed. So it's safe to #undefine getwc and putwc on MSVC.
> The gcc on Linux doesn't #define these macros. What about
> other platforms?

Are you looking for data for just getwc and putwc or all the
other symbols from <cwchar> (or the whole C library?)

If just the former the macros aren't defined on any of AIX
(XLC++ 9.0), HP-UX (aCC 3.73), IRIX (MIPSpro 7.41), Solaris
(Sun C++ 5.9), or Tru64 (HP/Compaq C++), but they are both
#defined on FreeBSD (gcc 3.4.4).

Martin

> 
> Farid.


RE: svn commit: r597425 - in /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar tests/strings/21.cwchar.cpp

Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Friday, November 30, 2007 2:51 AM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: svn commit: r597425 - in 
> /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar 
> tests/strings/21.cwchar.cpp
> 
> >   Yes, potentially here might be a problems.
> 
> So maybe we need to rethink the original strategy of 
> #undefining the macros only when _RWSTD_STRICT_ANSI is 
> #defined. Or is there a way to prevent the expansion of the 
> macros in the using declarations?
> 
> Btw., it occurs to me that if they are defined as function 
> macros (i.e., #define getwc() as opposed to #define getwc, 
> without the parentheses), mentioning getwc w/o an argument 
> list as is done in using declarations will not cause them to 
> be expanded. So the problem only exists for object macros 
> (i.e., those that aren't defined with parentheses).

  If the using directives are decorated by #ifndef _RWSTD_NO_funname
there would be no problems in case the STDCXX-451 issue resolved.

> >   BTW in ansi/cctype and ansi/cmath headers the masking macros are 
> > #undefined unconditionally.
> > 
> >  I think first we need to collect information how these macros are 
> > implemented on different platforms and then decide what 
> should we do.
> 
> I suppose we should do that. But either way we decide we 
> should be consistent. So if there already are unconditional 
> #undefs in several other headers we might as well follow suit 
> with cwchar (and wchar.h) until we gather more information 
> and decide to change all the other headers to #undef all the 
> other macros conditionally.

  Agreed. So it's safe to #undefine getwc and putwc on MSVC.
The gcc on Linux doesn't #define these macros. What about
other platforms?

Farid.

Re: svn commit: r597425 - in /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar tests/strings/21.cwchar.cpp

Posted by Martin Sebor <se...@roguewave.com>.
Farid Zaripov wrote:
>> -----Original Message-----
>> From: Martin Sebor [mailto:sebor@roguewave.com] 
>> Sent: Wednesday, November 28, 2007 7:00 PM
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: svn commit: r597425 - in 
>> /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar 
>> tests/strings/21.cwchar.cpp
>>
>> No, I mean when _RWSTD_STRICT_ANSI is not #defined but getwc 
>> and putwc are. Then we might end up with something like this:
>>
>>    #define getwc()   (stdin->__wide_char)
>>    ...
>>    using ::getwc;
>>
>> expanding to
>>
>>    using ::(stdin->__wide_char);
> 
>   Yes, potentially here might be a problems.

So maybe we need to rethink the original strategy of #undefining
the macros only when _RWSTD_STRICT_ANSI is #defined. Or is there
a way to prevent the expansion of the macros in the using
declarations?

Btw., it occurs to me that if they are defined as function macros
(i.e., #define getwc() as opposed to #define getwc, without the
parentheses), mentioning getwc w/o an argument list as is done
in using declarations will not cause them to be expanded. So
the problem only exists for object macros (i.e., those that
aren't defined with parentheses).

> 
>   BTW in ansi/cctype and ansi/cmath headers the masking macros
> are #undefined unconditionally.
> 
>  I think first we need to collect information how these macros are
> implemented
> on different platforms and then decide what should we do.

I suppose we should do that. But either way we decide we should be
consistent. So if there already are unconditional #undefs in several
other headers we might as well follow suit with cwchar (and wchar.h)
until we gather more information and decide to change all the other
headers to #undef all the other macros conditionally.

> 
>   In example the MSVC implements getwc() thus fgetwc() (the getwc macro
> is
> defined fo fgetwc and getwc() crt function just calls fgetwc()). So we
> can safely
> #undefine these macros on MSVC without functional changes or performance
> penalty (I suppose that in release the getwc() function should be
> implemented
> as "jmp _fgetwc").

Makes sense to me.

Martin

RE: svn commit: r597425 - in /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar tests/strings/21.cwchar.cpp

Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Wednesday, November 28, 2007 7:00 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: svn commit: r597425 - in 
> /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar 
> tests/strings/21.cwchar.cpp
> 
> No, I mean when _RWSTD_STRICT_ANSI is not #defined but getwc 
> and putwc are. Then we might end up with something like this:
> 
>    #define getwc()   (stdin->__wide_char)
>    ...
>    using ::getwc;
> 
> expanding to
> 
>    using ::(stdin->__wide_char);

  Yes, potentially here might be a problems.

  BTW in ansi/cctype and ansi/cmath headers the masking macros
are #undefined unconditionally.

 I think first we need to collect information how these macros are
implemented
on different platforms and then decide what should we do.

  In example the MSVC implements getwc() thus fgetwc() (the getwc macro
is
defined fo fgetwc and getwc() crt function just calls fgetwc()). So we
can safely
#undefine these macros on MSVC without functional changes or performance
penalty (I suppose that in release the getwc() function should be
implemented
as "jmp _fgetwc").

Farid.

Re: svn commit: r597425 - in /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar tests/strings/21.cwchar.cpp

Posted by Martin Sebor <se...@roguewave.com>.
Farid Zaripov wrote:
>> -----Original Message-----
>> From: Martin Sebor [mailto:sebor@roguewave.com] 
>> Sent: Wednesday, November 28, 2007 6:21 PM
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: svn commit: r597425 - in 
>> /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar 
>> tests/strings/21.cwchar.cpp
>>
>> faridz@apache.org wrote:
>>> Author: faridz
>>> Date: Thu Nov 22 07:20:29 2007
>>> New Revision: 597425
>>>
>>> URL: http://svn.apache.org/viewvc?rev=597425&view=rev
>> If _RWSTD_STRICT_ANSI is not #defined and one or both of getwc
>> or putwc is shadowed by a macro, aren't the using declarations
>> for the two functions going to cause problems?
> 
>   Do you meant "_RWSTD_STRICT_ANSI is defined" ?
> 
>   If so, yes, there would be a compiler errors if the compiler
> CRT doesn't provide getwc() and/or putwc().

No, I mean when _RWSTD_STRICT_ANSI is not #defined but getwc
and putwc are. Then we might end up with something like this:

   #define getwc()   (stdin->__wide_char)
   ...
   using ::getwc;

expanding to

   using ::(stdin->__wide_char);

Martin

> 
>   MSVC provides both getwc() and putwc() and also
> #defines getwc and putwc macros.
> 
> Farid.


RE: svn commit: r597425 - in /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar tests/strings/21.cwchar.cpp

Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Wednesday, November 28, 2007 6:21 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: svn commit: r597425 - in 
> /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar 
> tests/strings/21.cwchar.cpp
> 
> faridz@apache.org wrote:
> > Author: faridz
> > Date: Thu Nov 22 07:20:29 2007
> > New Revision: 597425
> > 
> > URL: http://svn.apache.org/viewvc?rev=597425&view=rev
> 
> If _RWSTD_STRICT_ANSI is not #defined and one or both of getwc
> or putwc is shadowed by a macro, aren't the using declarations
> for the two functions going to cause problems?

  Do you meant "_RWSTD_STRICT_ANSI is defined" ?

  If so, yes, there would be a compiler errors if the compiler
CRT doesn't provide getwc() and/or putwc().

  MSVC provides both getwc() and putwc() and also
#defines getwc and putwc macros.

Farid.

Re: svn commit: r597425 - in /incubator/stdcxx/branches/4.2.x: include/ansi/cwchar tests/strings/21.cwchar.cpp

Posted by Martin Sebor <se...@roguewave.com>.
faridz@apache.org wrote:
> Author: faridz
> Date: Thu Nov 22 07:20:29 2007
> New Revision: 597425
> 
> URL: http://svn.apache.org/viewvc?rev=597425&view=rev

If _RWSTD_STRICT_ANSI is not #defined and one or both of getwc
or putwc is shadowed by a macro, aren't the using declarations
for the two functions going to cause problems?

Martin

> Log:
> 2007-11-21 Farid Zaripov <fa...@epam.com>
> 
> 	STDCXX-637
> 	* include/ansi/cwchar [_RWSTD_STRICT_ANSI]: #undefine getwc
> 	and putwc masking macros.
> 	* tests/strings/21.cwchar.cpp (test_macros): Issue rw_warn()
> 	instead of rw_assert() in non strict ANSI mode.
> 	(test_functions): Issue rw_warn() instead of rw_assert().
> 
> Modified:
>     incubator/stdcxx/branches/4.2.x/include/ansi/cwchar
>     incubator/stdcxx/branches/4.2.x/tests/strings/21.cwchar.cpp
> 
> Modified: incubator/stdcxx/branches/4.2.x/include/ansi/cwchar
> URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/include/ansi/cwchar?rev=597425&r1=597424&r2=597425&view=diff
> ==============================================================================
> --- incubator/stdcxx/branches/4.2.x/include/ansi/cwchar (original)
> +++ incubator/stdcxx/branches/4.2.x/include/ansi/cwchar Thu Nov 22 07:20:29 2007
> @@ -46,6 +46,13 @@
>  #include _RWSTD_ANSI_C_WCHAR_H
>  
>  
> +#ifdef _RWSTD_STRICT_ANSI
> +// 17.4.1.2, p6 - masking macros are not allowed
> +#  undef getwc
> +#  undef putwc
> +#endif   // _RWSTD_STRICT_ANSI
> +
> +
>  #if _RWSTD_NAMESPACE_STD_OPEN == 17
>  #undef _RWSTD_NAMESPACE_STD_OPEN
>  
> 
> Modified: incubator/stdcxx/branches/4.2.x/tests/strings/21.cwchar.cpp
> URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/tests/strings/21.cwchar.cpp?rev=597425&r1=597424&r2=597425&view=diff
> ==============================================================================
> --- incubator/stdcxx/branches/4.2.x/tests/strings/21.cwchar.cpp (original)
> +++ incubator/stdcxx/branches/4.2.x/tests/strings/21.cwchar.cpp Thu Nov 22 07:20:29 2007
> @@ -509,9 +509,15 @@
>      }
>  
>      for (unsigned i = 0; masking_macros [i]; ++i) {
> +#ifdef _RWSTD_STRICT_ANSI
>          rw_assert ('\0' == masking_macros [i][0], 0, __LINE__,
>                     "masking macro %s unexpectedly defined",
>                     masking_macros [i]);
> +#else
> +        rw_warn ('\0' == masking_macros [i][0], 0, __LINE__,
> +                 "masking macro %s unexpectedly defined",
> +                 masking_macros [i]);
> +#endif
>      }
>  }
>  
> @@ -855,13 +861,13 @@
>                   std_name, #fun, overload < 0, 0 == overload);          \
>          const char* const return_type_name =                            \
>              get_type_name ((T)0, std::fun args);                        \
> -        rw_assert (0 == ncalls, 0, __LINE__,                            \
> -                   "%s::%s("                                            \
> -                   "%{?}%{:}/* %{?}non-%{;}const overload */%{;}) "     \
> -                   "not declared (_RWSTD_NO_%s = %d, "                  \
> -                   "_RWSTD_NO_%s_IN_LIBC = %d)",                        \
> -                   std_name, #fun, overload < 0, 0 == overload,         \
> -                   #macro, EVAL (macro), #macro, EVAL_IN_LIBC (macro)); \
> +        rw_warn (0 == ncalls, 0, __LINE__,                              \
> +                 "%s::%s("                                              \
> +                 "%{?}%{:}/* %{?}non-%{;}const overload */%{;}) "       \
> +                 "not declared (_RWSTD_NO_%s = %d, "                    \
> +                 "_RWSTD_NO_%s_IN_LIBC = %d)",                          \
> +                 std_name, #fun, overload < 0, 0 == overload,           \
> +                 #macro, EVAL (macro), #macro, EVAL_IN_LIBC (macro));   \
>          if (0 == ncalls)                                                \
>              rw_assert (0 == return_type_name, 0, __LINE__, "%s::%s("    \
>                         "%{?}%{:}/* %{?}non-%{;}const overload */%{;}) " \
> 
>