[cfe-commits] r133663 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/alignof-sizeof-reference.cpp
Douglas Gregor
dgregor at apple.com
Wed Jun 22 16:21:00 PDT 2011
Author: dgregor
Date: Wed Jun 22 18:21:00 2011
New Revision: 133663
URL: http://llvm.org/viewvc/llvm-project?rev=133663&view=rev
Log:
Check for placeholders early on in
Sema::CreateUnaryExprOrTypeTraitExpr() rather than recursing in some
cases. Fixes <rdar://problem/9659191>.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/alignof-sizeof-reference.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=133663&r1=133662&r2=133663&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jun 22 18:21:00 2011
@@ -3301,6 +3301,12 @@
ExprResult
Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
UnaryExprOrTypeTrait ExprKind) {
+ ExprResult PE = CheckPlaceholderExpr(E);
+ if (PE.isInvalid())
+ return ExprError();
+
+ E = PE.get();
+
// Verify that the operand is valid.
bool isInvalid = false;
if (E->isTypeDependent()) {
@@ -3312,10 +3318,6 @@
} else if (E->getBitField()) { // C99 6.5.3.4p1.
Diag(E->getExprLoc(), diag::err_sizeof_alignof_bitfield) << 0;
isInvalid = true;
- } else if (E->getType()->isPlaceholderType()) {
- ExprResult PE = CheckPlaceholderExpr(E);
- if (PE.isInvalid()) return ExprError();
- return CreateUnaryExprOrTypeTraitExpr(PE.take(), OpLoc, ExprKind);
} else {
isInvalid = CheckUnaryExprOrTypeTraitOperand(E, UETT_SizeOf);
}
Modified: cfe/trunk/test/SemaCXX/alignof-sizeof-reference.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/alignof-sizeof-reference.cpp?rev=133663&r1=133662&r2=133663&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/alignof-sizeof-reference.cpp (original)
+++ cfe/trunk/test/SemaCXX/alignof-sizeof-reference.cpp Wed Jun 22 18:21:00 2011
@@ -13,3 +13,9 @@
void g() {
sizeof(&f); // expected-error{{cannot resolve overloaded function 'f' from context}}
}
+
+template<typename T> void f_template(); // expected-note{{candidate function}}
+template<typename T> void f_template(T*); // expected-note{{candidate function}}
+void rdar9659191() {
+ (void)alignof(f_template<int>); // expected-error{{cannot resolve overloaded function 'f_template' from context}}
+}
More information about the cfe-commits
mailing list