# include "cgrammar.h"
# include "cgrammar_tokens.h"
-
-# include "fileIdList.h"
# include "portab.h"
static bool lastWasString = FALSE;
%%
-"/*" { llfatalbug (cstring_makeLiteral ("Comment in pre-processor output")); }
+"/*" { llfatalerror (cstring_makeLiteral ("Comment in pre-processor output")); }
"#"{Letter}({Letter}|{Digit})* {
context_saveLocation ();
"volatile" { setTokLength (8); RETURN_TOK (QVOLATILE); }
"const" { setTokLength (5); RETURN_TOK (QCONST); }
+"restrict" { setTokLength (8); RETURN_TOK (QRESTRICT); }
/* some systems expect this! [gack!] */
"__const" { setTokLength (7); RETURN_TOK (QCONST); }
if (context_inMacro ())
{
/* Don't use RETURN_TOK */
- yylval.tok = lltok_create (TENDMACRO, g_currentloc);
+ yylval.tok = lltok_create (TENDMACRO, fileloc_copy (g_currentloc)); /* !!! evans 2002-03-13 */
lastWasString = FALSE;
return (TENDMACRO);
}
(FLG_SYNTAX,
message ("Likely parse error: syntactic comment token spans multiple lines: %s",
cstring_fromChars (s)),
- g_currentloc);
+ loc);
}
s = mstring_append (s, c);
{
;
}
- else if (flagcode_isInvalid (fflag))
+ else if (flagcode_isModeName (fflag))
{
- if (isMode (flagname))
+ if (ynm_isMaybe (set))
{
- if (ynm_isMaybe (set))
- {
- llerror
- (FLG_BADFLAG,
- message
- ("Semantic comment attempts to restore flag %s. "
- "A mode flag cannot be restored.",
- flagname));
- }
- else
- {
- context_setMode (flagname);
- }
+ llerror
+ (FLG_BADFLAG,
+ message
+ ("Semantic comment attempts to restore flag %s. "
+ "A mode flag cannot be restored.",
+ flagname));
}
else
{
- voptgenerror
- (FLG_UNRECOGFLAGCOMMENTS,
- message ("Unrecognized option in semantic comment: %s",
- flagname),
- g_currentloc);
+ context_setMode (flagname);
}
}
+ else if (flagcode_isInvalid (fflag))
+ {
+ voptgenerror
+ (FLG_UNRECOGFLAGCOMMENTS,
+ message ("Unrecognized option in semantic comment: %s",
+ flagname),
+ loc);
+ }
else if (flagcode_isGlobalFlag (fflag))
{
voptgenerror
("Semantic comment attempts to set global flag %s. "
"A global flag cannot be set locally.",
flagname),
- g_currentloc);
+ loc);
}
else
{
- context_fileSetFlag (fflag, set);
+ context_fileSetFlag (fflag, set, loc);
if (flagcode_hasArgument (fflag))
{
("Semantic comment attempts to restore flag %s. "
"A flag for setting a value cannot be restored.",
flagname),
- g_currentloc);
+ loc);
}
else
{ /* cut-and-pastied from llmain...blecch */
if (context_inHeader () && !isArtificial (cstring_fromChars (os)))
{
DPRINTF (("Here adding comment: %s", os));
- context_addComment (cstring_fromCharsNew (os));
+ context_addComment (cstring_fromCharsNew (os), loc);
}
else
{
&& macrocode != SKIPTOK
&& !isArtificial (cstring_fromChars (os)))
{
- DPRINTF (("Add comment: %s", os));
- context_addComment (cstring_fromCharsNew (os));
+ if (context_processingMacros ())
+ {
+ /* evans 2002-02-24: don't add comments when procssing macros */
+ }
+ else
+ {
+ context_addComment (cstring_fromCharsNew (os), loc);
+ }
}
else
{
{
if (!context_getFlag (FLG_NOCOMMENTS))
{
- context_enterSuppressRegion ();
+ context_enterSuppressRegion (loc);
}
}
else if ((*t == 'i' || *t == 't')
if (!context_getFlag (FLG_NOCOMMENTS)
&& (*t == 'i' || context_getFlag (FLG_TMPCOMMENTS)))
{
- context_enterSuppressLine (-1); /* infinite suppression */
+ context_enterSuppressLine (-1, loc); /* infinite suppression */
}
}
else if (((*t == 'i') || (*t == 't'))
lc = *(++tt);
}
}
-
if (!context_getFlag (FLG_NOCOMMENTS)
&& (!tmpcomment || context_getFlag (FLG_TMPCOMMENTS)))
{
- context_enterSuppressLine (val);
+ DPRINTF (("Here: enter suppress: %s", fileloc_unparse (loc)));
+ context_enterSuppressLine (val, loc);
}
}
else if (mstring_equal (t, "end"))
{
if (!context_getFlag (FLG_NOCOMMENTS))
{
- context_exitSuppressRegion ();
+ context_exitSuppressRegion (loc);
}
}
else if (mstring_equal (t, "notfunction"))
message
("Non-abstract type %s used in access comment",
tname),
- g_currentloc);
+ loc);
}
}
else
{
if (!(context_inSuppressRegion ()
- || context_inSuppressZone (g_currentloc)))
+ || context_inSuppressZone (loc)))
{
voptgenerror
(FLG_COMMENTERROR,
message
("Unrecognized type %s used in access comment",
tname),
- g_currentloc);
+ loc);
}
}
}
else
{
if (!(context_inSuppressRegion ()
- || context_inSuppressZone (g_currentloc)))
+ || context_inSuppressZone (loc)))
{
uentry ue = usymtab_getTypeEntry (tuid);
message
("Non-accessible abstract type %s used in noaccess comment",
tname),
- g_currentloc);
+ loc);
}
else
{
message
("Non-abstract type %s used in noaccess comment",
tname),
- g_currentloc);
+ loc);
}
}
}
else
{
if (!(context_inSuppressRegion ()
- || context_inSuppressZone (g_currentloc)))
+ || context_inSuppressZone (loc)))
{
voptgenerror
(FLG_COMMENTERROR,
message
("Unrecognized type %s used in noaccess comment",
tname),
- g_currentloc);
+ loc);
}
}
}
{
voptgenerror (FLG_UNRECOGCOMMENTS,
message ("Semantic comment unrecognized: %s",
- cstring_fromChars (os)), loc);
+ cstring_fromChars (os)),
+ loc);
}
-
+
sfree (t);
}
{
tok = CALIGNOF; /* alignof is parsed like sizeof */
}
+ else if (cstring_equalLit (id, "__typeof__"))
+ {
+ tok = CTYPEOF;
+ }
+ else if (cstring_equalLit (id, "typeof"))
+ {
+ tok = CTYPEOF;
+ }
else if (cstring_equalLit (id, "__FUNCTION__")
|| cstring_equalLit (id, "__PRETTY_FUNCTION__"))
{