Author: Fangrui Song Date: 2020-11-05T10:25:30-08:00 New Revision: c6a384df1f8ab85815160297543ab329e02560ef
URL: https://github.com/llvm/llvm-project/commit/c6a384df1f8ab85815160297543ab329e02560ef DIFF: https://github.com/llvm/llvm-project/commit/c6a384df1f8ab85815160297543ab329e02560ef.diff LOG: [Sema] Special case -Werror-implicit-function-declaration and reject other -Werror- This is the only -Werror- form warning option GCC supports (gcc/c-family/c.opt). Fortunately no other form is used anywhere. Added: Modified: clang/lib/Basic/Warnings.cpp clang/test/CodeGen/vecshift.c clang/test/Frontend/warning-options.cpp clang/test/Modules/diagnose-missing-import.m clang/test/Preprocessor/if_warning.c clang/test/Sema/vecshift.c Removed: ################################################################################ diff --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp index 2c909d9510d4..cc8c138233ca 100644 --- a/clang/lib/Basic/Warnings.cpp +++ b/clang/lib/Basic/Warnings.cpp @@ -130,11 +130,14 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags, } // -Werror/-Wno-error is a special case, not controlled by the option - // table. It also has the "specifier" form of -Werror=foo and -Werror-foo. + // table. It also has the "specifier" form of -Werror=foo. GCC supports + // the deprecated -Werror-implicit-function-declaration which is used by + // a few projects. if (Opt.startswith("error")) { StringRef Specifier; if (Opt.size() > 5) { // Specifier must be present. - if ((Opt[5] != '=' && Opt[5] != '-') || Opt.size() == 6) { + if (Opt[5] != '=' && + Opt.substr(5) != "-implicit-function-declaration") { if (Report) Diags.Report(diag::warn_unknown_warning_specifier) << "-Werror" << ("-W" + OrigOpt.str()); diff --git a/clang/test/CodeGen/vecshift.c b/clang/test/CodeGen/vecshift.c index 1fa047cd30b9..f37c5092875f 100644 --- a/clang/test/CodeGen/vecshift.c +++ b/clang/test/CodeGen/vecshift.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -Wno-error-vec-elem-size -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -Wno-error-vec-elem-size -DEXT -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -Wno-error=vec-elem-size -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -Wno-error=vec-elem-size -DEXT -emit-llvm %s -o - | FileCheck %s #ifdef EXT typedef __attribute__((__ext_vector_type__(8))) char vector_char8; diff --git a/clang/test/Frontend/warning-options.cpp b/clang/test/Frontend/warning-options.cpp index 3c3396becaf8..444733c8b7f3 100644 --- a/clang/test/Frontend/warning-options.cpp +++ b/clang/test/Frontend/warning-options.cpp @@ -1,7 +1,8 @@ // RUN: %clang_cc1 -Wmonkey -Wno-monkey -Wno-unused-command-line-arguments \ -// RUN: -Wno-unused-command-line-argument -Wmodule-build -Rmodule-built %s 2>&1 | FileCheck %s +// RUN: -Wno-unused-command-line-argument -Wmodule-build -Werror-vla -Rmodule-built %s 2>&1 | FileCheck %s // CHECK: unknown warning option '-Wmonkey' // CHECK: unknown warning option '-Wno-monkey' // CHECK: unknown warning option '-Wno-unused-command-line-arguments'; did you mean '-Wno-unused-command-line-argument'? // CHECK: unknown warning option '-Wmodule-build'; did you mean '-Wmodule-conflict'? +// CHECK-NEXT: unknown -Werror warning specifier: '-Werror-vla' // CHECK: unknown remark option '-Rmodule-built'; did you mean '-Rmodule-build'? diff --git a/clang/test/Modules/diagnose-missing-import.m b/clang/test/Modules/diagnose-missing-import.m index 2c67e01944a9..f0e557ac09b0 100644 --- a/clang/test/Modules/diagnose-missing-import.m +++ b/clang/test/Modules/diagnose-missing-import.m @@ -2,6 +2,9 @@ // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/diagnose-missing-import \ // RUN: -Werror=implicit-function-declaration -fsyntax-only \ // RUN: -fimplicit-module-maps -verify %s +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/diagnose-missing-import \ +// RUN: -Werror-implicit-function-declaration -fsyntax-only \ +// RUN: -fimplicit-module-maps -verify %s @import NCI; void foo() { diff --git a/clang/test/Preprocessor/if_warning.c b/clang/test/Preprocessor/if_warning.c index 641ec3b1b970..47bc1c6b170a 100644 --- a/clang/test/Preprocessor/if_warning.c +++ b/clang/test/Preprocessor/if_warning.c @@ -1,5 +1,4 @@ // RUN: %clang_cc1 %s -Eonly -Werror=undef -verify -// RUN: %clang_cc1 %s -Eonly -Werror-undef -verify extern int x; diff --git a/clang/test/Sema/vecshift.c b/clang/test/Sema/vecshift.c index 7b6a30ad60dd..7ad19b82093b 100644 --- a/clang/test/Sema/vecshift.c +++ b/clang/test/Sema/vecshift.c @@ -1,7 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -DERR -verify %s -// RUN: %clang_cc1 -fsyntax-only -Wno-error-vec-elem-size -verify %s // RUN: %clang_cc1 -fsyntax-only -DEXT -DERR -verify %s -// RUN: %clang_cc1 -fsyntax-only -DEXT -Wno-error-vec-elem-size -verify %s #ifdef EXT typedef __attribute__((__ext_vector_type__(8))) char vector_char8; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits