<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jun 5, 2015 at 11:03 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Fri Jun 5 13:03:58 2015<br>
New Revision: 239170<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D239170-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=ZjVr-oKmZLeivCOVIYFj8_wFH3LzjR_3HS2Wu9m01-k&s=D4DAtepyODCS4OwpAP_SSmN0kP6yAWgOfutGcIX04cc&e=" target="_blank">http://llvm.org/viewvc/llvm-project?rev=239170&view=rev</a><br>
Log:<br>
[AST] There is no message for C++1z-style static_assert<br>
<br>
We would crash in the DeclPrinter trying to pretty-print the<br>
static_assert message. C++1z-style assertions don't have a message so<br>
we would crash.<br>
<br>
This fixes PR23756.<br>
<br>
Modified:<br>
cfe/trunk/lib/AST/DeclPrinter.cpp<br>
cfe/trunk/lib/Headers/Intrin.h<br>
cfe/trunk/test/SemaCXX/static-assert.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_AST_DeclPrinter.cpp-3Frev-3D239170-26r1-3D239169-26r2-3D239170-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=ZjVr-oKmZLeivCOVIYFj8_wFH3LzjR_3HS2Wu9m01-k&s=KwMkH0o4_b6FyG1DOmvG709oHdnETrSYkTjZcvYv9rI&e=" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=239170&r1=239169&r2=239170&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)<br>
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Fri Jun 5 13:03:58 2015<br>
@@ -733,8 +733,10 @@ void DeclPrinter::VisitImportDecl(Import<br>
void DeclPrinter::VisitStaticAssertDecl(StaticAssertDecl *D) {<br>
Out << "static_assert(";<br>
D->getAssertExpr()->printPretty(Out, nullptr, Policy, Indentation);<br>
- Out << ", ";<br>
- D->getMessage()->printPretty(Out, nullptr, Policy, Indentation);<br>
+ if (StringLiteral *SL = D->getMessage()) {<br>
+ Out << ", ";<br>
+ SL->printPretty(Out, nullptr, Policy, Indentation);<br>
+ }<br>
Out << ")";<br>
}<br>
<br>
<br>
Modified: cfe/trunk/lib/Headers/Intrin.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Headers_Intrin.h-3Frev-3D239170-26r1-3D239169-26r2-3D239170-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=ZjVr-oKmZLeivCOVIYFj8_wFH3LzjR_3HS2Wu9m01-k&s=J5rOpvA4ziOGpvkCoOPdddhdutlvN6ql3kCD0_NZCLs&e=" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/Intrin.h?rev=239170&r1=239169&r2=239170&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Headers/Intrin.h (original)<br>
+++ cfe/trunk/lib/Headers/Intrin.h Fri Jun 5 13:03:58 2015<br>
@@ -546,13 +546,8 @@ _bittestandset(long *a, long b) {<br>
#if defined(__i386__) || defined(__x86_64__)<br>
static __inline__ unsigned char __attribute__((__always_inline__, __nodebug__))<br>
_interlockedbittestandset(long volatile *__BitBase, long __BitPos) {<br>
- unsigned char __Res;<br>
- __asm__ ("xor %0, %0\n"<br>
- "lock bts %2, %1\n"<br>
- "setc %0\n"<br>
- : "=r" (__Res), "+m"(*__BitBase)<br>
- : "Ir"(__BitPos));<br>
- return __Res;<br>
+ long __OldVal = __atomic_fetch_or(__BitBase, 1 << __BitPos, 5);<br>
+ return (__OldVal >> __BitPos) & 1;<br>
}<br>
#endif<br>
#ifdef __x86_64__<br>
<br>
Modified: cfe/trunk/test/SemaCXX/static-assert.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_SemaCXX_static-2Dassert.cpp-3Frev-3D239170-26r1-3D239169-26r2-3D239170-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=ZjVr-oKmZLeivCOVIYFj8_wFH3LzjR_3HS2Wu9m01-k&s=G7QuXX8Ir3AbY--eJvspXaZF_tS9vrXfvE2YsAXgbFE&e=" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/static-assert.cpp?rev=239170&r1=239169&r2=239170&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/static-assert.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/static-assert.cpp Fri Jun 5 13:03:58 2015<br>
@@ -51,3 +51,12 @@ StaticAssertProtected<X> sap2; // expect<br>
<br>
static_assert(true); // expected-warning {{C++1z extension}}<br>
static_assert(false); // expected-error-re {{failed{{$}}}} expected-warning {{extension}}<br>
+<br>
+void PR23756() {<br>
+ struct { // expected-note 2 {{no known conversion from}}<br>
+ } _ = decltype( // expected-error {{no viable conversion}}<br>
+ ({ // expected-warning {{no effect in an unevaluated context}}<br>
+ static_assert(true); // expected-warning {{C++1z extension}}<br>
+ 1;<br>
+ })){};<br>
+}</blockquote><div><br></div><div>Can you add a pretty-printer test rather than relying on the diagnostics engine pretty-printing the expression within a 'decltype' here? I'm thinking we shouldn't pretty-print the operand of 'decltype' when printing the type...<br></div></div></div></div>