https://bugs.llvm.org/show_bug.cgi?id=49891

            Bug ID: 49891
           Summary: No hint to use -std=c++20 when using 'concept' or
                    'requires' with older -std modes
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

template<typename T>
  concept snackable = requires (sizeof(T) != 1)

template<typename T>
  struct S { };

template<typename T> requires snackable<T>
  struct S<T> { };


Compiling this C++20 code without -std=c++20 produces a load of parser errors:

c.C:2:3: error: unknown type name 'concept'
  concept snackable = requires (sizeof(T) != 1)
  ^
c.C:2:23: error: use of undeclared identifier 'requires'
  concept snackable = requires (sizeof(T) != 1)
                      ^
c.C:7:22: error: unknown type name 'requires'
template<typename T> requires snackable<T>
                     ^
c.C:7:31: error: variable template partial specialization does not specialize
any template argument; to define the primary template, remove the template
argument list
template<typename T> requires snackable<T>
                              ^        ~~~
c.C:7:43: error: expected ';' at end of declaration
template<typename T> requires snackable<T>
                                          ^
                                          ;
c.C:8:12: error: use of undeclared identifier 'T'
  struct S<T> { };
           ^
6 errors generated.

There's no hint that you need to enable C++20.

GCC does better:

c.C:2:3: error: 'concept' does not name a type
    2 |   concept snackable = requires (sizeof(T) != 1)
      |   ^~~~~~~
c.C:2:3: note: 'concept' only available with '-std=c++20' or '-fconcepts'
c.C:7:22: error: 'requires' does not name a type
    7 | template<typename T> requires snackable<T>
      |                      ^~~~~~~~
c.C:7:22: note: 'requires' only available with '-std=c++20' or '-fconcepts'

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to