On Fri, Nov 02, 2018 at 07:10:18AM -0400, Nathan Sidwell wrote:
> duplicate_decls is one of the more complex fns in decl.c, and I need to make
> it more complicated.  But first some refactoring, so it's a little more
> understandable.  Generally moving warning checks later when we know we've
> actually got a duplicate, and splitting up some conflict checking.
> 
> Applying to trunk after an x86_64-linux bootstrap.

> 2018-11-01  Nathan Sidwell  <nat...@acm.org>
> 
>       gcc/cp/
>       * decl.c (duplicate_decls): Refactor checks.
>       * name-lookup.c (name_lookup::process_module_binding): Only pubic
>       namespaces are shared.
> 
>       gcc/testsuite/
>       * g++.dg/lookup/crash6.C: Adjust error
>       * g++.dg/parse/crash38.C: Likewise.

This patch fixed PR c++/89325, previously we were diagnosing mismatched
attributes way too early, before establishing if e.g. different parameter
types don't actually make the decls not duplicate at all but overloaded.
The attrib5{8,9}.C testcases started to FAIL with g++ 7.x, while attrib60.C
testcase used to FAIL even in 3.2.

The following patch adds testcase coverage for that.  Tested on x86_64-linux
and i686-linux, ok for trunk?

Could the fix be eventually backported to release branches (or portions
thereof)?

2019-04-12  Jakub Jelinek  <ja...@redhat.com>

        PR c++/89325
        * g++.dg/ext/attrib58.C: New test.
        * g++.dg/ext/attrib59.C: New test.
        * g++.dg/ext/attrib60.C: New test.

--- gcc/testsuite/g++.dg/ext/attrib58.C.jj      2019-04-12 11:45:37.934754511 
+0200
+++ gcc/testsuite/g++.dg/ext/attrib58.C 2019-04-12 11:45:24.903969682 +0200
@@ -0,0 +1,8 @@
+// PR c++/89325
+// { dg-do compile }
+// { dg-options "-Wattributes" }
+
+struct A { friend int &operator<< (int &i, const A &) { return i; } }; // { 
dg-bogus "previous definition" }
+#pragma GCC optimize ("-fno-ipa-cp-clone")
+struct B {};
+int &operator<<(int &, const B &);     // { dg-bogus "optimization attribute 
on '\[^\n\r]*' follows definition but the attribute doesn.t match" }
--- gcc/testsuite/g++.dg/ext/attrib59.C.jj      2019-04-12 12:02:03.473483696 
+0200
+++ gcc/testsuite/g++.dg/ext/attrib59.C 2019-04-12 12:02:38.130910855 +0200
@@ -0,0 +1,11 @@
+// PR c++/89325
+// { dg-do compile }
+// { dg-options "-Wattributes" }
+
+int foo (int) { return 0; }    // { dg-bogus "previous definition" }
+int bar (int) { return 0; }    // { dg-bogus "previous definition" }
+int baz (int) { return 0; }    // { dg-message "previous definition" }
+__attribute__((optimize (0))) int bar (long); // { dg-bogus "optimization 
attribute on '\[^\n\r]*' follows definition but the attribute doesn.t match" }
+#pragma GCC optimize ("-fno-ipa-cp-clone")
+int foo (long);                        // { dg-bogus "optimization attribute 
on '\[^\n\r]*' follows definition but the attribute doesn.t match" }
+int baz (int);                 // { dg-warning "optimization attribute on 
'\[^\n\r]*' follows definition but the attribute doesn.t match" }
--- gcc/testsuite/g++.dg/ext/attrib60.C.jj      2019-04-12 12:03:01.002532806 
+0200
+++ gcc/testsuite/g++.dg/ext/attrib60.C 2019-04-12 12:07:33.056036076 +0200
@@ -0,0 +1,9 @@
+// PR c++/89325
+// { dg-do compile }
+// { dg-options "-Wattributes" }
+
+__attribute__((noinline)) void foo (int) {}    // { dg-bogus "previous 
definition" } 
+inline void foo (long);                                // { dg-bogus "inline 
declaration of '\[^\n\r]*' follows declaration with attribute 'noinline'" }
+inline void foo (long) {}
+__attribute__((noinline)) void bar (int) {}    // { dg-message "previous 
definition" } 
+inline void bar (int);                         // { dg-warning "inline 
declaration of '\[^\n\r]*' follows declaration with attribute 'noinline'" }

        Jakub

Reply via email to