public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix partial template specialization syntax in wide-int.h
@ 2015-07-17  9:30 Mikhail Maltsev
  2015-07-17 17:38 ` Mike Stump
  0 siblings, 1 reply; 6+ messages in thread
From: Mikhail Maltsev @ 2015-07-17  9:30 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]

Hi, all!
The following code (reduced from wide-int.h) is rejected by Intel C++ Compiler
(EDG-based):

$ cat genpreds1_min.cc
template <typename>
class A;

template <int>
struct B;

template <typename>
struct C;

template <>
template <int N>
struct C <B <N> >
{
    template<typename T>
    A <B <N> >
    m_fn(T);
};

template <int N>
template <typename T>
A <B <N> >
C <B <N> >::m_fn (T)
{
}

$ /opt/intel/bin/icpc -c genpreds1_min.cc
genpreds1_min.cc(22): error: incomplete type is not allowed
  C <B <N> >::m_fn (T)
  ^

genpreds1_min.cc(22): error: template argument list must match the parameter list
  C <B <N> >::m_fn (T)

Clang gives the following warning:

$ clang++ -c genpreds1_min.cc
genpreds1_min.cc:10:1: warning: extraneous template parameter list in template
specialization
template <>

I think that the warning is correct, and "template <>" should not be used here.
The attached patch should fix this issue. Bootstrapped and regtested on
x86_64-linux. OK for trunk?

-- 
Regards,
    Mikhail Maltsev

[-- Attachment #2: part_spec_wi.patch --]
[-- Type: text/x-patch, Size: 2230 bytes --]

diff --git a/gcc/wide-int.h b/gcc/wide-int.h
index d8f7b46..6e0275f 100644
--- a/gcc/wide-int.h
+++ b/gcc/wide-int.h
@@ -360,21 +360,18 @@ namespace wi
      inputs.  Note that CONST_PRECISION and VAR_PRECISION cannot be
      mixed, in order to give stronger type checking.  When both inputs
      are CONST_PRECISION, they must have the same precision.  */
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, FLEXIBLE_PRECISION, FLEXIBLE_PRECISION>
   {
     typedef widest_int result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, FLEXIBLE_PRECISION, VAR_PRECISION>
   {
     typedef wide_int result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, FLEXIBLE_PRECISION, CONST_PRECISION>
   {
@@ -384,14 +381,12 @@ namespace wi
 			       <int_traits <T2>::precision> > result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, VAR_PRECISION, FLEXIBLE_PRECISION>
   {
     typedef wide_int result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, CONST_PRECISION, FLEXIBLE_PRECISION>
   {
@@ -401,7 +396,6 @@ namespace wi
 			       <int_traits <T1>::precision> > result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, CONST_PRECISION, CONST_PRECISION>
   {
@@ -412,7 +406,6 @@ namespace wi
 			       <int_traits <T1>::precision> > result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, VAR_PRECISION, VAR_PRECISION>
   {
@@ -876,7 +869,6 @@ generic_wide_int <storage>::dump () const
 
 namespace wi
 {
-  template <>
   template <typename storage>
   struct int_traits < generic_wide_int <storage> >
     : public wi::int_traits <storage>
@@ -955,7 +947,6 @@ inline wide_int_ref_storage <SE>::wide_int_ref_storage (const T &x,
 
 namespace wi
 {
-  template <>
   template <bool SE>
   struct int_traits <wide_int_ref_storage <SE> >
   {
@@ -1142,7 +1133,6 @@ public:
 
 namespace wi
 {
-  template <>
   template <int N>
   struct int_traits < fixed_wide_int_storage <N> >
   {

[-- Attachment #3: part_spec_wi.clog --]
[-- Type: text/plain, Size: 173 bytes --]

gcc/ChangeLog:

2015-07-17  Mikhail Maltsev  <maltsevm@gmail.com>

	* wide-int.h (struct binary_traits): Fix partial specialization syntax.
	(struct int_traits): Likewise.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix partial template specialization syntax in wide-int.h
  2015-07-17  9:30 [PATCH] Fix partial template specialization syntax in wide-int.h Mikhail Maltsev
@ 2015-07-17 17:38 ` Mike Stump
  2015-07-20  7:51   ` Mikhail Maltsev
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Stump @ 2015-07-17 17:38 UTC (permalink / raw)
  To: Mikhail Maltsev; +Cc: gcc-patches

On Jul 17, 2015, at 2:28 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> The following code (reduced from wide-int.h) is rejected by Intel C++ Compiler
> (EDG-based):

So, could you test this with the top of the tree compiler and file a bug report against g++ for it, if it seems to not work right.  If that bug report is rejected, then I’d say file a bug report against clang and EDG.

> I think that the warning is correct, and "template <>" should not be used here.
> The attached patch should fix this issue. Bootstrapped and regtested on
> x86_64-linux. OK for trunk?

Ok.  Does this need to go into the gcc-5 release branch as well?  If so, ok there too.  Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix partial template specialization syntax in wide-int.h
  2015-07-17 17:38 ` Mike Stump
@ 2015-07-20  7:51   ` Mikhail Maltsev
  2015-10-19 19:41     ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Mikhail Maltsev @ 2015-07-20  7:51 UTC (permalink / raw)
  To: Mike Stump; +Cc: gcc-patches

On 07/17/2015 07:46 PM, Mike Stump wrote:
> On Jul 17, 2015, at 2:28 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
>> The following code (reduced from wide-int.h) is rejected by Intel C++
>> Compiler (EDG-based):
> 
> So, could you test this with the top of the tree compiler and file a bug
> report against g++ for it, if it seems to not work right.  If that bug report
> is rejected, then IÂ’d say file a bug report against clang and EDG.

In addition to usual bootstrap+regtest, I also checked that build succeeds with
GCC 4.3.6 (IIRC, this is now the minimal required version) as well as with
recent GCC snapshot used as stage 0. Committed as r225993.
I also filed this bugreport: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66941

>> I think that the warning is correct, and "template <>" should not be used
>> here. The attached patch should fix this issue. Bootstrapped and regtested
>> on x86_64-linux. OK for trunk?
> 
> Ok.  Does this need to go into the gcc-5 release branch as well?  If so, ok
> there too.  Thanks.
I think there is no need for it.

-- 
Regards,
    Mikhail Maltsev

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix partial template specialization syntax in wide-int.h
  2015-07-20  7:51   ` Mikhail Maltsev
@ 2015-10-19 19:41     ` H.J. Lu
  2015-10-19 19:48       ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2015-10-19 19:41 UTC (permalink / raw)
  To: Mikhail Maltsev; +Cc: Mike Stump, gcc-patches

On Mon, Jul 20, 2015 at 12:15 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> On 07/17/2015 07:46 PM, Mike Stump wrote:
>> On Jul 17, 2015, at 2:28 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
>>> The following code (reduced from wide-int.h) is rejected by Intel C++
>>> Compiler (EDG-based):
>>
>> So, could you test this with the top of the tree compiler and file a bug
>> report against g++ for it, if it seems to not work right.  If that bug report
>> is rejected, then I’d say file a bug report against clang and EDG.
>
> In addition to usual bootstrap+regtest, I also checked that build succeeds with
> GCC 4.3.6 (IIRC, this is now the minimal required version) as well as with
> recent GCC snapshot used as stage 0. Committed as r225993.
> I also filed this bugreport: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66941
>
>>> I think that the warning is correct, and "template <>" should not be used
>>> here. The attached patch should fix this issue. Bootstrapped and regtested
>>> on x86_64-linux. OK for trunk?
>>
>> Ok.  Does this need to go into the gcc-5 release branch as well?  If so, ok
>> there too.  Thanks.
> I think there is no need for it.

It is also need for gcc-5. I am backporting it now.


-- 
H.J.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix partial template specialization syntax in wide-int.h
  2015-10-19 19:41     ` H.J. Lu
@ 2015-10-19 19:48       ` H.J. Lu
  2015-10-21 17:01         ` Mike Stump
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2015-10-19 19:48 UTC (permalink / raw)
  To: Mikhail Maltsev; +Cc: Mike Stump, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1404 bytes --]

On Mon, Oct 19, 2015 at 12:39 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Jul 20, 2015 at 12:15 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
>> On 07/17/2015 07:46 PM, Mike Stump wrote:
>>> On Jul 17, 2015, at 2:28 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
>>>> The following code (reduced from wide-int.h) is rejected by Intel C++
>>>> Compiler (EDG-based):
>>>
>>> So, could you test this with the top of the tree compiler and file a bug
>>> report against g++ for it, if it seems to not work right.  If that bug report
>>> is rejected, then I’d say file a bug report against clang and EDG.
>>
>> In addition to usual bootstrap+regtest, I also checked that build succeeds with
>> GCC 4.3.6 (IIRC, this is now the minimal required version) as well as with
>> recent GCC snapshot used as stage 0. Committed as r225993.
>> I also filed this bugreport: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66941
>>
>>>> I think that the warning is correct, and "template <>" should not be used
>>>> here. The attached patch should fix this issue. Bootstrapped and regtested
>>>> on x86_64-linux. OK for trunk?
>>>
>>> Ok.  Does this need to go into the gcc-5 release branch as well?  If so, ok
>>> there too.  Thanks.
>> I think there is no need for it.
>
> It is also need for gcc-5. I am backporting it now.
>

This is what I checked into gcc-5-branch.

-- 
H.J.

[-- Attachment #2: 0001-Fix-partial-specialization-syntax-of-wide-int-traits.patch --]
[-- Type: text/x-patch, Size: 3251 bytes --]

From 4ae06c3dbe5fb2c4d345060b1ba9cd34b2dc7d37 Mon Sep 17 00:00:00 2001
From: miyuki <miyuki@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 20 Jul 2015 05:30:12 +0000
Subject: [PATCH] Fix partial specialization syntax of wide int traits.

gcc/
	* wide-int.h (struct binary_traits): Fix partial specialization syntax.
	(struct int_traits): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225993 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog  |  8 ++++++++
 gcc/wide-int.h | 10 ----------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7fb0538..45ae071 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2015-10-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+	Backport from mainline
+	2015-07-20  Mikhail Maltsev  <maltsevm@gmail.com>
+
+	* wide-int.h (struct binary_traits): Fix partial specialization syntax.
+	(struct int_traits): Likewise.
+
 2015-10-16  Richard Sandiford  <richard.sandiford@arm.com>
 
 	PR middle-end/66311
diff --git a/gcc/wide-int.h b/gcc/wide-int.h
index 46f4545..9a71c4f 100644
--- a/gcc/wide-int.h
+++ b/gcc/wide-int.h
@@ -365,21 +365,18 @@ namespace wi
      inputs.  Note that CONST_PRECISION and VAR_PRECISION cannot be
      mixed, in order to give stronger type checking.  When both inputs
      are CONST_PRECISION, they must have the same precision.  */
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, FLEXIBLE_PRECISION, FLEXIBLE_PRECISION>
   {
     typedef widest_int result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, FLEXIBLE_PRECISION, VAR_PRECISION>
   {
     typedef wide_int result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, FLEXIBLE_PRECISION, CONST_PRECISION>
   {
@@ -389,14 +386,12 @@ namespace wi
 			       <int_traits <T2>::precision> > result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, VAR_PRECISION, FLEXIBLE_PRECISION>
   {
     typedef wide_int result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, CONST_PRECISION, FLEXIBLE_PRECISION>
   {
@@ -406,7 +401,6 @@ namespace wi
 			       <int_traits <T1>::precision> > result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, CONST_PRECISION, CONST_PRECISION>
   {
@@ -417,7 +411,6 @@ namespace wi
 			       <int_traits <T1>::precision> > result_type;
   };
 
-  template <>
   template <typename T1, typename T2>
   struct binary_traits <T1, T2, VAR_PRECISION, VAR_PRECISION>
   {
@@ -881,7 +874,6 @@ generic_wide_int <storage>::dump () const
 
 namespace wi
 {
-  template <>
   template <typename storage>
   struct int_traits < generic_wide_int <storage> >
     : public wi::int_traits <storage>
@@ -960,7 +952,6 @@ inline wide_int_ref_storage <SE>::wide_int_ref_storage (const T &x,
 
 namespace wi
 {
-  template <>
   template <bool SE>
   struct int_traits <wide_int_ref_storage <SE> >
   {
@@ -1147,7 +1138,6 @@ public:
 
 namespace wi
 {
-  template <>
   template <int N>
   struct int_traits < fixed_wide_int_storage <N> >
   {
-- 
2.4.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix partial template specialization syntax in wide-int.h
  2015-10-19 19:48       ` H.J. Lu
@ 2015-10-21 17:01         ` Mike Stump
  0 siblings, 0 replies; 6+ messages in thread
From: Mike Stump @ 2015-10-21 17:01 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Mikhail Maltsev, gcc-patches

On Oct 19, 2015, at 12:46 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> Ok.  Does this need to go into the gcc-5 release branch as well?  If so, ok
>>>> there too.  Thanks.
>>> I think there is no need for it.
>> 
>> It is also need for gcc-5. I am backporting it now.
> 
> This is what I checked into gcc-5-branch.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-10-21 16:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-17  9:30 [PATCH] Fix partial template specialization syntax in wide-int.h Mikhail Maltsev
2015-07-17 17:38 ` Mike Stump
2015-07-20  7:51   ` Mikhail Maltsev
2015-10-19 19:41     ` H.J. Lu
2015-10-19 19:48       ` H.J. Lu
2015-10-21 17:01         ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).