[C++1z] Implement N3981: Disable trigraphs by default in C++1z mode.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 20 Jun 2014 19:23:57 +0000 (19:23 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 20 Jun 2014 19:23:57 +0000 (19:23 +0000)
llvm-svn: 211392

clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Lexer/cxx1z-trigraphs.cpp [new file with mode: 0644]

index beaa092..4647179 100644 (file)
@@ -1167,7 +1167,8 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
 
   // Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs
   // is specified, or -std is set to a conforming mode.
-  Opts.Trigraphs = !Opts.GNUMode;
+  // Trigraphs are disabled by default in c++1z onwards.
+  Opts.Trigraphs = !Opts.GNUMode && !Opts.CPlusPlus1z;
 
   Opts.DollarIdents = !Opts.AsmPreprocessor;
 
diff --git a/clang/test/Lexer/cxx1z-trigraphs.cpp b/clang/test/Lexer/cxx1z-trigraphs.cpp
new file mode 100644 (file)
index 0000000..410626f
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++1z %s -verify
+// RUN: %clang_cc1 -std=c++1z %s -trigraphs -fsyntax-only
+
+??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
+
+static_assert("??="[0] == '#', ""); // expected-error {{failed}} expected-warning {{trigraph ignored}}
+
+// ??/
+error here; // expected-error {{}}