[llvm-bugs] [Bug 46289] New: lack of "templates must have C++ linkage" error message in a linkage specification

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 11 11:01:14 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46289

            Bug ID: 46289
           Summary: lack of "templates must have C++ linkage" error
                    message in a linkage specification
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

This code bug.cc

namespace g_namespace{}
extern  "C" {template  <class> using g_namespace;}
extern  "C" {template  <class> void foo(){}}

Clang only gives the "templates must have C++ linkage" error message in line 3,
but missed in line2.

$clang++ -c bug.cc
<source>:2:32: error: cannot template a using declaration
extern  "C" {template  <class> using g_namespace;}
             ~~~~~~~~~~~~~~~~~ ^
<source>:3:14: error: templates must have C++ linkage
extern  "C" {template  <class> void foo(){}}
             ^~~~~~~~~~~~~~~~~
<source>:3:1: note: extern "C" language linkage specification begins here
extern  "C" {template  <class> void foo(){}}
^
2 errors generated.

While in GCC and msvc, they all give two error messages in line 2 and 3 that
indicates "template with C linkage" is wrong.

Reproduced in godbolt : https://godbolt.org/z/B-KzLw

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200611/be2f08ca/attachment.html>


More information about the llvm-bugs mailing list