summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-08 23:05:59 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-12-01 21:34:32 +0100
commit8d87c56817a360888af78c4a5c1dd23134feac12 (patch)
tree17439d401fd6f27a6ba171521f57a3c9b4cb491a
parent9307a65efd1945b9023dcb201b9b0609e8ea5f14 (diff)
downloadsparse-8d87c56817a360888af78c4a5c1dd23134feac12.tar.gz
teach sparse about C17
No real support is done here (or is needed) but the __STDC_VERSION__ will return the correct value. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--lib.c13
-rw-r--r--lib.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 904e0ad1..711e8fbe 100644
--- a/lib.c
+++ b/lib.c
@@ -1079,6 +1079,15 @@ static char **handle_switch_s(const char *arg, char **next)
else if (!strcmp(arg, "gnu11"))
standard = STANDARD_GNU11;
+ else if (!strcmp(arg, "c17") ||
+ !strcmp(arg, "c18") ||
+ !strcmp(arg, "iso9899:2017") ||
+ !strcmp(arg, "iso9899:2018"))
+ standard = STANDARD_C17;
+ else if (!strcmp(arg, "gnu17") ||
+ !strcmp(arg, "gnu18"))
+ standard = STANDARD_GNU17;
+
else
die ("Unsupported C dialect");
}
@@ -1421,6 +1430,10 @@ static void predefined_macros(void)
case STANDARD_GNU11:
predefine("__STDC_VERSION__", 1, "201112L");
break;
+ case STANDARD_C17:
+ case STANDARD_GNU17:
+ predefine("__STDC_VERSION__", 1, "201710L");
+ break;
}
if (!(standard & STANDARD_GNU) && (standard != STANDARD_NONE))
predefine("__STRICT_ANSI__", 1, "1");
diff --git a/lib.h b/lib.h
index 7958359c..3e565c6f 100644
--- a/lib.h
+++ b/lib.h
@@ -235,6 +235,8 @@ enum standard {
STANDARD_GNU99 = STANDARD_C99 | STANDARD_GNU,
STANDARD_C11,
STANDARD_GNU11 = STANDARD_C11 | STANDARD_GNU,
+ STANDARD_C17,
+ STANDARD_GNU17 = STANDARD_C17 | STANDARD_GNU,
};
extern enum standard standard;