diff options
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 003b813fc7d..a86cfdc01b6 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -4014,8 +4014,13 @@ grokdeclarator (const struct c_declarator *declarator, && !funcdef_flag) { /* 'extern' with initialization is invalid if not at file scope. */ - if (current_scope == file_scope) - warning (0, "%qs initialized and declared %<extern%>", name); + if (current_scope == file_scope) + { + /* It is fine to have 'extern const' when compiling at C + and C++ intersection. */ + if (!(warn_cxx_compat && constp)) + warning (0, "%qs initialized and declared %<extern%>", name); + } else error ("%qs has both %<extern%> and initializer", name); } |