Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)

2015-11-23 Thread Mike Stump
On Nov 23, 2015, at 3:13 AM, Joseph Myers  wrote:
> On Sun, 22 Nov 2015, David Malcolm wrote:
> 
>> Is there (or could there be) a precanned dg- directive to ask if ObjC is
>> available?  
> 
> I don't think so.  Normal practice is that each language's tests are in 
> appropriate directories for that language, with runtest never called with 
> a --tool option for that language if it wasn't built.

It is also reasonable to have a common to C/ObjC test directory if people want 
to do that and have them run if objc is present.  We do that for some tests in 
the C world.

Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)

2015-11-23 Thread Jeff Law

On 11/23/2015 12:50 PM, David Malcolm wrote:

On Mon, 2015-11-23 at 10:25 -0700, Jeff Law wrote:

On 11/23/2015 04:13 AM, Joseph Myers wrote:

On Sun, 22 Nov 2015, David Malcolm wrote:


Is there (or could there be) a precanned dg- directive to ask if ObjC is
available?


I don't think so.  Normal practice is that each language's tests are in
appropriate directories for that language, with runtest never called with
a --tool option for that language if it wasn't built.

Right.  Which argues that we really want to create a new test directory
for objc plugin tests.


Attached is a revised version of the patch which creates an
objc.dg/plugin subdirectory, and builds the plugin that way (directly
reusing the plugin src from the gcc.dg subdir).

Successfully bootstrapped®rtested on x86_64-pc-linux-gnu; adds 16
PASS results to objc.sum.

OK for trunk?


OK.
jeff


Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)

2015-11-23 Thread David Malcolm
On Mon, 2015-11-23 at 10:25 -0700, Jeff Law wrote:
> On 11/23/2015 04:13 AM, Joseph Myers wrote:
> > On Sun, 22 Nov 2015, David Malcolm wrote:
> >
> >> Is there (or could there be) a precanned dg- directive to ask if ObjC is
> >> available?
> >
> > I don't think so.  Normal practice is that each language's tests are in
> > appropriate directories for that language, with runtest never called with
> > a --tool option for that language if it wasn't built.
> Right.  Which argues that we really want to create a new test directory 
> for objc plugin tests.

Attached is a revised version of the patch which creates an
objc.dg/plugin subdirectory, and builds the plugin that way (directly
reusing the plugin src from the gcc.dg subdir).

Successfully bootstrapped®rtested on x86_64-pc-linux-gnu; adds 16
PASS results to objc.sum.

OK for trunk?

>From f09c48b2ac55b2f9b5c3688e76fb4b91c3325fbb Mon Sep 17 00:00:00 2001
From: David Malcolm 
Date: Fri, 20 Nov 2015 11:12:47 -0500
Subject: [PATCH] Fix PR objc/68438 (uninitialized source ranges)

gcc/c/ChangeLog:
	PR objc/68438
	* c-parser.c (c_parser_postfix_expression): Set up source ranges
	for various Objective-C constructs: Class.name syntax,
	@selector(), @protocol, @encode(), and [] message syntax.

gcc/testsuite/ChangeLog:
	PR objc/68438
	* objc.dg/plugin/diagnostic-test-expressions-1.m: New test file.
	* objc.dg/plugin/plugin.exp: New file, based on
	gcc.dg/plugin/plugin.exp.
---
 gcc/c/c-parser.c   | 17 +++-
 .../objc.dg/plugin/diagnostic-test-expressions-1.m | 94 ++
 gcc/testsuite/objc.dg/plugin/plugin.exp| 90 +
 3 files changed, 198 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m
 create mode 100644 gcc/testsuite/objc.dg/plugin/plugin.exp

diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 7b10764..18e9957 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -7338,10 +7338,13 @@ c_parser_postfix_expression (c_parser *parser)
 		expr.value = error_mark_node;
 		break;
 	  }
-	component = c_parser_peek_token (parser)->value;
+	c_token *component_tok = c_parser_peek_token (parser);
+	component = component_tok->value;
+	location_t end_loc = component_tok->get_finish ();
 	c_parser_consume_token (parser);
 	expr.value = objc_build_class_component_ref (class_name, 
 			 component);
+	set_c_expr_source_range (&expr, loc, end_loc);
 	break;
 	  }
 	default:
@@ -7816,9 +7819,11 @@ c_parser_postfix_expression (c_parser *parser)
 	}
 	  {
 	tree sel = c_parser_objc_selector_arg (parser);
+	location_t close_loc = c_parser_peek_token (parser)->location;
 	c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    "expected %<)%>");
 	expr.value = objc_build_selector_expr (loc, sel);
+	set_c_expr_source_range (&expr, loc, close_loc);
 	  }
 	  break;
 	case RID_AT_PROTOCOL:
@@ -7839,9 +7844,11 @@ c_parser_postfix_expression (c_parser *parser)
 	  {
 	tree id = c_parser_peek_token (parser)->value;
 	c_parser_consume_token (parser);
+	location_t close_loc = c_parser_peek_token (parser)->location;
 	c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    "expected %<)%>");
 	expr.value = objc_build_protocol_expr (id);
+	set_c_expr_source_range (&expr, loc, close_loc);
 	  }
 	  break;
 	case RID_AT_ENCODE:
@@ -7860,11 +7867,13 @@ c_parser_postfix_expression (c_parser *parser)
 	  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
 	  break;
 	}
-	  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
- "expected %<)%>");
 	  {
+	location_t close_loc = c_parser_peek_token (parser)->location;
+	c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
+ "expected %<)%>");
 	tree type = groktypename (t1, NULL, NULL);
 	expr.value = objc_build_encode_expr (type);
+	set_c_expr_source_range (&expr, loc, close_loc);
 	  }
 	  break;
 	case RID_GENERIC:
@@ -7907,9 +7916,11 @@ c_parser_postfix_expression (c_parser *parser)
 	  c_parser_consume_token (parser);
 	  receiver = c_parser_objc_receiver (parser);
 	  args = c_parser_objc_message_args (parser);
+	  location_t close_loc = c_parser_peek_token (parser)->location;
 	  c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
  "expected %<]%>");
 	  expr.value = objc_build_message_expr (receiver, args);
+	  set_c_expr_source_range (&expr, loc, close_loc);
 	  break;
 	}
   /* Else fall through to report error.  */
diff --git a/gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m b/gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m
new file mode 100644
index 000..ed7aca3
--- /dev/null
+++ b/gcc/testsui

Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)

2015-11-23 Thread Jeff Law

On 11/23/2015 04:13 AM, Joseph Myers wrote:

On Sun, 22 Nov 2015, David Malcolm wrote:


Is there (or could there be) a precanned dg- directive to ask if ObjC is
available?


I don't think so.  Normal practice is that each language's tests are in
appropriate directories for that language, with runtest never called with
a --tool option for that language if it wasn't built.
Right.  Which argues that we really want to create a new test directory 
for objc plugin tests.


jeff


Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)

2015-11-23 Thread Joseph Myers
On Sun, 22 Nov 2015, David Malcolm wrote:

> Is there (or could there be) a precanned dg- directive to ask if ObjC is
> available?  

I don't think so.  Normal practice is that each language's tests are in 
appropriate directories for that language, with runtest never called with 
a --tool option for that language if it wasn't built.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)

2015-11-22 Thread David Malcolm
On Fri, 2015-11-20 at 23:28 +, Joseph Myers wrote:
> On Fri, 20 Nov 2015, David Malcolm wrote:
> 
> > The source ranges are verified using the same unit-testing plugin used
> > for C expressions.  This leads to a wart, which is that it means having
> > a .m test file lurking below gcc.dg/plugin.  A workaround would be to
> > create an objc.dg/plugin subdirectory, with a new plugin.exp for testing
> > Objective C plugins, and having it reference the existing plugin below
> > gcc.dg/plugin.  That seemed like excessive complication, so I went for
> > the simpler approach of simply putting the .m file below gcc.dg/plugin.
> 
> Have you made sure that this test is quietly not run if the 
> --enable-languages configuration does not build the ObjC compiler?

Good point; sadly, it does introduce FAILs for that configuration.

Is there (or could there be) a precanned dg- directive to ask if ObjC is
available?  

Otherwise I can look at creating an objc.dg/plugin subdirectory.

Thanks
Dave



Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)

2015-11-20 Thread Joseph Myers
On Fri, 20 Nov 2015, David Malcolm wrote:

> The source ranges are verified using the same unit-testing plugin used
> for C expressions.  This leads to a wart, which is that it means having
> a .m test file lurking below gcc.dg/plugin.  A workaround would be to
> create an objc.dg/plugin subdirectory, with a new plugin.exp for testing
> Objective C plugins, and having it reference the existing plugin below
> gcc.dg/plugin.  That seemed like excessive complication, so I went for
> the simpler approach of simply putting the .m file below gcc.dg/plugin.

Have you made sure that this test is quietly not run if the 
--enable-languages configuration does not build the ObjC compiler?

-- 
Joseph S. Myers
jos...@codesourcery.com


[PATCH] Fix PR objc/68438 (uninitialized source ranges)

2015-11-20 Thread David Malcolm
The attached patch fixes some more places in c/c-parser.c where the
src_range field of a c_expr was being left uninitialized, this time for
various Objective C constructs.

The source ranges are verified using the same unit-testing plugin used
for C expressions.  This leads to a wart, which is that it means having
a .m test file lurking below gcc.dg/plugin.  A workaround would be to
create an objc.dg/plugin subdirectory, with a new plugin.exp for testing
Objective C plugins, and having it reference the existing plugin below
gcc.dg/plugin.  That seemed like excessive complication, so I went for
the simpler approach of simply putting the .m file below gcc.dg/plugin.

I manually verified that this fixes the specific valgrind warnings
reported in the PR, and visually inspected the code for
objective-c-specific instances of uninitialized c_expr src_range values.

Bootstrapped®rtested on x86_64-pc-linux-gnu; adds 15 PASS results to
gcc.sum.

OK for trunk?

>From afdae8b15f71164d0d05e790078519b38bd674a4 Mon Sep 17 00:00:00 2001
From: David Malcolm 
Date: Fri, 20 Nov 2015 11:12:47 -0500
Subject: [PATCH] Fix PR objc/68438 (uninitialized source ranges)

gcc/c/ChangeLog:
	PR objc/68438
	* c-parser.c (c_parser_postfix_expression): Set up source ranges
	for various Objective-C constructs: Class.name syntax,
	@selector(), @protocol, @encode(), and [] message syntax.

gcc/testsuite/ChangeLog:
	PR objc/68438
	* gcc.dg/plugin/diagnostic-test-expressions-2.m: New test file.
	* gcc.dg/plugin/plugin.exp (plugin_test_list): Add the above file.
---
 gcc/c/c-parser.c   | 17 +++-
 .../gcc.dg/plugin/diagnostic-test-expressions-2.m  | 94 ++
 gcc/testsuite/gcc.dg/plugin/plugin.exp |  3 +-
 3 files changed, 110 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-2.m

diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 7b10764..18e9957 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -7338,10 +7338,13 @@ c_parser_postfix_expression (c_parser *parser)
 		expr.value = error_mark_node;
 		break;
 	  }
-	component = c_parser_peek_token (parser)->value;
+	c_token *component_tok = c_parser_peek_token (parser);
+	component = component_tok->value;
+	location_t end_loc = component_tok->get_finish ();
 	c_parser_consume_token (parser);
 	expr.value = objc_build_class_component_ref (class_name, 
 			 component);
+	set_c_expr_source_range (&expr, loc, end_loc);
 	break;
 	  }
 	default:
@@ -7816,9 +7819,11 @@ c_parser_postfix_expression (c_parser *parser)
 	}
 	  {
 	tree sel = c_parser_objc_selector_arg (parser);
+	location_t close_loc = c_parser_peek_token (parser)->location;
 	c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    "expected %<)%>");
 	expr.value = objc_build_selector_expr (loc, sel);
+	set_c_expr_source_range (&expr, loc, close_loc);
 	  }
 	  break;
 	case RID_AT_PROTOCOL:
@@ -7839,9 +7844,11 @@ c_parser_postfix_expression (c_parser *parser)
 	  {
 	tree id = c_parser_peek_token (parser)->value;
 	c_parser_consume_token (parser);
+	location_t close_loc = c_parser_peek_token (parser)->location;
 	c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    "expected %<)%>");
 	expr.value = objc_build_protocol_expr (id);
+	set_c_expr_source_range (&expr, loc, close_loc);
 	  }
 	  break;
 	case RID_AT_ENCODE:
@@ -7860,11 +7867,13 @@ c_parser_postfix_expression (c_parser *parser)
 	  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
 	  break;
 	}
-	  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
- "expected %<)%>");
 	  {
+	location_t close_loc = c_parser_peek_token (parser)->location;
+	c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
+ "expected %<)%>");
 	tree type = groktypename (t1, NULL, NULL);
 	expr.value = objc_build_encode_expr (type);
+	set_c_expr_source_range (&expr, loc, close_loc);
 	  }
 	  break;
 	case RID_GENERIC:
@@ -7907,9 +7916,11 @@ c_parser_postfix_expression (c_parser *parser)
 	  c_parser_consume_token (parser);
 	  receiver = c_parser_objc_receiver (parser);
 	  args = c_parser_objc_message_args (parser);
+	  location_t close_loc = c_parser_peek_token (parser)->location;
 	  c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
  "expected %<]%>");
 	  expr.value = objc_build_message_expr (receiver, args);
+	  set_c_expr_source_range (&expr, loc, close_loc);
 	  break;
 	}
   /* Else fall through to report error.  */
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-2.m b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-2.m
new file mode 100644
index 000..ed7aca3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-