Abbreviated function template in extern "C"
block generates error with bad location (original) (raw)
Bugzilla Link | 47042 |
---|---|
Version | trunk |
OS | All |
CC | @zygoloid |
Extended Description
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 ():
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