summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-06-10 23:34:28 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-06-10 23:34:28 +0000
commitf6d7030f0f99de010dbf2737dc4a58b234e0f4b6 (patch)
tree3f7bc4ed694a94b1ab98985db97c46bd9dd511c0 /clang/lib/Sema/SemaExpr.cpp
parent377c1592f8d3c634c2ad395dbf6d5cc92ebc9458 (diff)
downloadbcm5719-llvm-f6d7030f0f99de010dbf2737dc4a58b234e0f4b6.tar.gz
bcm5719-llvm-f6d7030f0f99de010dbf2737dc4a58b234e0f4b6.zip
Related to PR19992: when the GNU alignof-expression extension is applied to an
expression of array-of-unknown-bound type, don't try to complete the array bound, and return the alignment of the element type rather than 1. llvm-svn: 210608
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index d2ba82bc167..041a9eb9d44 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3341,10 +3341,21 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
E->getSourceRange(), ExprKind))
return false;
- if (RequireCompleteExprType(E,
- diag::err_sizeof_alignof_incomplete_type,
- ExprKind, E->getSourceRange()))
- return true;
+ // 'alignof' applied to an expression only requires the base element type of
+ // the expression to be complete. 'sizeof' requires the expression's type to
+ // be complete (and will attempt to complete it if it's an array of unknown
+ // bound).
+ if (ExprKind == UETT_AlignOf) {
+ if (RequireCompleteType(E->getExprLoc(),
+ Context.getBaseElementType(E->getType()),
+ diag::err_sizeof_alignof_incomplete_type, ExprKind,
+ E->getSourceRange()))
+ return true;
+ } else {
+ if (RequireCompleteExprType(E, diag::err_sizeof_alignof_incomplete_type,
+ ExprKind, E->getSourceRange()))
+ return true;
+ }
// Completing the expression's type may have changed it.
ExprTy = E->getType();
OpenPOWER on IntegriCloud