[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 8 11:34:52 PDT 2024
https://github.com/AmrDeveloper updated https://github.com/llvm/llvm-project/pull/111573
>From 076c867c16141f2c1b78c55fd78250155c0d97fd Mon Sep 17 00:00:00 2001
From: AmrDeveloper <amr96 at programmer.net>
Date: Tue, 8 Oct 2024 20:12:45 +0200
Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent
return type
---
clang/lib/Sema/SemaDeclAttr.cpp | 2 ++
clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 3 +++
2 files changed, 5 insertions(+)
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af983349a89b58..f3ed556faba778 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL) {
}
bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
+ if (T->isDependentType())
+ return true;
if (RefOkay) {
if (T->isReferenceType())
return true;
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>();
More information about the cfe-commits
mailing list