[clang-tools-extra] r326605 - Adds a clang-tidy test for a failing assertion in the misc-misplaced-const check.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 2 11:14:34 PST 2018


Author: aaronballman
Date: Fri Mar  2 11:14:34 2018
New Revision: 326605

URL: http://llvm.org/viewvc/llvm-project?rev=326605&view=rev
Log:
Adds a clang-tidy test for a failing assertion in the misc-misplaced-const check.

The test case previously triggered an assertion in the AST matchers because the QualType being matched is invalid. That is no longer the case after r326604.

Added:
    clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const-cxx17.cpp

Added: clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const-cxx17.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const-cxx17.cpp?rev=326605&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const-cxx17.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const-cxx17.cpp Fri Mar  2 11:14:34 2018
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -std=c++17
+
+// This test previously would cause a failed assertion because the structured
+// binding declaration had no valid type associated with it. This ensures the
+// expected clang diagnostic is generated instead.
+// CHECK-MESSAGES: :[[@LINE+1]]:6: error: decomposition declaration '[x]' requires an initializer [clang-diagnostic-error]
+auto [x];
+
+struct S { int a; };
+S f();
+
+int main() {
+  auto [x] = f();
+}
+




More information about the cfe-commits mailing list