re PR c++/46336 ([C++0X] ICE on invalid: in register_constexpr_fundef, at cp/semantic...
authorJason Merrill <jason@redhat.com>
Thu, 17 Mar 2011 02:36:12 +0000 (22:36 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 17 Mar 2011 02:36:12 +0000 (22:36 -0400)
PR c++/46336
* decl.c (duplicate_decls): Return NULL_TREE for clashing
C functions.

From-SVN: r171084

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-46336.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/friend5.C

index 074c776b08de5e635100baae84ca422451e15eb5..66c831658353e48e29b2bb7bc106e8afe3ef370f 100644 (file)
@@ -1,5 +1,9 @@
 2011-03-16  Jason Merrill  <jason@redhat.com>
 
+       PR c++/46336
+       * decl.c (duplicate_decls): Return NULL_TREE for clashing
+       C functions.
+
        PR c++/47570
        * semantics.c (cxx_eval_constant_expression) [COMPOUND_EXPR]: Don't
        use the generic binary expression handling.
index 3139ad89b563a6ddd2d6f0a20f9d6b1f194015af..17b316381ec0225731617d7f1b0792f9dea2dae7 100644 (file)
@@ -1456,6 +1456,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
              error ("declaration of C function %q#D conflicts with",
                     newdecl);
              error ("previous declaration %q+#D here", olddecl);
+             return NULL_TREE;
            }
          else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)),
                              TYPE_ARG_TYPES (TREE_TYPE (olddecl))))
index 355e09deac53e5f892867ffb64a858b46252cc55..122beef0b1a43c3667387e2ba64e3b87e1d586a6 100644 (file)
@@ -1,5 +1,8 @@
 2011-03-16  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/constexpr-46336.C: New.
+       * g++.dg/parse/friend5.C: Adjust expected errors.
+
        * g++.dg/cpp0x/constexpr-47570.C: New.
 
 2011-03-16  Dodji Seketeli  <dodji@redhat.com>
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-46336.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-46336.C
new file mode 100644 (file)
index 0000000..3c51c2c
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/46336
+// { dg-options -std=c++0x }
+
+extern "C" {
+  enum A { };
+  inline constexpr A
+  f(A a, A b)                  // { dg-error "previous declaration" }
+  { return A(static_cast<int>(a) & static_cast<int>(b)); }
+  enum B { };
+  inline constexpr B
+  f(B a, B b)                  // { dg-error "C function" }
+  { return B(static_cast<int>(a) & static_cast<int>(b)); }
+}
+
index ec134c26ea905afe9f9b847e16ac8b5ea8a9cd33..bf1e6bfa6dd6d9ef6216668b5b4d63466c8708fd 100644 (file)
@@ -4,5 +4,4 @@ extern "C" struct A
 {
   friend void foo(int) {} // { dg-error "declaration" }
   friend void foo() {} // { dg-error "foo" "err" }
-  // { dg-warning "already a friend" "warn" { target *-*-* } 6 }
 };