Commit 2cb4817b by Anatoly Sokolov Committed by Anatoly Sokolov

re PR target/34299 ([avr] ICE on function attribute syntax for main())

	PR target/34299
	* config/avr/avr.c (avr_handle_fndecl_attribute): Move code for
	generate a warning if the function name does not begin with
	"__vector" and the function has either the 'signal' or 'interrupt'
	attribute, from here to ...
	(avr_declare_function_name): ...here. New function.
	* config/avr/avr.h (ASM_DECLARE_FUNCTION_NAME): Redefine.
	* config/avr/avr-protos.h (avr_declare_function_name): Declare.

From-SVN: r144870
parent 58366b08
2009-03-14 Anatoly Sokolov <aesok@post.ru>
PR target/34299
* config/avr/avr.c (avr_handle_fndecl_attribute): Move code for
generate a warning if the function name does not begin with
"__vector" and the function has either the 'signal' or 'interrupt'
attribute, from here to ...
(avr_declare_function_name): ...here. New function.
* config/avr/avr.h (ASM_DECLARE_FUNCTION_NAME): Redefine.
* config/avr/avr-protos.h (avr_declare_function_name): Declare.
2009-03-14 Jakub Jelinek <jakub@redhat.com> 2009-03-14 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/39454 PR bootstrap/39454
......
/* Prototypes for exported functions defined in avr.c /* Prototypes for exported functions defined in avr.c
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Denis Chertykov (denisc@overta.ru) Contributed by Denis Chertykov (denisc@overta.ru)
...@@ -32,6 +32,7 @@ extern enum reg_class avr_regno_reg_class (int r); ...@@ -32,6 +32,7 @@ extern enum reg_class avr_regno_reg_class (int r);
extern enum reg_class avr_reg_class_from_letter (int c); extern enum reg_class avr_reg_class_from_letter (int c);
extern int frame_pointer_required_p (void); extern int frame_pointer_required_p (void);
extern void asm_globalize_label (FILE *file, const char *name); extern void asm_globalize_label (FILE *file, const char *name);
extern void avr_asm_declare_function_name (FILE *, const char *, tree);
extern void order_regs_for_local_alloc (void); extern void order_regs_for_local_alloc (void);
extern int initial_elimination_offset (int from, int to); extern int initial_elimination_offset (int from, int to);
extern int avr_simple_epilogue (void); extern int avr_simple_epilogue (void);
......
...@@ -4595,6 +4595,39 @@ avr_assemble_integer (rtx x, unsigned int size, int aligned_p) ...@@ -4595,6 +4595,39 @@ avr_assemble_integer (rtx x, unsigned int size, int aligned_p)
return default_assemble_integer (x, size, aligned_p); return default_assemble_integer (x, size, aligned_p);
} }
/* Worker function for ASM_DECLARE_FUNCTION_NAME. */
void
avr_asm_declare_function_name (FILE *file, const char *name, tree decl)
{
/* If the function has the 'signal' or 'interrupt' attribute, test to
make sure that the name of the function is "__vector_NN" so as to
catch when the user misspells the interrupt vector name. */
if (cfun->machine->is_interrupt)
{
if (strncmp (name, "__vector", strlen ("__vector")) != 0)
{
warning_at (DECL_SOURCE_LOCATION (decl), 0,
"%qs appears to be a misspelled interrupt handler",
name);
}
}
else if (cfun->machine->is_signal)
{
if (strncmp (name, "__vector", strlen ("__vector")) != 0)
{
warning_at (DECL_SOURCE_LOCATION (decl), 0,
"%qs appears to be a misspelled signal handler",
name);
}
}
ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
ASM_OUTPUT_LABEL (file, name);
}
/* The routine used to output NUL terminated strings. We use a special /* The routine used to output NUL terminated strings. We use a special
version of this for most svr4 targets because doing so makes the version of this for most svr4 targets because doing so makes the
generated assembly code more compact (and thus faster to assemble) generated assembly code more compact (and thus faster to assemble)
...@@ -4779,32 +4812,6 @@ avr_handle_fndecl_attribute (tree *node, tree name, ...@@ -4779,32 +4812,6 @@ avr_handle_fndecl_attribute (tree *node, tree name,
IDENTIFIER_POINTER (name)); IDENTIFIER_POINTER (name));
*no_add_attrs = true; *no_add_attrs = true;
} }
else
{
const char *func_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (*node));
const char *attr = IDENTIFIER_POINTER (name);
/* If the function has the 'signal' or 'interrupt' attribute, test to
make sure that the name of the function is "__vector_NN" so as to
catch when the user misspells the interrupt vector name. */
if (strncmp (attr, "interrupt", strlen ("interrupt")) == 0)
{
if (strncmp (func_name, "__vector", strlen ("__vector")) != 0)
{
warning (0, "%qs appears to be a misspelled interrupt handler",
func_name);
}
}
else if (strncmp (attr, "signal", strlen ("signal")) == 0)
{
if (strncmp (func_name, "__vector", strlen ("__vector")) != 0)
{
warning (0, "%qs appears to be a misspelled signal handler",
func_name);
}
}
}
return NULL_TREE; return NULL_TREE;
} }
......
...@@ -590,10 +590,7 @@ do { \ ...@@ -590,10 +590,7 @@ do { \
specific tm.h file (depending upon the particulars of your assembler). */ specific tm.h file (depending upon the particulars of your assembler). */
#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
do { \ avr_asm_declare_function_name ((FILE), (NAME), (DECL))
ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
ASM_OUTPUT_LABEL (FILE, NAME); \
} while (0)
#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
do { \ do { \
......
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