diff options
| author | Alexander Kornienko <alexfh@google.com> | 2017-07-31 15:21:26 +0000 |
|---|---|---|
| committer | Alexander Kornienko <alexfh@google.com> | 2017-07-31 15:21:26 +0000 |
| commit | 160d9472f4ae7cdb9df9dec0768a97fa1c3533d0 (patch) | |
| tree | 3396480e68a6a7deaac539b4b6cadcac9fe5eb76 /clang/test | |
| parent | 1e4f60275f8ffc85772621215bf8ef78422364ae (diff) | |
| download | bcm5719-llvm-160d9472f4ae7cdb9df9dec0768a97fa1c3533d0.tar.gz bcm5719-llvm-160d9472f4ae7cdb9df9dec0768a97fa1c3533d0.zip | |
Fix -Wshadow false positives with function-local classes.
Summary:
Fixes http://llvm.org/PR33947.
https://godbolt.org/g/54XRMT
void f(int a) {
struct A {
void g(int a) {}
A() { int a; }
};
}
3 : <source>:3:16: warning: declaration shadows a local variable [-Wshadow]
void g(int a) {}
^
1 : <source>:1:12: note: previous declaration is here
void f(int a) {
^
4 : <source>:4:15: warning: declaration shadows a local variable [-Wshadow]
A() { int a; }
^
1 : <source>:1:12: note: previous declaration is here
void f(int a) {
^
2 warnings generated.
The local variable `a` of the function `f` can't be accessed from a method of
the function-local class A, thus no shadowing occurs and no diagnostic is
needed.
Reviewers: rnk, rsmith, arphaman, Quuxplusone
Reviewed By: rnk, Quuxplusone
Subscribers: Quuxplusone, cfe-commits
Differential Revision: https://reviews.llvm.org/D35941
llvm-svn: 309569
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/SemaCXX/warn-shadow.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-shadow.cpp b/clang/test/SemaCXX/warn-shadow.cpp index d5f0623eb32..3d09c786285 100644 --- a/clang/test/SemaCXX/warn-shadow.cpp +++ b/clang/test/SemaCXX/warn-shadow.cpp @@ -213,3 +213,12 @@ typedef int externC; // expected-note {{previous declaration is here}} void handleLinkageSpec() { typedef void externC; // expected-warning {{declaration shadows a typedef in the global namespace}} } + +namespace PR33947 { +void f(int a) { + struct A { + void g(int a) {} + A() { int a; } + }; +} +} |

