From: Richard Smith Date: Fri, 20 Jun 2014 19:23:57 +0000 (+0000) Subject: [C++1z] Implement N3981: Disable trigraphs by default in C++1z mode. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b795c57e5759ed77c8f4a5509317dcdf71b6735;p=clang [C++1z] Implement N3981: Disable trigraphs by default in C++1z mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211392 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index beaa092c1e..4647179d6f 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -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/test/Lexer/cxx1z-trigraphs.cpp b/test/Lexer/cxx1z-trigraphs.cpp new file mode 100644 index 0000000000..410626fd7b --- /dev/null +++ b/test/Lexer/cxx1z-trigraphs.cpp @@ -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 {{}}