summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2014-05-08 07:50:13 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2014-05-08 07:50:13 +0000
commitb4200796aab1ec26288a1376c7dd99c0927b5ee9 (patch)
treee9d937ce0d0c37b3aa7593207494a1e6858a944a
parent6019b688884901ee2a51fb0d1b4318b259c99bfc (diff)
- Added alternate keywords __inline, __restrict, etc, for GCC compatibility
- Skip comments that might remain after preprocessing git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2487 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
-rw-r--r--cparser/Lexer.mll26
-rw-r--r--test/spass/misc.h2
2 files changed, 24 insertions, 4 deletions
diff --git a/cparser/Lexer.mll b/cparser/Lexer.mll
index 059c568..7066213 100644
--- a/cparser/Lexer.mll
+++ b/cparser/Lexer.mll
@@ -35,6 +35,8 @@ let init filename channel : Lexing.lexbuf =
("case", fun loc -> CASE loc);
("char", fun loc -> CHAR loc);
("const", fun loc -> CONST loc);
+ ("__const", fun loc -> CONST loc);
+ ("__const__", fun loc -> CONST loc);
("continue", fun loc -> CONTINUE loc);
("default", fun loc -> DEFAULT loc);
("do", fun loc -> DO loc);
@@ -47,10 +49,14 @@ let init filename channel : Lexing.lexbuf =
("goto", fun loc -> GOTO loc);
("if", fun loc -> IF loc);
("inline", fun loc -> INLINE loc);
+ ("__inline", fun loc -> INLINE loc);
+ ("__inline__", fun loc -> INLINE loc);
("int", fun loc -> INT loc);
("long", fun loc -> LONG loc);
("register", fun loc -> REGISTER loc);
("restrict", fun loc -> RESTRICT loc);
+ ("__restrict", fun loc -> RESTRICT loc);
+ ("__restrict__", fun loc -> RESTRICT loc);
("return", fun loc -> RETURN loc);
("short", fun loc -> SHORT loc);
("signed", fun loc -> SIGNED loc);
@@ -229,10 +235,11 @@ let string_literal =
'"' s_char_sequence? '"'
| 'L' '"' s_char_sequence? '"'
-(* We assume comments are removed by the preprocessor. *)
rule initial = parse
| '\n' { new_line lexbuf; initial_linebegin lexbuf }
- | whitespace_char_no_newline { initial lexbuf }
+ | whitespace_char_no_newline + { initial lexbuf }
+ | "/*" { multiline_comment lexbuf; initial lexbuf }
+ | "//" { singleline_comment lexbuf; initial lexbuf }
| integer_constant as s { CONSTANT (Cabs.CONST_INT s, currentLoc lexbuf) }
| decimal_floating_constant { CONSTANT (Cabs.CONST_FLOAT
{Cabs.isHex_FI = false;
@@ -353,6 +360,21 @@ and hash = parse
{ Cerrors.fatal_error "%s:%d Error:@ invalid symbol %C"
lexbuf.lex_curr_p.pos_fname lexbuf.lex_curr_p.pos_lnum c }
+(* Multi-line comment terminated by "*/" *)
+and multiline_comment = parse
+ | "*/" { () }
+ | eof { Cerrors.error "%s:%d Error: unterminated comment"
+ lexbuf.lex_curr_p.pos_fname lexbuf.lex_curr_p.pos_lnum }
+ | '\n' { new_line lexbuf; multiline_comment lexbuf }
+ | _ { multiline_comment lexbuf }
+
+(* Single-line comment terminated by a newline *)
+and singleline_comment = parse
+ | '\n' { new_line lexbuf }
+ | eof { Cerrors.error "%s:%d Error: unterminated comment"
+ lexbuf.lex_curr_p.pos_fname lexbuf.lex_curr_p.pos_lnum }
+ | _ { singleline_comment lexbuf }
+
{
open Streams
open Specif
diff --git a/test/spass/misc.h b/test/spass/misc.h
index 6f70a23..69d929d 100644
--- a/test/spass/misc.h
+++ b/test/spass/misc.h
@@ -48,8 +48,6 @@
#ifndef _MISC_
#define _MISC_
-#define __inline__ inline
-
/**************************************************************/
/* Includes */
/**************************************************************/