Target Hook to issue diagnostics for AltiVec argument to funtion with unknown prototype.
Target Hook to issue diagnostics for AltiVec argument to funtion with unknown prototype. OKed by Mark Mitchel. From-SVN: r96124
This commit is contained in:
parent
2470e6670a
commit
4d3e6fae4d
@ -1,3 +1,18 @@
|
||||
2005-03-08 Fariborz Jahanian <fjahanian@apple.com>
|
||||
|
||||
* config/rs6000/rs6000.c (invalid_arg_for_unprototyped_fn):
|
||||
Define the real function for ppc-darwin.
|
||||
* c-typeck.c (convert_arguments): Check for target-specific
|
||||
invalid argument call to unprototyped function.
|
||||
* target-def.h (TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN):
|
||||
New Macro.
|
||||
* target.h (invalid_arg_for_unprototyped_fn): New field
|
||||
in struct calls.
|
||||
* targhooks.c (hook_invalid_arg_for_unprototyped_fn): New
|
||||
default target hook.
|
||||
* targhooks.h (hook_invalid_arg_for_unprototyped_fn):
|
||||
Declare.
|
||||
|
||||
2005-03-08 Kazu Hirata <kazu@cs.umass.edu>
|
||||
|
||||
* c-typeck.c (constructor_stack, constructor_range_stack,
|
||||
|
@ -2122,6 +2122,7 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl)
|
||||
tree val = TREE_VALUE (valtail);
|
||||
tree rname = function;
|
||||
int argnum = parmnum + 1;
|
||||
const char *invalid_func_diag;
|
||||
|
||||
if (type == void_type_node)
|
||||
{
|
||||
@ -2273,6 +2274,12 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl)
|
||||
< TYPE_PRECISION (double_type_node)))
|
||||
/* Convert `float' to `double'. */
|
||||
result = tree_cons (NULL_TREE, convert (double_type_node, val), result);
|
||||
else if ((invalid_func_diag =
|
||||
targetm.calls.invalid_arg_for_unprototyped_fn (typelist, fundecl, val)))
|
||||
{
|
||||
error (invalid_func_diag);
|
||||
return error_mark_node;
|
||||
}
|
||||
else
|
||||
/* Convert `short' and `char' to full-size `int'. */
|
||||
result = tree_cons (NULL_TREE, default_conversion (val), result);
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "cfglayout.h"
|
||||
#include "sched-int.h"
|
||||
#include "tree-gimple.h"
|
||||
#include "intl.h"
|
||||
#if TARGET_XCOFF
|
||||
#include "xcoffout.h" /* get declarations of xcoff_*_section_name */
|
||||
#endif
|
||||
@ -757,6 +758,7 @@ static bool rs6000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
|
||||
tree, bool);
|
||||
static int rs6000_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
|
||||
tree, bool);
|
||||
static const char *invalid_arg_for_unprototyped_fn (tree, tree, tree);
|
||||
#if TARGET_MACHO
|
||||
static void macho_branch_islands (void);
|
||||
static void add_compiler_branch_island (tree, tree, int);
|
||||
@ -1003,6 +1005,9 @@ static const char alt_reg_names[][8] =
|
||||
#undef TARGET_VECTOR_MODE_SUPPORTED_P
|
||||
#define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
|
||||
|
||||
#undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
|
||||
#define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
|
||||
|
||||
/* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors
|
||||
The PowerPC architecture requires only weak consistency among
|
||||
processors--that is, memory accesses between processors need not be
|
||||
@ -17504,4 +17509,18 @@ rs6000_vector_mode_supported_p (enum machine_mode mode)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Target hook for invalid_arg_for_unprototyped_fn. */
|
||||
static const char *
|
||||
invalid_arg_for_unprototyped_fn (tree typelist, tree funcdecl, tree val)
|
||||
{
|
||||
return (!rs6000_darwin64_abi
|
||||
&& typelist == 0
|
||||
&& TREE_CODE (TREE_TYPE (val)) == VECTOR_TYPE
|
||||
&& (funcdecl == NULL_TREE
|
||||
|| (TREE_CODE (funcdecl) == FUNCTION_DECL
|
||||
&& DECL_BUILT_IN_CLASS (funcdecl) != BUILT_IN_MD)))
|
||||
? N_("AltiVec argument passed to unprototyped function")
|
||||
: NULL;
|
||||
}
|
||||
|
||||
#include "gt-rs6000.h"
|
||||
|
@ -9587,6 +9587,12 @@ many recent processors which implement a policy of ``relaxed,''
|
||||
and ia64. The default is @code{false}.
|
||||
@end deftypefn
|
||||
|
||||
@deftypefn {Target Hook} const char *TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN (tree @var{typelist}, tree @var{funcdecl}, tree @var{val})
|
||||
If defined, this macro returns the diagnostic message when it is
|
||||
illegal to pass argument @var{val} to function @var{funcdecl}
|
||||
with prototype @var{typelist}.
|
||||
@end deftypefn
|
||||
|
||||
@defmac TARGET_USE_JCR_SECTION
|
||||
This macro determines whether to use the JCR section to register Java
|
||||
classes. By default, TARGET_USE_JCR_SECTION is defined to 1 if both
|
||||
|
@ -356,6 +356,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#define TARGET_ENCODE_SECTION_INFO default_encode_section_info
|
||||
#endif
|
||||
|
||||
#ifndef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
|
||||
#define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN hook_invalid_arg_for_unprototyped_fn
|
||||
#endif
|
||||
|
||||
#define TARGET_FIXED_CONDITION_CODE_REGS hook_bool_uintp_uintp_false
|
||||
|
||||
#define TARGET_CC_MODES_COMPATIBLE default_cc_modes_compatible
|
||||
@ -416,7 +420,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
TARGET_SPLIT_COMPLEX_ARG, \
|
||||
TARGET_MUST_PASS_IN_STACK, \
|
||||
TARGET_CALLEE_COPIES, \
|
||||
TARGET_ARG_PARTIAL_BYTES \
|
||||
TARGET_ARG_PARTIAL_BYTES, \
|
||||
TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN \
|
||||
}
|
||||
|
||||
|
||||
|
@ -543,6 +543,11 @@ struct gcc_target
|
||||
in registers; the balance is therefore passed on the stack. */
|
||||
int (* arg_partial_bytes) (CUMULATIVE_ARGS *ca, enum machine_mode mode,
|
||||
tree type, bool named);
|
||||
|
||||
/* Return the diagnostic message string if function without a prototype
|
||||
is not allowed for this 'val' argument; NULL otherwise. */
|
||||
const char *(*invalid_arg_for_unprototyped_fn) (tree typelist,
|
||||
tree funcdecl, tree val);
|
||||
} calls;
|
||||
|
||||
/* Functions specific to the C++ frontend. */
|
||||
|
@ -288,3 +288,12 @@ hook_int_CUMULATIVE_ARGS_mode_tree_bool_0 (
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *
|
||||
hook_invalid_arg_for_unprototyped_fn (
|
||||
tree typelist ATTRIBUTE_UNUSED,
|
||||
tree funcdecl ATTRIBUTE_UNUSED,
|
||||
tree val ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -58,3 +58,5 @@ extern bool hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true
|
||||
(CUMULATIVE_ARGS *, enum machine_mode, tree, bool);
|
||||
extern int hook_int_CUMULATIVE_ARGS_mode_tree_bool_0
|
||||
(CUMULATIVE_ARGS *, enum machine_mode, tree, bool);
|
||||
extern const char *hook_invalid_arg_for_unprototyped_fn
|
||||
(tree, tree, tree);
|
||||
|
17
gcc/testsuite/gcc.dg/altivec-21.c
Normal file
17
gcc/testsuite/gcc.dg/altivec-21.c
Normal file
@ -0,0 +1,17 @@
|
||||
/* { dg-do compile { target powerpc*-*-* } } */
|
||||
/* { dg-options "-maltivec" } */
|
||||
|
||||
#include <altivec.h>
|
||||
|
||||
extern void preansi();
|
||||
|
||||
typedef void (*pvecfunc) ();
|
||||
|
||||
void foo(pvecfunc pvf) {
|
||||
vector int v = (vector int){1, 2, 3, 4};
|
||||
#ifndef __LP64__
|
||||
preansi (4, 4.0, v); /* { dg-error "AltiVec argument passed to unprototyped function" } */
|
||||
(*pvf) (4, 4.0, v); /* { dg-error "AltiVec argument passed to unprototyped function" } */
|
||||
#endif /* __LP64__ */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user