aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@integrable-solutions.net>2005-11-23 07:07:33 +0000
committerGabriel Dos Reis <gdr@gcc.gnu.org>2005-11-23 07:07:33 +0000
commitb8b47f42511415601638a9efde76b54c39729c32 (patch)
tree57cdce0dac387244542b1a40a789f1005b4896da /gcc/c-decl.c
parent638c5a49dade942b12af632d1d298986a3cadb74 (diff)
downloadgcc-b8b47f42511415601638a9efde76b54c39729c32.zip
gcc-b8b47f42511415601638a9efde76b54c39729c32.tar.gz
gcc-b8b47f42511415601638a9efde76b54c39729c32.tar.bz2
re PR c/21668 (gratuitous warning about "extern const" with initializer)
PR c/21668 * c-decl.c (grokdeclarator): Don't warn for 'extern const' when compiling at the intersection of C and C++. testsuite/ PR c/21668 * gcc.dg/Wc++-compat.c: New. * gcc.dg/Wno-c++-compat.c: New. From-SVN: r107401
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 003b813..a86cfdc 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);
}