llvm-project/clang/test/Driver/cl-delayed-template-parsing-cxx20.cpp
Chuanqi Xu 366ffbaf62
[C++20] [Modules] [Driver] Don't enable -fdelayed-template-parsing by default on windows with C++20 (#69431)
There are already 3 issues about the broken state of
-fdelayed-template-parsing and C++20 modules:
- https://github.com/llvm/llvm-project/issues/61068
- https://github.com/llvm/llvm-project/issues/64810
- https://github.com/llvm/llvm-project/issues/65027

The problem is more complex than I thought. I am not sure how to fix it
properly now. Given the complexities and -fdelayed-template-parsing is
actually an extension to support old MS codes, I think it may make sense
to not enable the -fdelayed-template-parsing option by default with
C++20 modules to give more user friendly experience. Users who still
want -fdelayed-template-parsing can specify it explicitly.

Also according to https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-170, MSVC actually defaults to -fno-delayed-template-parsing (/Zc:twoPhase-
with MSVC CLI) if using C++20. So we match the behavior with MSVC here to
not enable -fdelayed-template-parsing by default after C++20.
2023-10-23 10:06:16 +08:00

11 lines
463 B
C++

// RUN: %clang_cl -### -- %s 2>&1 | FileCheck %s --check-prefix=PRE-CXX20
// RUN: %clang_cl -std:c++20 -### -- %s 2>&1 | FileCheck %s
// RUN: %clang_cl -std:c++20 -### -fdelayed-template-parsing -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-EXPLICIT
// PRE-CXX20: -fdelayed-template-parsing
// CHECK-NOT: -fdelayed-template-parsing
// CHECK-EXPLICIT: warning: -fdelayed-template-parsing is deprecated after C++20
// CHECK-EXPLICIT: -fdelayed-template-parsing