Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] Bail out if the result of function template instantiation is not a function. #69449

Closed
wants to merge 2 commits into from

Conversation

VitaNuo
Copy link
Contributor

@VitaNuo VitaNuo commented Oct 18, 2023

No description provided.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Oct 18, 2023
Copy link
Collaborator

@sam-mccall sam-mccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks great, just comment nits

@@ -2649,7 +2649,9 @@ TypeSourceInfo *Sema::SubstFunctionDeclType(TypeSourceInfo *T,
} else {
Result = Instantiator.TransformType(TLB, TL);
}
if (Result.isNull())
// When clang goes into recovery mode, it might substitute
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure "recovery mode" is well-defined enough to refer to in this way

maybe:
When there are errors resolving types, clang may use IntTy as a fallback, breaking our assumption that function declarations have function types.

(I thought there was a name for this usage of IntTy but I can't find one. It happens e.g. at GetFullTypeForDeclarator, SemaType.cpp:5734)

template <typename T>
void Func() {
using MyType = Type<T>(); // expected-note{{in instantiation of template type alias 'Type' requested here}}
MyType var;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// This is a function declaration, not a variable declaration!
// After substitution, we do not have a valid function type, and used to crash.

@VitaNuo
Copy link
Contributor Author

VitaNuo commented Oct 18, 2023

Pre-empted by #69459.

@VitaNuo VitaNuo closed this Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants