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@4 {{}} notri-warning@4 {{trigraph ignored}} tri-warning@4
{{trigraph converted}}
+// notri-error@6 {{failed}} notri-warning@6 {{trigraph ignored}} tri-warning@6
{{trigraph converted}}
+// notri-error@9 {{}}
+// tri-warning@12 {{backslash and newline separated by space}}
+// notri-error@13 {{}}
+#else
+// notri-warning@4 {{trigraph converted}} tri-warning@4 {{trigraph converted}}
+// notri-warning@6 {{trigraph converted}} tri-warning@6 {{trigraph converted}}
+// notri-warning@12 {{backslash and newline separated by space}}
tri-warning@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);
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@4 {{}} notri-warning@4 {{trigraph ignored}} tri-warning@4 {{trigraph converted}}
+// notri-error@6 {{failed}} notri-warning@6 {{trigraph ignored}} tri-warning@6 {{trigraph converted}}
+// notri-error@9 {{}}
+// tri-warning@12 {{backslash and newline separated by space}}
+// notri-error@13 {{}}
+#else
+// notri-warning@4 {{trigraph converted}} tri-warning@4 {{trigraph converted}}
+// notri-warning@6 {{trigraph converted}} tri-warning@6 {{trigraph converted}}
+// notri-warning@12 {{backslash and newline separated by space}} tri-warning@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);
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits