aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl.c9
-rw-r--r--gcc/cp/error.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/ext/attrib18.C10
6 files changed, 37 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b569b94..fee23b5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+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.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 580a73b..307809f 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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 */
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index c435e48..63227df 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.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
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 9f79a26..a586112 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 95e2a9d..3255d47 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/g++.dg/ext/attrib18.C b/gcc/testsuite/g++.dg/ext/attrib18.C
new file mode 100644
index 0000000..0c3a072
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/attrib18.C
@@ -0,0 +1,10 @@
+// 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();
+};