<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Done.<div><br></div><div>-bw</div><div><br><div style=""><div>On Aug 14, 2014, at 12:53 PM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">OK, sounds good.  Let's merge it.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 14, 2014 at 12:12 PM, 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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="">On Thu, Aug 14, 2014 at 11:47 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">Two things:<div><br></div><div>1. I would check Triple::isOSBinFormatCOFF() instead of the MSVC-ness of the environment. I think both Cygwin and MinGW probably use the .CRT$XCU section for initializers.</div>

</div></blockquote><div><br></div></div><div>Nope, neither do: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?revision=214538&view=markup#l629" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?revision=214538&view=markup#l629</a></div>
<div class="">
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">
<div><br></div><div>2. Should we parse the pragma for well-formedness before ignoring it in Sema::ActOnPragmaInitSeg?</div></div></blockquote><div><br></div></div><div>Eh, we could but it's not likely to do anything helpful.</div>
<div><div class="h5">
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Aug 14, 2014 at 12:58 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Should this get merged in for the next release?</div>

<div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Aug 13, 2014 at 11:35 PM, 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: majnemer<br>
Date: Thu Aug 14 01:35:08 2014<br>
New Revision: 215618<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=215618&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=215618&view=rev</a><br>
Log:<br>
Parse: Don't attempt to act on #pragma init_seg when not targeting MSVC<br>
<br>
It doesn't really make sense to try and do stuff with #pragma init_seg<br>
when targeting non-Microsoft platforms; notions like library vs user<br>
initializers don't exist for other targets.<br>
<br>
This fixes PR20639.<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td<br>
    cfe/trunk/lib/Parse/ParsePragma.cpp<br>
    cfe/trunk/test/SemaCXX/pragma-init_seg.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=215618&r1=215617&r2=215618&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=215618&r1=215617&r2=215618&view=diff</a><br>




==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Aug 14 01:35:08 2014<br>
@@ -867,6 +867,11 @@ def warn_pragma_pack_malformed : Warning<br>
 def warn_pragma_unused_expected_var : Warning<<br>
   "expected '#pragma unused' argument to be a variable name">,<br>
   InGroup<IgnoredPragmas>;<br>
+// - #pragma init_seg<br>
+def warn_pragma_init_seg_unsupported_target : Warning<<br>
+  "'#pragma init_seg' is only supported when targeting a "<br>
+  "Microsoft environment">,<br>
+  InGroup<IgnoredPragmas>;<br>
 // - #pragma fp_contract<br>
 def err_pragma_fp_contract_scope : Error<<br>
   "'#pragma fp_contract' can only appear at file scope or at the start of a "<br>
<br>
Modified: cfe/trunk/lib/Parse/ParsePragma.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=215618&r1=215617&r2=215618&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=215618&r1=215617&r2=215618&view=diff</a><br>




==============================================================================<br>
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Thu Aug 14 01:35:08 2014<br>
@@ -12,6 +12,7 @@<br>
 //===----------------------------------------------------------------------===//<br>
<br>
 #include "RAIIObjectsForParser.h"<br>
+#include "clang/Basic/TargetInfo.h"<br>
 #include "clang/Lex/Preprocessor.h"<br>
 #include "clang/Parse/ParseDiagnostic.h"<br>
 #include "clang/Parse/Parser.h"<br>
@@ -661,6 +662,11 @@ bool Parser::HandlePragmaMSSegment(Strin<br>
 // #pragma init_seg({ compiler | lib | user | "section-name" [, func-name]} )<br>
 bool Parser::HandlePragmaMSInitSeg(StringRef PragmaName,<br>
                                    SourceLocation PragmaLocation) {<br>
+  if (getTargetInfo().getTriple().getEnvironment() != llvm::Triple::MSVC) {<br>
+    PP.Diag(PragmaLocation, diag::warn_pragma_init_seg_unsupported_target);<br>
+    return false;<br>
+  }<br>
+<br>
   if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,<br>
                        PragmaName))<br>
     return false;<br>
<br>
Modified: cfe/trunk/test/SemaCXX/pragma-init_seg.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pragma-init_seg.cpp?rev=215618&r1=215617&r2=215618&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pragma-init_seg.cpp?rev=215618&r1=215617&r2=215618&view=diff</a><br>




==============================================================================<br>
--- cfe/trunk/test/SemaCXX/pragma-init_seg.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/pragma-init_seg.cpp Thu Aug 14 01:35:08 2014<br>
@@ -1,5 +1,7 @@<br>
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32<br>
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple i386-apple-darwin13.3.0<br>
<br>
+#ifndef __APPLE__<br>
 #pragma init_seg(L".my_seg") // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}}<br>
 #pragma init_seg( // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}}<br>
 #pragma init_seg asdf // expected-warning {{missing '('}}<br>
@@ -10,6 +12,10 @@<br>
 #pragma init_seg("\x") // expected-error {{\x used with no following hex digits}}<br>
 #pragma init_seg("a" L"b") // expected-warning {{expected non-wide string literal in '#pragma init_seg'}}<br>
<br>
-int f();<br>
 #pragma init_seg(compiler)<br>
+#else<br>
+#pragma init_seg(compiler) // expected-warning {{'#pragma init_seg' is only supported when targeting a Microsoft environment}}<br>
+#endif<br>
+<br>
+int f();<br>
 int __declspec(thread) x = f(); // expected-error {{initializer for thread-local variable must be a constant expression}}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">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>
</div></blockquote></div><br></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>
</blockquote></div><br></div></body></html>