On Wed, May 11, 2016 at 04:56:05PM +0200, Bernd Schmidt wrote:
> On 05/11/2016 03:59 PM, Marek Polacek wrote:
> > The C++ FE was missing diagnostics e.g. when an "always_inline" on DECL was
> > followed by DECL with the "noinline" attribute.  The C FE already has code
> > dealing with this, so I factored it out to a common function.
> > 
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> Ok, but could you first look whether there are existing testcases that could
> be moved to c-c++-common from gcc.dg instead of adding a new one?

I checked and we don't have a test testing all the contradicting attributes
as in the new test.  But with that added, we can do the following...

Tested on x86_64-linux, ok for trunk?

2016-05-11  Marek Polacek  <pola...@redhat.com>

        * gcc.dg/attr-opt-1.c: Move to c-c++-common/.
        * gcc.dg/pr18079-2.c: Remove file.

diff --git gcc/testsuite/c-c++-common/attr-opt-1.c 
gcc/testsuite/c-c++-common/attr-opt-1.c
index e69de29..fc9b4a6 100644
--- gcc/testsuite/c-c++-common/attr-opt-1.c
+++ gcc/testsuite/c-c++-common/attr-opt-1.c
@@ -0,0 +1,37 @@
+/* PR c/70255 */
+/* { dg-do compile } */
+
+double
+fn1 (double h, double l) /* { dg-message "previous definition" } */
+{
+  return h + l;
+}
+double fn1 (double, double) __attribute__ ((optimize 
("no-associative-math"))); /* { dg-warning "optimization attribute" } */
+
+__attribute__ ((optimize ("no-associative-math"))) double
+fn2 (double h, double l)
+{
+  return h + l;
+}
+double fn2 (double, double) __attribute__ ((optimize ("no-associative-math")));
+
+__attribute__ ((optimize ("no-associative-math"))) double
+fn3 (double h, double l) /* { dg-message "previous definition" } */
+{
+  return h + l;
+}
+double fn3 (double, double) __attribute__ ((optimize 
("O2,no-associative-math"))); /* { dg-warning "optimization attribute" } */
+
+__attribute__ ((optimize ("no-associative-math,O2"))) double
+fn4 (double h, double l) /* { dg-message "previous definition" } */
+{
+  return h + l;
+}
+double fn4 (double, double) __attribute__ ((optimize 
("O2,no-associative-math"))); /* { dg-warning "optimization attribute" } */
+
+__attribute__ ((optimize ("no-reciprocal-math"), optimize 
("no-associative-math"))) int
+fn5 (void)
+{
+  return 0;
+}
+int __attribute__ ((optimize ("no-associative-math"), optimize 
("no-reciprocal-math"))) fn5 (void);
diff --git gcc/testsuite/gcc.dg/attr-opt-1.c gcc/testsuite/gcc.dg/attr-opt-1.c
deleted file mode 100644
index 4140fda..0000000
--- gcc/testsuite/gcc.dg/attr-opt-1.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* PR c/70255 */
-/* { dg-do compile } */
-
-double
-fn1 (double h, double l) /* { dg-message "previous definition" } */
-{
-  return h + l;
-}
-double fn1 (double, double) __attribute__ ((optimize 
("no-associative-math"))); /* { dg-warning "optimization attribute on .fn1. 
follows definition" } */
-
-__attribute__ ((optimize ("no-associative-math"))) double
-fn2 (double h, double l)
-{
-  return h + l;
-}
-double fn2 (double, double) __attribute__ ((optimize ("no-associative-math")));
-
-__attribute__ ((optimize ("no-associative-math"))) double
-fn3 (double h, double l) /* { dg-message "previous definition" } */
-{
-  return h + l;
-}
-double fn3 (double, double) __attribute__ ((optimize 
("O2,no-associative-math"))); /* { dg-warning "optimization attribute on .fn3. 
follows definition" } */
-
-__attribute__ ((optimize ("no-associative-math,O2"))) double
-fn4 (double h, double l) /* { dg-message "previous definition" } */
-{
-  return h + l;
-}
-double fn4 (double, double) __attribute__ ((optimize 
("O2,no-associative-math"))); /* { dg-warning "optimization attribute on .fn4. 
follows definition" } */
-
-__attribute__ ((optimize ("no-reciprocal-math"), optimize 
("no-associative-math"))) int
-fn5 (void)
-{
-  return 0;
-}
-int __attribute__ ((optimize ("no-associative-math"), optimize 
("no-reciprocal-math"))) fn5 (void);
diff --git gcc/testsuite/gcc.dg/pr18079-2.c gcc/testsuite/gcc.dg/pr18079-2.c
deleted file mode 100644
index 2c83b70..0000000
--- gcc/testsuite/gcc.dg/pr18079-2.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* PR c/18079 */
-/* { dg-do compile } */
-/* { dg-options "-Wall" } */
-
-__attribute__ ((always_inline)) void fndecl1 (void);
-__attribute__ ((noinline)) void fndecl1 (void); /* { dg-warning "attribute 
'noinline' follows declaration with attribute 'always_inline'" } */
-
-__attribute__ ((noinline)) void fndecl2 (void);
-__attribute__ ((always_inline)) void fndecl2 (void); /* { dg-warning 
"attribute 'always_inline' follows declaration with attribute 'noinline'" } */
-
-
-__attribute__ ((hot)) void fndecl3 (void);
-__attribute__ ((cold)) void fndecl3 (void); /* { dg-warning "attribute 'cold' 
follows declaration with attribute 'hot'" } */
-
-__attribute__ ((cold)) void fndecl4 (void);
-__attribute__ ((hot)) void fndecl4 (void); /* { dg-warning "attribute 'hot' 
follows declaration with attribute 'cold'" } */

        Marek

Reply via email to