This revision was automatically updated to reflect the committed changes.
Closed by commit rL291253: Make ASTContext::getDeclAlign return the correct
alignment for (authored by ahatanak).
Changed prior to commit:
https://reviews.llvm.org/D27478?vs=80464&id=83378#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27478
Files:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/Sema/warn-cast-align.c
Index: cfe/trunk/test/Sema/warn-cast-align.c
===================================================================
--- cfe/trunk/test/Sema/warn-cast-align.c
+++ cfe/trunk/test/Sema/warn-cast-align.c
@@ -59,3 +59,11 @@
i = (int *)&s.s0;
i = (int *)a;
}
+
+// No warnings.
+typedef int (*FnTy)(void);
+unsigned int func5(void);
+
+FnTy test5(void) {
+ return (FnTy)&func5;
+}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -1458,7 +1458,9 @@
T = getPointerType(RT->getPointeeType());
}
QualType BaseT = getBaseElementType(T);
- if (!BaseT->isIncompleteType() && !T->isFunctionType()) {
+ if (T->isFunctionType())
+ Align = getTypeInfoImpl(T.getTypePtr()).Align;
+ else if (!BaseT->isIncompleteType()) {
// Adjust alignments of declarations with array type by the
// large-array alignment on the target.
if (const ArrayType *arrayType = getAsArrayType(T)) {
Index: cfe/trunk/test/Sema/warn-cast-align.c
===================================================================
--- cfe/trunk/test/Sema/warn-cast-align.c
+++ cfe/trunk/test/Sema/warn-cast-align.c
@@ -59,3 +59,11 @@
i = (int *)&s.s0;
i = (int *)a;
}
+
+// No warnings.
+typedef int (*FnTy)(void);
+unsigned int func5(void);
+
+FnTy test5(void) {
+ return (FnTy)&func5;
+}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -1458,7 +1458,9 @@
T = getPointerType(RT->getPointeeType());
}
QualType BaseT = getBaseElementType(T);
- if (!BaseT->isIncompleteType() && !T->isFunctionType()) {
+ if (T->isFunctionType())
+ Align = getTypeInfoImpl(T.getTypePtr()).Align;
+ else if (!BaseT->isIncompleteType()) {
// Adjust alignments of declarations with array type by the
// large-array alignment on the target.
if (const ArrayType *arrayType = getAsArrayType(T)) {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits