Skip to content

[clang] Don't use -Wno-nested-anon-types on GCC #95029

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

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

mstorsjo
Copy link
Member

GCC usually doesn't warn about unrecognized -Wno- options, if no diagnostics are printed. However if some diagnostics are printed, it also mentions that there were unrecognized -Wno- options.

Before 4feae05, we checked for whether -Wnested-anon-types was supported, and added the -Wno- form if the positive form of the option was supported.

As of GCC 14, -Wnested-anon-types isn't supported, thus limit the use of the option to actual Clang (and still only while using the GCC compatible driver).

This avoids unnecessary mentions about unrecognized -Wno- options when building with GCC.

GCC usually doesn't warn about unrecognized -Wno-<foo> options,
if no diagnostics are printed. However if some diagnostics are
printed, it also mentions that there were unrecognized -Wno-<foo>
options.

Before 4feae05, we checked
for whether -Wnested-anon-types was supported, and added the
-Wno-<foo> form if the positive form of the option was supported.

As of GCC 14, -Wnested-anon-types isn't supported, thus limit
the use of the option to actual Clang (and still only while using
the GCC compatible driver).
@mstorsjo mstorsjo requested a review from Endilll June 10, 2024 19:38
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jun 10, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 10, 2024

@llvm/pr-subscribers-clang

Author: Martin Storsjö (mstorsjo)

Changes

GCC usually doesn't warn about unrecognized -Wno-<foo> options, if no diagnostics are printed. However if some diagnostics are printed, it also mentions that there were unrecognized -Wno-<foo> options.

Before 4feae05, we checked for whether -Wnested-anon-types was supported, and added the -Wno-<foo> form if the positive form of the option was supported.

As of GCC 14, -Wnested-anon-types isn't supported, thus limit the use of the option to actual Clang (and still only while using the GCC compatible driver).

This avoids unnecessary mentions about unrecognized -Wno-<foo> options when building with GCC.


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

1 Files Affected:

  • (modified) clang/CMakeLists.txt (+3-1)
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 2ac0bccb42f50..2b5269f2ce2e7 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -350,7 +350,9 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long")
   endif ()
 
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
+  if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
+  endif ()
 endif ()
 
 # Determine HOST_LINK_VERSION on Darwin.

Copy link
Contributor

@Endilll Endilll left a comment

Choose a reason for hiding this comment

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

-Wnested-anon-types isn't supported even by GCC 7.4, so yeah, thank you for fixing this.

@mstorsjo mstorsjo merged commit 41c650e into llvm:main Jun 11, 2024
9 checks passed
@mstorsjo mstorsjo deleted the clang-gcc-warning branch June 11, 2024 06:03
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Jun 12, 2024
GCC usually doesn't warn about unrecognized -Wno-<foo> options, if no
diagnostics are printed. However if some diagnostics are printed, it
also mentions that there were unrecognized -Wno-<foo> options.

Before 4feae05, we checked for whether
-Wnested-anon-types was supported, and added the -Wno-<foo> form if the
positive form of the option was supported.

As of GCC 14, -Wnested-anon-types isn't supported, thus limit the use of
the option to actual Clang (and still only while using the GCC
compatible driver).

This avoids unnecessary mentions about unrecognized -Wno-<foo> options
when building with GCC.
@HerrCai0907 HerrCai0907 mentioned this pull request Jun 13, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants