Bug 56167 - ICE with invalid __attribute__ arguments
Summary: ICE with invalid __attribute__ arguments
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.8.0
: P3 minor
Target Milestone: 4.8.0
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-01 01:50 UTC by Dmitry Gorbachev
Modified: 2013-02-05 08:10 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-02-01 00:00:00


Attachments
gcc48-pr56167.patch (601 bytes, patch)
2013-02-01 07:54 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Gorbachev 2013-02-01 01:50:10 UTC
$ cat > bug.c
extern void foo(void) __attribute__((target(0)));

int main(void)
{
  foo();
  return 0;
}
^D
$ gcc -S bug.c
bug.c:1:1: internal compiler error: in ix86_valid_target_attribute_inner_p, at config/i386/i386.c:4226
 extern void foo(void) __attribute__((target(0)));
 ^
[...]
$ sed -i s/target/error/ bug.c
$ gcc -S bug.c
bug.c: In function 'main':
bug.c:5:6: internal compiler error: tree check: expected string_cst, have integer_cst in expand_expr_real_1, at expr.c:10191
   foo();
      ^
[...]
$ sed -i s/error/warning/ bug.c
$ gcc -S bug.c
bug.c: In function 'main':
bug.c:5:6: internal compiler error: tree check: expected string_cst, have integer_cst in expand_expr_real_1, at expr.c:10198
   foo();
      ^
[...]

A few other __attribute__ bugs:

$ sed -i s/warning/weakref/ bug.c
$ gcc -S bug.c
bug.c:1:1: error: attribute 'alias' argument not a string
 extern void foo(void) __attribute__((weakref(0)));
 ^
bug.c:1:13: warning: 'weakref' attribute should be accompanied with an 'alias' attribute [-Wattributes]
 extern void foo(void) __attribute__((weakref(0)));
             ^
$ sed -i s/weakref/section/ bug.c
$ gcc -S bug.c
bug.c:1:13: error: section attribute not allowed for 'foo'
 extern void foo(void) __attribute__((section(0)));
             ^
$ echo 'void *foo(int) __attribute__((alloc_size("1")));' > 1.c
$ gcc -S 1.c
1.c:1:1: warning: alloc_size parameter outside range [-Wattributes]
 void *foo(int) __attribute__((alloc_size("1")));
 ^
Comment 1 Jakub Jelinek 2013-02-01 07:43:11 UTC
Your gcc is too old.  There is no ICE on the first testcase anymore.
Comment 2 Jakub Jelinek 2013-02-01 07:54:48 UTC
Created attachment 29327 [details]
gcc48-pr56167.patch

Fix for the attribute warning/error ICEs.  No idea why you consider the rest as bugs.
Comment 3 Dmitry Gorbachev 2013-02-01 16:21:58 UTC
> No idea why you consider the rest as bugs.

The diagnostic messages are somewhat confusing. I believe that `weakref', by analogy with `alias', should give:

bug.c:1:1: error: attribute 'weakref' argument not a string

And the same can be said about `section'.

In regard to `alloc_size', I think it could report something like:

1.c:1:1: error: 'alloc_size' parameter is not an integer constant

Needless to say, all these things are not of the utmost importance...
Comment 4 Jakub Jelinek 2013-02-05 08:08:33 UTC
Author: jakub
Date: Tue Feb  5 08:08:27 2013
New Revision: 195748

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195748
Log:
	PR middle-end/56167
	* c-common.c (handle_error_attribute): Fix condition.

	* gcc.dg/pr56167.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr56167.c
Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Jakub Jelinek 2013-02-05 08:10:39 UTC
Fixed.