public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, 2/4] Replace error_at with assert in build_va_arg
@ 2016-08-24  6:10 Tom de Vries
  2016-08-29 15:50 ` Joseph Myers
  2016-09-03 15:44 ` Andreas Schwab
  0 siblings, 2 replies; 6+ messages in thread
From: Tom de Vries @ 2016-08-24  6:10 UTC (permalink / raw)
  To: GCC Patches

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

Hi,

at the start of build_va_arg, we error out if there's an invalid va_list 
argument.

Therefore, the following checks on va_list type are not user errors, but 
internal errors.

This patch changes the user errors into internal errors.

Bootstrapped and reg-tested on x86_64.

OK for trunk?

Thanks,
- Tom

[-- Attachment #2: 0002-Replace-error_at-with-assert-in-build_va_arg.patch --]
[-- Type: text/x-patch, Size: 1391 bytes --]

Replace error_at with assert in build_va_arg

2016-08-22  Tom de Vries  <tom@codesourcery.com>

	* c-common.c (build_va_arg): Replace first argument type error
	with assert.

---
 gcc/c-family/c-common.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 7ad1930..a289d2b 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -5820,12 +5820,7 @@ build_va_arg (location_t loc, tree expr, tree type)
       /* Verify that &ap is still recognized as having va_list type.  */
       tree canon_expr_type
 	= targetm.canonical_va_list_type (TREE_TYPE (expr));
-      if (canon_expr_type == NULL_TREE)
-	{
-	  error_at (loc,
-		    "first argument to %<va_arg%> not of type %<va_list%>");
-	  return error_mark_node;
-	}
+      gcc_assert (canon_expr_type != NULL_TREE);
 
       return build_va_arg_1 (loc, type, expr);
     }
@@ -5893,12 +5888,7 @@ build_va_arg (location_t loc, tree expr, tree type)
       /* Verify that &ap is still recognized as having va_list type.  */
       tree canon_expr_type
 	= targetm.canonical_va_list_type (TREE_TYPE (expr));
-      if (canon_expr_type == NULL_TREE)
-	{
-	  error_at (loc,
-		    "first argument to %<va_arg%> not of type %<va_list%>");
-	  return error_mark_node;
-	}
+      gcc_assert (canon_expr_type != NULL_TREE);
     }
   else
     {

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

* Re: [PATCH, 2/4] Replace error_at with assert in build_va_arg
  2016-08-24  6:10 [PATCH, 2/4] Replace error_at with assert in build_va_arg Tom de Vries
@ 2016-08-29 15:50 ` Joseph Myers
  2016-09-03 15:44 ` Andreas Schwab
  1 sibling, 0 replies; 6+ messages in thread
From: Joseph Myers @ 2016-08-29 15:50 UTC (permalink / raw)
  To: Tom de Vries; +Cc: GCC Patches

On Wed, 24 Aug 2016, Tom de Vries wrote:

> Hi,
> 
> at the start of build_va_arg, we error out if there's an invalid va_list
> argument.
> 
> Therefore, the following checks on va_list type are not user errors, but
> internal errors.
> 
> This patch changes the user errors into internal errors.
> 
> Bootstrapped and reg-tested on x86_64.
> 
> OK for trunk?

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH, 2/4] Replace error_at with assert in build_va_arg
  2016-08-24  6:10 [PATCH, 2/4] Replace error_at with assert in build_va_arg Tom de Vries
  2016-08-29 15:50 ` Joseph Myers
@ 2016-09-03 15:44 ` Andreas Schwab
  2016-09-03 21:24   ` Tom de Vries
  2016-09-04 10:33   ` Tom de Vries
  1 sibling, 2 replies; 6+ messages in thread
From: Andreas Schwab @ 2016-09-03 15:44 UTC (permalink / raw)
  To: Tom de Vries; +Cc: GCC Patches

On Aug 24 2016, Tom de Vries <Tom_deVries@mentor.com> wrote:

> Replace error_at with assert in build_va_arg
>
> 2016-08-22  Tom de Vries  <tom@codesourcery.com>
>
> 	* c-common.c (build_va_arg): Replace first argument type error
> 	with assert.

/daten/gcc/gcc-20160902/gcc/testsuite/c-c++-common/pr70651.c: In function 'void fn1()':
/daten/gcc/gcc-20160902/gcc/testsuite/c-c++-common/pr70651.c:8:31: internal compiler error: in build_va_arg, at c-family/c-common.c:5837
0x103a856b build_va_arg(unsigned int, tree_node*, tree_node*)
	../../gcc/c-family/c-common.c:5837
0x101c8eaf build_x_va_arg(unsigned int, tree_node*, tree_node*)
	../../gcc/cp/call.c:6986
0x1028cef3 cp_parser_primary_expression
	../../gcc/cp/parser.c:5096
0x1028f6cf cp_parser_postfix_expression
	../../gcc/cp/parser.c:6721
0x102981cb cp_parser_unary_expression
	../../gcc/cp/parser.c:8019
0x10298ad7 cp_parser_cast_expression
	../../gcc/cp/parser.c:8696
0x10299267 cp_parser_binary_expression
	../../gcc/cp/parser.c:8797
0x10299acf cp_parser_assignment_expression
	../../gcc/cp/parser.c:9084
0x1029c9d7 cp_parser_expression
	../../gcc/cp/parser.c:9253
0x1029d477 cp_parser_expression_statement
	../../gcc/cp/parser.c:10736
0x1028aeb3 cp_parser_statement
	../../gcc/cp/parser.c:10587
0x1028bdcf cp_parser_statement_seq_opt
	../../gcc/cp/parser.c:10859
0x1028bed7 cp_parser_compound_statement
	../../gcc/cp/parser.c:10813
0x102a9e4f cp_parser_function_body
	../../gcc/cp/parser.c:20832
0x102a9e4f cp_parser_ctor_initializer_opt_and_function_body
	../../gcc/cp/parser.c:20868
0x102aa8eb cp_parser_function_definition_after_declarator
	../../gcc/cp/parser.c:25565
0x102ab827 cp_parser_function_definition_from_specifiers_and_declarator
	../../gcc/cp/parser.c:25477
0x102ab827 cp_parser_init_declarator
	../../gcc/cp/parser.c:18603
0x102abaa3 cp_parser_simple_declaration
	../../gcc/cp/parser.c:12487
0x102abf23 cp_parser_block_declaration
	../../gcc/cp/parser.c:12363
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
compiler exited with status 1
FAIL: c-c++-common/pr70651.c  -std=c++11 (internal compiler error)

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH, 2/4] Replace error_at with assert in build_va_arg
  2016-09-03 15:44 ` Andreas Schwab
@ 2016-09-03 21:24   ` Tom de Vries
  2016-09-04  6:12     ` Andreas Schwab
  2016-09-04 10:33   ` Tom de Vries
  1 sibling, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2016-09-03 21:24 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: GCC Patches

On 03/09/16 17:37, Andreas Schwab wrote:
> On Aug 24 2016, Tom de Vries <Tom_deVries@mentor.com> wrote:
>
>> > Replace error_at with assert in build_va_arg
>> >
>> > 2016-08-22  Tom de Vries  <tom@codesourcery.com>
>> >
>> > 	* c-common.c (build_va_arg): Replace first argument type error
>> > 	with assert.
> /daten/gcc/gcc-20160902/gcc/testsuite/c-c++-common/pr70651.c: In function 'void fn1()':
> /daten/gcc/gcc-20160902/gcc/testsuite/c-c++-common/pr70651.c:8:31: internal compiler error: in build_va_arg, at c-family/c-common.c:5837
> 0x103a856b build_va_arg(unsigned int, tree_node*, tree_node*)
> 	../../gcc/c-family/c-common.c:5837
> 0x101c8eaf build_x_va_arg(unsigned int, tree_node*, tree_node*)
> 	../../gcc/cp/call.c:6986
> 0x1028cef3 cp_parser_primary_expression
> 	../../gcc/cp/parser.c:5096
> 0x1028f6cf cp_parser_postfix_expression
> 	../../gcc/cp/parser.c:6721
> 0x102981cb cp_parser_unary_expression
> 	../../gcc/cp/parser.c:8019
> 0x10298ad7 cp_parser_cast_expression
> 	../../gcc/cp/parser.c:8696
> 0x10299267 cp_parser_binary_expression
> 	../../gcc/cp/parser.c:8797
> 0x10299acf cp_parser_assignment_expression
> 	../../gcc/cp/parser.c:9084
> 0x1029c9d7 cp_parser_expression
> 	../../gcc/cp/parser.c:9253
> 0x1029d477 cp_parser_expression_statement
> 	../../gcc/cp/parser.c:10736
> 0x1028aeb3 cp_parser_statement
> 	../../gcc/cp/parser.c:10587
> 0x1028bdcf cp_parser_statement_seq_opt
> 	../../gcc/cp/parser.c:10859
> 0x1028bed7 cp_parser_compound_statement
> 	../../gcc/cp/parser.c:10813
> 0x102a9e4f cp_parser_function_body
> 	../../gcc/cp/parser.c:20832
> 0x102a9e4f cp_parser_ctor_initializer_opt_and_function_body
> 	../../gcc/cp/parser.c:20868
> 0x102aa8eb cp_parser_function_definition_after_declarator
> 	../../gcc/cp/parser.c:25565
> 0x102ab827 cp_parser_function_definition_from_specifiers_and_declarator
> 	../../gcc/cp/parser.c:25477
> 0x102ab827 cp_parser_init_declarator
> 	../../gcc/cp/parser.c:18603
> 0x102abaa3 cp_parser_simple_declaration
> 	../../gcc/cp/parser.c:12487
> 0x102abf23 cp_parser_block_declaration
> 	../../gcc/cp/parser.c:12363
> Please submit a full bug report,
> with preprocessed source if appropriate.
> Please include the complete backtrace with any bug report.
> See <http://gcc.gnu.org/bugs.html> for instructions.
> compiler exited with status 1
> FAIL: c-c++-common/pr70651.c  -std=c++11 (internal compiler error)

Sorry, I need more data to reproduce this. Works for me with x86_64 
-m64/-m32 at r239971.

Thanks,
- Tom

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

* Re: [PATCH, 2/4] Replace error_at with assert in build_va_arg
  2016-09-03 21:24   ` Tom de Vries
@ 2016-09-04  6:12     ` Andreas Schwab
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Schwab @ 2016-09-04  6:12 UTC (permalink / raw)
  To: Tom de Vries; +Cc: GCC Patches

http://gcc.gnu.org/ml/gcc-testresults/2016-09/msg00298.html

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH, 2/4] Replace error_at with assert in build_va_arg
  2016-09-03 15:44 ` Andreas Schwab
  2016-09-03 21:24   ` Tom de Vries
@ 2016-09-04 10:33   ` Tom de Vries
  1 sibling, 0 replies; 6+ messages in thread
From: Tom de Vries @ 2016-09-04 10:33 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: GCC Patches

On 03/09/16 17:37, Andreas Schwab wrote:
> On Aug 24 2016, Tom de Vries <Tom_deVries@mentor.com> wrote:
>
>> > Replace error_at with assert in build_va_arg
>> >
>> > 2016-08-22  Tom de Vries  <tom@codesourcery.com>
>> >
>> > 	* c-common.c (build_va_arg): Replace first argument type error
>> > 	with assert.
> /daten/gcc/gcc-20160902/gcc/testsuite/c-c++-common/pr70651.c: In function 'void fn1()':
> /daten/gcc/gcc-20160902/gcc/testsuite/c-c++-common/pr70651.c:8:31: internal compiler error: in build_va_arg, at c-family/c-common.c:5837

Hi,

I build gcc for ppc64 far enough to reproduce it.

The error disappears when reverting the patch.

The error also disappears when applying the fix for PR71602 (awaiting 
approval at https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01981.html).

I've revert the patch on trunk, and will merge it with the fix for PR71602.

Thanks,
- Tom

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

end of thread, other threads:[~2016-09-04  9:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-24  6:10 [PATCH, 2/4] Replace error_at with assert in build_va_arg Tom de Vries
2016-08-29 15:50 ` Joseph Myers
2016-09-03 15:44 ` Andreas Schwab
2016-09-03 21:24   ` Tom de Vries
2016-09-04  6:12     ` Andreas Schwab
2016-09-04 10:33   ` Tom de Vries

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).