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 9e011e9..56ecf72 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 6f3a348..6101bdf 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 ad989fd..dc5ae01 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;
+}