diff mbox

[v3] libstdc++/46303 + minor ratio vs constepr tweaks

Message ID 4CD2E831.7050401@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Nov. 4, 2010, 5:06 p.m. UTC
Hi,

tested x86_64-linux, committed.

Paolo.

PS: Benjamin, I believe testcases like constexpr_data.cc would pass also
if I remove the constexpr qualifier and revert to the old const. It
would be nice to have something stricter...

/////////////////
2010-11-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/46303
	* testsuite/30_threads/call_once/constexpr.cc: Add missing dg-require
	directives.
	* testsuite/30_threads/mutex/cons/constexpr.cc: Likewise.
	* testsuite/30_threads/once_flag/cons/constexpr.cc: Likewise.

2010-11-04  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/std/ratio (ratio_add, ratio_subtract, ratio_multiply,
	ratio_divide): Declare the data members constexpr.
	* testsuite/20_util/ratio/requirements/constexpr_data.cc: Extend.

Comments

Benjamin Kosnik Nov. 5, 2010, 8:06 p.m. UTC | #1
> PS: Benjamin, I believe testcases like constexpr_data.cc would pass
> also if I remove the constexpr qualifier and revert to the old const.

Yes, you are correct. Deplorable!

> It would be nice to have something stricter...

Agreed. I failed to find one. Please advise.

-benjamin
diff mbox

Patch

Index: include/std/ratio
===================================================================
--- include/std/ratio	(revision 166316)
+++ include/std/ratio	(working copy)
@@ -185,15 +185,15 @@ 
           __safe_multiply<_R2::num, (_R1::den / __gcd)>::value>::value,
         __safe_multiply<_R1::den, (_R2::den / __gcd)>::value> type;
 
-      static const intmax_t num = type::num;
-      static const intmax_t den = type::den;
+      static constexpr intmax_t num = type::num;
+      static constexpr intmax_t den = type::den;
     };
 
   template<typename _R1, typename _R2>
-    const intmax_t ratio_add<_R1, _R2>::num;
+    constexpr intmax_t ratio_add<_R1, _R2>::num;
 
   template<typename _R1, typename _R2>
-    const intmax_t ratio_add<_R1, _R2>::den;
+    constexpr intmax_t ratio_add<_R1, _R2>::den;
 
   /// ratio_subtract
   template<typename _R1, typename _R2>
@@ -203,15 +203,15 @@ 
         _R1,
         ratio<-_R2::num, _R2::den>>::type type;
 
-      static const intmax_t num = type::num;
-      static const intmax_t den = type::den;
+      static constexpr intmax_t num = type::num;
+      static constexpr intmax_t den = type::den;
     };
 
   template<typename _R1, typename _R2>
-    const intmax_t ratio_subtract<_R1, _R2>::num;
+    constexpr intmax_t ratio_subtract<_R1, _R2>::num;
 
   template<typename _R1, typename _R2>
-    const intmax_t ratio_subtract<_R1, _R2>::den;
+    constexpr intmax_t ratio_subtract<_R1, _R2>::den;
 
   /// ratio_multiply
   template<typename _R1, typename _R2>
@@ -230,15 +230,15 @@ 
         __safe_multiply<(_R1::den / __gcd2),
                         (_R2::den / __gcd1)>::value> type;
 
-      static const intmax_t num = type::num;
-      static const intmax_t den = type::den;
+      static constexpr intmax_t num = type::num;
+      static constexpr intmax_t den = type::den;
     };
 
   template<typename _R1, typename _R2>
-    const intmax_t ratio_multiply<_R1, _R2>::num;
+    constexpr intmax_t ratio_multiply<_R1, _R2>::num;
 
   template<typename _R1, typename _R2>
-    const intmax_t ratio_multiply<_R1, _R2>::den;
+    constexpr intmax_t ratio_multiply<_R1, _R2>::den;
 
   /// ratio_divide
   template<typename _R1, typename _R2>
@@ -250,15 +250,15 @@ 
         _R1,
         ratio<_R2::den, _R2::num>>::type type;
 
-      static const intmax_t num = type::num;
-      static const intmax_t den = type::den;
+      static constexpr intmax_t num = type::num;
+      static constexpr intmax_t den = type::den;
     };
 
   template<typename _R1, typename _R2>
-    const intmax_t ratio_divide<_R1, _R2>::num;
+    constexpr intmax_t ratio_divide<_R1, _R2>::num;
 
   template<typename _R1, typename _R2>
-    const intmax_t ratio_divide<_R1, _R2>::den;
+    constexpr intmax_t ratio_divide<_R1, _R2>::den;
 
   /// ratio_equal
   template<typename _R1, typename _R2>
Index: testsuite/30_threads/call_once/constexpr.cc
===================================================================
--- testsuite/30_threads/call_once/constexpr.cc	(revision 166316)
+++ testsuite/30_threads/call_once/constexpr.cc	(working copy)
@@ -1,5 +1,7 @@ 
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2010 Free Software Foundation, Inc.
 //
Index: testsuite/30_threads/mutex/cons/constexpr.cc
===================================================================
--- testsuite/30_threads/mutex/cons/constexpr.cc	(revision 166316)
+++ testsuite/30_threads/mutex/cons/constexpr.cc	(working copy)
@@ -1,5 +1,7 @@ 
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2010 Free Software Foundation, Inc.
 //
Index: testsuite/30_threads/once_flag/cons/constexpr.cc
===================================================================
--- testsuite/30_threads/once_flag/cons/constexpr.cc	(revision 166316)
+++ testsuite/30_threads/once_flag/cons/constexpr.cc	(working copy)
@@ -1,5 +1,7 @@ 
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
 
 // Copyright (C) 2010 Free Software Foundation, Inc.
 //
Index: testsuite/20_util/ratio/requirements/constexpr_data.cc
===================================================================
--- testsuite/20_util/ratio/requirements/constexpr_data.cc	(revision 166316)
+++ testsuite/20_util/ratio/requirements/constexpr_data.cc	(working copy)
@@ -49,6 +49,12 @@ 
 int main()
 {
   __gnu_test::constexpr_member_data test;
-  test.operator()<std::ratio<600, 900>>();
+  typedef std::ratio<600, 900> R1;
+  typedef std::ratio<700, 200> R2;
+  test.operator()<R1>();
+  test.operator()<std::ratio_add<R1, R2>>();
+  test.operator()<std::ratio_subtract<R1, R2>>();
+  test.operator()<std::ratio_multiply<R1, R2>>();
+  test.operator()<std::ratio_divide<R1, R2>>();
   return 0;
 }