aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-08-19 06:04:38 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-08-19 06:04:38 +0000
commit35aff4fb82ce0f615dc5e0ad73341a1fe77cbd12 (patch)
tree252dbb8b85e09aa8d379abb28ffc5e483fa4edb2 /gcc
parentfdec323d35ab9bf489e374c0545621bc90dd08c0 (diff)
downloadgcc-35aff4fb82ce0f615dc5e0ad73341a1fe77cbd12.zip
gcc-35aff4fb82ce0f615dc5e0ad73341a1fe77cbd12.tar.gz
gcc-35aff4fb82ce0f615dc5e0ad73341a1fe77cbd12.tar.bz2
invoke.texi: Document -Wc99-c11-compat.
* doc/invoke.texi: Document -Wc99-c11-compat. c-family/ * c.opt (Wc99-c11-compat): New option. c/ * c-decl.c (diagnose_mismatched_decls): Unconditionally call pedwarn_c99 instead of pedwarn. (grokfield): Likewise. (warn_defaults_to): New function. (grokdeclarator): Call warn_defaults_to instead of pedwarn_c99. Unconditionally call pedwarn_c99 instead of pedwarn. (start_function): Call warn_defaults_to instead of pedwarn_c99. (declspecs_add_scspec): Call pedwarn_c99 instead of pedwarn, don't check flag_isoc11 before. * c-errors.c (pedwarn_c99): Change the return type to bool. Handle -Wc99-c11-compat. * c-parser.c (disable_extension_diagnostics): Handle warn_c99_c11_compat. (restore_extension_diagnostics): Likewise. (c_parser_static_assert_declaration_no_semi): Call pedwarn_c99 instead of pedwarn, don't check flag_isoc11 before. (c_parser_declspecs): Likewise. (c_parser_alignas_specifier): Likewise. (c_parser_alignof_expression): Likewise. (c_parser_generic_selection): Likewise. * c-tree.h (pedwarn_c99): Update declaration. * c-typeck.c (c_finish_return): Call pedwarn or warning_at instead of pedwarn_c99. testsuite/ * gcc.dg/Wc99-c11-compat-1.c: New test. * gcc.dg/Wc99-c11-compat-2.c: New test. * gcc.dg/Wc99-c11-compat-3.c: New test. * gcc.dg/Wc99-c11-compat-4.c: New test. * gcc.dg/Wc99-c11-compat-5.c: New test. * gcc.dg/Wc99-c11-compat-6.c: New test. * gcc.dg/Wc99-c11-compat-7.c: New test. From-SVN: r214133
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/c-family/ChangeLog4
-rw-r--r--gcc/c-family/c.opt4
-rw-r--r--gcc/c/ChangeLog26
-rw-r--r--gcc/c/c-decl.c76
-rw-r--r--gcc/c/c-errors.c34
-rw-r--r--gcc/c/c-parser.c62
-rw-r--r--gcc/c/c-tree.h2
-rw-r--r--gcc/c/c-typeck.c9
-rw-r--r--gcc/doc/invoke.texi12
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/gcc.dg/Wc99-c11-compat-1.c18
-rw-r--r--gcc/testsuite/gcc.dg/Wc99-c11-compat-2.c18
-rw-r--r--gcc/testsuite/gcc.dg/Wc99-c11-compat-3.c18
-rw-r--r--gcc/testsuite/gcc.dg/Wc99-c11-compat-4.c18
-rw-r--r--gcc/testsuite/gcc.dg/Wc99-c11-compat-5.c18
-rw-r--r--gcc/testsuite/gcc.dg/Wc99-c11-compat-6.c18
-rw-r--r--gcc/testsuite/gcc.dg/Wc99-c11-compat-7.c18
18 files changed, 291 insertions, 78 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f2258a7..002da55 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2014-08-19 Marek Polacek <polacek@redhat.com>
+
+ * doc/invoke.texi: Document -Wc99-c11-compat.
+
2014-08-19 David Malcolm <dmalcolm@redhat.com>
* rtl.h (PREV_INSN): Split macro in two: the existing one,
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 3fa60ab..e25f1d8 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,5 +1,9 @@
2014-08-19 Marek Polacek <polacek@redhat.com>
+ * c.opt (Wc99-c11-compat): New option.
+
+2014-08-19 Marek Polacek <polacek@redhat.com>
+
* c-opts.c (sanitize_cpp_opts): Make warn_long_long be set according
to warn_c90_c99_compat.
* c.opt (Wc90-c99-compat, Wdeclaration-after-statement): Initialize
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 087eabd..4848399 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -295,6 +295,10 @@ Wc90-c99-compat
C ObjC Var(warn_c90_c99_compat) Init(-1) Warning
Warn about features not present in ISO C90, but present in ISO C99
+Wc99-c11-compat
+C ObjC Var(warn_c99_c11_compat) Init(-1) Warning
+Warn about features not present in ISO C99, but present in ISO C11
+
Wc++-compat
C ObjC Var(warn_cxx_compat) Warning
Warn about C constructs that are not in the common subset of C and C++
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 4f67dec..27f865e 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,5 +1,31 @@
2014-08-19 Marek Polacek <polacek@redhat.com>
+ * c-decl.c (diagnose_mismatched_decls): Unconditionally call
+ pedwarn_c99 instead of pedwarn.
+ (grokfield): Likewise.
+ (warn_defaults_to): New function.
+ (grokdeclarator): Call warn_defaults_to instead of pedwarn_c99.
+ Unconditionally call pedwarn_c99 instead of pedwarn.
+ (start_function): Call warn_defaults_to instead of pedwarn_c99.
+ (declspecs_add_scspec): Call pedwarn_c99 instead of pedwarn, don't
+ check flag_isoc11 before.
+ * c-errors.c (pedwarn_c99): Change the return type to bool.
+ Handle -Wc99-c11-compat.
+ * c-parser.c (disable_extension_diagnostics): Handle
+ warn_c99_c11_compat.
+ (restore_extension_diagnostics): Likewise.
+ (c_parser_static_assert_declaration_no_semi): Call pedwarn_c99
+ instead of pedwarn, don't check flag_isoc11 before.
+ (c_parser_declspecs): Likewise.
+ (c_parser_alignas_specifier): Likewise.
+ (c_parser_alignof_expression): Likewise.
+ (c_parser_generic_selection): Likewise.
+ * c-tree.h (pedwarn_c99): Update declaration.
+ * c-typeck.c (c_finish_return): Call pedwarn or warning_at instead
+ of pedwarn_c99.
+
+2014-08-19 Marek Polacek <polacek@redhat.com>
+
* c-decl.c (warn_variable_length_array): Pass OPT_Wvla unconditionally
to pedwarn_c90.
* c-errors.c: Include "opts.h".
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 138b014..ec0d0ef 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -538,6 +538,8 @@ static tree grokdeclarator (const struct c_declarator *,
bool *, enum deprecated_states);
static tree grokparms (struct c_arg_info *, bool);
static void layout_array_type (tree);
+static void warn_defaults_to (location_t, int, const char *, ...)
+ ATTRIBUTE_GCC_DIAG(3,4);
/* T is a statement. Add it to the statement-tree. This is the
C/ObjC version--C++ has a slightly different version of this
@@ -1844,12 +1846,9 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
newdecl);
locate_old_decl (olddecl);
}
- else if (pedantic && !flag_isoc11)
- {
- pedwarn (input_location, OPT_Wpedantic,
- "redefinition of typedef %q+D", newdecl);
- locate_old_decl (olddecl);
- }
+ else if (pedwarn_c99 (input_location, OPT_Wpedantic,
+ "redefinition of typedef %q+D", newdecl))
+ locate_old_decl (olddecl);
return true;
}
@@ -4941,6 +4940,22 @@ warn_variable_length_array (tree name, tree size)
}
}
+/* Print warning about defaulting to int if necessary. */
+
+static void
+warn_defaults_to (location_t location, int opt, const char *gmsgid, ...)
+{
+ diagnostic_info diagnostic;
+ va_list ap;
+
+ va_start (ap, gmsgid);
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
+ flag_isoc99 ? DK_PEDWARN : DK_WARNING);
+ diagnostic.option_index = opt;
+ report_diagnostic (&diagnostic);
+ va_end (ap);
+}
+
/* Given declspecs and a declarator,
determine the name and type of the object declared
and construct a ..._DECL node for it.
@@ -5117,12 +5132,12 @@ grokdeclarator (const struct c_declarator *declarator,
else
{
if (name)
- pedwarn_c99 (loc, flag_isoc99 ? 0 : OPT_Wimplicit_int,
- "type defaults to %<int%> in declaration of %qE",
- name);
+ warn_defaults_to (loc, flag_isoc99 ? 0 : OPT_Wimplicit_int,
+ "type defaults to %<int%> in declaration "
+ "of %qE", name);
else
- pedwarn_c99 (input_location, flag_isoc99 ? 0 : OPT_Wimplicit_int,
- "type defaults to %<int%> in type name");
+ warn_defaults_to (loc, flag_isoc99 ? 0 : OPT_Wimplicit_int,
+ "type defaults to %<int%> in type name");
}
}
@@ -6249,15 +6264,12 @@ grokdeclarator (const struct c_declarator *declarator,
DECL_DECLARED_INLINE_P (decl) = 1;
if (declspecs->noreturn_p)
{
- if (!flag_isoc11)
- {
- if (flag_isoc99)
- pedwarn (loc, OPT_Wpedantic,
+ if (flag_isoc99)
+ pedwarn_c99 (loc, OPT_Wpedantic,
"ISO C99 does not support %<_Noreturn%>");
- else
- pedwarn (loc, OPT_Wpedantic,
+ else
+ pedwarn_c99 (loc, OPT_Wpedantic,
"ISO C90 does not support %<_Noreturn%>");
- }
TREE_THIS_VOLATILE (decl) = 1;
}
}
@@ -6964,15 +6976,12 @@ grokfield (location_t loc,
pedwarn (loc, 0, "declaration does not declare anything");
return NULL_TREE;
}
- if (!flag_isoc11)
- {
- if (flag_isoc99)
- pedwarn (loc, OPT_Wpedantic,
+ if (flag_isoc99)
+ pedwarn_c99 (loc, OPT_Wpedantic,
"ISO C99 doesn%'t support unnamed structs/unions");
- else
- pedwarn (loc, OPT_Wpedantic,
+ else
+ pedwarn_c99 (loc, OPT_Wpedantic,
"ISO C90 doesn%'t support unnamed structs/unions");
- }
}
value = grokdeclarator (declarator, declspecs, FIELD, false,
@@ -7913,9 +7922,10 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
}
if (warn_about_return_type)
- pedwarn_c99 (loc, flag_isoc99 ? 0
- : (warn_return_type ? OPT_Wreturn_type : OPT_Wimplicit_int),
- "return type defaults to %<int%>");
+ warn_defaults_to (loc, flag_isoc99 ? 0
+ : (warn_return_type ? OPT_Wreturn_type
+ : OPT_Wimplicit_int),
+ "return type defaults to %<int%>");
/* Make the init_value nonzero so pushdecl knows this is not tentative.
error_mark_node is replaced below (in pop_scope) with the BLOCK. */
@@ -9893,14 +9903,14 @@ declspecs_add_scspec (source_location loc,
identifier in the implementation namespace; only diagnose
it for the C11 spelling because of existing code using
the other spelling. */
- if (!flag_isoc11 && !specs->thread_gnu_p)
+ if (!specs->thread_gnu_p)
{
if (flag_isoc99)
- pedwarn (loc, OPT_Wpedantic,
- "ISO C99 does not support %qE", scspec);
+ pedwarn_c99 (loc, OPT_Wpedantic,
+ "ISO C99 does not support %qE", scspec);
else
- pedwarn (loc, OPT_Wpedantic,
- "ISO C90 does not support %qE", scspec);
+ pedwarn_c99 (loc, OPT_Wpedantic,
+ "ISO C90 does not support %qE", scspec);
}
specs->locations[cdw_thread] = loc;
}
diff --git a/gcc/c/c-errors.c b/gcc/c/c-errors.c
index 89393b9..c1f9c35 100644
--- a/gcc/c/c-errors.c
+++ b/gcc/c/c-errors.c
@@ -29,20 +29,42 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h"
#include "opts.h"
-/* Issue an ISO C99 pedantic warning MSGID. */
+/* Issue an ISO C99 pedantic warning MSGID if -pedantic outside C11 mode,
+ otherwise issue warning MSGID if -Wc99-c11-compat is specified.
+ This function is supposed to be used for matters that are allowed in
+ ISO C11 but not supported in ISO C99, thus we explicitly don't pedwarn
+ when C11 is specified. */
-void
+bool
pedwarn_c99 (location_t location, int opt, const char *gmsgid, ...)
{
diagnostic_info diagnostic;
va_list ap;
+ bool warned = false;
va_start (ap, gmsgid);
- diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
- flag_isoc99 ? DK_PEDWARN : DK_WARNING);
- diagnostic.option_index = opt;
- report_diagnostic (&diagnostic);
+ /* If desired, issue the C99/C11 compat warning, which is more specific
+ than -pedantic. */
+ if (warn_c99_c11_compat > 0)
+ {
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
+ (pedantic && !flag_isoc11)
+ ? DK_PEDWARN : DK_WARNING);
+ diagnostic.option_index = OPT_Wc99_c11_compat;
+ warned = report_diagnostic (&diagnostic);
+ }
+ /* -Wno-c99-c11-compat suppresses even the pedwarns. */
+ else if (warn_c99_c11_compat == 0)
+ ;
+ /* For -pedantic outside C11, issue a pedwarn. */
+ else if (pedantic && !flag_isoc11)
+ {
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_PEDWARN);
+ diagnostic.option_index = opt;
+ warned = report_diagnostic (&diagnostic);
+ }
va_end (ap);
+ return warned;
}
/* Issue an ISO C90 pedantic warning MSGID if -pedantic outside C99 mode,
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 6afe3eb..d588797 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -1076,7 +1076,11 @@ disable_extension_diagnostics (void)
/* warn_c90_c99_compat has three states: -1/0/1, so we must
play tricks to properly restore it. */
| ((warn_c90_c99_compat == 1) << 7)
- | ((warn_c90_c99_compat == -1) << 8));
+ | ((warn_c90_c99_compat == -1) << 8)
+ /* Similarly for warn_c99_c11_compat. */
+ | ((warn_c99_c11_compat == 1) << 9)
+ | ((warn_c99_c11_compat == -1) << 10)
+ );
cpp_opts->cpp_pedantic = pedantic = 0;
warn_pointer_arith = 0;
cpp_opts->cpp_warn_traditional = warn_traditional = 0;
@@ -1085,6 +1089,7 @@ disable_extension_diagnostics (void)
warn_cxx_compat = 0;
warn_overlength_strings = 0;
warn_c90_c99_compat = 0;
+ warn_c99_c11_compat = 0;
return ret;
}
@@ -1103,6 +1108,7 @@ restore_extension_diagnostics (int flags)
warn_overlength_strings = (flags >> 6) & 1;
/* See above for why is this needed. */
warn_c90_c99_compat = (flags >> 7) & 1 ? 1 : ((flags >> 8) & 1 ? -1 : 0);
+ warn_c99_c11_compat = (flags >> 9) & 1 ? 1 : ((flags >> 10) & 1 ? -1 : 0);
}
/* Possibly kinds of declarator to parse. */
@@ -2009,15 +2015,12 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser)
gcc_assert (c_parser_next_token_is_keyword (parser, RID_STATIC_ASSERT));
assert_loc = c_parser_peek_token (parser)->location;
- if (!flag_isoc11)
- {
- if (flag_isoc99)
- pedwarn (assert_loc, OPT_Wpedantic,
+ if (flag_isoc99)
+ pedwarn_c99 (assert_loc, OPT_Wpedantic,
"ISO C99 does not support %<_Static_assert%>");
- else
- pedwarn (assert_loc, OPT_Wpedantic,
+ else
+ pedwarn_c99 (assert_loc, OPT_Wpedantic,
"ISO C90 does not support %<_Static_assert%>");
- }
c_parser_consume_token (parser);
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
return;
@@ -2382,15 +2385,12 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
correct lvalue-to-rvalue conversions. */
if (flag_openmp)
sorry ("%<_Atomic%> with OpenMP");
- if (!flag_isoc11)
- {
- if (flag_isoc99)
- pedwarn (loc, OPT_Wpedantic,
+ if (flag_isoc99)
+ pedwarn_c99 (loc, OPT_Wpedantic,
"ISO C99 does not support the %<_Atomic%> qualifier");
- else
- pedwarn (loc, OPT_Wpedantic,
+ else
+ pedwarn_c99 (loc, OPT_Wpedantic,
"ISO C90 does not support the %<_Atomic%> qualifier");
- }
attrs_ok = true;
tree value;
value = c_parser_peek_token (parser)->value;
@@ -3055,15 +3055,12 @@ c_parser_alignas_specifier (c_parser * parser)
location_t loc = c_parser_peek_token (parser)->location;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_ALIGNAS));
c_parser_consume_token (parser);
- if (!flag_isoc11)
- {
- if (flag_isoc99)
- pedwarn (loc, OPT_Wpedantic,
+ if (flag_isoc99)
+ pedwarn_c99 (loc, OPT_Wpedantic,
"ISO C99 does not support %<_Alignas%>");
- else
- pedwarn (loc, OPT_Wpedantic,
+ else
+ pedwarn_c99 (loc, OPT_Wpedantic,
"ISO C90 does not support %<_Alignas%>");
- }
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
return ret;
if (c_parser_next_tokens_start_typename (parser, cla_prefer_id))
@@ -6579,14 +6576,14 @@ c_parser_alignof_expression (c_parser *parser)
/* A diagnostic is not required for the use of this identifier in
the implementation namespace; only diagnose it for the C11
spelling because of existing code using the other spellings. */
- if (!flag_isoc11 && is_c11_alignof)
+ if (is_c11_alignof)
{
if (flag_isoc99)
- pedwarn (loc, OPT_Wpedantic, "ISO C99 does not support %qE",
- alignof_spelling);
+ pedwarn_c99 (loc, OPT_Wpedantic, "ISO C99 does not support %qE",
+ alignof_spelling);
else
- pedwarn (loc, OPT_Wpedantic, "ISO C90 does not support %qE",
- alignof_spelling);
+ pedwarn_c99 (loc, OPT_Wpedantic, "ISO C90 does not support %qE",
+ alignof_spelling);
}
c_parser_consume_token (parser);
c_inhibit_evaluation_warnings++;
@@ -6745,15 +6742,12 @@ c_parser_generic_selection (c_parser *parser)
gcc_assert (c_parser_next_token_is_keyword (parser, RID_GENERIC));
generic_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
- if (!flag_isoc11)
- {
- if (flag_isoc99)
- pedwarn (generic_loc, OPT_Wpedantic,
+ if (flag_isoc99)
+ pedwarn_c99 (generic_loc, OPT_Wpedantic,
"ISO C99 does not support %<_Generic%>");
- else
- pedwarn (generic_loc, OPT_Wpedantic,
+ else
+ pedwarn_c99 (generic_loc, OPT_Wpedantic,
"ISO C90 does not support %<_Generic%>");
- }
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
return error_expr;
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index 55e71dc..6004d50 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -678,7 +678,7 @@ extern tree c_check_omp_declare_reduction_r (tree *, int *, void *);
/* In c-errors.c */
extern void pedwarn_c90 (location_t, int opt, const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
-extern void pedwarn_c99 (location_t, int opt, const char *, ...)
+extern bool pedwarn_c99 (location_t, int opt, const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
#endif /* ! GCC_C_TREE_H */
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 0ed92c6..b1eac34 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -9220,9 +9220,12 @@ c_finish_return (location_t loc, tree retval, tree origtype)
if ((warn_return_type || flag_isoc99)
&& valtype != 0 && TREE_CODE (valtype) != VOID_TYPE)
{
- pedwarn_c99 (loc, flag_isoc99 ? 0 : OPT_Wreturn_type,
- "%<return%> with no value, in "
- "function returning non-void");
+ if (flag_isoc99)
+ pedwarn (loc, 0, "%<return%> with no value, in "
+ "function returning non-void");
+ else
+ warning_at (loc, OPT_Wreturn_type, "%<return%> with no value, "
+ "in function returning non-void");
no_warning = true;
}
}
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 6374261..8ea3689 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -241,7 +241,7 @@ Objective-C and Objective-C++ Dialects}.
-w -Wextra -Wall -Waddress -Waggregate-return @gol
-Waggressive-loop-optimizations -Warray-bounds @gol
-Wno-attributes -Wno-builtin-macro-redefined @gol
--Wc90-c99-compat @gol
+-Wc90-c99-compat -Wc99-c11-compat @gol
-Wc++-compat -Wc++11-compat -Wcast-align -Wcast-qual @gol
-Wchar-subscripts -Wclobbered -Wcomment -Wconditionally-supported @gol
-Wconversion -Wcoverage-mismatch -Wdate-time -Wdelete-incomplete -Wno-cpp @gol
@@ -4527,6 +4527,16 @@ type, @code{bool} type, compound literals, designated initializers, and so
on. This option is independent of the standards mode. Warnings are disabled
in the expression that follows @code{__extension__}.
+@item -Wc99-c11-compat @r{(C and Objective-C only)}
+@opindex Wc99-c11-compat
+@opindex Wno-c99-c11-compat
+Warn about features not present in ISO C99, but present in ISO C11.
+For instance, warn about use of anonymous structures and unions,
+@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
+@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
+and so on. This option is independent of the standards mode. Warnings are
+disabled in the expression that follows @code{__extension__}.
+
@item -Wc++-compat @r{(C and Objective-C only)}
Warn about ISO C constructs that are outside of the common subset of
ISO C and ISO C++, e.g.@: request for implicit conversion from
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 94f9ef0..f5d5d7f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,15 @@
2014-08-19 Marek Polacek <polacek@redhat.com>
+ * gcc.dg/Wc99-c11-compat-1.c: New test.
+ * gcc.dg/Wc99-c11-compat-2.c: New test.
+ * gcc.dg/Wc99-c11-compat-3.c: New test.
+ * gcc.dg/Wc99-c11-compat-4.c: New test.
+ * gcc.dg/Wc99-c11-compat-5.c: New test.
+ * gcc.dg/Wc99-c11-compat-6.c: New test.
+ * gcc.dg/Wc99-c11-compat-7.c: New test.
+
+2014-08-19 Marek Polacek <polacek@redhat.com>
+
* gcc.dg/Wc90-c99-compat-4.c: Remove all dg-warnings.
* gcc.dg/Wc90-c99-compat-5.c: Remove all dg-errors.
* gcc.dg/Wc90-c99-compat-7.c: New test.
diff --git a/gcc/testsuite/gcc.dg/Wc99-c11-compat-1.c b/gcc/testsuite/gcc.dg/Wc99-c11-compat-1.c
new file mode 100644
index 0000000..58fc5b8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wc99-c11-compat-1.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu90 -pedantic -Wc99-c11-compat" } */
+
+struct S { int i; struct { int a; }; }; /* { dg-warning "ISO C90 doesn.t support unnamed structs/unions" } */
+_Noreturn void foo (void); /* { dg-warning "ISO C90 does not support ._Noreturn." } */
+typedef int A;
+typedef int A; /* { dg-warning "redefinition of typedef .A." } */
+_Thread_local int i; /* { dg-warning "ISO C90 does not support ._Thread_local." } */
+_Static_assert (1, "foo"); /* { dg-warning "ISO C90 does not support ._Static_assert." } */
+_Atomic int a; /* { dg-warning "ISO C90 does not support the ._Atomic. qualifier" } */
+_Alignas (int) int aa; /* { dg-warning "ISO C90 does not support ._Alignas." } */
+enum e { E = _Alignof (double) }; /* { dg-warning "ISO C90 does not support ._Alignof." } */
+
+void
+fn (int n)
+{
+ _Generic (n, int: 0); /* { dg-warning "ISO C90 does not support ._Generic." } */
+}
diff --git a/gcc/testsuite/gcc.dg/Wc99-c11-compat-2.c b/gcc/testsuite/gcc.dg/Wc99-c11-compat-2.c
new file mode 100644
index 0000000..9d1aa81
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wc99-c11-compat-2.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -pedantic -Wc99-c11-compat" } */
+
+struct S { int i; struct { int a; }; }; /* { dg-warning "ISO C99 doesn.t support unnamed structs/unions" } */
+_Noreturn void foo (void); /* { dg-warning "ISO C99 does not support ._Noreturn." } */
+typedef int A;
+typedef int A; /* { dg-warning "redefinition of typedef .A." } */
+_Thread_local int i; /* { dg-warning "ISO C99 does not support ._Thread_local." } */
+_Static_assert (1, "foo"); /* { dg-warning "ISO C99 does not support ._Static_assert." } */
+_Atomic int a; /* { dg-warning "ISO C99 does not support the ._Atomic. qualifier" } */
+_Alignas (int) int aa; /* { dg-warning "ISO C99 does not support ._Alignas." } */
+enum e { E = _Alignof (double) }; /* { dg-warning "ISO C99 does not support ._Alignof." } */
+
+void
+fn (int n)
+{
+ _Generic (n, int: 0); /* { dg-warning "ISO C99 does not support ._Generic." } */
+}
diff --git a/gcc/testsuite/gcc.dg/Wc99-c11-compat-3.c b/gcc/testsuite/gcc.dg/Wc99-c11-compat-3.c
new file mode 100644
index 0000000..64e24f8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wc99-c11-compat-3.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu11 -pedantic-errors -Wc99-c11-compat" } */
+
+struct S { int i; struct { int a; }; }; /* { dg-warning "ISO C99 doesn.t support unnamed structs/unions" } */
+_Noreturn void foo (void); /* { dg-warning "ISO C99 does not support ._Noreturn." } */
+typedef int A;
+typedef int A; /* { dg-warning "redefinition of typedef .A." } */
+_Thread_local int i; /* { dg-warning "ISO C99 does not support ._Thread_local." } */
+_Static_assert (1, "foo"); /* { dg-warning "ISO C99 does not support ._Static_assert." } */
+_Atomic int a; /* { dg-warning "ISO C99 does not support the ._Atomic. qualifier" } */
+_Alignas (int) int aa; /* { dg-warning "ISO C99 does not support ._Alignas." } */
+enum e { E = _Alignof (double) }; /* { dg-warning "ISO C99 does not support ._Alignof." } */
+
+void
+fn (int n)
+{
+ _Generic (n, int: 0); /* { dg-warning "ISO C99 does not support ._Generic." } */
+}
diff --git a/gcc/testsuite/gcc.dg/Wc99-c11-compat-4.c b/gcc/testsuite/gcc.dg/Wc99-c11-compat-4.c
new file mode 100644
index 0000000..511ccee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wc99-c11-compat-4.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -pedantic-errors -Wno-c99-c11-compat" } */
+
+struct S { int i; struct { int a; }; };
+_Noreturn void foo (void);
+typedef int A;
+typedef int A;
+_Thread_local int i;
+_Static_assert (1, "foo");
+_Atomic int a;
+_Alignas (int) int aa;
+enum e { E = _Alignof (double) };
+
+void
+fn (int n)
+{
+ _Generic (n, int: 0);
+}
diff --git a/gcc/testsuite/gcc.dg/Wc99-c11-compat-5.c b/gcc/testsuite/gcc.dg/Wc99-c11-compat-5.c
new file mode 100644
index 0000000..ce9698c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wc99-c11-compat-5.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu11 -Wc99-c11-compat" } */
+
+__extension__ struct S { int i; struct { int a; }; };
+__extension__ _Noreturn void foo (void);
+typedef int A;
+__extension__ typedef int A;
+__extension__ _Thread_local int i;
+__extension__ _Static_assert (1, "foo");
+__extension__ _Atomic int a;
+__extension__ _Alignas (int) int aa;
+enum e { E = __extension__ _Alignof (double) };
+
+void
+fn (int n)
+{
+ __extension__ _Generic (n, int: 0);
+}
diff --git a/gcc/testsuite/gcc.dg/Wc99-c11-compat-6.c b/gcc/testsuite/gcc.dg/Wc99-c11-compat-6.c
new file mode 100644
index 0000000..07d7582
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wc99-c11-compat-6.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu90 -pedantic-errors -Wc99-c11-compat" } */
+
+struct S { int i; struct { int a; }; }; /* { dg-error "ISO C90 doesn.t support unnamed structs/unions" } */
+_Noreturn void foo (void); /* { dg-error "ISO C90 does not support ._Noreturn." } */
+typedef int A;
+typedef int A; /* { dg-error "redefinition of typedef .A." } */
+_Thread_local int i; /* { dg-error "ISO C90 does not support ._Thread_local." } */
+_Static_assert (1, "foo"); /* { dg-error "ISO C90 does not support ._Static_assert." } */
+_Atomic int a; /* { dg-error "ISO C90 does not support the ._Atomic. qualifier" } */
+_Alignas (int) int aa; /* { dg-error "ISO C90 does not support ._Alignas." } */
+enum e { E = _Alignof (double) }; /* { dg-error "ISO C90 does not support ._Alignof." } */
+
+void
+fn (int n)
+{
+ _Generic (n, int: 0); /* { dg-error "ISO C90 does not support ._Generic." } */
+}
diff --git a/gcc/testsuite/gcc.dg/Wc99-c11-compat-7.c b/gcc/testsuite/gcc.dg/Wc99-c11-compat-7.c
new file mode 100644
index 0000000..a7033c9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wc99-c11-compat-7.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -pedantic-errors -Wc99-c11-compat" } */
+
+struct S { int i; struct { int a; }; }; /* { dg-error "ISO C99 doesn.t support unnamed structs/unions" } */
+_Noreturn void foo (void); /* { dg-error "ISO C99 does not support ._Noreturn." } */
+typedef int A;
+typedef int A; /* { dg-error "redefinition of typedef .A." } */
+_Thread_local int i; /* { dg-error "ISO C99 does not support ._Thread_local." } */
+_Static_assert (1, "foo"); /* { dg-error "ISO C99 does not support ._Static_assert." } */
+_Atomic int a; /* { dg-error "ISO C99 does not support the ._Atomic. qualifier" } */
+_Alignas (int) int aa; /* { dg-error "ISO C99 does not support ._Alignas." } */
+enum e { E = _Alignof (double) }; /* { dg-error "ISO C99 does not support ._Alignof." } */
+
+void
+fn (int n)
+{
+ _Generic (n, int: 0); /* { dg-error "ISO C99 does not support ._Generic." } */
+}