<div dir="ltr">This is also a candidate for the 3.6 release branch as it fixes another post-3.5 diagnostics regression.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 27, 2015 at 10:26 AM, Kaelyn Takata <span dir="ltr"><<a href="mailto:rikka@google.com" target="_blank">rikka@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rikka<br>
Date: Tue Jan 27 12:26:18 2015<br>
New Revision: 227220<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=227220&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=227220&view=rev</a><br>
Log:<br>
Properly handle typos in the conditional of ?: expressions in C.<br>
<br>
In particular, remove the OpaqueExpr transformation from r225389 and<br>
move the correction of the conditional from CheckConditionalOperands to<br>
ActOnConditionalOp before the OpaqueExpr is created. This fixes the<br>
typo correction behavior in C code that uses the GNU extension for a<br>
binary ?: (without an expression between the "?" and the ":").<br>
<br>
Modified:<br>
cfe/trunk/lib/Sema/SemaExpr.cpp<br>
cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
cfe/trunk/test/Sema/typo-correction.c<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=227220&r1=227219&r2=227220&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=227220&r1=227219&r2=227220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jan 27 12:26:18 2015<br>
@@ -5785,15 +5785,6 @@ QualType Sema::CheckConditionalOperands(<br>
ExprObjectKind &OK,<br>
SourceLocation QuestionLoc) {<br>
<br>
- if (!getLangOpts().CPlusPlus) {<br>
- // C cannot handle TypoExpr nodes on either side of a binop because it<br>
- // doesn't handle dependent types properly, so make sure any TypoExprs have<br>
- // been dealt with before checking the operands.<br>
- ExprResult CondResult = CorrectDelayedTyposInExpr(Cond);<br>
- if (!CondResult.isUsable()) return QualType();<br>
- Cond = CondResult;<br>
- }<br>
-<br>
ExprResult LHSResult = CheckPlaceholderExpr(LHS.get());<br>
if (!LHSResult.isUsable()) return QualType();<br>
LHS = LHSResult;<br>
@@ -6175,6 +6166,15 @@ ExprResult Sema::ActOnConditionalOp(Sour<br>
SourceLocation ColonLoc,<br>
Expr *CondExpr, Expr *LHSExpr,<br>
Expr *RHSExpr) {<br>
+ if (!getLangOpts().CPlusPlus) {<br>
+ // C cannot handle TypoExpr nodes in the condition because it<br>
+ // doesn't handle dependent types properly, so make sure any TypoExprs have<br>
+ // been dealt with before checking the operands.<br>
+ ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);<br>
+ if (!CondResult.isUsable()) return ExprError();<br>
+ CondExpr = CondResult.get();<br>
+ }<br>
+<br>
// If this is the gnu "x ?: y" extension, analyze the types as though the LHS<br>
// was the condition.<br>
OpaqueValueExpr *opaqueValue = nullptr;<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=227220&r1=227219&r2=227220&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=227220&r1=227219&r2=227220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jan 27 12:26:18 2015<br>
@@ -6146,12 +6146,6 @@ public:<br>
<br>
ExprResult TransformLambdaExpr(LambdaExpr *E) { return Owned(E); }<br>
<br>
- ExprResult TransformOpaqueValueExpr(OpaqueValueExpr *E) {<br>
- if (Expr *SE = E->getSourceExpr())<br>
- return TransformExpr(SE);<br>
- return BaseTransform::TransformOpaqueValueExpr(E);<br>
- }<br>
-<br>
ExprResult Transform(Expr *E) {<br>
ExprResult Res;<br>
while (true) {<br>
<br>
Modified: cfe/trunk/test/Sema/typo-correction.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=227220&r1=227219&r2=227220&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=227220&r1=227219&r2=227220&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Sema/typo-correction.c (original)<br>
+++ cfe/trunk/test/Sema/typo-correction.c Tue Jan 27 12:26:18 2015<br>
@@ -13,6 +13,11 @@ void PR21656() {<br>
a = b ? : 0; // expected-warning {{type specifier missing, defaults to 'int'}} \<br>
// expected-error {{use of undeclared identifier 'b'}}<br>
<br>
+int foobar; // expected-note {{'foobar' declared here}}<br>
+a = goobar ?: 4; // expected-warning {{type specifier missing, defaults to 'int'}} \<br>
+ // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \<br>
+ // expected-error {{initializer element is not a compile-time constant}}<br>
+<br>
struct ContainerStuct {<br>
enum { SOME_ENUM }; // expected-note {{'SOME_ENUM' declared here}}<br>
};<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>