[clang] [clang][ASTImporter] fix variable inline of CXX17 (PR #87314)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 2 08:47:10 PDT 2024


================
@@ -5317,6 +5317,34 @@ TEST_P(ASTImporterOptionSpecificTestBase,
   EXPECT_FALSE(ToX);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, VarTemplateDeclInlineWithCXX17) {
+  Decl *FromTU = getTuDecl(
+      R"(
+      struct S {
+        template <unsigned> static constexpr bool X = true;
+      };
+      )",
+      Lang_CXX17, "input1.cc");
+  Decl *FromTU2 = getTuDecl(
+      R"(
+      struct S {
+        template <unsigned> static constexpr bool X = true;
+        template <typename T> void get() { X<sizeof(T)>; }
+      };
+      template <typename T> T qvariant_cast(const S &v) { return v.get; }
+      )",
+      Lang_CXX17, "input2.cc");
+  auto *FromX = FirstDeclMatcher<VarTemplateDecl>().match(
+      FromTU, varTemplateDecl(hasName("X")));
+  auto *ToX = Import(FromX, Lang_CXX17);
+  EXPECT_TRUE(ToX);
----------------
steakhal wrote:

```suggestion
  ASSERT_TRUE(ToX);
```

https://github.com/llvm/llvm-project/pull/87314


More information about the cfe-commits mailing list