diff options
author | Ian Lance Taylor <iant@google.com> | 2009-06-19 15:25:16 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2009-06-19 15:25:16 +0000 |
commit | 88eeff6f5a1347dc09de33c26a68648c4dea7f80 (patch) | |
tree | fc52468ac72e4ed7eef097489864a842fdb17db4 /gcc/c-decl.c | |
parent | 28a876a42966c74582188b6c124c790f0b724535 (diff) | |
download | gcc-88eeff6f5a1347dc09de33c26a68648c4dea7f80.tar.gz |
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
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 4e48bac7f54..57cbd283588 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5875,6 +5875,19 @@ grokdeclarator (const struct c_declarator *declarator, name of a variable. Thus, if it's known before this, die horribly. */ 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; } } |