llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.88k stars 11.93k forks source link

#pragma clang diagnostic ignored "-Wdelayed-template-parsing-in-cxx20" does not stop emitting warning #96061

Open torsten48 opened 4 months ago

torsten48 commented 4 months ago

using clang-cl with /Zc:twoPhase-

and #pragma clang diagnostic ignored "-Wdelayed-template-parsing-in-cxx20"

but clang-cl still emits

clang-cl: warning: -fdelayed-template-parsing is deprecated after C++20 [-Wdelayed-template-parsing-in-cxx20]

C:\build\clang> clang-cl --version clang version 18.1.6 Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: c:\devtools\LLVM\bin

llvmbot commented 4 months ago

@llvm/issue-subscribers-clang-frontend

Author: None (torsten48)

using clang-cl with `/Zc:twoPhase-` and `#pragma clang diagnostic ignored "-Wdelayed-template-parsing-in-cxx20"` but clang-cl still emits `clang-cl: warning: -fdelayed-template-parsing is deprecated after C++20 [-Wdelayed-template-parsing-in-cxx20]` C:\build\clang> clang-cl --version clang version 18.1.6 Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: c:\devtools\LLVM\bin
MitalAshok commented 4 months ago

The warning is emitted in the clang driver before the source file is read (i.e., the warning is written to the console before it gets to the pragma), and Clang don't support retroactively removing diagnostics.

Like if you wrote this:

char* p = "";  // Still has a warning

#pragma clang diagnostic ignored "-Wwritable-strings"

Since the pragma directive ignores the warning in the code after it, it doesn't do anything about warnings before it.

Another warning could be added to suggest modifying the command line flags to have -Wno-delayed-template-parsing-in-cxx20. Or this diagnostic could be emitted at the end of every TU so ignoring it would actually work.