[PATCH] D38009: [Sema] Fix using old initializer during switch statement transformation.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 21 11:00:24 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313896: [Sema] Fix using old initializer during switch statement transformation. (authored by vsapsai).
Changed prior to commit:
https://reviews.llvm.org/D38009?vs=115754&id=116226#toc
Repository:
rL LLVM
https://reviews.llvm.org/D38009
Files:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
Index: cfe/trunk/lib/Sema/TreeTransform.h
===================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -6601,8 +6601,7 @@
// Rebuild the switch statement.
StmtResult Switch
- = getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(),
- S->getInit(), Cond);
+ = getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Init.get(), Cond);
if (Switch.isInvalid())
return StmtError();
Index: cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
+++ cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++1z -verify -emit-llvm-only %s
+// expected-no-diagnostics
+
+// rdar://problem/33888545
+template <unsigned int BUFFER_SIZE> class Buffer {};
+
+class A {
+public:
+ int status;
+};
+
+template <unsigned int N> A parse(Buffer<N> buffer);
+
+template<unsigned int N>
+void init_in_if(Buffer<N> buffer) {
+ if (A a = parse(buffer); a.status > 0) {
+ }
+}
+
+template<unsigned int N>
+void init_in_switch(Buffer<N> buffer) {
+ switch (A a = parse(buffer); a.status) {
+ default:
+ break;
+ }
+}
+
+void test() {
+ Buffer<10> buffer;
+ init_in_if(buffer);
+ init_in_switch(buffer);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38009.116226.patch
Type: text/x-patch
Size: 1426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170921/b5a67240/attachment-0001.bin>
More information about the cfe-commits
mailing list