[cfe-commits] r69403 - in /cfe/trunk: include/clang/Basic/DiagnosticLexKinds.td lib/Lex/PPDirectives.cpp test/Preprocessor/line-directive.c

Chris Lattner sabre at nondot.org
Fri Apr 17 16:37:50 PDT 2009


Author: lattner
Date: Fri Apr 17 18:37:49 2009
New Revision: 69403

URL: http://llvm.org/viewvc/llvm-project?rev=69403&view=rev
Log:
implement PR3940: #line numbers not fully checked

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/test/Preprocessor/line-directive.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=69403&r1=69402&r2=69403&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Apr 17 18:37:49 2009
@@ -223,6 +223,8 @@
   "#line directive requires a positive integer argument">;
 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 err_pp_linemarker_requires_integer : Error<
   "line marker directive requires a positive integer argument">;
 def err_pp_linemarker_invalid_filename : Error<

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=69403&r1=69402&r2=69403&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri Apr 17 18:37:49 2009
@@ -650,6 +650,11 @@
     return true;
   }
   
+  // Warn about hex and octal line numbers.  Do this after the check for 0,
+  // because it is octal.
+  if (Literal.getRadix() != 10) 
+    PP.Diag(DigitTok, diag::warn_pp_line_decimal);
+  
   return false;
 }
 

Modified: cfe/trunk/test/Preprocessor/line-directive.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/line-directive.c?rev=69403&r1=69402&r2=69403&view=diff

==============================================================================
--- cfe/trunk/test/Preprocessor/line-directive.c (original)
+++ cfe/trunk/test/Preprocessor/line-directive.c Fri Apr 17 18:37:49 2009
@@ -68,3 +68,5 @@
 #line 2 "foo.c" EMPTY( )
 #line 2 "foo.c" NONEMPTY( )  // expected-warning{{extra tokens at end of #line directive}}
 
+// PR3940
+#line 0xf  // expected-warning {{#line directive requires decimal line number}}





More information about the cfe-commits mailing list