[PATCH] D141591: [clang][Interp] Properly identify not-yet-defined functions

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 3 01:39:40 PST 2023


tbaeder added inline comments.


================
Comment at: clang/test/AST/Interp/functions.cpp:158-174
+struct F {
+  constexpr bool ok() const {
+    return okRecurse();
+  }
+  constexpr bool okRecurse() const {
+    return true;
+  }
----------------
aaron.ballman wrote:
> Should we have some similar tests involving free functions as well?
> 
> Also, how does `BodylessMemberFunction` differ from `F`? They both look to be testing the same thing aside from return types.
> 
> Should we have a test that involves a defaulted special member function that is called explicitly? e.g., https://godbolt.org/z/nzjEcPMKG (Clang is correct here, GCC fails to catch the UB).
We have a test for free-standing functions already higher up:

```
constexpr int f(); // expected-note {{declared here}} \
                   // ref-note {{declared here}}
[...]
constexpr int a() {
  return f();
}
constexpr int f() {
  return 5;
}
static_assert(a() == 5, "");
```

I //think// the two used to test something different, but now they test the same thing, yes. I'll remove one of them.

> Should we have a test that involves a defaulted special member function that is called explicitly? e.g., https://godbolt.org/z/nzjEcPMKG (Clang is correct here, GCC fails to catch the UB).

That is also caught but the diagnostics are in the wrong place (and slightly different. The old interpreter emits "destruction of dereferenced null pointer" while the new one does "member call on dereferenced null pointer").


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

https://reviews.llvm.org/D141591



More information about the cfe-commits mailing list