According to a comment in grokdeclarator in file gcc/cp/decl.c:

    /* If we just have "complex", it is equivalent to
    "complex double", but if any modifiers at all are specified it is
    the complex form of TYPE. E.g, "complex short" is
    "complex short int". */

Yet, __complex is equivalent to __complex int as shows the following testcase:

#include <typeinfo>

int
main (void)
{
  return typeid (__complex) != typeid (__complex int);
}

The following patch fix the problem. 


ChangeLog are as follows:

*** gcc/cp/ChangeLog ***

2014-09-26  Thomas Preud'homme  <thomas.preudho...@arm.com>

        * decl.c (grokdeclarator): Set defaulted_int when defaulting to int
        because type is null.

*** gcc/testsuite/ChangeLog ***

2014-10-26  Thomas Preud'homme  <thomas.preudho...@arm.com>

        * g++.dg/torture/pr63366.C: New test.


diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index d26a432..449efdf 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9212,6 +9212,7 @@ grokdeclarator (const cp_declarator *declarator,
                  "ISO C++ forbids declaration of %qs with no type", name);
 
       type = integer_type_node;
+      defaulted_int = 1;
     }
 
   ctype = NULL_TREE;
diff --git a/gcc/testsuite/g++.dg/torture/pr63366.C 
b/gcc/testsuite/g++.dg/torture/pr63366.C
new file mode 100644
index 0000000..af59b98
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr63366.C
@@ -0,0 +1,11 @@
+// { dg-do run }
+// { dg-options "-fpermissive" }
+// { dg-prune-output "ISO C\\+\\+ forbids declaration of 'type name' with no 
type" }
+
+#include <typeinfo>
+
+int
+main (void)
+{
+  return typeid (__complex) != typeid (__complex double);
+}


Is this ok for trunk?

Best regards,

Thomas Preud'homme



Reply via email to