http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58289

            Bug ID: 58289
           Summary: gcc/gengtype.c includes gcc/double-int.h, which uses
                    C++ constructs
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: bootstrap
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jklowden at schemamania dot org

I pulled from svn://gcc.gnu.org/svn/gcc/trunk today to build gcc on OS X using
Clang.  Some header files use C++ syntax, but are included in C files.  The
error I'm seeing is:

/Developer/usr/bin/clang [...options omitted...]
                -o build/gengtype.o ../../gcc/gengtype.c
[...warnings ommitted...]
In file included from ../../gcc/gengtype.c:28:
../../gcc/double-int.h:58:10: error: must use 'struct' tag to refer to type
'double_int'
  static double_int from_uhwi (unsigned HOST_WIDE_INT cst);


The error stems from this construct in double-int.h:

==snip==
struct double_int
{
  /* Normally, we would define constructors to create instances.
     Two things prevent us from doing so.
     First, defining a constructor makes the class non-POD in C++03,
     and we certainly want double_int to be a POD.
     Second, the GCC conding conventions prefer explicit conversion,
     and explicit conversion operators are not available until C++11.  */

  static double_int from_uhwi (unsigned HOST_WIDE_INT cst);
==pins==

Comment not withstanding, the file could easily be converted to C; there are no
classes declared, for instance.  All that's needed is say,

    static struct double-int from_uhwi = cst;

perhaps with a cast.  

I found similar problems in two other files that were small enough to repair or
work around.  This file seems to be a pupa determined to become C++, and I'm
not quite sure what should be done.

Reply via email to