forked from OSchip/llvm-project
				
			[Concepts] Add check for dependent RC when checking function constraints
Do not attempt to check a dependent requires clause in a function constraint (may be triggered by, for example, DiagnoseUseOfDecl).
This commit is contained in:
		
							parent
							
								
									c83d9bedc0
								
							
						
					
					
						commit
						a424ef99e7
					
				| 
						 | 
					@ -325,9 +325,10 @@ bool Sema::CheckFunctionConstraints(const FunctionDecl *FD,
 | 
				
			||||||
                                    ConstraintSatisfaction &Satisfaction,
 | 
					                                    ConstraintSatisfaction &Satisfaction,
 | 
				
			||||||
                                    SourceLocation UsageLoc) {
 | 
					                                    SourceLocation UsageLoc) {
 | 
				
			||||||
  const Expr *RC = FD->getTrailingRequiresClause();
 | 
					  const Expr *RC = FD->getTrailingRequiresClause();
 | 
				
			||||||
  assert(!RC->isInstantiationDependent() &&
 | 
					  if (RC->isInstantiationDependent()) {
 | 
				
			||||||
         "CheckFunctionConstraints can only be used with functions with "
 | 
					    Satisfaction.IsSatisfied = true;
 | 
				
			||||||
         "non-dependent constraints");
 | 
					    return false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  // We substitute with empty arguments in order to rebuild the atomic
 | 
					  // We substitute with empty arguments in order to rebuild the atomic
 | 
				
			||||||
  // constraint in a constant-evaluated context.
 | 
					  // constraint in a constant-evaluated context.
 | 
				
			||||||
  // FIXME: Should this be a dedicated TreeTransform?
 | 
					  // FIXME: Should this be a dedicated TreeTransform?
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -333,11 +333,9 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  // See if this is a function with constraints that need to be satisfied.
 | 
					  // See if this is a function with constraints that need to be satisfied.
 | 
				
			||||||
  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
 | 
					  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
 | 
				
			||||||
    if (Expr *RC = FD->getTrailingRequiresClause()) {
 | 
					    if (FD->getTrailingRequiresClause()) {
 | 
				
			||||||
      ConstraintSatisfaction Satisfaction;
 | 
					      ConstraintSatisfaction Satisfaction;
 | 
				
			||||||
      bool Failed = CheckConstraintSatisfaction(FD, {RC}, /*TemplateArgs=*/{},
 | 
					      if (CheckFunctionConstraints(FD, Satisfaction, Loc))
 | 
				
			||||||
                                                SourceRange(Loc), Satisfaction);
 | 
					 | 
				
			||||||
      if (Failed)
 | 
					 | 
				
			||||||
        // A diagnostic will have already been generated (non-constant
 | 
					        // A diagnostic will have already been generated (non-constant
 | 
				
			||||||
        // constraint expression, for example)
 | 
					        // constraint expression, for example)
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue