[llvm-branch-commits] [cfe-branch] r195721 - Merging r195710:

Bill Wendling isanbard at gmail.com
Mon Nov 25 20:10:07 PST 2013


Author: void
Date: Mon Nov 25 22:10:07 2013
New Revision: 195721

URL: http://llvm.org/viewvc/llvm-project?rev=195721&view=rev
Log:
Merging r195710:
------------------------------------------------------------------------
r195710 | alp | 2013-11-25 17:30:10 -0800 (Mon, 25 Nov 2013) | 10 lines

Unbreak -fms-extensions with GNU libc headers

GNU libc uses '__uptr' as a member name in C mode, conflicting with the
eponymous MSVC pointer modifier keyword.

Detect and mark the token as an identifier when these specific conditions are
met. __uptr will continue to work as a keyword for the remainder of the
translation unit.

Fixes PR17824.
------------------------------------------------------------------------

Added:
    cfe/branches/release_34/test/Sema/Inputs/ms-keyword-system-header.h
      - copied unchanged from r195710, cfe/trunk/test/Sema/Inputs/ms-keyword-system-header.h
    cfe/branches/release_34/test/Sema/ms-keyword-system-header.c
      - copied unchanged from r195710, cfe/trunk/test/Sema/ms-keyword-system-header.c
Modified:
    cfe/branches/release_34/   (props changed)
    cfe/branches/release_34/include/clang/Parse/Parser.h
    cfe/branches/release_34/lib/Parse/ParseDecl.cpp

Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 25 22:10:07 2013
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195326,195329,195367,195384,195501,195547,195556,195558,195620,195687
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195326,195329,195367,195384,195501,195547,195556,195558,195620,195687,195710
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_34/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/include/clang/Parse/Parser.h?rev=195721&r1=195720&r2=195721&view=diff
==============================================================================
--- cfe/branches/release_34/include/clang/Parse/Parser.h (original)
+++ cfe/branches/release_34/include/clang/Parse/Parser.h Mon Nov 25 22:10:07 2013
@@ -2064,7 +2064,8 @@ private:
 
   void ParseTypeQualifierListOpt(DeclSpec &DS, bool GNUAttributesAllowed = true,
                                  bool CXX11AttributesAllowed = true,
-                                 bool AtomicAllowed = true);
+                                 bool AtomicAllowed = true,
+                                 bool IdentifierRequired = false);
   void ParseDirectDeclarator(Declarator &D);
   void ParseParenDeclarator(Declarator &D);
   void ParseFunctionDeclarator(Declarator &D,

Modified: cfe/branches/release_34/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/Parse/ParseDecl.cpp?rev=195721&r1=195720&r2=195721&view=diff
==============================================================================
--- cfe/branches/release_34/lib/Parse/ParseDecl.cpp (original)
+++ cfe/branches/release_34/lib/Parse/ParseDecl.cpp Mon Nov 25 22:10:07 2013
@@ -4414,7 +4414,8 @@ bool Parser::isConstructorDeclarator() {
 void Parser::ParseTypeQualifierListOpt(DeclSpec &DS,
                                        bool VendorAttributesAllowed,
                                        bool CXX11AttributesAllowed,
-                                       bool AtomicAllowed) {
+                                       bool AtomicAllowed,
+                                       bool IdentifierRequired) {
   if (getLangOpts().CPlusPlus11 && CXX11AttributesAllowed &&
       isCXX11AttributeSpecifier()) {
     ParsedAttributesWithRange attrs(AttrFactory);
@@ -4468,8 +4469,16 @@ void Parser::ParseTypeQualifierListOpt(D
       ParseOpenCLQualifiers(DS);
       break;
 
-    case tok::kw___sptr:
     case tok::kw___uptr:
+      // GNU libc headers in C mode use '__uptr' as an identifer which conflicts
+      // with the MS modifier keyword.
+      if (VendorAttributesAllowed && !getLangOpts().CPlusPlus &&
+          IdentifierRequired && DS.isEmpty() && NextToken().is(tok::semi) &&
+          PP.getSourceManager().isInSystemHeader(Loc)) {
+        Tok.setKind(tok::identifier);
+        continue;
+      }
+    case tok::kw___sptr:
     case tok::kw___w64:
     case tok::kw___ptr64:
     case tok::kw___ptr32:
@@ -4625,7 +4634,7 @@ void Parser::ParseDeclaratorInternal(Dec
     DeclSpec DS(AttrFactory);
 
     // FIXME: GNU attributes are not allowed here in a new-type-id.
-    ParseTypeQualifierListOpt(DS);
+    ParseTypeQualifierListOpt(DS, true, true, true, !D.mayOmitIdentifier());
     D.ExtendWithDeclSpec(DS);
 
     // Recursively parse the declarator.





More information about the llvm-branch-commits mailing list