diff mbox

[2/4] Replace error_at with assert in build_va_arg

Message ID 12cfe94e-2e89-f105-903e-2c68e280f9d9@mentor.com
State New
Headers show

Commit Message

Tom de Vries Aug. 24, 2016, 6:10 a.m. UTC
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

Comments

Joseph Myers Aug. 29, 2016, 3:50 p.m. UTC | #1
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.
Andreas Schwab Sept. 3, 2016, 3:37 p.m. UTC | #2
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.
Tom de Vries Sept. 3, 2016, 8:50 p.m. UTC | #3
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
Andreas Schwab Sept. 3, 2016, 9:23 p.m. UTC | #4
http://gcc.gnu.org/ml/gcc-testresults/2016-09/msg00298.html

Andreas.
Tom de Vries Sept. 4, 2016, 9:13 a.m. UTC | #5
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
diff mbox

Patch

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
     {