aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2006-08-20 08:46:13 +0000
committerDanny Smith <dannysmith@users.sourceforge.net>2006-08-20 08:46:13 +0000
commitb2f5a8c80b350e7d3d3cc9eeca6a9fcfc40c4ccf (patch)
tree26a4e207b3099822df6d3fef23730184c651c6b8
parentecb5e3971830366ca8449dead50effccefda2e81 (diff)
PR target/28648 c:
* tree.c (handle_dll_attribute): Return early if not a var or function decl. testsuite * gcc.dg/attr-invalid.c: Add tests for invalid dllimport. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@116270 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/attr-invalid.c21
-rw-r--r--gcc/tree.c11
4 files changed, 42 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3dbd11b3924..6104ecda4f8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+006-08-20 Danny Smith <dannysmith@users.sourceforge.net>
+
+ PR target/28648 c:
+ * tree.c (handle_dll_attribute): Return early if not a
+ var or function decl.
+
2006-08-18 Joseph Myers <joseph@codesourcery.com>
PR target/27565
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ad646c5613c..abaa9b7f856 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-08-20 Danny Smith <dannysmith@users.sourceforge.net>
+
+ PR target/28648 c:
+ * gcc.dg/attr-invalid.c: Add tests for invalid dllimport.
+
2006-08-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/28630
diff --git a/gcc/testsuite/gcc.dg/attr-invalid.c b/gcc/testsuite/gcc.dg/attr-invalid.c
index c6c437d0bbf..7d1c151969b 100644
--- a/gcc/testsuite/gcc.dg/attr-invalid.c
+++ b/gcc/testsuite/gcc.dg/attr-invalid.c
@@ -77,3 +77,24 @@ int ATSYM(fn_knrarg) (arg)
{ return 0; }
int ATSYM(fn_isoarg) (int arg ATTR) { return 0; } /* { dg-warning "attribute ignored" "" } */
+
+
+/* PR target/28648 */
+/* These are invalid on all targets. Applying to PARM_ or FIELD_DECL
+ also caused a tree checking ice on targets that support dllimport. */
+#undef AT
+#define AT dllimport
+
+typedef int ATSYM(type) ATTR; /* { dg-warning "attribute ignored" "" } */
+
+typedef int (*ATSYM(fntype))(void) ATTR; /* { dg-warning "attribute ignored" "" } */
+
+struct ATSYM(struct) {
+ char dummy ATTR; /* { dg-warning "attribute ignored" "" } */
+};
+
+int ATSYM(fn_knrarg) (arg)
+ int arg ATTR; /* { dg-warning "attribute ignored" "" } */
+{ return 0; }
+
+int ATSYM(fn_isoarg) (int arg ATTR) { return 0; } /* { dg-warning "attribute ignored" "" } */
diff --git a/gcc/tree.c b/gcc/tree.c
index 2c95a266416..a58c3274c4b 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3706,9 +3706,18 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags,
return NULL_TREE;
}
+ if (TREE_CODE (node) != FUNCTION_DECL
+ && TREE_CODE (node) != VAR_DECL)
+ {
+ *no_add_attrs = true;
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
+ return NULL_TREE;
+ }
+
/* Report error on dllimport ambiguities seen now before they cause
any damage. */
- if (is_attribute_p ("dllimport", name))
+ else if (is_attribute_p ("dllimport", name))
{
/* Honor any target-specific overrides. */
if (!targetm.valid_dllimport_attribute_p (node))