diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2022-07-25 12:42:42 +0200 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2022-07-25 14:43:38 +0200 |
commit | 59179d72b2e3d3b99ebc342374c9c797d526ac5d (patch) | |
tree | 4c07c596d3e17f548a1ecd48defe8efdda4bf800 /clang/include | |
parent | aff68f5ad646303a4992fc04d329b4df06bc4c71 (diff) | |
download | llvm-59179d72b2e3d3b99ebc342374c9c797d526ac5d.zip llvm-59179d72b2e3d3b99ebc342374c9c797d526ac5d.tar.gz llvm-59179d72b2e3d3b99ebc342374c9c797d526ac5d.tar.bz2 |
[Sema] Merge C++20 concept definitions from different modules in same TU
Currently the C++20 concepts are only merged in `ASTReader`, i.e. when
coming from different TU. This can causes ambiguious reference errors when
trying to access the same concept that should otherwise be merged.
Please see the added test for an example.
Note that we currently use `ASTContext::isSameEntity` to check for ODR
violations. However, it will not check that concept requirements match.
The same issue holds for mering concepts from different TUs, I added a
FIXME and filed a GH issue to track this:
https://github.com/llvm/llvm-project/issues/56310
Reviewed By: ChuanqiXu
Differential Revision: https://reviews.llvm.org/D128921
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | clang/include/clang/Sema/Sema.h | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index c2cabcb..6ff5b8d 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -5774,6 +5774,8 @@ def warn_forward_class_redefinition : Warning< def err_redefinition_different_typedef : Error< "%select{typedef|type alias|type alias template}0 " "redefinition with different types%diff{ ($ vs $)|}1,2">; +def err_redefinition_different_concept : Error< + "redefinition of concept %0 with different template parameters or requirements">; def err_tag_reference_non_tag : Error< "%select{non-struct type|non-class type|non-union type|non-enum " "type|typedef|type alias|template|type alias template|template " diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index de9bde6..b149c24 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -8260,6 +8260,9 @@ public: Scope *S, MultiTemplateParamsArg TemplateParameterLists, IdentifierInfo *Name, SourceLocation NameLoc, Expr *ConstraintExpr); + void CheckConceptRedefinition(ConceptDecl *NewDecl, LookupResult &Previous, + bool &AddToScope); + RequiresExprBodyDecl * ActOnStartRequiresExpr(SourceLocation RequiresKWLoc, ArrayRef<ParmVarDecl *> LocalParameters, |