public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR objc/68438 (uninitialized source ranges)
@ 2015-11-20 20:28 David Malcolm
  2015-11-20 23:38 ` Joseph Myers
  0 siblings, 1 reply; 8+ messages in thread
From: David Malcolm @ 2015-11-20 20:28 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 968 bytes --]

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&regrtested on x86_64-pc-linux-gnu; adds 15 PASS results to
gcc.sum.

OK for trunk?


[-- Attachment #2: fix-PR-objc-68438-uninitialized-source-ranges.patch --]
[-- Type: text/x-patch, Size: 7495 bytes --]

From afdae8b15f71164d0d05e790078519b38bd674a4 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
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 0000000..ed7aca3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-expressions-2.m
@@ -0,0 +1,94 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdiagnostics-show-caret" } */
+
+/* This file is similar to diagnostic-test-expressions-1.c
+   (see the notes in that file); this file adds test
+   coverage for various Objective C constructs. */
+
+extern void __emit_expression_range (int dummy, ...);
+
+@protocol prot
+@end
+
+@interface tests <prot>
+- (int) func0;
+- (int) func1:(int)i;
++ (int) func2;
+- (void) test_sending_messages;
++ (void) test_class_dot_name;
+- (void) test_at_selector;
+- (void) test_at_protocol;
+- (void) test_at_encode:(int)i;
+@end
+
+@implementation tests
+- (int) func0
+{
+  return 42;
+}
+- (int) func1:(int)i
+{
+  return i * i;
+}
++ (int) func2
+{
+  return 0;
+}
+- (void) test_sending_messages
+{
+  __emit_expression_range ( 0, [self func0] ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, [self func0] );
+                                ~~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+  __emit_expression_range ( 0, [self func1:5] ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, [self func1:5] );
+                                ~~~~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+}
++ (void) test_class_dot_name
+{
+  __emit_expression_range ( 0, tests.func2 ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, tests.func2 );
+                                ~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+}
+- (void) test_at_selector
+{
+  __emit_expression_range ( 0, @selector(func0) ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, @selector(func0) );
+                                ^~~~~~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+}
+- (void) test_at_protocol
+{
+  __emit_expression_range ( 0, @protocol(prot) ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, @protocol(prot) );
+                                ~~~~~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+}
+- (void) test_at_encode:(int)i
+{
+  /* @encode() generates a STRING_CST which doesn't retain a location
+     after parsing, so we need to access it via compound expressions
+     that can't be folded away.  */
+
+  /* Verify start.  */
+  __emit_expression_range ( 0, @encode(int) + i ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, @encode(int) + i );
+                                ~~~~~~~~~~~~~^~~
+   { dg-end-multiline-output "" } */
+
+  /* Verify finish.  */
+  __emit_expression_range ( 0, i + @encode(int) ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, i + @encode(int) );
+                                ~~^~~~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+}
+@end
diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp
index 06080cc..6260a59 100644
--- a/gcc/testsuite/gcc.dg/plugin/plugin.exp
+++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp
@@ -67,7 +67,8 @@ set plugin_test_list [list \
 	  diagnostic-test-show-locus-bw.c \
 	  diagnostic-test-show-locus-color.c } \
     { diagnostic_plugin_test_tree_expression_range.c \
-	  diagnostic-test-expressions-1.c } \
+	  diagnostic-test-expressions-1.c \
+	  diagnostic-test-expressions-2.m } \
     { diagnostic_plugin_show_trees.c \
 	  diagnostic-test-show-trees-1.c } \
     { levenshtein_plugin.c levenshtein-test-1.c } \
-- 
1.8.5.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)
  2015-11-20 20:28 [PATCH] Fix PR objc/68438 (uninitialized source ranges) David Malcolm
@ 2015-11-20 23:38 ` Joseph Myers
  2015-11-22 16:21   ` David Malcolm
  0 siblings, 1 reply; 8+ messages in thread
From: Joseph Myers @ 2015-11-20 23:38 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

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
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)
  2015-11-20 23:38 ` Joseph Myers
@ 2015-11-22 16:21   ` David Malcolm
  2015-11-23 11:13     ` Joseph Myers
  0 siblings, 1 reply; 8+ messages in thread
From: David Malcolm @ 2015-11-22 16:21 UTC (permalink / raw)
  To: Joseph Myers; +Cc: gcc-patches

On Fri, 2015-11-20 at 23:28 +0000, 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)
  2015-11-22 16:21   ` David Malcolm
@ 2015-11-23 11:13     ` Joseph Myers
  2015-11-23 17:33       ` Jeff Law
  2015-11-23 21:06       ` Mike Stump
  0 siblings, 2 replies; 8+ messages in thread
From: Joseph Myers @ 2015-11-23 11:13 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

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
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)
  2015-11-23 11:13     ` Joseph Myers
@ 2015-11-23 17:33       ` Jeff Law
  2015-11-23 19:54         ` David Malcolm
  2015-11-23 21:06       ` Mike Stump
  1 sibling, 1 reply; 8+ messages in thread
From: Jeff Law @ 2015-11-23 17:33 UTC (permalink / raw)
  To: Joseph Myers, David Malcolm; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)
  2015-11-23 17:33       ` Jeff Law
@ 2015-11-23 19:54         ` David Malcolm
  2015-11-23 20:53           ` Jeff Law
  0 siblings, 1 reply; 8+ messages in thread
From: David Malcolm @ 2015-11-23 19:54 UTC (permalink / raw)
  To: Jeff Law; +Cc: Joseph Myers, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 848 bytes --]

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&regrtested on x86_64-pc-linux-gnu; adds 16
PASS results to objc.sum.

OK for trunk?


[-- Attachment #2: 0001-Fix-PR-objc-68438-uninitialized-source-ranges.patch --]
[-- Type: text/x-patch, Size: 10081 bytes --]

From f09c48b2ac55b2f9b5c3688e76fb4b91c3325fbb Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
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 0000000..ed7aca3
--- /dev/null
+++ b/gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m
@@ -0,0 +1,94 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdiagnostics-show-caret" } */
+
+/* This file is similar to diagnostic-test-expressions-1.c
+   (see the notes in that file); this file adds test
+   coverage for various Objective C constructs. */
+
+extern void __emit_expression_range (int dummy, ...);
+
+@protocol prot
+@end
+
+@interface tests <prot>
+- (int) func0;
+- (int) func1:(int)i;
++ (int) func2;
+- (void) test_sending_messages;
++ (void) test_class_dot_name;
+- (void) test_at_selector;
+- (void) test_at_protocol;
+- (void) test_at_encode:(int)i;
+@end
+
+@implementation tests
+- (int) func0
+{
+  return 42;
+}
+- (int) func1:(int)i
+{
+  return i * i;
+}
++ (int) func2
+{
+  return 0;
+}
+- (void) test_sending_messages
+{
+  __emit_expression_range ( 0, [self func0] ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, [self func0] );
+                                ~~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+  __emit_expression_range ( 0, [self func1:5] ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, [self func1:5] );
+                                ~~~~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+}
++ (void) test_class_dot_name
+{
+  __emit_expression_range ( 0, tests.func2 ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, tests.func2 );
+                                ~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+}
+- (void) test_at_selector
+{
+  __emit_expression_range ( 0, @selector(func0) ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, @selector(func0) );
+                                ^~~~~~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+}
+- (void) test_at_protocol
+{
+  __emit_expression_range ( 0, @protocol(prot) ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, @protocol(prot) );
+                                ~~~~~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+}
+- (void) test_at_encode:(int)i
+{
+  /* @encode() generates a STRING_CST which doesn't retain a location
+     after parsing, so we need to access it via compound expressions
+     that can't be folded away.  */
+
+  /* Verify start.  */
+  __emit_expression_range ( 0, @encode(int) + i ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, @encode(int) + i );
+                                ~~~~~~~~~~~~~^~~
+   { dg-end-multiline-output "" } */
+
+  /* Verify finish.  */
+  __emit_expression_range ( 0, i + @encode(int) ); /* { dg-warning "range" } */
+/* { dg-begin-multiline-output "" }
+   __emit_expression_range ( 0, i + @encode(int) );
+                                ~~^~~~~~~~~~~~~~
+   { dg-end-multiline-output "" } */
+}
+@end
diff --git a/gcc/testsuite/objc.dg/plugin/plugin.exp b/gcc/testsuite/objc.dg/plugin/plugin.exp
new file mode 100644
index 0000000..f98dff5
--- /dev/null
+++ b/gcc/testsuite/objc.dg/plugin/plugin.exp
@@ -0,0 +1,90 @@
+#   Copyright (C) 2009-2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Test the functionality of the GCC plugin support
+
+load_lib target-supports.exp
+load_lib objc-dg.exp
+
+global TESTING_IN_BUILD_TREE
+global ENABLE_PLUGIN
+
+# The plugin testcases currently only work when the build tree is available.
+# Also check whether the host supports plugins.
+if { ![info exists TESTING_IN_BUILD_TREE] || ![info exists ENABLE_PLUGIN] } {
+    return
+}
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# The procedures in plugin-support.exp need these parameters.
+set default_flags $DEFAULT_CFLAGS
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+# Load support procs.
+load_lib plugin-support.exp
+
+# These tests don't run runtest_file_p consistently if it
+# doesn't return the same values, so disable parallelization
+# of this *.exp file.  The first parallel runtest to reach
+# this will run all the tests serially.
+if ![gcc_parallel_test_run_p plugin] {
+    return
+}
+gcc_parallel_test_enable 0
+
+# Specify the plugin source file and the associated test files in a list.
+# plugin_test_list={ {plugin1 test1 test2 ...} {plugin2 test1 ...} ... }
+set plugin_test_list [list \
+    { ../../gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c \
+	  diagnostic-test-expressions-1.m } \
+]
+
+foreach plugin_test $plugin_test_list {
+    # Replace each source file with its full-path name
+    for {set i 0} {$i < [llength $plugin_test]} {incr i} {
+	set basename [lindex $plugin_test $i]
+	set plugin_test [lreplace $plugin_test $i $i $srcdir/$subdir/$basename]
+    }
+    set plugin_src [lindex $plugin_test 0]
+    # If we're only testing specific files and this isn't one of them, skip it.
+    if ![runtest_file_p $runtests $plugin_src] then {
+        continue
+    }
+    set plugin_input_tests [lreplace $plugin_test 0 0]
+    plugin-test-execute $plugin_src $plugin_input_tests
+}
+
+# run the plugindir tests
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/plugindir*.m]] \
+	"" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
+
+gcc_parallel_test_enable 1
-- 
1.8.5.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)
  2015-11-23 19:54         ` David Malcolm
@ 2015-11-23 20:53           ` Jeff Law
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Law @ 2015-11-23 20:53 UTC (permalink / raw)
  To: David Malcolm; +Cc: Joseph Myers, gcc-patches

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&regrtested on x86_64-pc-linux-gnu; adds 16
> PASS results to objc.sum.
>
> OK for trunk?
>
OK.
jeff

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix PR objc/68438 (uninitialized source ranges)
  2015-11-23 11:13     ` Joseph Myers
  2015-11-23 17:33       ` Jeff Law
@ 2015-11-23 21:06       ` Mike Stump
  1 sibling, 0 replies; 8+ messages in thread
From: Mike Stump @ 2015-11-23 21:06 UTC (permalink / raw)
  To: Joseph Myers; +Cc: David Malcolm, gcc-patches

On Nov 23, 2015, at 3:13 AM, Joseph Myers <joseph@codesourcery.com> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-11-23 21:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-20 20:28 [PATCH] Fix PR objc/68438 (uninitialized source ranges) David Malcolm
2015-11-20 23:38 ` Joseph Myers
2015-11-22 16:21   ` David Malcolm
2015-11-23 11:13     ` Joseph Myers
2015-11-23 17:33       ` Jeff Law
2015-11-23 19:54         ` David Malcolm
2015-11-23 20:53           ` Jeff Law
2015-11-23 21:06       ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).