[PATCH] D128119: [clang] enforce instantiation of constexpr template functions

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 1 07:36:14 PDT 2022


aaron.ballman added reviewers: rsmith, clang-language-wg.
aaron.ballman added a comment.

It's a bummer that patch application failed on precommit CI for reasons unrelated to your patch (as best I can tell, anyway)... Also, please update the patch summary to have some more details about what your changing and why.



================
Comment at: clang/test/SemaCXX/constexpr-late-instantiation.cpp:1
+// Make sure foo is sinstantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
----------------



================
Comment at: clang/test/SemaCXX/constexpr-late-instantiation.cpp:2
+// Make sure foo is sinstantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+
----------------
This test should be in CodeGenCXX, not SemaCXX. But there is a SemaCXX test I'd appreciate:
```
template <typename T>
constexpr T foo(T a);

int main() {
  int k = foo<int>(5); // Ok
  constexpr int j = foo<int>(5); // Not okay, a definition is needed for this
}

template <typename T>
constexpr T foo(T a) {
  return a;
}
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128119/new/

https://reviews.llvm.org/D128119



More information about the cfe-commits mailing list