diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -450,6 +450,7 @@ def : DiagGroup<"inline">; def : DiagGroup<"invalid-pch">; def GNULabelsAsValue : DiagGroup<"gnu-label-as-value">; +def GNULineMarker : DiagGroup<"gnu-line-marker">; def LiteralRange : DiagGroup<"literal-range">; def LocalTypeTemplateArgs : DiagGroup<"local-type-template-args", [CXX98CompatLocalTypeTemplateArgs]>; diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -428,7 +428,8 @@ "variadic macros are a Clang extension in OpenCL">; def ext_pp_gnu_line_directive : Extension< - "this style of line directive is a GNU extension">; + "this style of line directive is a GNU extension">, + InGroup; def err_pp_invalid_directive : Error<"invalid preprocessing directive">; def err_pp_directive_required : Error< diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -1346,9 +1346,14 @@ IsFileEntry = true; PP.Lex(FlagTok); - if (FlagTok.is(tok::eod)) return false; + if (FlagTok.is(tok::eod)) { + PP.Diag(FlagTok, diag::ext_pp_gnu_line_directive); + return false; + } if (GetLineValue(FlagTok, FlagVal, diag::err_pp_linemarker_invalid_flag,PP)) return true; + + PP.Diag(FlagTok, diag::ext_pp_gnu_line_directive); } else if (FlagVal == 2) { IsFileExit = true; diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c --- a/clang/test/Misc/warning-flags.c +++ b/clang/test/Misc/warning-flags.c @@ -90,4 +90,4 @@ The list of warnings in -Wpedantic should NEVER grow. -CHECK: Number in -Wpedantic (not covered by other -W flags): 28 +CHECK: Number in -Wpedantic (not covered by other -W flags): 27 diff --git a/clang/test/Preprocessor/line-directive.c b/clang/test/Preprocessor/line-directive.c --- a/clang/test/Preprocessor/line-directive.c +++ b/clang/test/Preprocessor/line-directive.c @@ -9,7 +9,7 @@ # 20 "" 2 // a push/pop before any other line control -# 10 "enter-0" 1 +# 10 "enter-0" 1 // expected-warning {{this style of line directive is a GNU extension}} # 11 "" 2 // pop to main file #error MAIN7 // expected-error@-1{{MAIN7}} @@ -30,7 +30,7 @@ # 42 // expected-warning {{this style of line directive is a GNU extension}} # 42 "foo" // expected-warning {{this style of line directive is a GNU extension}} # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop empty include stack}} -# 42 "foo" 1 3 // enter +# 42 "foo" 1 3 // enter expected-warning {{this style of line directive is a GNU extension}} # 42 "foo" 2 3 // exit # 42 "foo" 2 3 4 // expected-error {{invalid line marker flag '2': cannot pop empty include stack}} # 42 "foo" 3 4 @@ -116,8 +116,8 @@ undefined t; // expected-error {{unknown type name 'undefined'}} # 115 "main" // expected-warning {{this style of line directive is a GNU extension}} -# 116 "enter-1" 1 -# 117 "enter-2" 1 +# 116 "enter-1" 1 // expected-warning {{this style of line directive is a GNU extension}} +# 117 "enter-2" 1 // expected-warning {{this style of line directive is a GNU extension}} # 118 "" 2 // pop to enter-1 #error ENTER1 // expected-error@-1{{ENTER1}}