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] Add option to opt out of the missing_dependent_template_keyword diagnostic #98613

Merged
merged 2 commits into from
Jul 12, 2024

Conversation

hokein
Copy link
Collaborator

@hokein hokein commented Jul 12, 2024

After commit ce4aada, we observed many warnings in our internal codebase. It is
infeasible to fix all at once.

Currently, there is no way to disable this warning. This patch provides a way to disable it using the -Wno-missing-dependent-template-keyword flag.

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

llvmbot commented Jul 12, 2024

@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)

Changes

After commit ce4aada, we observed many warnings in our internal codebase. It is
infeasible to fix all at once.

Currently, there is no way to disable this warning. This patch provides a way to disable it using the -Wno-missing-dependent-template-keyword flag.


Full diff: https://github.com/llvm/llvm-project/pull/98613.diff

2 Files Affected:

  • (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+2-1)
  • (modified) clang/test/Misc/warning-flags.c (+1-2)
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 0bd2e35bf2e31..e00cd47411cb3 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -896,7 +896,8 @@ def missing_template_arg_list_after_template_kw : Extension<
   DefaultError;
 
 def ext_missing_dependent_template_keyword : ExtWarn<
-  "use 'template' keyword to treat '%0' as a dependent template name">;
+  "use 'template' keyword to treat '%0' as a dependent template name">,
+  InGroup<DiagGroup<"missing-dependent-template-keyword">>;
 
 def ext_extern_template : Extension<
   "extern templates are a C++11 extension">, InGroup<CXX11>;
diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c
index 651a86fb6e226..7b993f6849363 100644
--- a/clang/test/Misc/warning-flags.c
+++ b/clang/test/Misc/warning-flags.c
@@ -18,10 +18,9 @@ This test serves two purposes:
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (65):
+CHECK: Warnings without flags (64):
 
 CHECK-NEXT:   ext_expected_semi_decl_list
-CHECK-NEXT:   ext_missing_dependent_template_keyword
 CHECK-NEXT:   ext_missing_whitespace_after_macro_name
 CHECK-NEXT:   ext_new_paren_array_nonconst
 CHECK-NEXT:   ext_plain_complex

Copy link
Member

@sdkrystian sdkrystian left a comment

Choose a reason for hiding this comment

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

Reasonable, LGTM. Perhaps a release note should be added?

@hokein
Copy link
Collaborator Author

hokein commented Jul 12, 2024

Reasonable, LGTM. Perhaps a release note should be added?

Thanks for the review. Done.

@hokein hokein merged commit 8ef26f1 into llvm:main Jul 12, 2024
5 of 7 checks passed
@hokein hokein deleted the missing-template-warn-opt-out branch July 12, 2024 11:14
@pranavk
Copy link
Contributor

pranavk commented Jul 13, 2024

This doesn't seem to handle all the cases? See abseil/abseil-cpp#1711 for absl build failures that are not silenced by using this option.

@hokein
Copy link
Collaborator Author

hokein commented Jul 13, 2024

It does filter out the missing-dependent-template-keyword warnings, but doesn't fix the absl case.

With ce4aada, there is a behavior change in clang. Clang reject the following code which was accepted before by emitting a hard error err_no_member.

#define TYPE_OR_NONTYPE int

template<TYPE_OR_NONTYPE T>
struct BaseT {
  void Foo();
};

template<TYPE_OR_NONTYPE T>
struct DerivedT : BaseT<T> {
  void Inner();
};

template<TYPE_OR_NONTYPE T>
void DerivedT<T>::Inner() {
  this->BaseT<T>::Foo();
}
  • If the TYPE_OR_NONTYPE is typename (type template parameter case), clang emits a missing-dependent-template-keyword warning, which can be suppressed;
  • If the TYPE_OR_NONTYPE is int (non-type template parameter case), clang emits a hard error err_no_member;

aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this pull request Jul 14, 2024
…rd diagnostic (llvm#98613)

After commit ce4aada, we observed many
warnings in our internal codebase. It is infeasible to fix all at once.

Currently, there is no way to disable this warning. This patch provides
a way to disable it using the `-Wno-missing-dependent-template-keyword` flag.
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

4 participants