aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex
diff options
context:
space:
mode:
authorMichael Ilseman <milseman@apple.com>2013-04-10 01:04:18 +0000
committerMichael Ilseman <milseman@apple.com>2013-04-10 01:04:18 +0000
commitec27608da7f15b265135f5743fe71da1f8e25ee9 (patch)
treed7d99b24deeabc4a8948019097ed7ad8d4c21171 /lib/Lex
parent19b6a707a86302adc80d64464cbc3cb8a7a7f3a6 (diff)
Improve the diagnostics of the number-reading preprocessor directives.
The GNU line marker directive was sharing code with the #line directive, but some of the warnings/errors were reporting as #line directive diagnostics in both cases. Previously: #line 11foo1 ==> "#line directive requires a simple digit sequence" # 11foo1 ==> "#line directive requires a simple digit sequence" Now, we get: #line 11foo1 ==> "#line directive requires a simple digit sequence" # 11foo1 ==> "GNU line marker directive requires a simple digit sequence" git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179139 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r--lib/Lex/PPDirectives.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 07c1867010..3cd40eacf8 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -793,7 +793,8 @@ void Preprocessor::HandleDirective(Token &Result) {
/// GetLineValue - Convert a numeric token into an unsigned value, emitting
/// Diagnostic DiagID if it is invalid, and returning the value in Val.
static bool GetLineValue(Token &DigitTok, unsigned &Val,
- unsigned DiagID, Preprocessor &PP) {
+ unsigned DiagID, Preprocessor &PP,
+ bool IsGNULineDirective=false) {
if (DigitTok.isNot(tok::numeric_constant)) {
PP.Diag(DigitTok, DiagID);
@@ -817,7 +818,7 @@ static bool GetLineValue(Token &DigitTok, unsigned &Val,
for (unsigned i = 0; i != ActualLength; ++i) {
if (!isDigit(DigitTokBegin[i])) {
PP.Diag(PP.AdvanceToTokenCharacter(DigitTok.getLocation(), i),
- diag::err_pp_line_digit_sequence);
+ diag::err_pp_line_digit_sequence) << IsGNULineDirective;
PP.DiscardUntilEndOfDirective();
return true;
}
@@ -832,7 +833,8 @@ static bool GetLineValue(Token &DigitTok, unsigned &Val,
}
if (DigitTokBegin[0] == '0' && Val)
- PP.Diag(DigitTok.getLocation(), diag::warn_pp_line_decimal);
+ PP.Diag(DigitTok.getLocation(), diag::warn_pp_line_decimal)
+ << IsGNULineDirective;
return false;
}
@@ -998,7 +1000,7 @@ void Preprocessor::HandleDigitDirective(Token &DigitTok) {
// line # limit other than it fit in 32-bits.
unsigned LineNo;
if (GetLineValue(DigitTok, LineNo, diag::err_pp_linemarker_requires_integer,
- *this))
+ *this, true))
return;
Token StrTok;