as a gcc supported extension with usual treatment
with -pedantic (warn) and -pedantic-errors (error).
// rdar://
11550996
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159226
91177308-0d34-0410-b5e6-
96231b3b80d8
"floating point literal in preprocessor expression">;
def err_pp_line_requires_integer : Error<
"#line directive requires a positive integer argument">;
+def ext_pp_line_zero : Extension<
+ "#line directive with zero argument is a GNU extension">,
+ InGroup<GNU>;
def err_pp_line_invalid_filename : Error<
"invalid filename for #line directive">;
def warn_pp_line_decimal : Warning<
Val = NextVal;
}
- // Reject 0, this is needed both by #line numbers and flags.
- if (Val == 0) {
- PP.Diag(DigitTok, DiagID);
- PP.DiscardUntilEndOfDirective();
- return true;
- }
-
- if (DigitTokBegin[0] == '0')
+ if (DigitTokBegin[0] == '0' && Val)
PP.Diag(DigitTok.getLocation(), diag::warn_pp_line_decimal);
return false;
unsigned LineNo;
if (GetLineValue(DigitTok, LineNo, diag::err_pp_line_requires_integer,*this))
return;
+
+ if (LineNo == 0)
+ Diag(DigitTok, diag::ext_pp_line_zero);
// Enforce C99 6.10.4p3: "The digit sequence shall not specify ... a
// number greater than 2147483647". C90 requires that the line # be <= 32767.
// 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}}
-#line 00 // expected-error {{#line directive requires a positive integer argument}}
+#line 0 // expected-warning {{#line directive with zero argument is a GNU extension}}
+#line 00 // expected-warning {{#line directive with zero argument is a GNU extension}}
#line 2147483648 // expected-warning {{C requires #line number to be less than 2147483648, allowed as extension}}
#line 42 // ok
#line 42 'a' // expected-error {{invalid filename for #line directive}}
_\
_LINE__ == 42 ? 1: -1]; /* line marker is location of first _ */
+// rdar://11550996
+#line 0 "line-directive.c" // expected-warning {{#line directive with zero argument is a GNU extension}}
+undefined t; // expected-error {{unknown type name 'undefined'}}