From 21c38cfcdf9ecc8aa5325bcdc46cc00f5a8e3015 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 11 Aug 2014 18:09:03 +0000 Subject: [PATCH] GCC compatibility: Ignore -fexec-charset=UTF-8 argument. It is the default in Clang. Reject other values. Summary: Just like with -finput-charset=UTF-8 in review http://reviews.llvm.org/D4347, I think we should just ignore it when UTF-8 is provided. Reviewers: rnk, rafael Reviewed By: rafael Subscribers: rafael, cfe-commits Differential Revision: http://reviews.llvm.org/D4841 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215368 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Options.td | 2 +- lib/Driver/Tools.cpp | 8 ++++++++ test/Driver/clang_f_opts.c | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 82e6fafa23..2e400e56b5 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -481,7 +481,6 @@ def femit_all_decls : Flag<["-"], "femit-all-decls">, Group, Flags<[CC1 HelpText<"Emit all declarations, even if unused">; def fencoding_EQ : Joined<["-"], "fencoding=">, Group; def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group, Flags<[CoreOption]>; -def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group; def fexceptions : Flag<["-"], "fexceptions">, Group, Flags<[CC1Option]>, HelpText<"Enable support for exception handling">; def fexcess_precision_EQ : Joined<["-"], "fexcess-precision=">, @@ -584,6 +583,7 @@ def : Flag<["-"], "findirect-virtual-calls">, Alias; def finline_functions : Flag<["-"], "finline-functions">, Group; def finline : Flag<["-"], "finline">, Group; def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group; +def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group; def finstrument_functions : Flag<["-"], "finstrument-functions">, Group, Flags<[CC1Option]>, HelpText<"Generate calls to instrument function entry and exit">; def flat__namespace : Flag<["-"], "flat_namespace">; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index b6274a8fc7..2a817f7863 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -4177,6 +4177,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, D.Diag(diag::err_drv_invalid_value) << inputCharset->getAsString(Args) << value; } + // -fexec_charset=UTF-8 is default. Reject others + if (Arg *execCharset = Args.getLastArg( + options::OPT_fexec_charset_EQ)) { + StringRef value = execCharset->getValue(); + if (value != "UTF-8") + D.Diag(diag::err_drv_invalid_value) << execCharset->getAsString(Args) << value; + } + // -fcaret-diagnostics is default. if (!Args.hasFlag(options::OPT_fcaret_diagnostics, options::OPT_fno_caret_diagnostics, true)) diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c index 1a616a8651..30075ba975 100644 --- a/test/Driver/clang_f_opts.c +++ b/test/Driver/clang_f_opts.c @@ -139,6 +139,9 @@ // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1' +// RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s +// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1' + // Test that we don't error on these. // RUN: %clang -### -S -Werror \ // RUN: -falign-functions -falign-functions=2 -fno-align-functions \ @@ -151,6 +154,7 @@ // RUN: -fident -fno-ident \ // RUN: -fimplicit-templates -fno-implicit-templates \ // RUN: -finput-charset=UTF-8 \ +// RUN: -fexec-charset=UTF-8 \ // RUN: -fivopts -fno-ivopts \ // RUN: -fnon-call-exceptions -fno-non-call-exceptions \ // RUN: -fpermissive -fno-permissive \ @@ -219,7 +223,6 @@ // RUN: -ffriend-injection \ // RUN: -fno-implement-inlines -fimplement-inlines \ // RUN: -fstack-check \ -// RUN: -fexec-charset=UTF-8 \ // RUN: -fforce-addr \ // RUN: -malign-functions=100 \ // RUN: -malign-loops=100 \ -- 2.40.0