From: Jason Merrill Date: Thu, 17 Mar 2011 02:36:12 +0000 (-0400) Subject: re PR c++/46336 ([C++0X] ICE on invalid: in register_constexpr_fundef, at cp/semantic... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9f2a22d0b89e8e4208e84aaeab23f563c085c6c8;p=gcc.git re PR c++/46336 ([C++0X] ICE on invalid: in register_constexpr_fundef, at cp/semantics.c:5571) PR c++/46336 * decl.c (duplicate_decls): Return NULL_TREE for clashing C functions. From-SVN: r171084 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 074c776b08d..66c83165835 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-03-16 Jason Merrill + 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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3139ad89b56..17b316381ec 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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)))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 355e09deac5..122beef0b1a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-03-16 Jason Merrill + * 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 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-46336.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-46336.C new file mode 100644 index 00000000000..3c51c2cbf54 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-46336.C @@ -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(a) & static_cast(b)); } + enum B { }; + inline constexpr B + f(B a, B b) // { dg-error "C function" } + { return B(static_cast(a) & static_cast(b)); } +} + diff --git a/gcc/testsuite/g++.dg/parse/friend5.C b/gcc/testsuite/g++.dg/parse/friend5.C index ec134c26ea9..bf1e6bfa6dd 100644 --- a/gcc/testsuite/g++.dg/parse/friend5.C +++ b/gcc/testsuite/g++.dg/parse/friend5.C @@ -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 } };