[RFC PATCH] avoid applying attributes to explicit specializations (PR 83871)

Jakub Jelinek jakub@redhat.com
Wed Feb 28 09:51:00 GMT 2018


On Mon, Feb 26, 2018 at 09:19:56PM -0700, Martin Sebor wrote:
> 	PR c++/83871
> 	PR c++/83503
> 	* g++.dg/ext/attr-const.C: New test.
> 	* g++.dg/ext/attr-pure.C: New test.

I've tried to fix these 2 tests with following patch, without
-fdump-tree-optimized all the scan-tree-dump* tests are UNRESOLVED,
and when you use the same function for multiple-subtests all you get
is the same failures reported multiple times, but without knowing which
of them failed.

Unfortunately, even with this patch there are failures:
FAIL: g++.dg/ext/attr-const.C  -std=gnu++11  scan-tree-dump-not optimized "test_func_none_const_failed"
FAIL: g++.dg/ext/attr-const.C  -std=gnu++11  scan-tree-dump-not optimized "test_template_none_const_failed"
FAIL: g++.dg/ext/attr-const.C  -std=gnu++14  scan-tree-dump-not optimized "test_func_none_const_failed"
FAIL: g++.dg/ext/attr-const.C  -std=gnu++14  scan-tree-dump-not optimized "test_template_none_const_failed"
FAIL: g++.dg/ext/attr-const.C  -std=gnu++17 -fconcepts  scan-tree-dump-not optimized "test_func_none_const_failed"
FAIL: g++.dg/ext/attr-const.C  -std=gnu++17 -fconcepts  scan-tree-dump-not optimized "test_template_none_const_failed"
FAIL: g++.dg/ext/attr-const.C  -std=gnu++17  scan-tree-dump-not optimized "test_func_none_const_failed"
FAIL: g++.dg/ext/attr-const.C  -std=gnu++17  scan-tree-dump-not optimized "test_template_none_const_failed"
FAIL: g++.dg/ext/attr-const.C  -std=gnu++2a  scan-tree-dump-not optimized "test_func_none_const_failed"
FAIL: g++.dg/ext/attr-const.C  -std=gnu++2a  scan-tree-dump-not optimized "test_template_none_const_failed"
FAIL: g++.dg/ext/attr-const.C  -std=gnu++98  scan-tree-dump-not optimized "test_func_none_const_failed"
FAIL: g++.dg/ext/attr-const.C  -std=gnu++98  scan-tree-dump-not optimized "test_template_none_const_failed"
FAIL: g++.dg/ext/attr-pure.C  -std=gnu++11  scan-tree-dump-not optimized "test_template_none_pure_failed"
FAIL: g++.dg/ext/attr-pure.C  -std=gnu++14  scan-tree-dump-not optimized "test_template_none_pure_failed"
FAIL: g++.dg/ext/attr-pure.C  -std=gnu++17 -fconcepts  scan-tree-dump-not optimized "test_template_none_pure_failed"
FAIL: g++.dg/ext/attr-pure.C  -std=gnu++17  scan-tree-dump-not optimized "test_template_none_pure_failed"
FAIL: g++.dg/ext/attr-pure.C  -std=gnu++2a  scan-tree-dump-not optimized "test_template_none_pure_failed"
FAIL: g++.dg/ext/attr-pure.C  -std=gnu++98  scan-tree-dump-not optimized "test_template_none_pure_failed"
so if the test is right, then something is still broken on the C++ FE side.

I'll defer debugging this to you.

--- gcc/testsuite/g++.dg/ext/attr-const.C.jj	2018-02-28 09:55:57.235897906 +0100
+++ gcc/testsuite/g++.dg/ext/attr-const.C	2018-02-28 10:37:09.775438593 +0100
@@ -1,37 +1,37 @@
 /*  PR c++/83871 - wrong code for attribute const and pure on distinct
     template specializations
     { dg-do compile }
-    { dg-options "-O -Wall" } */
+    { dg-options "-O -Wall -fdump-tree-optimized" } */
 
 int __attribute__ ((const)) fconst_none ();
 int fconst_none ();
 
-void test_const_none_failed ();
+void test_func_const_none_failed ();
 
 void func_const_none ()
 {
   int i0 = fconst_none ();
   int i1 = fconst_none ();
   if (i0 != i1)
-    test_const_none_failed ();
+    test_func_const_none_failed ();
 
-  // { dg-final { scan-tree-dump-not "test_const_none_failed" "optimized" } }
+  // { dg-final { scan-tree-dump-not "test_func_const_none_failed" "optimized" } }
 }
 
 
 int fnone_const ();
 int __attribute__ ((const)) fnone_const ();
 
-void test_none_const_failed ();
+void test_func_none_const_failed ();
 
 void func_none_const ()
 {
   int i0 = fnone_const ();
   int i1 = fnone_const ();
   if (i0 != i1)
-    test_none_const_failed ();
+    test_func_none_const_failed ();
 
-  // { dg-final { scan-tree-dump-not "test_none_const_failed" "optimized" } }
+  // { dg-final { scan-tree-dump-not "test_func_none_const_failed" "optimized" } }
 }
 
 
@@ -41,14 +41,16 @@ int __attribute__ ((const)) fconst_none
 template <class T>
 int fconst_none (T);
 
+void test_template_const_none_failed ();
+
 void template_const_none ()
 {
   int i0 = fconst_none<int> (0);
   int i1 = fconst_none<int> (0);
   if (i0 != i1)
-    test_const_none_failed ();
+    test_template_const_none_failed ();
 
-  // { dg-final { scan-tree-dump-not "test_const_none_failed" "optimized" } }
+  // { dg-final { scan-tree-dump-not "test_template_const_none_failed" "optimized" } }
 }
 
 
@@ -58,12 +60,14 @@ int fnone_const (T);
 template <class T>
 int __attribute__ ((const)) fnone_const (T);
 
+void test_template_none_const_failed ();
+
 void test_fnone_const ()
 {
   int i0 = fnone_const<int> (0);
   int i1 = fnone_const<int> (0);
   if (i0 != i1)
-    test_none_const_failed ();
+    test_template_none_const_failed ();
 
-  // { dg-final { scan-tree-dump-not "test_none_const_failed" "optimized" } }
+  // { dg-final { scan-tree-dump-not "test_template_none_const_failed" "optimized" } }
 }
--- gcc/testsuite/g++.dg/ext/attr-pure.C.jj	2018-02-28 09:55:57.236897905 +0100
+++ gcc/testsuite/g++.dg/ext/attr-pure.C	2018-02-28 10:35:39.864510362 +0100
@@ -1,37 +1,37 @@
 /*  PR c++/83871 - wrong code for attribute const and pure on distinct
     template specializations
     { dg-do compile }
-    { dg-options "-O -Wall" } */
+    { dg-options "-O -Wall -fdump-tree-optimized" } */
 
 int __attribute__ ((pure)) fpure_none ();
 int fpure_none ();
 
-void test_pure_none_failed ();
+void test_func_pure_none_failed ();
 
 void func_pure_none ()
 {
   int i0 = fpure_none ();
   int i1 = fpure_none ();
   if (i0 != i1)
-    test_pure_none_failed ();
+    test_func_pure_none_failed ();
 
-  // { dg-final { scan-tree-dump-not "test_pure_none_failed" "optimized" } }
+  // { dg-final { scan-tree-dump-not "test_func_pure_none_failed" "optimized" } }
 }
 
 
 int fnone_pure ();
 int __attribute__ ((pure)) fnone_pure ();
 
-void test_none_pure_failed ();
+void test_func_none_pure_failed ();
 
 void func_none_pure ()
 {
   int i0 = fnone_pure ();
   int i1 = fnone_pure ();
   if (i0 != i1)
-    test_none_pure_failed ();
+    test_func_none_pure_failed ();
 
-  // { dg-final { scan-tree-dump-not "test_none_pure_failed" "optimized" } }
+  // { dg-final { scan-tree-dump-not "test_func_none_pure_failed" "optimized" } }
 }
 
 
@@ -41,14 +41,16 @@ int __attribute__ ((pure)) fpure_none (T
 template <class T>
 int fpure_none (T);
 
+void test_template_pure_none_failed ();
+
 void template_pure_none ()
 {
   int i0 = fpure_none<int> (0);
   int i1 = fpure_none<int> (0);
   if (i0 != i1)
-    test_pure_none_failed ();
+    test_template_pure_none_failed ();
 
-  // { dg-final { scan-tree-dump-not "test_pure_none_failed" "optimized" } }
+  // { dg-final { scan-tree-dump-not "test_template_pure_none_failed" "optimized" } }
 }
 
 
@@ -58,12 +60,14 @@ int fnone_pure (T);
 template <class T>
 int __attribute__ ((pure)) fnone_pure (T);
 
+void test_template_none_pure_failed ();
+
 void test_fnone_pure ()
 {
   int i0 = fnone_pure<int> (0);
   int i1 = fnone_pure<int> (0);
   if (i0 != i1)
-    test_none_pure_failed ();
+    test_template_none_pure_failed ();
 
-  // { dg-final { scan-tree-dump-not "test_none_pure_failed" "optimized" } }
+  // { dg-final { scan-tree-dump-not "test_template_none_pure_failed" "optimized" } }
 }


	Jakub



More information about the Gcc-patches mailing list