summaryrefslogtreecommitdiffstats
path: root/clang/test/FixIt/fixit-vexing-parse.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-09-29 23:57:25 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-09-29 23:57:25 +0000
commitac63d63543ca824434236ffd788c46eec9339657 (patch)
treeb55ea78a09084f92211b3b4bbd8d7e69bf18260c /clang/test/FixIt/fixit-vexing-parse.cpp
parent1d8cf2be89087a2babc1dc38b16040fad0a555e2 (diff)
downloadbcm5719-llvm-ac63d63543ca824434236ffd788c46eec9339657.tar.gz
bcm5719-llvm-ac63d63543ca824434236ffd788c46eec9339657.zip
Add a "vexing parse" warning for ambiguity between a variable declaration and a
function-style cast. This fires for cases such as T(x); ... where 'x' was previously declared and T is a type. This construct declares a variable named 'x' rather than the (probably expected) interpretation of a function-style cast of 'x' to T. llvm-svn: 314570
Diffstat (limited to 'clang/test/FixIt/fixit-vexing-parse.cpp')
-rw-r--r--clang/test/FixIt/fixit-vexing-parse.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/test/FixIt/fixit-vexing-parse.cpp b/clang/test/FixIt/fixit-vexing-parse.cpp
index 71d3eff5329..973c6961a08 100644
--- a/clang/test/FixIt/fixit-vexing-parse.cpp
+++ b/clang/test/FixIt/fixit-vexing-parse.cpp
@@ -106,3 +106,24 @@ namespace N {
wchar_t wc(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
}
}
+
+namespace RedundantParens {
+struct Y {
+ Y();
+ Y(int);
+ ~Y();
+};
+int n;
+
+void test() {
+ // CHECK: add a variable name
+ // CHECK: fix-it:"{{.*}}":{[[@LINE+7]]:4-[[@LINE+7]]:4}:" varname"
+ // CHECK: add enclosing parentheses
+ // CHECK: fix-it:"{{.*}}":{[[@LINE+5]]:3-[[@LINE+5]]:3}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE+4]]:7-[[@LINE+4]]:7}:")"
+ // CHECK: remove parentheses
+ // CHECK: fix-it:"{{.*}}":{[[@LINE+2]]:4-[[@LINE+2]]:5}:" "
+ // CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:6-[[@LINE+1]]:7}:""
+ Y(n); // expected-warning {{declaration of variable named 'n'}} expected-note 3{{}}
+}
+}
OpenPOWER on IntegriCloud