[clang] [Clang][Interp] Fix display of syntactically-invalid note for member function calls (PR #102170)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 8 08:28:59 PDT 2024
================
@@ -67,15 +68,19 @@ struct Bar {
template <typename U, int num>
constexpr int fail2() const { return 1 / 0; } // expected-warning {{division by zero}} \
// expected-note {{division by zero}}
+#ifndef NEW_CONST_INTERP
template <typename ...Args>
constexpr int fail3(Args... args) const { return 1 / 0; } // expected-warning {{division by zero}} \
// expected-note {{division by zero}}
+#endif
};
constexpr Bar<int> bar;
static_assert(bar.fail1<int>()); // expected-error {{constant expression}} \
// expected-note {{in call to 'bar.fail1<int>()'}}
static_assert(bar.fail2<int*, 42>()); // expected-error {{constant expression}} \
// expected-note {{in call to 'bar.fail2<int *, 42>()'}}
+#ifndef NEW_CONST_INTERP
static_assert(bar.fail3(3, 4UL, bar, &bar)); // expected-error {{constant expression}} \
// expected-note {{in call to 'bar.fail3<int, unsigned long, Bar<int>, const Bar<int> *>(3, 4, {}, &bar)'}}
----------------
yronglin wrote:
Oh, the problem is in the example: https://godbolt.org/z/PP868Eh87. But I think there seem to be problems on both sides. The 3rd argument looks incorrect.
*New constant interpreter:*
```
<source>:19:15: note: in call to '&bar->fail3<int, unsigned long, Bar<int>, const Bar<int> *>(3, 4, &bar, &bar)'
19 | static_assert(bar.fail3(3, 4UL, bar, &bar)); // expected-error {{constant expression}} \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings and 3 errors generated.
```
*Current constant interpreter:*
```
<source>:19:15: note: in call to 'bar.fail3<int, unsigned long, Bar<int>, const Bar<int> *>(3, 4, {}, &bar)'
19 | static_assert(bar.fail3(3, 4UL, bar, &bar)); // expected-error {{constant expression}} \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings and 3 errors generated.
```
https://github.com/llvm/llvm-project/pull/102170
More information about the cfe-commits
mailing list