[Bug c++/101782] [12 regression] Excess errors in g++.dg/cpp2a/concepts-pr67774.C after r12-2729

2021-08-04 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101782

--- Comment #2 from Jonathan Wakely  ---
I think we can probably do this to stop the test failing:

--- a/gcc/testsuite/g++.dg/cpp2a/concepts-pr67774.C
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-pr67774.C
@@ -1,5 +1,4 @@
 // { dg-do compile { target c++20 } }
-// { dg-additional-options "-fconcepts-ts" }

 #include 
 #include 


Because that flag was present to enable concepts support, but concepts are
always enabled for c++20 now, and it gets run with -std=c++2a

But the FE bug still needs to be fixed.

[Bug c++/101782] [12 regression] Excess errors in g++.dg/cpp2a/concepts-pr67774.C after r12-2729

2021-08-04 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101782

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||rejects-valid
   Assignee|redi at gcc dot gnu.org|unassigned at gcc dot 
gnu.org
 Status|ASSIGNED|NEW
  Component|testsuite   |c++

--- Comment #1 from Jonathan Wakely  ---
This is a C++ FE bug.

This valid C++20 code:

template concept foo = true;

template requires foo
[[nodiscard]]
int bar(T) { return 1; }

is rejected with the -fconcepts-ts flag (as both C++20 and C++17):

conc.C:4:1: error: two consecutive ‘[’ shall only introduce an attribute before
‘[’ token
4 | [[nodiscard]]
  | ^

For C++17 mode, -fconcepts-ts defines __cpp_concepts=201507L so we could use
that to suppress the [[nodiscard]] attributes when the flag is given.

But we can't detect it for C++20 mode (which is when the testsuite errors
happen) because C++20 defines __cpp_concepts=201907L and -fconcepts-ts doesn't
change that. So I'm not sure what we can do, other than not apply the attribute
to constrained functions with a requires-clause.