From 997ffce43c6d2d3f647eb091c732665049b1f47f Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Sun, 21 Jan 2024 13:18:51 -0500 Subject: [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. --- clang/lib/Frontend/CompilerInvocation.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') 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); -- cgit v1.1