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]

Re: PATCH: Support for Pascal strings -- Take 2


On Fri, 29 Jun 2001, Ziemowit Laski wrote:

In general, your mailer seems to be wrapping lines.  Please fix this.

> +             if (t != strings && !is_pascal_string)
> +               warning ("Pascal string-length escape (\\p) ignored in 
> concatenation");

Should be a hard error.

>                        for (j=0; j<(WCHAR_TYPE_SIZE / BITS_PER_UNIT)-1; 

Use GNU coding style (spaces around < and = and -).

> +           {
> +             pedwarn ("Pascal string too long");
> +           }

Should be a hard error.  You don't seem to have a testcase for this; you 
should have testcases covering every line of code you add.

> +             pedwarn (wide?
> +                      "Pascal string-length escape (\\p) not allowed in 
> wide string":
> +                      "Pascal string-length escape (\\p) must be at 
> beginning of string");

Should be hard error.

> +       {
> +         pedwarn ("Pascal string too long");

Should be hard error.

>            if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
>                 != char_type_node)
> +             && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
> +              != unsigned_char_type_node)
>                && TYPE_PRECISION (typ1) == BITS_PER_UNIT)

I don't know exactly what you're doing with initialisation, but you need 
to document it, and have testcases.

> + As is the case with C string literals, Pascal string literals are
> + terminated with a NULL character; this character is @emph{not} counted

This character is known as NUL, not NULL.

> + Toolbox calls.  Unlike ordinary string literals, which are of type
> + @samp{const char *}, Pascal-style literals are treated by the compiler
> + as being of type @samp{const unsigned char *}.  This is necessary in
> + order to maintain backward compatibility with other MacOS compilers.

Your description of types is wrong.  String literals have array type, not
pointer type.  Also, in ISO 9899, the type is not const-qualified.  You
need to state what the actual type is, in the context of both ISO 9899 and
ISO 14882, and with -Wwrite-strings.  You need to document the absence of
a deprecated conversion to unsigned char * in C++, and test it.  You need
to include a statement of what the dimension of the array is, as well as
the element type.

> + int
> + strlen (const unsigned char *s)

Use strlen from the standard library rather than reimplementing it in a
testcase.

> Index: gcc/testsuite/g++.dg/pascal-strings-2.C
> ===================================================================
> RCS file: pascal-strings-2.C
> diff -N pascal-strings-2.C
> *** /dev/null   Fri Jun 29 12:03:01 2001
> --- pascal-strings-2.C  Fri Jun 29 12:01:54 2001
> ***************
> *** 0 ****
> --- 1,13 ----
> + /* Test for handling of Pascal-style string literals */
> + /* Origin: Ziemowit Laski <zlaski@apple.com> */
> + /* { dg-do compile } */
> + /* { dg-options "-std=iso9899:1999 -fpascal-strings" } */

Using a -std= option for a C standard version does not make sense in C++
tests.

-- 
Joseph S. Myers
jsm28@cam.ac.uk


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