mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-17 20:11:06 +08:00
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
This commit is contained in:
parent
638c5a49da
commit
b8b47f4251
@ -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);
|
||||
}
|
||||
|
@ -1,3 +1,9 @@
|
||||
2005-11-23 Gabriel Dos Reis <gdr@integrable-solutions.net>
|
||||
|
||||
PR c/21668
|
||||
* gcc.dg/Wc++-compat.c: New.
|
||||
* gcc.dg/Wno-c++-compat.c: New.
|
||||
|
||||
2005-11-23 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* gcc.target/powerpc/altivec-consts.c (vspltisb): Use int val.
|
||||
|
9
gcc/testsuite/gcc.dg/Wc++-compat.c
Normal file
9
gcc/testsuite/gcc.dg/Wc++-compat.c
Normal file
@ -0,0 +1,9 @@
|
||||
/* Copyright (C) 2005 Free Software Foundation.
|
||||
|
||||
by Gabriel Dos Reis <gdr@integrable-solutions.net> */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-Wc++-compat" } */
|
||||
|
||||
extern const int foo = 42;
|
||||
|
9
gcc/testsuite/gcc.dg/Wno-c++-compat.c
Normal file
9
gcc/testsuite/gcc.dg/Wno-c++-compat.c
Normal file
@ -0,0 +1,9 @@
|
||||
/* Copyright (C) 2005 Free Software Foundation.
|
||||
|
||||
by Gabriel Dos Reis <gdr@integrable-solutions.net> */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-Wno-c++-compat" } */
|
||||
|
||||
extern const int foo = 42; /* { dg-error "initialized and declared" } */
|
||||
|
Loading…
x
Reference in New Issue
Block a user