Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] Update documentation for #pragma diagnostic #78095

Merged
merged 4 commits into from
Feb 2, 2024

Conversation

Endilll
Copy link
Contributor

@Endilll Endilll commented Jan 14, 2024

GCC has changed over the past decade, and we're not implementing everything they do.
Fixes #51472

@Endilll Endilll added documentation clang Clang issues not falling into any other category extension:gnu labels Jan 14, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 14, 2024

@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)

Changes

GCC has changed over the past decade.
Fixes #51472


Full diff: https://github.com/llvm/llvm-project/pull/78095.diff

1 Files Affected:

  • (modified) clang/docs/UsersManual.rst (+6-10)
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index c6a6b06fc04be7..22fbb6764e2f00 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1132,7 +1132,7 @@ Controlling Diagnostics via Pragmas
 Clang can also control what diagnostics are enabled through the use of
 pragmas in the source code. This is useful for turning off specific
 warnings in a section of source code. Clang supports GCC's pragma for
-compatibility with existing source code, as well as several extensions.
+compatibility with existing source code.
 
 The pragma may control any warning that can be used from the command
 line. Warnings may be set to ignored, warning, error, or fatal. The
@@ -1143,8 +1143,7 @@ warnings:
 
   #pragma GCC diagnostic ignored "-Wall"
 
-In addition to all of the functionality provided by GCC's pragma, Clang
-also allows you to push and pop the current warning state. This is
+Clang also allows you to push and pop the current warning state. This is
 particularly useful when writing a header file that will be compiled by
 other people, because you don't know what warning flags they build with.
 
@@ -1157,19 +1156,16 @@ existed.
   #if foo
   #endif foo // warning: extra tokens at end of #endif directive
 
-  #pragma clang diagnostic push
-  #pragma clang diagnostic ignored "-Wextra-tokens"
+  #pragma GCC diagnostic push
+  #pragma GCC diagnostic ignored "-Wextra-tokens"
 
   #if foo
   #endif foo // no warning
 
-  #pragma clang diagnostic pop
+  #pragma GCC diagnostic pop
 
 The push and pop pragmas will save and restore the full diagnostic state
-of the compiler, regardless of how it was set. That means that it is
-possible to use push and pop around GCC compatible diagnostics and Clang
-will push and pop them appropriately, while GCC will ignore the pushes
-and pops as unknown pragmas. It should be noted that while Clang
+of the compiler, regardless of how it was set. It should be noted that while Clang
 supports the GCC pragma, Clang and GCC do not support the exact same set
 of warnings, so even when using GCC compatible #pragmas there is no
 guarantee that they will have identical behaviour on both compilers.

@Endilll
Copy link
Contributor Author

Endilll commented Jan 17, 2024

I documented that we don't support unpaired pop (tracked in #23065) and enabling diagnostics that are not enabled via CLI (tracked in #78418).

@Endilll Endilll changed the title [clang] Remove outdated parts of documentation for #pragma diagnostic [clang] Update documentation for #pragma diagnostic Jan 22, 2024
Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM aside from a nit, thank you for improving the documentation here!

clang/docs/UsersManual.rst Outdated Show resolved Hide resolved
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
@Endilll Endilll merged commit 3be7979 into llvm:main Feb 2, 2024
5 checks passed
@Endilll Endilll deleted the pragma-diagnostic-docs branch February 2, 2024 08:21
agozillon pushed a commit to agozillon/llvm-project that referenced this pull request Feb 5, 2024
GCC has changed over the past decade, and we're not implementing
everything they do.
Fixes llvm#51472

---------

Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category documentation extension:gnu
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#pragma diagnostic push/pop docs out of date re GCC
3 participants