llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.38k stars 12.15k forks source link

Clang++ not detecting ambiguous templates #7623

Closed llvmbot closed 1 year ago

llvmbot commented 14 years ago
Bugzilla Link 7251
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@efriedma-quic

Extended Description

The following is accepted by clang++, but rejected by g++ and icpc as an ambiguous reference as both 'int a' and 'template a' are in the global namespace.

namespace A { template struct a { }; }

using namespace A; int a;

/ a should be an ambiguous reference / a b;

clang++ -v clang version 2.0 (trunk 103456) Target: x86_64-apple-darwin10 Thread model: posix

efriedma-quic commented 14 years ago

I think the issue here is essentially that FilterAcceptableTemplateNames tosses out non-template names before Sema::isTemplateName checks for ambiguities. This tricks the parser into treating the identifier as a template-id, and in the end we ignore any non-template results entirely..

Endilll commented 1 year ago

Fixed as of Clang 3.0. https://godbolt.org/z/7En361Ezv