@@ -250,6 +250,8 @@ int preprocess_only;
static enum { STANDARD_C89,
STANDARD_C94,
STANDARD_C99,
+ STANDARD_C11,
+ STANDARD_GNU11,
STANDARD_GNU89,
STANDARD_GNU99, } standard = STANDARD_GNU89;
@@ -574,6 +576,8 @@ static void handle_switch_W_finalize(void)
case STANDARD_C99:
case STANDARD_GNU89:
case STANDARD_GNU99:
+ case STANDARD_C11:
+ case STANDARD_GNU11:
Wdeclarationafterstatement = 0;
break;
@@ -679,6 +683,14 @@ static char **handle_switch_s(char *arg, char **next)
else if (!strcmp (arg, "gnu99") || !strcmp (arg, "gnu9x"))
standard = STANDARD_GNU99;
+ else if (!strcmp(arg, "c11") ||
+ !strcmp(arg, "c1x") ||
+ !strcmp(arg, "iso9899:2011"))
+ standard = STANDARD_C11;
+
+ else if (!strcmp(arg, "gnu11"))
+ standard = STANDARD_GNU11;
+
else
die ("Unsupported C dialect");
}
@@ -971,6 +983,15 @@ void create_builtin_stream(void)
add_pre_buffer("#weak_define __STDC_VERSION__ 199901L\n");
break;
+ case STANDARD_C11:
+ add_pre_buffer("#weak_define __STRICT_ANSI__ 1\n");
+ case STANDARD_GNU11:
+ add_pre_buffer("#weak_define __STDC_NO_ATOMICS__ 1\n");
+ add_pre_buffer("#weak_define __STDC_NO_COMPLEX__ 1\n");
+ add_pre_buffer("#weak_define __STDC_NO_THREADS__ 1\n");
+ add_pre_buffer("#weak_define __STDC_VERSION__ 201112L\n");
+ break;
+
default:
assert (0);
}
new file mode 100644
@@ -0,0 +1,11 @@
+__STDC_VERSION__
+
+/*
+ * check-name: c11-stdc-version
+ * check-command: sparse -E -std=c11 $file
+ *
+ * check-output-start
+
+201112L
+ * check-output-end
+ */
Now that support have been added for C11 new syntax we can accept '--std={c11,gnu11}' no more dying with "Unsupported C dialect" message. Also adjust __STDC_VERSION__ accordingly and define the few associated feature macros (__STD_NO_ATOMICS__, ...). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- lib.c | 21 +++++++++++++++++++++ validation/c11-stdc-version.c | 11 +++++++++++ 2 files changed, 32 insertions(+) create mode 100644 validation/c11-stdc-version.c