[clang] Diagnose const and pure attributes on non-function declarations (PR #206039)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 26 05:43:19 PDT 2026
================
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s
+
+// The attributes apply to function declarations, nothing else.
+__attribute__((const)) int func1(void);
+__attribute__((pure)) int func2(void);
+
+[[gnu::const]] int func3(int x) { return 12; }
+[[gnu::pure]] int func4(int x) { return 12; }
+
+#ifdef __cplusplus
+struct CppTest {
----------------
cor3ntin wrote:
Can you add a function template test?
https://github.com/llvm/llvm-project/pull/206039
More information about the cfe-commits
mailing list