aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2024-01-21 13:18:51 -0500
committerAaron Ballman <aaron@aaronballman.com>2024-01-21 13:20:56 -0500
commit997ffce43c6d2d3f647eb091c732665049b1f47f (patch)
treef1029f75b98a5d3c07bd134295c9137008a53f6d /clang/lib/Frontend/CompilerInvocation.cpp
parentbc82cfb38d83f1afeb2c290aa472c2e2e88919cb (diff)
downloadllvm-997ffce43c6d2d3f647eb091c732665049b1f47f.zip
llvm-997ffce43c6d2d3f647eb091c732665049b1f47f.tar.gz
llvm-997ffce43c6d2d3f647eb091c732665049b1f47f.tar.bz2
[C23] Implement N2490, Remove trigraphs??!
This follows the same implementation logic as with C++ and is compatible with the GCC behavior in C. Trigraphs are enabled by default in -std=c* conformance modes before C23, but are disabled in GNU and Microsoft modes as well as in C23 or later.
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index ed9cd12..7edea77 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3480,7 +3480,8 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
Twine(Major) + "." + Twine(Minor) + "." + Twine(Subminor));
}
- if ((!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17) || T.isOSzOS()) {
+ if ((!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17 && !Opts.C23) ||
+ T.isOSzOS()) {
if (!Opts.Trigraphs)
GenerateArg(Consumer, OPT_fno_trigraphs);
} else {
@@ -3876,10 +3877,11 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
// Mimicking gcc's behavior, trigraphs are only enabled if -trigraphs
// is specified, or -std is set to a conforming mode.
- // Trigraphs are disabled by default in c++1z onwards.
+ // Trigraphs are disabled by default in C++17 and C23 onwards.
// For z/OS, trigraphs are enabled by default (without regard to the above).
Opts.Trigraphs =
- (!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17) || T.isOSzOS();
+ (!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17 && !Opts.C23) ||
+ T.isOSzOS();
Opts.Trigraphs =
Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);