diff options
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticLexKinds.td | 8 | ||||
| -rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 12 | ||||
| -rw-r--r-- | clang/test/Frontend/rewrite-macros.c | 2 | ||||
| -rw-r--r-- | clang/test/Index/retain-target-options.c | 2 | ||||
| -rw-r--r-- | clang/test/Misc/serialized-diags-no-category.c | 2 | ||||
| -rw-r--r-- | clang/test/Misc/warn-in-system-header.c | 2 | ||||
| -rw-r--r-- | clang/test/Preprocessor/line-directive.c | 4 |
7 files changed, 22 insertions, 10 deletions
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td index 3a564c4aa81..fde522c573d 100644 --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -148,8 +148,13 @@ def err_invalid_pth_file : Error< //===----------------------------------------------------------------------===// // Preprocessor Diagnostics //===----------------------------------------------------------------------===// -def pp_hash_warning : Warning<"#warning%0">, + +let CategoryName = "User Defined Issues" in { +def pp_hash_warning : Warning<"%0">, InGroup<PoundWarning>, DefaultWarnShowInSystemHeader; +def err_pp_hash_error : Error<"%0">; +} + def pp_include_next_in_primary : Warning< "#include_next in primary source file">; def pp_include_macros_out_of_predefines : Error< @@ -223,7 +228,6 @@ def warn_cxx98_compat_empty_fnmacro_arg : Warning< InGroup<CXX98CompatPedantic>, DefaultIgnore; def err_pp_invalid_directive : Error<"invalid preprocessing directive">; -def err_pp_hash_error : Error<"#error%0">; def err_pp_file_not_found : Error<"'%0' file not found">, DefaultFatal; def err_pp_error_opening_file : Error< "error opening file '%0': %1">, DefaultFatal; diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 76955604b08..9f2309e801d 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -1007,10 +1007,18 @@ void Preprocessor::HandleUserDiagnosticDirective(Token &Tok, // collapse multiple consequtive white space between tokens, but this isn't // specified by the standard. std::string Message = CurLexer->ReadToEndOfLine(); + + // Find the first non-whitespace character, so that we can make the + // diagnostic more succinct. + StringRef Msg(Message); + size_t i = Msg.find_first_not_of(' '); + if (i < Msg.size()) + Msg = Msg.substr(i); + if (isWarning) - Diag(Tok, diag::pp_hash_warning) << Message; + Diag(Tok, diag::pp_hash_warning) << Msg; else - Diag(Tok, diag::err_pp_hash_error) << Message; + Diag(Tok, diag::err_pp_hash_error) << Msg; } /// HandleIdentSCCSDirective - Handle a #ident/#sccs directive. diff --git a/clang/test/Frontend/rewrite-macros.c b/clang/test/Frontend/rewrite-macros.c index f44e545728e..bc7479693bf 100644 --- a/clang/test/Frontend/rewrite-macros.c +++ b/clang/test/Frontend/rewrite-macros.c @@ -9,7 +9,7 @@ A(1,2) _Pragma("mark") // RUN: grep "//#warning eek" %t -/* expected-warning {{#warning eek}} */ #warning eek +/* expected-warning {{eek}} */ #warning eek // RUN: grep "//#pragma mark mark" %t #pragma mark mark diff --git a/clang/test/Index/retain-target-options.c b/clang/test/Index/retain-target-options.c index 797971d12ce..2fba476fb1e 100644 --- a/clang/test/Index/retain-target-options.c +++ b/clang/test/Index/retain-target-options.c @@ -2,7 +2,7 @@ // RUN: c-index-test -test-load-source-reparse 1 all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s // RUN: c-index-test -test-load-source-reparse 5 all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s -// CHECK: error: #error SSE4_1 used +// CHECK: error: SSE4_1 used #if defined(__SSE4_1__) #error SSE4_1 used #endif diff --git a/clang/test/Misc/serialized-diags-no-category.c b/clang/test/Misc/serialized-diags-no-category.c index 9c92ac33309..3074892e0eb 100644 --- a/clang/test/Misc/serialized-diags-no-category.c +++ b/clang/test/Misc/serialized-diags-no-category.c @@ -7,6 +7,6 @@ // This test case tests that we can handle both fatal errors and errors without categories. -// CHECK: {{.*[/\\]}}serialized-diags-no-category.c:1:2: error: #error foo [] +// CHECK: {{.*[/\\]}}serialized-diags-no-category.c:1:2: error: foo [] // CHECK: Number of diagnostics: 2 diff --git a/clang/test/Misc/warn-in-system-header.c b/clang/test/Misc/warn-in-system-header.c index 7e4615e65ef..6e0237d0dcd 100644 --- a/clang/test/Misc/warn-in-system-header.c +++ b/clang/test/Misc/warn-in-system-header.c @@ -1,4 +1,4 @@ // RUN: %clang_cc1 -isystem %S %s -fsyntax-only -verify #include <warn-in-system-header.h> -// expected-warning {{#warning}} +// expected-warning {{the cake is a lie}} diff --git a/clang/test/Preprocessor/line-directive.c b/clang/test/Preprocessor/line-directive.c index 102469449e1..28e93029a5c 100644 --- a/clang/test/Preprocessor/line-directive.c +++ b/clang/test/Preprocessor/line-directive.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s -// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:92:2: error: #error ABC' -// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: #error DEF' +// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:92:2: error: ABC' +// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: DEF' #line 'a' // expected-error {{#line directive requires a positive integer argument}} #line 0 // expected-error {{#line directive requires a positive integer argument}} |

