https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96210
Bug ID: 96210
Summary: Diagnostic message for using-directive in template
definition should be more clear?
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.
Alias template is allowed since c++11 while using-directive is not. The
diagnostic message in using-directive used in template maybe not so clear in
GCC.
For example,
$cat test.cc
namespace N{ }
template <class> using namespace N;
$g++ test.cc
test.cc:2:24: error: expected identifier before 'namespace'
2 | template <class> using namespace N;
| ^~~~~~~~~
<source>:2:35: error: expected '{' before ';' token
2 | template <class> using namespace N;
|
I guess users will be confused with above two error messages and may feel
hopeless to fix it according to the diagnostic information.
Clang might be better in parsing this code
$clang++ test.cc
test.cc:2:18: error: cannot template a using directive
template <class> using namespace N;
~~~~~~~~~~~~~~~~~^
1 error generated.
I guess GCC should also recognize the using directive first and then tell users
this is not allowed in template definition.
Please understand if anything I presented is unsuitable.
Thanks,
Haoxin