[Bug c++/96209] New: Redundant error message split out when adding "typename" keyword

haoxintu at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jul 15 15:23:14 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96209

            Bug ID: 96209
           Summary: Redundant error message split out when adding
                    "typename" keyword
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

This code, test1.cc and test2.cc ( they are in the same meaning I guess), are
invalid code with a little mistake, but the compiling output is different when
I add the "typename" keyword. Here are the examples:

$cat test1.cc
template <class...> class T{};
:: T < int ... > 
foo ( ... )
{ } 

$cat test2.cc
template <class...> class T{};
typename :: T < int ... > 
foo ( ... )
{ } 

$g++ -w test1.cc
test1.cc:2:12: error: expansion pattern ‘int’ contains no parameter packs
    2 | :: T < int ... >
      |            ^~~
test1.cc:2:16: error: template argument 1 is invalid
    2 | :: T < int ... >
      |                ^

$g++ -w test2.cc
test2.cc:2:21: error: expansion pattern ‘int’ contains no parameter packs
    2 | typename :: T < int ... >
      |                     ^~~
test2.cc:2:25: error: template argument 1 is invalid
    2 | typename :: T < int ... >
      |                         ^
test2.cc:3:1: error: ‘foo’ in namespace ‘::’ does not name a type
    3 | foo ( ... )
      | ^~~
test2.cc:3:7: error: expected unqualified-id before ‘...’ token
    3 | foo ( ... )
      |       ^~~
test2.cc:3:6: error: expected ‘)’ before ‘...’ token
    3 | foo ( ... )
      |     ~^~~~
      |      )

The first two message are ok in test2.cc. And the following message in
unnecessary and useless.

While in clang, only one error message ("error: pack expansion does not contain
any unexpanded parameter packs") is edited in both two cases.

I guess GCC has some room to improve this diagnostic case. Every GCC version
from 5.x onwards behaves the same.

Thanks,
Haoxin


More information about the Gcc-bugs mailing list