abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: thakis, hubert.reinterpretcast, 
uweigand, yusra.syeda, Kai, zibi, MaskRay, anirudhp.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
abhina.sreeskantharajan requested review of this revision.

This patch enables trigraphs on z/OS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85722

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Frontend/trigraphs.cpp


Index: clang/test/Frontend/trigraphs.cpp
===================================================================
--- clang/test/Frontend/trigraphs.cpp
+++ clang/test/Frontend/trigraphs.cpp
@@ -4,12 +4,15 @@
 // 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 -DZOS -triple=s390x-none-zos -verify -fsyntax-only %s
+// RUN: %clang_cc1 -DZOSNOTRI -triple=s390x-none-zos -fno-trigraphs -verify 
-fsyntax-only %s
 
 void foo() {
 #if defined(NOFLAGS) || defined(STDCPP11) || defined(STDGNU11TRI) || \
-    defined(STDCPP17TRI)
+    defined(STDCPP17TRI) || defined(ZOS)
   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(ZOSNOTRI)
   const char c[] = "??/n"; // expected-warning{{trigraph ignored}}
 #else
 #error Not handled.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2785,9 +2785,10 @@
   }
 
   // Mimicking gcc's behavior, trigraphs are only enabled if -trigraphs
-  // is specified, or -std is set to a conforming mode.
+  // is specified, -std is set to a conforming mode, or on z/OS.
   // Trigraphs are disabled by default in c++1z onwards.
-  Opts.Trigraphs = !Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17;
+  Opts.Trigraphs =
+      (!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17) || T.isOSzOS();
   Opts.Trigraphs =
       Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
 


Index: clang/test/Frontend/trigraphs.cpp
===================================================================
--- clang/test/Frontend/trigraphs.cpp
+++ clang/test/Frontend/trigraphs.cpp
@@ -4,12 +4,15 @@
 // 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 -DZOS -triple=s390x-none-zos -verify -fsyntax-only %s
+// RUN: %clang_cc1 -DZOSNOTRI -triple=s390x-none-zos -fno-trigraphs -verify -fsyntax-only %s
 
 void foo() {
 #if defined(NOFLAGS) || defined(STDCPP11) || defined(STDGNU11TRI) || \
-    defined(STDCPP17TRI)
+    defined(STDCPP17TRI) || defined(ZOS)
   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(ZOSNOTRI)
   const char c[] = "??/n"; // expected-warning{{trigraph ignored}}
 #else
 #error Not handled.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2785,9 +2785,10 @@
   }
 
   // Mimicking gcc's behavior, trigraphs are only enabled if -trigraphs
-  // is specified, or -std is set to a conforming mode.
+  // is specified, -std is set to a conforming mode, or on z/OS.
   // Trigraphs are disabled by default in c++1z onwards.
-  Opts.Trigraphs = !Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17;
+  Opts.Trigraphs =
+      (!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17) || T.isOSzOS();
   Opts.Trigraphs =
       Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to