[clang] [Clang][Sema] Diagnose invalid 'pure'/'const' attributes on writes (PR #217817)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 31 00:59:11 PDT 2026
================
@@ -10,16 +10,14 @@ __attribute__((pure)) int func2(void);
#ifdef __cplusplus
struct CppTest {
- // They are fine on member functions.
- __attribute__((const)) int func();
+// They are fine on member functions.
+__attribute__((const)) int func();
[[gnu::pure]] int other_func();
-
- int another();
-
- // Constructors and destructors are not allowed though because they
- // notionally return void.
+int another();
+// Constructors and destructors are not allowed though because they
+// notionally return void.
[[__gnu__::__const__]] CppTest(); // expected-warning {{'const' attribute on function returning 'void'; attribute ignored}}
- __attribute__((pure)) ~CppTest(); // expected-warning {{'pure' attribute on function returning 'void'; attribute ignored}}
+__attribute__((pure)) ~CppTest(); // expected-warning {{'pure' attribute on function returning 'void'; attribute ignored}}
----------------
ojhunt wrote:
unneeded change
https://github.com/llvm/llvm-project/pull/217817
More information about the cfe-commits
mailing list