This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch] PR target/28648 Tree check ICE on invalid attribute.
- From: Danny Smith <dannysmith at clear dot net dot nz>
- To: GCC-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 08 Aug 2006 21:06:15 +1200
- Subject: [Patch] PR target/28648 Tree check ICE on invalid attribute.
The following causes ICE on windows targets on mainline.
void foo ( int __attribute__ ((dllimport)) bar);
dllimp_parm.c:1: internal compiler error: tree check: expected tree that
contains 'decl with visibility' structure, have 'parm_decl' in
handle_dll_attribute, at tree.c:3762
Please submit a full bug report,
I believe this is a regression from 3.4.5, but that is only because tree
check now picks up the bug.
Here is the fix. It affects only targets where
TARGET_DLLIMPORT_DECL_ATTRIBUTES
OK for mainline?
ChangeLog
2006-08-08 Danny Smith <dannysmith@users.sourceforge.net>
PR target/28648
* tree.c (handle_dll_attribute): Return early if not a
var or function decl.
testsuite/ChangeLog
* gcc.dg/attr-invalid.c: Add tests for invalid dllimport.
Index: tree.c
===================================================================
*** tree.c (revision 116011)
--- tree.c (working copy)
*************** handle_dll_attribute (tree * pnode, tree
*** 3707,3715 ****
return NULL_TREE;
}
/* Report error on dllimport ambiguities seen now before they cause
any damage. */
! if (is_attribute_p ("dllimport", name))
{
/* Honor any target-specific overrides. */
if (!targetm.valid_dllimport_attribute_p (node))
--- 3717,3734 ----
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. */
! else if (is_attribute_p ("dllimport", name))
{
/* Honor any target-specific overrides. */
if (!targetm.valid_dllimport_attribute_p (node))
Index: testsuite/gcc.dg/attr-invalid.c
===================================================================
*** testsuite/gcc.dg/attr-invalid.c (revision 116011)
--- testsuite/gcc.dg/attr-invalid.c (working copy)
*************** int ATSYM(fn_vars) (void) {
*** 56,58 ****
--- 56,84 ----
auto int lvar ATTR; /* { dg-warning "attribute ignored" "" } */
return 0;
}
+
+ /* PR target/28648 */
+ /* These are invalid on all targets. They also caused a tree checking
ICE on mingw32. */
+ #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(var) ATTR;
+
+ 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" "" } */
+
+ int ATSYM(fn_vars) (void) {
+ auto int lvar ATTR; /* { dg-warning "attribute ignored" "" } */
+ return 0;
+ }