From: David Majnemer Date: Sat, 23 May 2015 18:48:37 +0000 (+0000) Subject: [Driver] Handle -fno-signed-char and -fno-unsigned-char X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=68906e417523ac3cc4e5bd3e8e62e60efafc9b61;p=clang [Driver] Handle -fno-signed-char and -fno-unsigned-char GCC maps -fno-unsigned-char to -fsigned-char and -fno-signed-char to -funsigned-char. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238105 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 892d656e36..dec917b6e9 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -924,8 +924,8 @@ def fspell_checking : Flag<["-"], "fspell-checking">, Group; def fspell_checking_limit_EQ : Joined<["-"], "fspell-checking-limit=">, Group; def fsigned_bitfields : Flag<["-"], "fsigned-bitfields">, Group; def fsigned_char : Flag<["-"], "fsigned-char">, Group; -def fno_signed_char : Flag<["-"], "fno-signed-char">, Flags<[CC1Option]>, - Group, HelpText<"Char is unsigned">; +def fno_signed_char : Flag<["-"], "fno-signed-char">, Group, + Flags<[CC1Option]>, HelpText<"Char is unsigned">; def fsplit_stack : Flag<["-"], "fsplit-stack">, Group; def fstack_protector_all : Flag<["-"], "fstack-protector-all">, Group, HelpText<"Force the usage of stack protectors for all functions">; @@ -1006,7 +1006,7 @@ def fno_trigraphs : Flag<["-"], "fno-trigraphs">, Group, HelpText<"Do not process trigraph sequences">, Flags<[CC1Option]>; def funsigned_bitfields : Flag<["-"], "funsigned-bitfields">, Group; def funsigned_char : Flag<["-"], "funsigned-char">, Group; -def fno_unsigned_char : Flag<["-"], "fno-unsigned-char">, Group; +def fno_unsigned_char : Flag<["-"], "fno-unsigned-char">; def funwind_tables : Flag<["-"], "funwind-tables">, Group; def fuse_cxa_atexit : Flag<["-"], "fuse-cxa-atexit">, Group; def fuse_init_array : Flag<["-"], "fuse-init-array">, Group, Flags<[CC1Option]>, diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 9b25cab970..19236ebd53 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -4151,9 +4151,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-fshort-enums"); // -fsigned-char is default. - if (!Args.hasFlag(options::OPT_fsigned_char, options::OPT_funsigned_char, - isSignedCharDefault(getToolChain().getTriple()))) + if (Arg *A = Args.getLastArg( + options::OPT_fsigned_char, options::OPT_fno_signed_char, + options::OPT_funsigned_char, options::OPT_fno_unsigned_char)) { + if (A->getOption().matches(options::OPT_funsigned_char) || + A->getOption().matches(options::OPT_fno_signed_char)) { + CmdArgs.push_back("-fno-signed-char"); + } + } else if (!isSignedCharDefault(getToolChain().getTriple())) { CmdArgs.push_back("-fno-signed-char"); + } // -fuse-cxa-atexit is default. if (!Args.hasFlag(options::OPT_fuse_cxa_atexit, diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c index f6fe9b9894..68890a70bc 100644 --- a/test/Driver/clang_f_opts.c +++ b/test/Driver/clang_f_opts.c @@ -383,6 +383,17 @@ // CHECK-NO-WARNING1-NOT: optimization flag '-finline-limit=1000' is not supported // CHECK-NO-WARNING2-NOT: optimization flag '-finline-limit' is not supported +// RUN: %clang -### -S -fsigned-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN1 %s +// CHAR-SIGN1-NOT: -fno-signed-char + +// RUN: %clang -### -S -funsigned-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN2 %s +// CHAR-SIGN2: -fno-signed-char + +// RUN: %clang -### -S -fno-signed-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN3 %s +// CHAR-SIGN3: -fno-signed-char + +// RUN: %clang -### -S -fno-unsigned-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN4 %s +// CHAR-SIGN4-NOT: -fno-signed-char // RUN: %clang -### -fshort-wchar -fno-short-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR1 -check-prefix=DELIMITERS %s // RUN: %clang -### -fno-short-wchar -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR2 -check-prefix=DELIMITERS %s