mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 14:12:36 +00:00
-Wunknown-attribute; and don't error on unknown attributes
This commit is contained in:
parent
7cf0ba5aa8
commit
e8cd9411b0
3 changed files with 11 additions and 2 deletions
1
opts.c
1
opts.c
|
@ -53,6 +53,7 @@ static void opts_setdefault() {
|
|||
opts_set(opts.warn, WARN_UNKNOWN_PRAGMAS, true);
|
||||
opts_set(opts.warn, WARN_UNREACHABLE_CODE, true);
|
||||
opts_set(opts.warn, WARN_CPP, true);
|
||||
opts_set(opts.warn, WARN_UNKNOWN_ATTRIBUTE, true);
|
||||
/* flags */
|
||||
opts_set(opts.flags, ADJUST_VECTOR_FIELDS, true);
|
||||
opts_set(opts.flags, FTEPP, false);
|
||||
|
|
1
opts.def
1
opts.def
|
@ -73,6 +73,7 @@
|
|||
GMQCC_DEFINE_FLAG(UNKNOWN_PRAGMAS)
|
||||
GMQCC_DEFINE_FLAG(UNREACHABLE_CODE)
|
||||
GMQCC_DEFINE_FLAG(CPP)
|
||||
GMQCC_DEFINE_FLAG(UNKNOWN_ATTRIBUTE)
|
||||
#endif
|
||||
|
||||
#ifdef GMQCC_TYPE_OPTIMIZATIONS
|
||||
|
|
11
parser.c
11
parser.c
|
@ -2349,19 +2349,23 @@ static bool parse_var_qualifiers(parser_t *parser, bool with_local, int *cvq, bo
|
|||
bool had_var = false;
|
||||
bool had_noref = false;
|
||||
bool had_noreturn = false;
|
||||
bool had_attrib = false;
|
||||
|
||||
*cvq = CV_WRONG;
|
||||
*cvq = CV_NONE;
|
||||
for (;;) {
|
||||
if (parser->tok == TOKEN_ATTRIBUTE_OPEN) {
|
||||
had_attrib = true;
|
||||
/* parse an attribute */
|
||||
if (!parser_next(parser)) {
|
||||
parseerror(parser, "expected attribute after `[[`");
|
||||
*cvq = CV_WRONG;
|
||||
return false;
|
||||
}
|
||||
if (!strcmp(parser_tokval(parser), "noreturn")) {
|
||||
had_noreturn = true;
|
||||
if (!parser_next(parser) || parser->tok != TOKEN_ATTRIBUTE_CLOSE) {
|
||||
parseerror(parser, "`noreturn` attribute has no parameters, expected `]]`");
|
||||
*cvq = CV_WRONG;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2369,15 +2373,18 @@ static bool parse_var_qualifiers(parser_t *parser, bool with_local, int *cvq, bo
|
|||
had_noref = true;
|
||||
if (!parser_next(parser) || parser->tok != TOKEN_ATTRIBUTE_CLOSE) {
|
||||
parseerror(parser, "`noref` attribute has no parameters, expected `]]`");
|
||||
*cvq = CV_WRONG;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Skip tokens until we hit a ]] */
|
||||
(void)!parsewarning(parser, WARN_UNKNOWN_ATTRIBUTE, "unknown attribute starting with `%s`", parser_tokval(parser));
|
||||
while (parser->tok != TOKEN_ATTRIBUTE_CLOSE) {
|
||||
if (!parser_next(parser)) {
|
||||
parseerror(parser, "error inside attribute");
|
||||
*cvq = CV_WRONG;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2391,7 +2398,7 @@ static bool parse_var_qualifiers(parser_t *parser, bool with_local, int *cvq, bo
|
|||
had_var = true;
|
||||
else if (!strcmp(parser_tokval(parser), "noref"))
|
||||
had_noref = true;
|
||||
else if (!had_const && !had_var && !had_noref && !had_noreturn) {
|
||||
else if (!had_const && !had_var && !had_noref && !had_noreturn && !had_attrib) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue