[llvm-branch-commits] [cfe-branch] r215880 - Merging r215618:
Bill Wendling
isanbard at gmail.com
Sun Aug 17 22:18:12 PDT 2014
Author: void
Date: Mon Aug 18 00:18:12 2014
New Revision: 215880
URL: http://llvm.org/viewvc/llvm-project?rev=215880&view=rev
Log:
Merging r215618:
------------------------------------------------------------------------
r215618 | majnemer | 2014-08-13 23:35:08 -0700 (Wed, 13 Aug 2014) | 7 lines
Parse: Don't attempt to act on #pragma init_seg when not targeting MSVC
It doesn't really make sense to try and do stuff with #pragma init_seg
when targeting non-Microsoft platforms; notions like library vs user
initializers don't exist for other targets.
This fixes PR20639.
------------------------------------------------------------------------
Modified:
cfe/branches/release_35/ (props changed)
cfe/branches/release_35/include/clang/Basic/DiagnosticParseKinds.td
cfe/branches/release_35/lib/Parse/ParsePragma.cpp
cfe/branches/release_35/test/SemaCXX/pragma-init_seg.cpp
Propchange: cfe/branches/release_35/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug 18 00:18:12 2014
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:213609,213611,213613,213741,213834,213840,213902,213912-213913,213993,213998-213999,214008,214050,214060,214119,214208,214222,214369,214390,214471,214734-214735,214777,215046,215229,215245,215806-215808
+/cfe/trunk:213609,213611,213613,213741,213834,213840,213902,213912-213913,213993,213998-213999,214008,214050,214060,214119,214208,214222,214369,214390,214471,214734-214735,214777,215046,215229,215245,215618,215806-215808
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_35/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_35/include/clang/Basic/DiagnosticParseKinds.td?rev=215880&r1=215879&r2=215880&view=diff
==============================================================================
--- cfe/branches/release_35/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/branches/release_35/include/clang/Basic/DiagnosticParseKinds.td Mon Aug 18 00:18:12 2014
@@ -849,6 +849,11 @@ def warn_pragma_pack_malformed : Warning
def warn_pragma_unused_expected_var : Warning<
"expected '#pragma unused' argument to be a variable name">,
InGroup<IgnoredPragmas>;
+// - #pragma init_seg
+def warn_pragma_init_seg_unsupported_target : Warning<
+ "'#pragma init_seg' is only supported when targeting a "
+ "Microsoft environment">,
+ InGroup<IgnoredPragmas>;
// - #pragma fp_contract
def err_pragma_fp_contract_scope : Error<
"'#pragma fp_contract' can only appear at file scope or at the start of a "
Modified: cfe/branches/release_35/lib/Parse/ParsePragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_35/lib/Parse/ParsePragma.cpp?rev=215880&r1=215879&r2=215880&view=diff
==============================================================================
--- cfe/branches/release_35/lib/Parse/ParsePragma.cpp (original)
+++ cfe/branches/release_35/lib/Parse/ParsePragma.cpp Mon Aug 18 00:18:12 2014
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "RAIIObjectsForParser.h"
+#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Parse/Parser.h"
@@ -655,6 +656,11 @@ bool Parser::HandlePragmaMSSegment(Strin
// #pragma init_seg({ compiler | lib | user | "section-name" [, func-name]} )
bool Parser::HandlePragmaMSInitSeg(StringRef PragmaName,
SourceLocation PragmaLocation) {
+ if (getTargetInfo().getTriple().getEnvironment() != llvm::Triple::MSVC) {
+ PP.Diag(PragmaLocation, diag::warn_pragma_init_seg_unsupported_target);
+ return false;
+ }
+
if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
PragmaName))
return false;
Modified: cfe/branches/release_35/test/SemaCXX/pragma-init_seg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_35/test/SemaCXX/pragma-init_seg.cpp?rev=215880&r1=215879&r2=215880&view=diff
==============================================================================
--- cfe/branches/release_35/test/SemaCXX/pragma-init_seg.cpp (original)
+++ cfe/branches/release_35/test/SemaCXX/pragma-init_seg.cpp Mon Aug 18 00:18:12 2014
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple i386-apple-darwin13.3.0
+#ifndef __APPLE__
#pragma init_seg(L".my_seg") // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}}
#pragma init_seg( // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}}
#pragma init_seg asdf // expected-warning {{missing '('}}
@@ -10,6 +12,10 @@
#pragma init_seg("\x") // expected-error {{\x used with no following hex digits}}
#pragma init_seg("a" L"b") // expected-warning {{expected non-wide string literal in '#pragma init_seg'}}
-int f();
#pragma init_seg(compiler)
+#else
+#pragma init_seg(compiler) // expected-warning {{'#pragma init_seg' is only supported when targeting a Microsoft environment}}
+#endif
+
+int f();
int __declspec(thread) x = f(); // expected-error {{initializer for thread-local variable must be a constant expression}}
More information about the llvm-branch-commits
mailing list