[Bug c++/86243] unknown attribute before throw causes hard error

2019-04-16 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86243

Jonathan Wakely  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |9.0

--- Comment #5 from Jonathan Wakely  ---
(In reply to Hannes Hauswedell from comment #0)
> This strongly looks like a bug. If one encloses the if-block in braces, I
> instead get a warning:
> 
> int main()
> {
> if (1 == 2) [[unlikely]]
> {
> throw int{};
> }
> 
> return 2;
> }
> 
> results in:
> 
> % g++7 -std=c++17 test.cpp
> test.cpp: In function 'int main()':
> test.cpp:3:17: warning: attributes at the beginning of statement are ignored
> [-Wattributes]
>  if (1 == 2) [[unlikely]]
>  ^

That warning is Bug 89962.

But this bug has been fixed by r266223 and the code is accepted now.

[Bug c++/86243] unknown attribute before throw causes hard error

2018-07-02 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86243

Martin Sebor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-07-02
 CC||msebor at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #4 from Martin Sebor  ---
Confirmed.  GCC recognizes an attribute when it applies to other statements but
gets confused when it's applied to a throw expression statement as in comment
#0.

$ cat t.C && gcc -S t.C
int f ()
{
  [[unlikely]] return 0;
  [[unlikely]] { }

  [[unlikely]] throw 0;
}

t.C: In function ‘int f()’:
t.C:3:3: warning: attributes at the beginning of statement are ignored
[-Wattributes]
   [[unlikely]] return 0;
   ^
t.C:4:3: warning: attributes at the beginning of statement are ignored
[-Wattributes]
   [[unlikely]] { }
   ^
t.C:6:4: error: expected identifier before ‘[’ token
   [[unlikely]] throw 0;
^
t.C: In lambda function:
t.C:6:16: error: expected ‘{’ before ‘throw’
   [[unlikely]] throw 0;
^
t.C: In function ‘int f()’:
t.C:6:15: error: expected ‘;’ before ‘throw’
   [[unlikely]] throw 0;
   ^~
   ;

[Bug c++/86243] unknown attribute before throw causes hard error

2018-06-30 Thread h2+bugs at fsfe dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86243

Hannes Hauswedell  changed:

   What|Removed |Added

   Keywords||rejects-valid
Summary|unknown attributes causing  |unknown attribute before
   |hard error  |throw causes hard error

--- Comment #3 from Hannes Hauswedell  ---
I have changed the title to reflect that this report is only about the error
related to the throw and will open a separate issue for the warning.