[PATCH] D153911: [cmake] Add -Wcast-qual to C flags if LLVM_ENABLE_WARNINGS is defined.

Alex MacLean via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 17:11:26 PDT 2023


AlexM created this revision.
Herald added subscribers: ekilmer, hiraditya.
Herald added a project: All.
AlexM retitled this revision from "[CMAKE] Add -Wcast-qual to C flags if LLVM_ENABLE_WARNINGS is defined." to "[cmake] Add -Wcast-qual to C flags if LLVM_ENABLE_WARNINGS is defined.".
AlexM added reviewers: dblaikie, nikic, MaskRay, rnk.
Herald added a subscriber: StephenFan.
AlexM published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Disable this warning for specific cast in llvm_regcomp().


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153911

Files:
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/lib/Support/regcomp.c


Index: llvm/lib/Support/regcomp.c
===================================================================
--- llvm/lib/Support/regcomp.c
+++ llvm/lib/Support/regcomp.c
@@ -329,7 +329,15 @@
 
 	/* set things up */
 	p->g = g;
+	/* suppress warning from the following explicit cast. */
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif /* __GNUC__ */
 	p->next = (char *)pattern;	/* convenience; we do not modify it */
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif /* __GNUC__ */
 	p->end = p->next + len;
 	p->error = 0;
 	p->ncsalloc = 0;
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -736,7 +736,7 @@
   endif()
 
   append("-Wextra -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
-  append("-Wcast-qual" CMAKE_CXX_FLAGS)
+  append("-Wcast-qual" CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
 
   # Turn off missing field initializer warnings for gcc to avoid noise from
   # false positives with empty {}. Turn them on otherwise (they're off by


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153911.535100.patch
Type: text/x-patch
Size: 1176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230628/aa89a21b/attachment-0001.bin>


More information about the llvm-commits mailing list