[LLVMbugs] [Bug 17731] New: Name Hiding is not properly handled.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Oct 29 15:35:26 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17731
Bug ID: 17731
Summary: Name Hiding is not properly handled.
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: zhaoshiz at codeaurora.org
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu,
richard-llvm at metafoo.co.uk
Classification: Unclassified
$ cat name-hiding.cpp
// Hide class name with a function name
void foo1 () {
class C {
public:
C() {}
~C() {}
};
int C();
int ti = C();
class C tc;
}
void goo1 () {
int C();
class C {
public:
C() {}
~C() {}
};
int ti = C();
class C tc;
}
$ clang++ -target arm-none-linux-gnueabi -mfloat-abi=softfp -mfpu=neon
--sysroot=~/build_tools/gcc-4.6.1-cs/arm-2011.09 -Os -mthumb -c name-hiding.cpp
name-hiding.cpp:17:12: error: reference to 'C' is ambiguous
int ti = C();
^
name-hiding.cpp:17:7: error: no viable conversion from 'C' to 'int'
int ti = C();
^ ~~~
name-hiding.cpp:28:12: error: reference to 'C' is ambiguous
int ti = C();
^
name-hiding.cpp:28:7: error: no viable conversion from 'C' to 'int'
int ti = C();
^ ~~~
2 warnings and 4 errors generated.
(Warnings and notes are removed for clarity.)
>From C++ lang spec:
A class name or enumeration name can be hidden by the name of a variable, data
member,
function, or enumerator declared in the same scope. If a class or enumeration
name and a variable, data
member, function, or enumerator are declared in the same scope (in any order)
with the same name, the
class or enumeration name is hidden wherever the variable, data member,
function, or enumerator name is
visible.
Seems to related to this commit:
commit a41c97a5d1912ffd184381d269fd8e5a25ee5e59
Author: Richard Smith <richard-llvm at metafoo.co.uk>
Date: Fri Sep 20 01:15:31 2013 +0000
Switch the semantic DeclContext for a block-scope declaration of a function
or
variable from being the function to being the enclosing namespace scope (in
C++) or the TU (in C). This allows us to fix a selection of related issues
where we would build incorrect redeclaration chains for such declarations,
and
fail to notice type mismatches.
Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern,
which is only found when searching scopes, and not found when searching
DeclContexts. Such a declaration is only made visible in its DeclContext if
there are no non-LocalExtern declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191064
91177308-0d34-0410-b5e6-96231b3b80d8
--
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/20131029/6da6085b/attachment.html>
More information about the llvm-bugs
mailing list