Commit 3cabd8f9 by Matt Austern Committed by Matt Austern

re PR c++/17542 (Visibility attribute ignored when it precedes class head)

	PR c++/17542
	* cp-tree.h (class_key_or_enum_as_string): Declare.
	* error.c (class_key_or_enum): Rename to class_key_or_enum_as_string
	and remove static qualifier.
	* decl.c (shadow_tag): Warn about ignored attributes in class/struct/
	union/enum declaration.
	* g++.dg/ext/attrib18.C: New test.

From-SVN: r89898
parent 46bfe5e3
1004-10-28 Matt Austern <austern@apple.com>
PR c++/17542
* cp-tree.h (class_key_or_enum_as_string): Declare.
* error.c (class_key_or_enum): Rename to class_key_or_enum_as_string
and remove static qualifier.
* decl.c (shadow_tag): Warn about ignored attributes in class/struct/
union/enum declaration.
2004-10-29 Kazu Hirata <kazu@cs.umass.edu>
* pt.c: Fix a comment typo.
......
......@@ -3823,6 +3823,7 @@ extern const char *expr_as_string (tree, int);
extern const char *context_as_string (tree, int);
extern const char *lang_decl_name (tree, int);
extern const char *language_to_string (enum languages);
extern const char *class_key_or_enum_as_string (tree);
extern void print_instantiation_context (void);
/* in except.c */
......
......@@ -3596,6 +3596,15 @@ shadow_tag (cp_decl_specifier_seq *declspecs)
if (!t)
return NULL_TREE;
if (declspecs->attributes)
{
cp_warning_at ("attribute ignored in declaration of %q#T", t);
cp_warning_at ("attribute for %q#T must follow the %qs keyword",
t,
class_key_or_enum_as_string (t));
}
maybe_process_partial_specialization (t);
/* This is where the variables in an anonymous union are
......
......@@ -70,7 +70,6 @@ static void dump_expr_list (tree, int);
static void dump_global_iord (tree);
static void dump_parameters (tree, int);
static void dump_exception_spec (tree, int);
static const char *class_key_or_enum (tree);
static void dump_template_argument (tree, int);
static void dump_template_argument_list (tree, int);
static void dump_template_parameter (tree, int);
......@@ -396,8 +395,8 @@ dump_typename (tree t, int flags)
/* Return the name of the supplied aggregate, or enumeral type. */
static const char *
class_key_or_enum (tree t)
const char *
class_key_or_enum_as_string (tree t)
{
if (TREE_CODE (t) == ENUMERAL_TYPE)
return "enum";
......@@ -416,7 +415,7 @@ static void
dump_aggr_type (tree t, int flags)
{
tree name;
const char *variety = class_key_or_enum (t);
const char *variety = class_key_or_enum_as_string (t);
int typdef = 0;
int tmplate = 0;
......
2004-10-30 Matt Austern <austern@apple.com>
PR c++/17542
* g++.dg/ext/attrib18.C: New test.
2004-10-30 Roger Sayle <roger@eyesopen.com>
PR middle-end/18096
......
// PR c++/17542
// Test that we warn when an attribute preceding the class-key is ignored.
// { dg-do compile }
__attribute__ ((packed)) struct A
{ // { dg-warning "attribute" }
char c;
int x;
void f();
};
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