re PR c++/70621 (ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_r...
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 12 Sep 2017 19:45:37 +0000 (19:45 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 12 Sep 2017 19:45:37 +0000 (19:45 +0000)
/cp
2017-09-12  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/70621
* decl.c (start_decl): Early return error_mark_node if duplicate_decls
returns it; avoid misleading error message.

/testsuite
2017-09-12  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/70621
* g++.dg/torture/pr70621.C: New.

From-SVN: r252040

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr70621.C [new file with mode: 0644]

index 9e011e94429f7a94d4be0cb768897dd4461896c7..56ecf72b81647c74c311d965147c3d44578b6837 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-12  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/70621
+       * decl.c (start_decl): Early return error_mark_node if duplicate_decls
+       returns it; avoid misleading error message.
+
 2017-09-12  Nathan Sidwell  <nathan@acm.org>
 
        Kill CLASSTYPE_SORTED_FIELDS.
index 6f3a348f9fdf5f3a06909f3ce73d0498b995c4e3..6101bdf2bc83a13b615a68de7fac7d3af14a1fb1 100644 (file)
@@ -5022,11 +5022,12 @@ start_decl (const cp_declarator *declarator,
                 about this situation, and so we check here.  */
              if (initialized && DECL_INITIALIZED_IN_CLASS_P (field))
                error ("duplicate initialization of %qD", decl);
-             if (duplicate_decls (decl, field, /*newdecl_is_friend=*/false))
+             field = duplicate_decls (decl, field,
+                                      /*newdecl_is_friend=*/false);
+             if (field == error_mark_node)
+               return error_mark_node;
+             else if (field)
                decl = field;
-              if (decl_spec_seq_has_spec_p (declspecs, ds_constexpr)
-                  && !DECL_DECLARED_CONSTEXPR_P (field))
-                error ("%qD declared %<constexpr%> outside its class", field);
            }
        }
       else
index ad989fd8ac2be1cd08bd740d9f3a1012c6880113..dc5ae01a641365f0115e9d5d0d43adf0807cad36 100644 (file)
@@ -1,3 +1,8 @@
+017-09-12  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/70621
+       * g++.dg/torture/pr70621.C: New.
+
 2017-09-12  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/82173
diff --git a/gcc/testsuite/g++.dg/torture/pr70621.C b/gcc/testsuite/g++.dg/torture/pr70621.C
new file mode 100644 (file)
index 0000000..63eb928
--- /dev/null
@@ -0,0 +1,13 @@
+float foo();
+
+struct A
+{
+  static float x;  // { dg-message "previous declaration" }
+};
+
+double A::x = foo();  // { dg-error "conflicting declaration" }
+
+void bar()
+{
+  A::x = 0;
+}