diff options
author | Sunil Srivastava <sunil_srivastava@playstation.sony.com> | 2016-02-13 01:44:05 +0000 |
---|---|---|
committer | Sunil Srivastava <sunil_srivastava@playstation.sony.com> | 2016-02-13 01:44:05 +0000 |
commit | 5239de724d39eeb4dc3bc694696c763f7ed1ec43 (patch) | |
tree | 0be573814213799454f62680695945fda44bbe77 | |
parent | f5c53b859baedaa2102ef435a2f08ce05ab31128 (diff) | |
download | bcm5719-llvm-5239de724d39eeb4dc3bc694696c763f7ed1ec43.tar.gz bcm5719-llvm-5239de724d39eeb4dc3bc694696c763f7ed1ec43.zip |
Accept "-Weverything" in clang diagnistic pragmas
Differential Revision: http://reviews.llvm.org/D15095
llvm-svn: 260788
-rw-r--r-- | clang/lib/Lex/Pragma.cpp | 17 | ||||
-rw-r--r-- | clang/test/Preprocessor/Weverything_pragma.c | 29 | ||||
-rw-r--r-- | clang/test/Preprocessor/pragma_diagnostic.c | 15 | ||||
-rw-r--r-- | clang/test/Preprocessor/pushable-diagnostics.c | 24 |
4 files changed, 81 insertions, 4 deletions
diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp index fea66daa5f8..f2a7e65e450 100644 --- a/clang/lib/Lex/Pragma.cpp +++ b/clang/lib/Lex/Pragma.cpp @@ -1024,10 +1024,19 @@ public: return; } - if (PP.getDiagnostics().setSeverityForGroup( - WarningName[1] == 'W' ? diag::Flavor::WarningOrError - : diag::Flavor::Remark, - WarningName.substr(2), SV, DiagLoc)) + diag::Flavor Flavor = WarningName[1] == 'W' ? diag::Flavor::WarningOrError + : diag::Flavor::Remark; + StringRef Group = WarningName.substr(2); + bool unknownDiag = false; + if (Group == "everything") { + // Special handling for pragma clang diagnostic ... "-Weverything". + // There is no formal group named "everything", so there has to be a + // special case for it. + PP.getDiagnostics().setSeverityForAll(Flavor, SV, DiagLoc); + } else + unknownDiag = PP.getDiagnostics().setSeverityForGroup(Flavor, Group, SV, + DiagLoc); + if (unknownDiag) PP.Diag(StringLoc, diag::warn_pragma_diagnostic_unknown_warning) << WarningName; else if (Callbacks) diff --git a/clang/test/Preprocessor/Weverything_pragma.c b/clang/test/Preprocessor/Weverything_pragma.c new file mode 100644 index 00000000000..14254317545 --- /dev/null +++ b/clang/test/Preprocessor/Weverything_pragma.c @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -Weverything -fsyntax-only -verify %s + +// Test that the pragma overrides command line option -Weverythings, + +// a diagnostic with DefaultIgnore. This is part of a group 'unused-macro' +// but -Weverything forces it +#define UNUSED_MACRO1 1 // expected-warning{{macro is not used}} + +void foo() // expected-warning {{no previous prototype for function}} +{ + // A diagnostic without DefaultIgnore, and not part of a group. + (void) L'ab'; // expected-warning {{extraneous characters in character constant ignored}} + +#pragma clang diagnostic warning "-Weverything" // Should not change anyhting. +#define UNUSED_MACRO2 1 // expected-warning{{macro is not used}} + (void) L'cd'; // expected-warning {{extraneous characters in character constant ignored}} + +#pragma clang diagnostic ignored "-Weverything" // Ignore warnings now. +#define UNUSED_MACRO2 1 // no warning + (void) L'ef'; // no warning here + +#pragma clang diagnostic warning "-Weverything" // Revert back to warnings. +#define UNUSED_MACRO3 1 // expected-warning{{macro is not used}} + (void) L'gh'; // expected-warning {{extraneous characters in character constant ignored}} + +#pragma clang diagnostic error "-Weverything" // Give errors now. +#define UNUSED_MACRO4 1 // expected-error{{macro is not used}} + (void) L'ij'; // expected-error {{extraneous characters in character constant ignored}} +} diff --git a/clang/test/Preprocessor/pragma_diagnostic.c b/clang/test/Preprocessor/pragma_diagnostic.c index e8a67abb79e..3970dbbc8e2 100644 --- a/clang/test/Preprocessor/pragma_diagnostic.c +++ b/clang/test/Preprocessor/pragma_diagnostic.c @@ -30,3 +30,18 @@ #pragma GCC diagnostic error "-Winvalid-name" // expected-warning {{unknown warning group '-Winvalid-name', ignored}} + +// Testing pragma clang diagnostic with -Weverything +void ppo(){} // First test that we do not diagnose on this. + +#pragma clang diagnostic warning "-Weverything" +void ppp(){} // expected-warning {{no previous prototype for function 'ppp'}} + +#pragma clang diagnostic ignored "-Weverything" // Reset it. +void ppq(){} + +#pragma clang diagnostic error "-Weverything" // Now set to error +void ppr(){} // expected-error {{no previous prototype for function 'ppr'}} + +#pragma clang diagnostic warning "-Weverything" // This should not be effective +void pps(){} // expected-error {{no previous prototype for function 'pps'}} diff --git a/clang/test/Preprocessor/pushable-diagnostics.c b/clang/test/Preprocessor/pushable-diagnostics.c index 877eaaa0b36..6e05d8e1450 100644 --- a/clang/test/Preprocessor/pushable-diagnostics.c +++ b/clang/test/Preprocessor/pushable-diagnostics.c @@ -15,3 +15,27 @@ int b = 'df'; // no warning. int c = 'df'; // expected-warning{{multi-character character constant}} #pragma clang diagnostic pop // expected-warning{{pragma diagnostic pop could not pop, no matching push}} + +// Test -Weverything + +void ppo0(){} // first verify that we do not give anything on this +#pragma clang diagnostic push // now push + +#pragma clang diagnostic warning "-Weverything" +void ppr1(){} // expected-warning {{no previous prototype for function 'ppr1'}} + +#pragma clang diagnostic push // push again +#pragma clang diagnostic ignored "-Weverything" // Set to ignore in this level. +void pps2(){} +#pragma clang diagnostic warning "-Weverything" // Set to warning in this level. +void ppt2(){} // expected-warning {{no previous prototype for function 'ppt2'}} +#pragma clang diagnostic error "-Weverything" // Set to error in this level. +void ppt3(){} // expected-error {{no previous prototype for function 'ppt3'}} +#pragma clang diagnostic pop // pop should go back to warning level + +void pps1(){} // expected-warning {{no previous prototype for function 'pps1'}} + + +#pragma clang diagnostic pop // Another pop should disble it again +void ppu(){} + |