Re: [C++ Patch] PR 50956

2011-11-03 Thread Tom Tromey
 Paolo == Paolo Carlini paolo.carl...@oracle.com writes:

Paolo By the way, I have no idea why I didn't see it, only Fortran includes
Paolo that header in the *libcpp* directory? Anyway, I'm proceeding to
Paolo bootstrap the attached.

It really isn't ok to do this.  That header is supposedly private to
libcpp.

Tom


Re: [C++ Patch] PR 50956

2011-11-03 Thread Paolo Carlini
Hi,
 It really isn't ok to do this.  That header is supposedly private to
 libcpp.

Eh, eh looks like somebody wandered around and found a few handy helper 
functions ;)
 

Paolo


gfortran using libcpp/internal.h (was Re: [C++ Patch] PR 50956)

2011-11-03 Thread Jason Merrill

On 11/03/2011 09:51 AM, Tom Tromey wrote:

Paolo == Paolo Carlinipaolo.carl...@oracle.com  writes:


Paolo  By the way, I have no idea why I didn't see it, only Fortran includes
Paolo  [internal.h] in the *libcpp* directory? Anyway, I'm proceeding to
Paolo  bootstrap the attached.

It really isn't ok to do this.  That header is supposedly private to
libcpp.


That include seems to have been there since cpp.c was first checked in 
by Daniel Franke.


Jason



Re: gfortran using libcpp/internal.h (was Re: [C++ Patch] PR 50956)

2011-11-03 Thread Richard Guenther
On Thu, Nov 3, 2011 at 3:46 PM, Jason Merrill ja...@redhat.com wrote:
 On 11/03/2011 09:51 AM, Tom Tromey wrote:

 Paolo == Paolo Carlinipaolo.carl...@oracle.com  writes:

 Paolo  By the way, I have no idea why I didn't see it, only Fortran
 includes
 Paolo  [internal.h] in the *libcpp* directory? Anyway, I'm proceeding to
 Paolo  bootstrap the attached.

 It really isn't ok to do this.  That header is supposedly private to
 libcpp.

 That include seems to have been there since cpp.c was first checked in by
 Daniel Franke.

Most of the errors go away with replacing it with #include cpplib.h,
remaining:

,,,
k/gcc/fortran/cpp.c -o fortran/cpp.o
/space/rguenther/src/svn/trunk/gcc/fortran/cpp.c: In function
‘scan_translation_unit_trad’:
/space/rguenther/src/svn/trunk/gcc/fortran/cpp.c:769: warning:
implicit declaration of function ‘_cpp_read_logical_line_trad’

but then we dereference struct cpp_reader:

/space/rguenther/src/svn/trunk/gcc/fortran/cpp.c:771: error:
dereferencing pointer to incomplete type
/space/rguenther/src/svn/trunk/gcc/fortran/cpp.c:771: error:
dereferencing pointer to incomplete type
/space/rguenther/src/svn/trunk/gcc/fortran/cpp.c:772: error:
dereferencing pointer to incomplete type
...

Richard.

 Jason




Re: gfortran using libcpp/internal.h (was Re: [C++ Patch] PR 50956)

2011-11-03 Thread Richard Guenther
On Thu, Nov 3, 2011 at 4:03 PM, Daniel Franke franke.dan...@gmail.com wrote:
 2011/11/3 Richard Guenther richard.guent...@gmail.com:
 On Thu, Nov 3, 2011 at 3:46 PM, Jason Merrill ja...@redhat.com wrote:
 On 11/03/2011 09:51 AM, Tom Tromey wrote:

 Paolo == Paolo Carlinipaolo.carl...@oracle.com  writes:

 Paolo  By the way, I have no idea why I didn't see it, only Fortran
 includes
 Paolo  [internal.h] in the *libcpp* directory? Anyway, I'm proceeding to
 Paolo  bootstrap the attached.

 It really isn't ok to do this.  That header is supposedly private to
 libcpp.

 That include seems to have been there since cpp.c was first checked in by
 Daniel Franke.

 Most of the errors go away with replacing it with #include cpplib.h,
 remaining:

 ,,,
 k/gcc/fortran/cpp.c -o fortran/cpp.o
 /space/rguenther/src/svn/trunk/gcc/fortran/cpp.c: In function
 ‘scan_translation_unit_trad’:
 /space/rguenther/src/svn/trunk/gcc/fortran/cpp.c:769: warning:
 implicit declaration of function ‘_cpp_read_logical_line_trad’

 but then we dereference struct cpp_reader:

 /space/rguenther/src/svn/trunk/gcc/fortran/cpp.c:771: error:
 dereferencing pointer to incomplete type
 /space/rguenther/src/svn/trunk/gcc/fortran/cpp.c:771: error:
 dereferencing pointer to incomplete type
 /space/rguenther/src/svn/trunk/gcc/fortran/cpp.c:772: error:
 dereferencing pointer to incomplete type

 Hi all.

 This was then mimicking (actually mostly duplicating), the
 implementation of the C frontend. In particular around the usage of
 scan_translation_unit_trad and associated friends. I wasn't happy to
 do this, but to get at least some functionality done without
 rebuilding everything, it was required.

 If you go back to the 4.6 branch you will find similar code in
 c-family/c-ppoutput.c.

It still includes internal.h on trunk it seems ...

Richard.

 Regards

    Daniel



Re: [C++ Patch] PR 50956

2011-11-02 Thread Jason Merrill

OK.

Jason


Re: [C++ Patch] PR 50956

2011-11-02 Thread Paolo Carlini
... ehm, we use -Wcast-qual during the bootstrap, thus if I don't want 
to break it again, better doing the below too. Seems obvious, by itself.


Paolo.

//


2011-11-02  Paolo Carlini  paolo.carl...@oracle.com

PR c++/50956
* builtins.c (fold_builtin_memchr): Fix cast.
Index: builtins.c
===
--- builtins.c  (revision 180778)
+++ builtins.c  (working copy)
@@ -8427,7 +8427,7 @@ fold_builtin_memchr (location_t loc, tree arg1, tr
  if (target_char_cast (arg2, c))
return NULL_TREE;
 
- r = (char *) memchr (p1, c, tree_low_cst (len, 1));
+ r = (const char *) memchr (p1, c, tree_low_cst (len, 1));
 
  if (r == NULL)
return build_int_cst (TREE_TYPE (arg1), 0);


Re: [C++ Patch] PR 50956

2011-11-02 Thread Jason Merrill

On 11/02/2011 01:45 PM, Paolo Carlini wrote:

... ehm, we use -Wcast-qual during the bootstrap, thus if I don't want
to break it again, better doing the below too. Seems obvious, by itself.


Yep.

Jason



Re: [C++ Patch] PR 50956

2011-11-02 Thread Paolo Carlini

On 11/02/2011 07:26 PM, Jason Merrill wrote:

On 11/02/2011 01:45 PM, Paolo Carlini wrote:

... ehm, we use -Wcast-qual during the bootstrap, thus if I don't want
to break it again, better doing the below too. Seems obvious, by itself.

Yep.
Great, all done. Note for the accidental reader: it's indeed obvious, 
but only if you are used to the C++ memchr, the two overloads. For the 
targets (many outside Linux) not providing those (via libc hooks) I 
would not have broken the bootstrap ;)


Paolo.


Re: [C++ Patch] PR 50956

2011-11-02 Thread Jason Merrill

Another bootstrap issue:

In file included from /home/jason/src/trunk/gcc/fortran/cpp.c:35:0:
/home/jason/src/trunk/gcc/fortran/../../libcpp/internal.h: In function 
‘unsigned char* ustrchr(const unsigned char*, int)’:
/home/jason/src/trunk/gcc/fortran/../../libcpp/internal.h:782:55: error: 
cast from type ‘const char*’ to type ‘unsigned char*’ casts away 
qualifiers [-Werror=cast-qual]


Re: [C++ Patch] PR 50956

2011-11-02 Thread Paolo Carlini

On 11/02/2011 08:12 PM, Jason Merrill wrote:

Another bootstrap issue:

In file included from /home/jason/src/trunk/gcc/fortran/cpp.c:35:0:
/home/jason/src/trunk/gcc/fortran/../../libcpp/internal.h: In function 
‘unsigned char* ustrchr(const unsigned char*, int)’:
/home/jason/src/trunk/gcc/fortran/../../libcpp/internal.h:782:55: 
error: cast from type ‘const char*’ to type ‘unsigned char*’ casts 
away qualifiers [-Werror=cast-qual]

Argh, I'll fix it momentarily.

Paolo.


Re: [C++ Patch] PR 50956

2011-11-02 Thread Paolo Carlini

On 11/02/2011 08:44 PM, Paolo Carlini wrote:

On 11/02/2011 08:12 PM, Jason Merrill wrote:

Another bootstrap issue:

In file included from /home/jason/src/trunk/gcc/fortran/cpp.c:35:0:
/home/jason/src/trunk/gcc/fortran/../../libcpp/internal.h: In 
function ‘unsigned char* ustrchr(const unsigned char*, int)’:
/home/jason/src/trunk/gcc/fortran/../../libcpp/internal.h:782:55: 
error: cast from type ‘const char*’ to type ‘unsigned char*’ casts 
away qualifiers [-Werror=cast-qual]

Argh, I'll fix it momentarily.
By the way, I have no idea why I didn't see it, only Fortran includes 
that header in the *libcpp* directory? Anyway, I'm proceeding to 
bootstrap the attached.


Paolo.

/

Index: internal.h
===
--- internal.h  (revision 180785)
+++ internal.h  (working copy)
@@ -770,16 +770,16 @@ ustrlen (const unsigned char *s1)
   return strlen ((const char *)s1);
 }
 
-static inline unsigned char *
+static inline const unsigned char *
 uxstrdup (const unsigned char *s1)
 {
-  return (unsigned char *) xstrdup ((const char *)s1);
+  return (const unsigned char *) xstrdup ((const char *)s1);
 }
 
-static inline unsigned char *
+static inline const unsigned char *
 ustrchr (const unsigned char *s1, int c)
 {
-  return (unsigned char *) strchr ((const char *)s1, c);
+  return (const unsigned char *) strchr ((const char *)s1, c);
 }
 
 static inline int


Re: [C++ Patch] PR 50956

2011-11-02 Thread Paolo Carlini

 this actually.

Paolo.

/
Index: internal.h
===
--- internal.h  (revision 180785)
+++ internal.h  (working copy)
@@ -739,8 +739,8 @@
 static inline int ustrncmp (const unsigned char *, const unsigned char *,
size_t);
 static inline size_t ustrlen (const unsigned char *);
-static inline unsigned char *uxstrdup (const unsigned char *);
-static inline unsigned char *ustrchr (const unsigned char *, int);
+static inline const unsigned char *uxstrdup (const unsigned char *);
+static inline const unsigned char *ustrchr (const unsigned char *, int);
 static inline int ufputs (const unsigned char *, FILE *);
 
 /* Use a const char for the second parameter since it is usually a literal.  */
@@ -770,16 +770,16 @@
   return strlen ((const char *)s1);
 }
 
-static inline unsigned char *
+static inline const unsigned char *
 uxstrdup (const unsigned char *s1)
 {
-  return (unsigned char *) xstrdup ((const char *)s1);
+  return (const unsigned char *) xstrdup ((const char *)s1);
 }
 
-static inline unsigned char *
+static inline const unsigned char *
 ustrchr (const unsigned char *s1, int c)
 {
-  return (unsigned char *) strchr ((const char *)s1, c);
+  return (const unsigned char *) strchr ((const char *)s1, c);
 }
 
 static inline int