[llvm-bugs] [Bug 47042] New: Abbreviated function template in extern "C" block generates error with bad location

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 7 13:31:40 PDT 2020


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

            Bug ID: 47042
           Summary: Abbreviated function template in extern "C" block
                    generates error with bad location
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

When producing an error message about an abbreviated function template
appearing in an extern "C" block, Clang does not appear to have a proper
diagnostic location to refer to (notice the first line of the actual output
listed below).

Note: The error message itself appears to stem from words in [temp.pre] that
prohibit C language linkage for templates, although [dcl.link] doesn't apply C
language linkage to templates in the first place.

Compiler Explorer link: https://godbolt.org/z/GPcoMe

### SOURCE (<stdin>):
extern "C" {
  void g(auto) {}
  void g(void) { g(42); }
}


### COMPILER INVOCATION:
clang++ -cc1 -fsyntax-only -std=c++20 -Wall -Wextra -pedantic-errors -xc++ -


### ACTUAL OUTPUT:
error: templates must have C++ linkage
<stdin>:1:1: note: extern "C" language linkage specification begins here
extern "C" {
^
<stdin>:3:18: error: no matching function for call to 'g'
  void g(void) { g(42); }
                 ^
<stdin>:3:8: note: candidate function not viable: requires 0 arguments, but 1
was provided
  void g(void) { g(42); }
       ^
2 errors generated.


### EXPECTED OUTPUT:
(first error should point to the declarator-id of the abbreviated function
template)


### COMPILER VERSION INFO (clang++ -v):
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
f92e0d9384763913a745cbe9c757fbb40691dcd1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

-- 
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/20200807/ac84f961/attachment.html>


More information about the llvm-bugs mailing list