[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 09:23:39 PDT 2020


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

Thanks Hubert for the suggestion. I've updated the lit test.


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,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;
+
+// Note, there is intentionally trailing whitespace one lines below.
 // ??/
-error here; // expected-error {{}}
+error here;
 
-// Note, there is intentionally trailing whitespace two lines below.
-// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
-// ??/  
-error here; // expected-error {{}}
+#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
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.285399.patch
Type: text/x-patch
Size: 3392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200813/f62f7953/attachment.bin>


More information about the cfe-commits mailing list