[clang] dedaf78 - [SystemZ][z/OS] enable trigraphs by default on z/OS
Hubert Tong via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 13 13:02:13 PDT 2020
Author: Abhina Sreeskantharajan
Date: 2020-08-13T16:02:07-04:00
New Revision: dedaf78fa71433d3c9da2e3d2f3dad3e9cd3bdd2
URL: https://github.com/llvm/llvm-project/commit/dedaf78fa71433d3c9da2e3d2f3dad3e9cd3bdd2
DIFF: https://github.com/llvm/llvm-project/commit/dedaf78fa71433d3c9da2e3d2f3dad3e9cd3bdd2.diff
LOG: [SystemZ][z/OS] enable trigraphs by default on z/OS
This patch enables trigraphs on z/OS.
Reviewed By: hubert.reinterpretcast, fanbo-meng
Differential Revision: https://reviews.llvm.org/D85722
Added:
Modified:
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Frontend/trigraphs.cpp
clang/test/Lexer/cxx1z-trigraphs.cpp
Removed:
################################################################################
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index c3c8f3b9c6a9..17c43ec55c79 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2787,7 +2787,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
// 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.
- Opts.Trigraphs = !Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17;
+ // For z/OS, trigraphs are enabled by default (without regard to the above).
+ Opts.Trigraphs =
+ (!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17) || T.isOSzOS();
Opts.Trigraphs =
Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
diff --git a/clang/test/Frontend/trigraphs.cpp b/clang/test/Frontend/trigraphs.cpp
index 552078951aee..f65ad10b8eb7 100644
--- a/clang/test/Frontend/trigraphs.cpp
+++ b/clang/test/Frontend/trigraphs.cpp
@@ -4,12 +4,14 @@
// RUN: %clang_cc1 -DSTDCPP17 -std=c++1z -verify -fsyntax-only %s
// RUN: %clang_cc1 -DSTDCPP17TRI -ftrigraphs -std=c++1z -verify -fsyntax-only %s
// RUN: %clang_cc1 -DMSCOMPAT -fms-compatibility -std=c++11 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -DNOTRI -fno-trigraphs -verify -fsyntax-only %s
void foo() {
#if defined(NOFLAGS) || defined(STDCPP11) || defined(STDGNU11TRI) || \
- defined(STDCPP17TRI)
+ defined(STDCPP17TRI) || (defined(__MVS__) && !defined(NOTRI))
const char c[] = "??/n"; // expected-warning{{trigraph converted to '\' character}}
-#elif defined(STDGNU11) || defined(STDCPP17) || defined(MSCOMPAT)
+#elif defined(STDGNU11) || defined(STDCPP17) || defined(MSCOMPAT) || \
+ defined(NOTRI)
const char c[] = "??/n"; // expected-warning{{trigraph ignored}}
#else
#error Not handled.
diff --git a/clang/test/Lexer/cxx1z-trigraphs.cpp b/clang/test/Lexer/cxx1z-trigraphs.cpp
index 08c45e51f833..d6069e77f897 100644
--- a/clang/test/Lexer/cxx1z-trigraphs.cpp
+++ b/clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -1,14 +1,31 @@
// RUN: %clang_cc1 -std=c++1z %s -verify
-// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only 2>&1 | FileCheck --check-prefix=TRIGRAPHS %s
+// RUN: %clang_cc1 -std=c++1z %s -verify -ftrigraphs -DENABLED_TRIGRAPHS=1
+// RUN: %clang_cc1 -std=c++1z %s -verify -fno-trigraphs -DENABLED_TRIGRAPHS=0
-??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
+#ifdef __MVS__
+#ifndef ENABLED_TRIGRAPHS
+#define ENABLED_TRIGRAPHS 1
+#endif
+#endif
-static_assert("??="[0] == '#', ""); // expected-error {{failed}} expected-warning {{trigraph ignored}}
+??= define foo ;
+
+static_assert("??="[0] == '#', "");
// ??/
-error here; // expected-error {{}}
+error here;
-// Note, there is intentionally trailing whitespace two lines below.
-// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
+// Note, there is intentionally trailing whitespace one line below.
// ??/
-error here; // expected-error {{}}
+error here;
+
+#if !ENABLED_TRIGRAPHS
+// expected-error at 11 {{}} expected-warning at 11 {{trigraph ignored}}
+// expected-error at 13 {{failed}} expected-warning at 13 {{trigraph ignored}}
+// expected-error at 16 {{}}
+// expected-error at 20 {{}}
+#else
+// expected-warning at 11 {{trigraph converted}}
+// expected-warning at 13 {{trigraph converted}}
+// expected-warning at 19 {{backslash and newline separated by space}}
+#endif
More information about the cfe-commits
mailing list