[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2019-08-15 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

Marek Polacek  changed:

   What|Removed |Added

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

--- Comment #12 from Marek Polacek  ---
Fixed for 9.3+.

[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2019-08-15 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

--- Comment #11 from Marek Polacek  ---
Author: mpolacek
Date: Thu Aug 15 18:31:16 2019
New Revision: 274544

URL: https://gcc.gnu.org/viewcvs?rev=274544=gcc=rev
Log:
PR c++/81429 - wrong parsing of constructor with C++11 attribute.
* parser.c (cp_parser_constructor_declarator_p): Handle the scenario
when a parameter declaration begins with [[attribute]].

* g++.dg/cpp0x/gen-attrs-68.C: New test.
* g++.dg/cpp0x/gen-attrs-69.C: New test.

Added:
branches/gcc-9-branch/gcc/testsuite/g++.dg/cpp0x/gen-attrs-68.C
branches/gcc-9-branch/gcc/testsuite/g++.dg/cpp0x/gen-attrs-69.C
Modified:
branches/gcc-9-branch/gcc/cp/ChangeLog
branches/gcc-9-branch/gcc/cp/parser.c

[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2019-08-07 Thread rbock at eudoxos dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

--- Comment #10 from Roland B  ---
(In reply to Marek Polacek from comment #9)
> Fixed on trunk, will backport to 9.3 later.

Thanks! Much appreciated :-)

[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2019-08-07 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

--- Comment #9 from Marek Polacek  ---
Fixed on trunk, will backport to 9.3 later.

[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2019-08-07 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

--- Comment #8 from Marek Polacek  ---
Author: mpolacek
Date: Wed Aug  7 17:32:12 2019
New Revision: 274181

URL: https://gcc.gnu.org/viewcvs?rev=274181=gcc=rev
Log:
PR c++/81429 - wrong parsing of constructor with C++11 attribute.
* parser.c (cp_parser_constructor_declarator_p): Handle the scenario
when a parameter declaration begins with [[attribute]].

* g++.dg/cpp0x/gen-attrs-68.C: New test.
* g++.dg/cpp0x/gen-attrs-69.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/gen-attrs-68.C
trunk/gcc/testsuite/g++.dg/cpp0x/gen-attrs-69.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog

[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2019-08-06 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

Marek Polacek  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #7 from Marek Polacek  ---
https://gcc.gnu.org/ml/gcc-patches/2019-08/msg00426.html

[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2019-08-06 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

--- Comment #6 from Marek Polacek  ---
I have a fix.  Extended testcase:

void fn1([[maybe_unused]] int a) { }
void fn2(int a [[maybe_unused]]) { }
void fn3(__attribute__((unused)) int a) { }
void fn4(int a __attribute__((unused))) { }

struct S1 {
  S1([[maybe_unused]] int a) { }
};

struct S2 {
  S2(int f,  [[maybe_unused]] int a) { }
};

struct S3 {
  S3(int a [[maybe_unused]]) { }
};

struct S4 {
  S4(int f, int a [[maybe_unused]]) { }
};

struct S5 {
  S5(__attribute__((unused)) int a) { }
};

struct S6 {
  S6(int f, __attribute__((unused)) int a) { }
};

struct S7 {
  S7(int a __attribute__((unused))) { }
};

struct S8 {
  S8(int f, int a __attribute__((unused))) { }
};

[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2019-08-06 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

--- Comment #5 from Marek Polacek  ---
Small test from Hana:

void foo([[maybe_unused]] int a) { }

struct bar {
bar([[maybe_unused]] int a) { }
};

[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2019-08-06 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||mpolacek at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

--- Comment #4 from Marek Polacek  ---
I'll take a look.

[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2019-08-06 Thread hanicka at hanicka dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

Hana Dusíková  changed:

   What|Removed |Added

 CC||hanicka at hanicka dot net

--- Comment #3 from Hana Dusíková  ---
Hi I run into same issue recently with GCC trunk. EDG, clang, MSVC accept such
code.

[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2017-09-11 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

Martin Liška  changed:

   What|Removed |Added

   Keywords||rejects-valid
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-09-11
 CC||jason at gcc dot gnu.org,
   ||marxin at gcc dot gnu.org
 Ever confirmed|0   |1
  Known to fail||8.0

--- Comment #2 from Martin Liška  ---
Confirmed, it's not accepted.

[Bug c++/81429] maybe_unused attribute triggers syntax error when used on first argument to a constructor

2017-07-13 Thread jeff.benshetler at stackpath dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429

--- Comment #1 from Jeff Benshetler  ---
Created attachment 41747
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41747=edit
Source test case that triggers the bug; corresponds to .ii file

Added in an abundance of caution. 
No header files are used. 
The first constructor has [[maybe_used]] on the first constructor parameter and
it triggers the bug.
The second constructor uses [[maybe_unused]] on the second constructor
parameter and it is fine.