[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 8 11:14:58 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Amr Hesham (AmrDeveloper)
<details>
<summary>Changes</summary>
Fix `assume_aligned` incorrectly diagnoses a dependent return type
Fixes: #<!-- -->111563
---
Full diff: https://github.com/llvm/llvm-project/pull/111573.diff
2 Files Affected:
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+2)
- (modified) clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp (+3)
``````````diff
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af983349a89b58..c1d1ef31db6e92 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1217,6 +1217,8 @@ static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL) {
bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
if (RefOkay) {
+ if (T->isDependentType())
+ return true;
if (T->isReferenceType())
return true;
} else {
diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
index 61b85557d6b294..4459580cdccc5d 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
@@ -52,6 +52,9 @@ T *atest3() __attribute__((assume_aligned(31, o))); // expected-error {{requeste
template <typename T, int o>
T *atest4() __attribute__((assume_aligned(32, o)));
+template<typename T>
+T atest5(int) __attribute__((assume_aligned(2)));
+
void test22() {
atest3<int, 5>();
atest4<int, 5>();
``````````
</details>
https://github.com/llvm/llvm-project/pull/111573
More information about the cfe-commits
mailing list