[llvm-bugs] [Bug 46606] New: Missing -Wshadow warning in a try-catch block
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jul 6 09:22:55 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46606
Bug ID: 46606
Summary: Missing -Wshadow warning in a try-catch block
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
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
Hi, all.
This code, test.cc, Clang might miss the -Wshadow warning message.
$cat test.cc
int var = 10;
int main(){
try { } catch ( int var ) { }
}
$clang++ -Wshadow test.cc
//emits nothing
$clang++ -v
clang version 11.0.0 (https://github.com/llvm/llvm-project
b9306fd042ce1c11d84f05d2124dfdc65b8331fe)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
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
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64
While in gcc
$g++ -Wshadow test.cc
test.cc: In function ‘int main()’:
test.cc:3:24: warning: declaration of ‘var’ shadows a global declaration
[-Wshadow]
3 | try { } catch ( int var ) { }
| ^~~
test.cc:1:5: note: shadowed declaration is here
1 | int var = 10;
| ^~~
Every version from clang 3.0 onwards behaves the same.
Thanks,
Haoxin
--
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/20200706/3aa65848/attachment.html>
More information about the llvm-bugs
mailing list