[Bug c/88886] [9 Regression] ice in get_constant, at c-family/c-format.c:292

2019-01-24 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6

Martin Sebor  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Martin Sebor  ---
Fixed via r268251.  GCC issues the following warnings for the test case in
comment #0:

$ cat pr6.c && gcc -S -Wall -Wextra pr6.c
int sscanf(long, unsigned[], ...);
void a() { sscanf(0, ""); }
pr6.c:1:5: warning: conflicting types for built-in function ‘sscanf’;
expected ‘int(const char *, const char *, ...)’
[-Wbuiltin-declaration-mismatch]
1 | int sscanf(long, unsigned[], ...);
  | ^~
pr6.c:1:1: note: ‘sscanf’ is declared in header ‘’
  +++ |+#include 
1 | int sscanf(long, unsigned[], ...);
pr6.c: In function ‘a’:
pr6.c:2:22: warning: passing argument 2 of ‘sscanf’ from incompatible
pointer type [-Wincompatible-pointer-types]
2 | void a() { sscanf(0, ""); }
  |  ^~
  |  |
  |  char *
pr6.c:1:18: note: expected ‘unsigned int *’ but argument is of type ‘char
*’
1 | int sscanf(long, unsigned[], ...);
  |  ^~

[Bug c/88886] [9 Regression] ice in get_constant, at c-family/c-format.c:292

2019-01-24 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6

--- Comment #4 from Martin Sebor  ---
Author: msebor
Date: Thu Jan 24 21:06:01 2019
New Revision: 268251

URL: https://gcc.gnu.org/viewcvs?rev=268251&root=gcc&view=rev
Log:
PR c/86125 - missing -Wbuiltin-declaration-mismatch on a mismatched return type
PR middle-end/86308 - ICE in verify_gimple calling index() with an invalid
declaration
PR c/86125 - missing -Wbuiltin-declaration-mismatch on a mismatched return type
PR c/6 - [9 Regression] ice in get_constant, at c-family/c-format.c:292

gcc/c/ChangeLog:

PR c/86125
PR c/6
PR middle-end/86308
* c-decl.c (match_builtin_function_types): Add arguments.
(diagnose_mismatched_decls): Diagnose mismatched declarations
of built-ins more strictly.

gcc/testsuite/ChangeLog:

PR c/86125
PR c/6
PR middle-end/86308
* gcc.dg/Wbuiltin-declaration-mismatch-6.c: New test.
* gcc.dg/Wbuiltin-declaration-mismatch-7.c: New test.
* gcc.dg/Wbuiltin-declaration-mismatch-8.c: New test.
* gcc.dg/Wbuiltin-declaration-mismatch-9.c: New test.
* gcc.dg/Wbuiltin-declaration-mismatch-10.c: New test.
* gcc.dg/builtins-69.c: New test.
* gcc.dg/Wint-conversion-2.c: Add expected warning.
* gcc.c-torture/execute/eeprof-1.c: Adjust function signatures.


Added:
trunk/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-10.c
trunk/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-6.c
trunk/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-7.c
trunk/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-8.c
trunk/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-9.c
trunk/gcc/testsuite/gcc.dg/builtins-69.c
Modified:
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-decl.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.c-torture/execute/eeprof-1.c
trunk/gcc/testsuite/gcc.dg/Wint-conversion-2.c

[Bug c/88886] [9 Regression] ice in get_constant, at c-family/c-format.c:292

2019-01-17 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P1
   Target Milestone|--- |9.0

[Bug c/88886] [9 Regression] ice in get_constant, at c-family/c-format.c:292

2019-01-16 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6

Martin Sebor  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #3 from Martin Sebor  ---
Updated patch for GCC 9:
https://gcc.gnu.org/ml/gcc-patches/2019-01/msg00969.html

[Bug c/88886] [9 Regression] ice in get_constant, at c-family/c-format.c:292

2019-01-16 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6

Martin Sebor  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=86125
   Assignee|unassigned at gcc dot gnu.org  |msebor at gcc dot 
gnu.org

--- Comment #2 from Martin Sebor  ---
The patch posted for bug 86125 fixes this ICE and results in the output below. 
Let me try to revive it.

$ /build/gcc-86125/gcc/xgcc -B /build/gcc-86125/gcc -S pr6.c
pr6.c:1:5: warning: conflicting types for built-in function ‘sscanf’;
expected ‘int(const char *, const char *, ...)’
[-Wbuiltin-declaration-mismatch]
1 | int sscanf(long, unsigned[], ...);
  | ^~
pr6.c:1:1: note: ‘sscanf’ is declared in header ‘’
  +++ |+#include 
1 | int sscanf(long, unsigned[], ...);
pr6.c:1:5: warning: conflicting types for built-in function ‘sscanf’;
expected ‘int(const char *, const char *, ...)’
[-Wbuiltin-declaration-mismatch]
1 | int sscanf(long, unsigned[], ...);
  | ^~
pr6.c: In function ‘a’:
pr6.c:2:22: warning: passing argument 2 of ‘sscanf’ from incompatible
pointer type [-Wincompatible-pointer-types]
2 | void a() { sscanf(0, ""); }
  |  ^~
  |  |
  |  char *
pr6.c:1:18: note: expected ‘unsigned int *’ but argument is of type ‘char
*’
1 | int sscanf(long, unsigned[], ...);
  |  ^~

[Bug c/88886] [9 Regression] ice in get_constant, at c-family/c-format.c:292

2019-01-16 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6

Martin Sebor  changed:

   What|Removed |Added

   Keywords||ice-on-invalid-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-01-16
 CC||msebor at gcc dot gnu.org
Version|8.0 |9.0
Summary|ice in get_constant, at |[9 Regression] ice in
   |c-family/c-format.c:292 |get_constant, at
   ||c-family/c-format.c:292
 Ever confirmed|0   |1

--- Comment #1 from Martin Sebor  ---
The ICE was introduced in r266195 (GCC 9):

r266195 | msebor | 2018-11-15 17:53:57 -0500 (Thu, 15 Nov 2018) | 50 lines

PR c++/87541 - ICE using a constant decl as an attribute alloc_size argument
PR c++/87542 - bogus error on attribute format with a named constant argument

gcc/ChangeLog:

PR c++/87541
PR c++/87542
* tree.c (type_argument_type): New function.
* tree.h (type_argument_type): Declare it.
* gcc/doc/extend.texi (alloc_align): Update and clarify.
(alloc_size, nonnull, sentinel): Same.

gcc/c-family/ChangeLog:

PR c++/87541
PR c++/87542
* c-attribs.c (positional_argument): New function.
(handle_alloc_size_attribute): Use it and simplify.
(handle_alloc_align_attribute): Same.
(handle_assume_aligned_attribute): Same.
(handle_nonnull_attribute): Same.
* c-common.c (check_function_arguments): Pass fntype to
check_function_format.
* c-common.h (check_function_format): Add an argument.
(PosArgFlags, positional_argument): Declare new type and function.
* c-format.c (decode_format_attr): Add arguments.
(check_format_string, get_constant): Same.
(convert_format_name_to_system_name): Adjust.