OSDN Git Service

PR c++/46336
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Mar 2011 02:36:12 +0000 (02:36 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Mar 2011 02:36:12 +0000 (02:36 +0000)
* decl.c (duplicate_decls): Return NULL_TREE for clashing
C functions.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171084 138bc75d-0d04-0410-961f-82ee72b054a4

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 074c776..66c8316 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 3139ad8..17b3163 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 355e09d..122beef 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 ec134c2..bf1e6bf 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 }
 };