aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/DiagnosticLexKinds.td2
-rw-r--r--lib/Lex/PPDirectives.cpp3
-rw-r--r--test/Preprocessor/line-directive.c3
3 files changed, 7 insertions, 1 deletions
diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td
index 17ff3f0683..564608865e 100644
--- a/include/clang/Basic/DiagnosticLexKinds.td
+++ b/include/clang/Basic/DiagnosticLexKinds.td
@@ -229,6 +229,8 @@ def err_pp_line_invalid_filename : Error<
"invalid filename for #line directive">;
def warn_pp_line_decimal : Warning<
"#line directive requires decimal line number">;
+def warn_pp_line_digit_sequence : Warning<
+ "#line directive requires a simple digit sequence">;
def err_pp_linemarker_requires_integer : Error<
"line marker directive requires a positive integer argument">;
def err_pp_linemarker_invalid_filename : Error<
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index e4b36fd157..3d312748f9 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -654,7 +654,8 @@ static bool GetLineValue(Token &DigitTok, unsigned &Val,
// because it is octal.
if (Literal.getRadix() != 10)
PP.Diag(DigitTok, diag::warn_pp_line_decimal);
-
+ else if (Literal.hasSuffix())
+ PP.Diag(DigitTok, diag::warn_pp_line_digit_sequence);
return false;
}
diff --git a/test/Preprocessor/line-directive.c b/test/Preprocessor/line-directive.c
index 8877406adc..98f92f130c 100644
--- a/test/Preprocessor/line-directive.c
+++ b/test/Preprocessor/line-directive.c
@@ -70,3 +70,6 @@ typedef int w; // expected-error {{redefinition of typedef 'w' is invalid in C}
// PR3940
#line 0xf // expected-warning {{#line directive requires decimal line number}}
+#line 42U // expected-warning {{#line directive requires a simple digit sequence}}
+
+