From: Chandler Carruth Date: Sat, 22 May 2010 02:21:53 +0000 (+0000) Subject: Daniel re-educated me about what Alias does and does not do. Turn that off for X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c304ba341a7daa88da42faf8f86310b764dd7b6a;p=clang Daniel re-educated me about what Alias does and does not do. Turn that off for '-fasm' and explicitly map from that flag to -fgnu-keywords in the driver. Turn off the driver in the lexer test for this madness and add a test to the driver that the translation actually works. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104428 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 45c36376cc..abab2ddd65 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -231,6 +231,7 @@ def fPIC : Flag<"-fPIC">, Group; def fPIE : Flag<"-fPIE">, Group; def faccess_control : Flag<"-faccess-control">, Group; def fapple_kext : Flag<"-fapple-kext">, Group; +def fasm : Flag<"-fasm">, Group; def fasm_blocks : Flag<"-fasm-blocks">, Group; def fassume_sane_operator_new : Flag<"-fassume-sane-operator-new">, Group; def fastcp : Flag<"-fastcp">, Group; @@ -266,10 +267,7 @@ def fexceptions : Flag<"-fexceptions">, Group; def fextdirs_EQ : Joined<"-fextdirs=">, Group; def fhosted : Flag<"-fhosted">, Group; def ffreestanding : Flag<"-ffreestanding">, Group; - def fgnu_keywords : Flag<"-fgnu-keywords">, Group; -def fasm : Flag<"-fasm">, Alias; - def fgnu_runtime : Flag<"-fgnu-runtime">, Group; def fheinous_gnu_extensions : Flag<"-fheinous-gnu-extensions">; def filelist : Separate<"-filelist">, Flags<[LinkerInput]>; @@ -292,6 +290,7 @@ def fmudflap : Flag<"-fmudflap">, Group; def fnested_functions : Flag<"-fnested-functions">, Group; def fnext_runtime : Flag<"-fnext-runtime">, Group; def fno_access_control : Flag<"-fno-access-control">, Group; +def fno_asm : Flag<"-fno-asm">, Group; def fno_asynchronous_unwind_tables : Flag<"-fno-asynchronous-unwind-tables">, Group; def fno_assume_sane_operator_new : Flag<"-fno-assume-sane-operator-new">, Group; def fno_blocks : Flag<"-fno-blocks">, Group; @@ -307,10 +306,7 @@ def fno_diagnostics_show_option : Flag<"-fno-diagnostics-show-option">, Group, Group; def fno_eliminate_unused_debug_symbols : Flag<"-fno-eliminate-unused-debug-symbols">, Group; def fno_exceptions : Flag<"-fno-exceptions">, Group; - def fno_gnu_keywords : Flag<"-fno-gnu-keywords">, Group; -def fno_asm : Flag<"-fno-asm">, Alias; - def fno_inline_functions : Flag<"-fno-inline-functions">, Group; def fno_inline : Flag<"-fno-inline">, Group; def fno_keep_inline_functions : Flag<"-fno-keep-inline-functions">, Group; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 36a1630aad..896811d5d3 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1078,6 +1078,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_trigraphs); } + // Translate GCC's misnamer '-fasm' arguments to '-fgnu-keywords'. + if (Arg *Asm = Args.getLastArg(options::OPT_fasm, options::OPT_fno_asm)) { + if (Asm->getOption().matches(options::OPT_fasm)) + CmdArgs.push_back("-fgnu-keywords"); + else + CmdArgs.push_back("-fno-gnu-keywords"); + } + if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_)) { CmdArgs.push_back("-ftemplate-depth"); CmdArgs.push_back(A->getValue(Args)); diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c index f1d6759777..50bce3b274 100644 --- a/test/Driver/clang_f_opts.c +++ b/test/Driver/clang_f_opts.c @@ -1,10 +1,12 @@ -// RUN: %clang -### -S -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s -// RUN: %clang -### -S -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s +// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s +// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s // RUN: %clang -### -fshort-enums %s 2>&1 | FileCheck -check-prefix=CHECK-SHORT-ENUMS %s +// CHECK-OPTIONS1: -fgnu-keywords // CHECK-OPTIONS1: -fblocks // CHECK-OPTIONS1: -fpascal-strings +// CHECK_OPTIONS2: -fno-gnu-keywords // CHECK-OPTIONS2: -fmath-errno // CHECK-OPTIONS2: -fno-builtin // CHECK-OPTIONS2: -fshort-wchar diff --git a/test/Lexer/gnu_keywords.c b/test/Lexer/gnu_keywords.c index 3234f58114..c4bd9b3e59 100644 --- a/test/Lexer/gnu_keywords.c +++ b/test/Lexer/gnu_keywords.c @@ -1,7 +1,7 @@ -// RUN: %clang -DGNU_KEYWORDS -std=gnu89 -fsyntax-only -verify %s -// RUN: %clang -DGNU_KEYWORDS -std=c99 -fgnu-keywords -fsyntax-only -verify %s -// RUN: %clang -std=c99 -fsyntax-only -verify %s -// RUN: %clang -std=gnu89 -fno-gnu-keywords -fsyntax-only -verify %s +// RUN: %clang_cc1 -DGNU_KEYWORDS -std=gnu89 -fsyntax-only -verify %s +// RUN: %clang_cc1 -DGNU_KEYWORDS -std=c99 -fgnu-keywords -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=gnu89 -fno-gnu-keywords -fsyntax-only -verify %s void f() { #ifdef GNU_KEYWORDS