[2/2] gdb: fix array-view-selftests.c build with g++ 4.8

Message ID 20211118205053.2429353-2-simon.marchi@efficios.com
State New
Headers show
Series
  • [1/2] gdb: fix ia64-tdep.c build with g++ 4.8
Related show

Commit Message

Mike Frysinger via Gdb-patches Nov. 18, 2021, 8:50 p.m.
When building with g++ 4.8, I get:

    CXX    unittests/array-view-selftests.o
  /home/smarchi/src/binutils-gdb/gdb/unittests/array-view-selftests.c:123:42: error: expected 'class' before 'Container'
   template<template<typename ...> typename Container>
					    ^

I am no C++ template expert, but it looks like if I change "typename" for
"class", as the compiler kind of suggests, the code compiles.

Change-Id: I9c3edd29fb2b190069f0ce0dbf3bc3604d175f48
---
 gdb/unittests/array-view-selftests.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.33.1

Comments

Mike Frysinger via Gdb-patches Nov. 18, 2021, 9:11 p.m. | #1
On Thu, Nov 18, 2021 at 03:50:53PM -0500, Simon Marchi via Gdb-patches wrote:
> When building with g++ 4.8, I get:

> 

>     CXX    unittests/array-view-selftests.o

>   /home/smarchi/src/binutils-gdb/gdb/unittests/array-view-selftests.c:123:42: error: expected 'class' before 'Container'

>    template<template<typename ...> typename Container>

> 					    ^

> 

> I am no C++ template expert, but it looks like if I change "typename" for

> "class", as the compiler kind of suggests, the code compiles.


Indeed. Apparently 'typename' can be used instead of 'class' in a
template template parameter only starting c++17[1].

Thanks for taking care of this.

Lancelot.

[1] https://en.cppreference.com/w/cpp/language/template_parameters#Template_template_parameter

q> 
> Change-Id: I9c3edd29fb2b190069f0ce0dbf3bc3604d175f48

> ---

>  gdb/unittests/array-view-selftests.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/gdb/unittests/array-view-selftests.c b/gdb/unittests/array-view-selftests.c

> index fe211a647b5..9df48db3912 100644

> --- a/gdb/unittests/array-view-selftests.c

> +++ b/gdb/unittests/array-view-selftests.c

> @@ -120,7 +120,7 @@ check ()

>  /* Check that there's no container->view conversion for containers of derived

>     types or subclasses.  */

>  

> -template<template<typename ...> typename Container>

> +template<template<typename ...> class Container>

>  static constexpr bool

>  check_ctor_from_container ()

>  {

> -- 

> 2.33.1

>
Simon Marchi Nov. 18, 2021, 9:36 p.m. | #2
On 2021-11-18 4:11 p.m., Lancelot SIX via Gdb-patches wrote:
> On Thu, Nov 18, 2021 at 03:50:53PM -0500, Simon Marchi via Gdb-patches wrote:

>> When building with g++ 4.8, I get:

>>

>>     CXX    unittests/array-view-selftests.o

>>   /home/smarchi/src/binutils-gdb/gdb/unittests/array-view-selftests.c:123:42: error: expected 'class' before 'Container'

>>    template<template<typename ...> typename Container>

>> 					    ^

>>

>> I am no C++ template expert, but it looks like if I change "typename" for

>> "class", as the compiler kind of suggests, the code compiles.

> 

> Indeed. Apparently 'typename' can be used instead of 'class' in a

> template template parameter only starting c++17[1].

> 

> Thanks for taking care of this.

> 

> Lancelot.

> 

> [1] https://en.cppreference.com/w/cpp/language/template_parameters#Template_template_parameter


Ok, thanks for the info.  Since you acked this patch and patch 1/2
fixes a regression I introduced, I pushed the two patches.

Simon

Patch

diff --git a/gdb/unittests/array-view-selftests.c b/gdb/unittests/array-view-selftests.c
index fe211a647b5..9df48db3912 100644
--- a/gdb/unittests/array-view-selftests.c
+++ b/gdb/unittests/array-view-selftests.c
@@ -120,7 +120,7 @@  check ()
 /* Check that there's no container->view conversion for containers of derived
    types or subclasses.  */
 
-template<template<typename ...> typename Container>
+template<template<typename ...> class Container>
 static constexpr bool
 check_ctor_from_container ()
 {