aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Preud'homme <thomas.preudhomme@arm.com>2014-11-07 16:21:15 +0000
committerJason Merrill <jason@gcc.gnu.org>2014-11-07 11:21:15 -0500
commit1dc090e2f4a1b952e9369c31b6a154430de175d1 (patch)
treebb38c89f10c827b87445e8cc237594089faf1318 /gcc
parentd296d8f327520a7cb2430212c68bfbbb493166fa (diff)
downloadgcc-1dc090e2f4a1b952e9369c31b6a154430de175d1.zip
gcc-1dc090e2f4a1b952e9369c31b6a154430de175d1.tar.gz
gcc-1dc090e2f4a1b952e9369c31b6a154430de175d1.tar.bz2
re PR c++/63366 (C++ __complex is not equivalent to __complex double)
PR c++/63366 * decl.c (grokdeclarator): Fix __complex meaning __complex double. From-SVN: r217229
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c29
-rw-r--r--gcc/testsuite/g++.dg/torture/pr63366.C10
3 files changed, 33 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c86f85b..de04ab7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-07 Thomas Preud'homme <thomas.preudhomme@arm.com>
+
+ PR c++/63366
+ * decl.c (grokdeclarator): Fix __complex meaning __complex double.
+
2014-10-29 Richard Sandiford <richard.sandiford@arm.com>
* constexpr.c: Remove redundant enum from machine_mode.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 320c39f..4abc101 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9182,11 +9182,23 @@ grokdeclarator (const cp_declarator *declarator,
}
/* No type at all: default to `int', and set DEFAULTED_INT
because it was not a user-defined typedef. */
- if (type == NULL_TREE && (signed_p || unsigned_p || long_p || short_p))
+ if (type == NULL_TREE)
{
- /* These imply 'int'. */
- type = integer_type_node;
- defaulted_int = 1;
+ if (signed_p || unsigned_p || long_p || short_p)
+ {
+ /* These imply 'int'. */
+ type = integer_type_node;
+ defaulted_int = 1;
+ }
+ /* If we just have "complex", it is equivalent to "complex double". */
+ else if (!longlong && !explicit_intN
+ && decl_spec_seq_has_spec_p (declspecs, ds_complex))
+ {
+ type = double_type_node;
+ pedwarn (declspecs->locations[ds_complex], OPT_Wpedantic,
+ "ISO C++ does not support plain %<complex%> meaning "
+ "%<double complex%>");
+ }
}
/* Gather flags. */
explicit_int = declspecs->explicit_int_p;
@@ -9371,13 +9383,8 @@ grokdeclarator (const cp_declarator *declarator,
{
if (TREE_CODE (type) != INTEGER_TYPE && TREE_CODE (type) != REAL_TYPE)
error ("complex invalid for %qs", name);
- /* 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". */
- else if (defaulted_int && ! longlong && ! explicit_intN
- && ! (long_p || short_p || signed_p || unsigned_p))
- type = complex_double_type_node;
+ /* If a modifier is specified, the resulting complex is the complex
+ form of TYPE. E.g, "complex short" is "complex short int". */
else if (type == integer_type_node)
type = complex_integer_type_node;
else if (type == float_type_node)
diff --git a/gcc/testsuite/g++.dg/torture/pr63366.C b/gcc/testsuite/g++.dg/torture/pr63366.C
new file mode 100644
index 0000000..f089123
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr63366.C
@@ -0,0 +1,10 @@
+// { dg-do run }
+// { dg-options "-pedantic" }
+
+#include <typeinfo>
+
+int
+main (void)
+{
+ return typeid (__complex) != typeid (__complex double); /* { dg-warning "ISO C\\+\\+ does not support plain 'complex' meaning 'double complex'" } */
+}