Commit cc2a672a by Martin Liska Committed by Martin Liska

Enhance target and target_clone error messages.

2019-05-02  Martin Liska  <mliska@suse.cz>

	* cgraphclones.c: Call valid_attribute_p with 1 for
	target_clone.
	* config/i386/i386-c.c (ix86_pragma_target_parse): Use 0 as
	it's for target attribute.
	* config/i386/i386-protos.h (ix86_valid_target_attribute_tree):
	Add new boolean argument.
	* config/i386/i386.c (ix86_valid_target_attribute_inner_p):
	Likewise.
	(ix86_valid_target_attribute_tree): Pass target_clone_attr
	to ix86_valid_target_attribute_inner_p.
	(ix86_valid_target_attribute_p): Pass flags argument to
	ix86_valid_target_attribute_inner_p.
	(get_builtin_code_for_version): Use 0 as it's target attribute.
2019-05-02  Martin Liska  <mliska@suse.cz>

	* gcc.target/i386/funcspec-4.c: Update scanned pattern.
	* g++.target/i386/pr57362.C: Likewise.

From-SVN: r270789
parent 2dcfc872
2019-05-02 Martin Liska <mliska@suse.cz> 2019-05-02 Martin Liska <mliska@suse.cz>
* cgraphclones.c: Call valid_attribute_p with 1 for
target_clone.
* config/i386/i386-c.c (ix86_pragma_target_parse): Use 0 as
it's for target attribute.
* config/i386/i386-protos.h (ix86_valid_target_attribute_tree):
Add new boolean argument.
* config/i386/i386.c (ix86_valid_target_attribute_inner_p):
Likewise.
(ix86_valid_target_attribute_tree): Pass target_clone_attr
to ix86_valid_target_attribute_inner_p.
(ix86_valid_target_attribute_p): Pass flags argument to
ix86_valid_target_attribute_inner_p.
(get_builtin_code_for_version): Use 0 as it's target attribute.
2019-05-02 Martin Liska <mliska@suse.cz>
* gcc.c (process_command): Add dummy file only * gcc.c (process_command): Add dummy file only
if n_infiles == 0. if n_infiles == 0.
* opts-global.c (decode_options): Pass lang_mask. * opts-global.c (decode_options): Pass lang_mask.
......
...@@ -1056,7 +1056,7 @@ cgraph_node::create_version_clone_with_body ...@@ -1056,7 +1056,7 @@ cgraph_node::create_version_clone_with_body
location_t saved_loc = input_location; location_t saved_loc = input_location;
tree v = TREE_VALUE (target_attributes); tree v = TREE_VALUE (target_attributes);
input_location = DECL_SOURCE_LOCATION (new_decl); input_location = DECL_SOURCE_LOCATION (new_decl);
bool r = targetm.target_option.valid_attribute_p (new_decl, NULL, v, 0); bool r = targetm.target_option.valid_attribute_p (new_decl, NULL, v, 1);
input_location = saved_loc; input_location = saved_loc;
if (!r) if (!r)
return NULL; return NULL;
......
...@@ -586,8 +586,9 @@ ix86_pragma_target_parse (tree args, tree pop_target) ...@@ -586,8 +586,9 @@ ix86_pragma_target_parse (tree args, tree pop_target)
} }
else else
{ {
cur_tree = ix86_valid_target_attribute_tree (args, &global_options, cur_tree = ix86_valid_target_attribute_tree (NULL_TREE, args,
&global_options_set); &global_options,
&global_options_set, 0);
if (!cur_tree || cur_tree == error_mark_node) if (!cur_tree || cur_tree == error_mark_node)
{ {
cl_target_option_restore (&global_options, cl_target_option_restore (&global_options,
......
...@@ -215,9 +215,9 @@ extern unsigned int ix86_minimum_alignment (tree, machine_mode, ...@@ -215,9 +215,9 @@ extern unsigned int ix86_minimum_alignment (tree, machine_mode,
extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *); extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *);
extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *); extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *);
extern int x86_field_alignment (tree, int); extern int x86_field_alignment (tree, int);
extern tree ix86_valid_target_attribute_tree (tree, extern tree ix86_valid_target_attribute_tree (tree, tree,
struct gcc_options *, struct gcc_options *,
struct gcc_options *); struct gcc_options *, bool);
extern unsigned int ix86_get_callcvt (const_tree); extern unsigned int ix86_get_callcvt (const_tree);
#endif #endif
......
...@@ -847,10 +847,11 @@ static void ix86_function_specific_post_stream_in (struct cl_target_option *); ...@@ -847,10 +847,11 @@ static void ix86_function_specific_post_stream_in (struct cl_target_option *);
static void ix86_function_specific_print (FILE *, int, static void ix86_function_specific_print (FILE *, int,
struct cl_target_option *); struct cl_target_option *);
static bool ix86_valid_target_attribute_p (tree, tree, tree, int); static bool ix86_valid_target_attribute_p (tree, tree, tree, int);
static bool ix86_valid_target_attribute_inner_p (tree, char *[], static bool ix86_valid_target_attribute_inner_p (tree, tree, char *[],
struct gcc_options *, struct gcc_options *,
struct gcc_options *, struct gcc_options *,
struct gcc_options *); struct gcc_options *,
bool);
static bool ix86_can_inline_p (tree, tree); static bool ix86_can_inline_p (tree, tree);
static void ix86_set_current_function (tree); static void ix86_set_current_function (tree);
static unsigned int ix86_minimum_incoming_stack_boundary (bool); static unsigned int ix86_minimum_incoming_stack_boundary (bool);
...@@ -5149,10 +5150,11 @@ ix86_function_specific_print (FILE *file, int indent, ...@@ -5149,10 +5150,11 @@ ix86_function_specific_print (FILE *file, int indent,
over the list. */ over the list. */
static bool static bool
ix86_valid_target_attribute_inner_p (tree args, char *p_strings[], ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[],
struct gcc_options *opts, struct gcc_options *opts,
struct gcc_options *opts_set, struct gcc_options *opts_set,
struct gcc_options *enum_opts_set) struct gcc_options *enum_opts_set,
bool target_clone_attr)
{ {
char *next_optstr; char *next_optstr;
bool ret = true; bool ret = true;
...@@ -5296,9 +5298,12 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[], ...@@ -5296,9 +5298,12 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[],
IX86_ATTR_YES ("recip", IX86_ATTR_YES ("recip",
OPT_mrecip, OPT_mrecip,
MASK_RECIP), MASK_RECIP),
}; };
location_t loc
= fndecl == NULL ? UNKNOWN_LOCATION : DECL_SOURCE_LOCATION (fndecl);
const char *attr_name = target_clone_attr ? "target_clone" : "target";
/* If this is a list, recurse to get the options. */ /* If this is a list, recurse to get the options. */
if (TREE_CODE (args) == TREE_LIST) if (TREE_CODE (args) == TREE_LIST)
{ {
...@@ -5306,9 +5311,10 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[], ...@@ -5306,9 +5311,10 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[],
for (; args; args = TREE_CHAIN (args)) for (; args; args = TREE_CHAIN (args))
if (TREE_VALUE (args) if (TREE_VALUE (args)
&& !ix86_valid_target_attribute_inner_p (TREE_VALUE (args), && !ix86_valid_target_attribute_inner_p (fndecl, TREE_VALUE (args),
p_strings, opts, opts_set, p_strings, opts, opts_set,
enum_opts_set)) enum_opts_set,
target_clone_attr))
ret = false; ret = false;
return ret; return ret;
...@@ -5316,7 +5322,7 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[], ...@@ -5316,7 +5322,7 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[],
else if (TREE_CODE (args) != STRING_CST) else if (TREE_CODE (args) != STRING_CST)
{ {
error ("attribute %<target%> argument not a string"); error_at (loc, "attribute %qs argument is not a string", attr_name);
return false; return false;
} }
...@@ -5328,7 +5334,6 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[], ...@@ -5328,7 +5334,6 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[],
char *p = next_optstr; char *p = next_optstr;
char *orig_p = p; char *orig_p = p;
char *comma = strchr (next_optstr, ','); char *comma = strchr (next_optstr, ',');
const char *opt_string;
size_t len, opt_len; size_t len, opt_len;
int opt; int opt;
bool opt_set_p; bool opt_set_p;
...@@ -5374,7 +5379,6 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[], ...@@ -5374,7 +5379,6 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[],
{ {
opt = attrs[i].opt; opt = attrs[i].opt;
mask = attrs[i].mask; mask = attrs[i].mask;
opt_string = attrs[i].string;
break; break;
} }
} }
...@@ -5382,7 +5386,8 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[], ...@@ -5382,7 +5386,8 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[],
/* Process the option. */ /* Process the option. */
if (opt == N_OPTS) if (opt == N_OPTS)
{ {
error ("attribute(target(\"%s\")) is unknown", orig_p); error_at (loc, "attribute %qs argument %qs is unknown",
orig_p, attr_name);
ret = false; ret = false;
} }
...@@ -5410,7 +5415,8 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[], ...@@ -5410,7 +5415,8 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[],
{ {
if (p_strings[opt]) if (p_strings[opt])
{ {
error ("option(\"%s\") was already specified", opt_string); error_at (loc, "attribute value %qs was already specified "
"in %qs attribute", orig_p, attr_name);
ret = false; ret = false;
} }
else else
...@@ -5429,7 +5435,8 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[], ...@@ -5429,7 +5435,8 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[],
global_dc); global_dc);
else else
{ {
error ("attribute(target(\"%s\")) is unknown", orig_p); error_at (loc, "attribute value %qs is unknown in %qs attribute",
orig_p, attr_name);
ret = false; ret = false;
} }
} }
...@@ -5453,9 +5460,10 @@ release_options_strings (char **option_strings) ...@@ -5453,9 +5460,10 @@ release_options_strings (char **option_strings)
/* Return a TARGET_OPTION_NODE tree of the target options listed or NULL. */ /* Return a TARGET_OPTION_NODE tree of the target options listed or NULL. */
tree tree
ix86_valid_target_attribute_tree (tree args, ix86_valid_target_attribute_tree (tree fndecl, tree args,
struct gcc_options *opts, struct gcc_options *opts,
struct gcc_options *opts_set) struct gcc_options *opts_set,
bool target_clone_attr)
{ {
const char *orig_arch_string = opts->x_ix86_arch_string; const char *orig_arch_string = opts->x_ix86_arch_string;
const char *orig_tune_string = opts->x_ix86_tune_string; const char *orig_tune_string = opts->x_ix86_tune_string;
...@@ -5471,8 +5479,9 @@ ix86_valid_target_attribute_tree (tree args, ...@@ -5471,8 +5479,9 @@ ix86_valid_target_attribute_tree (tree args,
memset (&enum_opts_set, 0, sizeof (enum_opts_set)); memset (&enum_opts_set, 0, sizeof (enum_opts_set));
/* Process each of the options on the chain. */ /* Process each of the options on the chain. */
if (! ix86_valid_target_attribute_inner_p (args, option_strings, opts, if (!ix86_valid_target_attribute_inner_p (fndecl, args, option_strings, opts,
opts_set, &enum_opts_set)) opts_set, &enum_opts_set,
target_clone_attr))
return error_mark_node; return error_mark_node;
/* If the changed options are different from the default, rerun /* If the changed options are different from the default, rerun
...@@ -5545,7 +5554,7 @@ static bool ...@@ -5545,7 +5554,7 @@ static bool
ix86_valid_target_attribute_p (tree fndecl, ix86_valid_target_attribute_p (tree fndecl,
tree ARG_UNUSED (name), tree ARG_UNUSED (name),
tree args, tree args,
int ARG_UNUSED (flags)) int flags)
{ {
struct gcc_options func_options; struct gcc_options func_options;
tree new_target, new_optimize; tree new_target, new_optimize;
...@@ -5580,8 +5589,10 @@ ix86_valid_target_attribute_p (tree fndecl, ...@@ -5580,8 +5589,10 @@ ix86_valid_target_attribute_p (tree fndecl,
cl_target_option_restore (&func_options, cl_target_option_restore (&func_options,
TREE_TARGET_OPTION (target_option_default_node)); TREE_TARGET_OPTION (target_option_default_node));
new_target = ix86_valid_target_attribute_tree (args, &func_options, /* FLAGS == 1 is used for target_clones attribute. */
&global_options_set); new_target
= ix86_valid_target_attribute_tree (fndecl, args, &func_options,
&global_options_set, flags == 1);
new_optimize = build_optimization_node (&func_options); new_optimize = build_optimization_node (&func_options);
...@@ -32071,8 +32082,9 @@ get_builtin_code_for_version (tree decl, tree *predicate_list) ...@@ -32071,8 +32082,9 @@ get_builtin_code_for_version (tree decl, tree *predicate_list)
if (strstr (attrs_str, "arch=") != NULL) if (strstr (attrs_str, "arch=") != NULL)
{ {
cl_target_option_save (&cur_target, &global_options); cl_target_option_save (&cur_target, &global_options);
target_node = ix86_valid_target_attribute_tree (attrs, &global_options, target_node
&global_options_set); = ix86_valid_target_attribute_tree (decl, attrs, &global_options,
&global_options_set, 0);
gcc_assert (target_node); gcc_assert (target_node);
if (target_node == error_mark_node) if (target_node == error_mark_node)
2019-05-02 Martin Liska <mliska@suse.cz> 2019-05-02 Martin Liska <mliska@suse.cz>
* gcc.target/i386/funcspec-4.c: Update scanned pattern.
* g++.target/i386/pr57362.C: Likewise.
2019-05-02 Martin Liska <mliska@suse.cz>
PR target/88809 PR target/88809
* gcc.target/i386/pr88809.c: New test. * gcc.target/i386/pr88809.c: New test.
* gcc.target/i386/pr88809-2.c: New test. * gcc.target/i386/pr88809-2.c: New test.
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
extern void error1 (void) __attribute__((__target__("fma400"))); /* { dg-error "unknown" } */ extern void error1 (void) __attribute__((__target__("fma400"))); /* { dg-error "unknown" } */
/* Multiple arch switches */ /* Multiple arch switches */
extern void error2 (void) __attribute__((__target__("arch=core2,arch=k8"))); /* { dg-error "already specified" } */ extern void error2 (void) __attribute__((__target__("arch=core2,arch=k8"))); /* { dg-error "attribute value 'arch=k8' was already specified in 'target' attribute" } */
/* Unknown tune target */ /* Unknown tune target */
extern void error3 (void) __attribute__((__target__("tune=foobar"))); /* { dg-error "bad value" } */ extern void error3 (void) __attribute__((__target__("tune=foobar"))); /* { dg-error "bad value" } */
......
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