Commit 88eeff6f by Ian Lance Taylor Committed by Ian Lance Taylor

c-decl.c (grokdeclarator): If -Wc++-compat, warn about a global variable with an anonymous type.

./:	* c-decl.c (grokdeclarator): If -Wc++-compat, warn about a global
	variable with an anonymous type.
fortran/:
	* cpp.c (struct gfc_cpp_option_data): Give this struct, used for
	the global variable gfc_cpp_option, a name.
testsuite/:
	* gcc.dg/Wcxx-compat-16.c: New testcase.

From-SVN: r148708
parent 28a876a4
2009-06-19 Ian Lance Taylor <iant@google.com>
* c-decl.c (grokdeclarator): If -Wc++-compat, warn about a global
variable with an anonymous type.
2009-06-19 Uros Bizjak <ubizjak@gmail.com> 2009-06-19 Uros Bizjak <ubizjak@gmail.com>
* see.c: Remove for real. * see.c: Remove for real.
......
...@@ -5875,6 +5875,19 @@ grokdeclarator (const struct c_declarator *declarator, ...@@ -5875,6 +5875,19 @@ grokdeclarator (const struct c_declarator *declarator,
name of a variable. Thus, if it's known before this, die horribly. */ name of a variable. Thus, if it's known before this, die horribly. */
gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl)); gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl));
if (warn_cxx_compat
&& TREE_CODE (decl) == VAR_DECL
&& TREE_PUBLIC (decl)
&& TREE_STATIC (decl)
&& (TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
|| TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE
|| TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
&& TYPE_NAME (TREE_TYPE (decl)) == NULL_TREE)
warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
("non-local variable %qD with anonymous type is "
"questionable in C++"),
decl);
return decl; return decl;
} }
} }
......
2009-06-19 Ian Lance Taylor <iant@google.com>
* cpp.c (struct gfc_cpp_option_data): Give this struct, used for
the global variable gfc_cpp_option, a name.
2009-06-19 Janus Weil <janus@gcc.gnu.org> 2009-06-19 Janus Weil <janus@gcc.gnu.org>
PR fortran/40450 PR fortran/40450
......
...@@ -66,7 +66,7 @@ typedef struct gfc_cpp_macro_queue ...@@ -66,7 +66,7 @@ typedef struct gfc_cpp_macro_queue
} gfc_cpp_macro_queue; } gfc_cpp_macro_queue;
static gfc_cpp_macro_queue *cpp_define_queue, *cpp_undefine_queue; static gfc_cpp_macro_queue *cpp_define_queue, *cpp_undefine_queue;
struct struct gfc_cpp_option_data
{ {
/* Argument of -cpp, implied by SPEC; /* Argument of -cpp, implied by SPEC;
if NULL, preprocessing disabled. */ if NULL, preprocessing disabled. */
......
2009-06-19 Ian Lance Taylor <iant@google.com>
* gcc.dg/Wcxx-compat-16.c: New testcase.
2009-06-19 Uros Bizjak <ubizjak@gmail.com> 2009-06-19 Uros Bizjak <ubizjak@gmail.com>
* gcc.dg/builtins-34.c: Add significand cases. * gcc.dg/builtins-34.c: Add significand cases.
......
/* { dg-do compile } */
/* { dg-options "-Wc++-compat" } */
struct { int f1; } g1; /* { dg-warning "C\[+\]\[+\]" } */
static struct { int f2; } g2;
struct s { int f3; } g3;
union { int f4; } g4; /* { dg-warning "C\[+\]\[+\]" } */
static union { int f5; } g5;
union u { int f6; } g6;
enum { A } g7; /* { dg-warning "C\[+\]\[+\]" } */
static enum { B } g8;
enum E { C } g9;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment