[PATCH] D85722: [SystemZ][z/OS] enable trigraphs by default on z/OS

Abhina Sree via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 13 06:59:26 PDT 2020


abhina.sreeskantharajan updated this revision to Diff 285362.
abhina.sreeskantharajan added a comment.

Thanks Hubert and Fanbo for reviewing. I updated the comment to Hubert's suggestion, and updated both testcases as requested.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85722/new/

https://reviews.llvm.org/D85722

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Frontend/trigraphs.cpp
  clang/test/Lexer/cxx1z-trigraphs.cpp


Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===================================================================
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -1,14 +1,25 @@
-// 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=notri
+// RUN: %clang_cc1 -std=c++1z %s -verify=tri -ftrigraphs
 
-??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
+??= define foo ;
 
-static_assert("??="[0] == '#', ""); // expected-error {{failed}} expected-warning {{trigraph ignored}}
+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;
+
+#ifndef __MVS__
+// notri-error at 4 {{}} notri-warning at 4 {{trigraph ignored}} tri-warning at 4 {{trigraph converted}}
+// notri-error at 6 {{failed}} notri-warning at 6 {{trigraph ignored}} tri-warning at 6 {{trigraph converted}}
+// notri-error at 9 {{}}
+// tri-warning at 12 {{backslash and newline separated by space}}
+// notri-error at 13 {{}}
+#else
+// notri-warning at 4 {{trigraph converted}} tri-warning at 4 {{trigraph converted}}
+// notri-warning at 6 {{trigraph converted}} tri-warning at 6 {{trigraph converted}}
+// notri-warning at 12 {{backslash and newline separated by space}} tri-warning at 12 {{backslash and newline separated by space}}
+#endif
Index: clang/test/Frontend/trigraphs.cpp
===================================================================
--- clang/test/Frontend/trigraphs.cpp
+++ 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.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2787,7 +2787,9 @@
   // 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);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85722.285362.patch
Type: text/x-patch
Size: 3471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200813/8030c26f/attachment-0001.bin>


More information about the cfe-commits mailing list