]> granicus.if.org Git - clang/commitdiff
Fix for P41852 where builtin attributes were being caught by FindLocsWithCommonFileID().
authorLeonard Chan <leonardchan@google.com>
Sun, 12 May 2019 21:50:01 +0000 (21:50 +0000)
committerLeonard Chan <leonardchan@google.com>
Sun, 12 May 2019 21:50:01 +0000 (21:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360544 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/Driver/mingw-macro-qualified-type.c [new file with mode: 0644]

index 86fb8897e62af0d962c6f73eb08d90ae7a8d151f..fe597ed2dfb36131c4a71c3888b114f8f2a04010 100644 (file)
@@ -224,8 +224,9 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs,
 
     // If this was declared in a macro, attach the macro IdentifierInfo to the
     // parsed attribute.
-    if (FindLocsWithCommonFileID(PP, AttrTokLoc, Loc)) {
-      auto &SM = PP.getSourceManager();
+    auto &SM = PP.getSourceManager();
+    if (!SM.isWrittenInBuiltinFile(SM.getSpellingLoc(AttrTokLoc)) &&
+        FindLocsWithCommonFileID(PP, AttrTokLoc, Loc)) {
       CharSourceRange ExpansionRange = SM.getExpansionRange(AttrTokLoc);
       StringRef FoundName =
           Lexer::getSourceText(ExpansionRange, SM, PP.getLangOpts());
diff --git a/test/Driver/mingw-macro-qualified-type.c b/test/Driver/mingw-macro-qualified-type.c
new file mode 100644 (file)
index 0000000..43b744b
--- /dev/null
@@ -0,0 +1,12 @@
+// Ensure that builtin attributes do not get treated as user defined macros to
+// be weapped in macro qualified types. This addresses P41852.
+//
+// RUN: %clang -c %s -target i686-w64-mingw32
+
+typedef int WINBOOL;
+typedef unsigned int UINT_PTR, *PUINT_PTR;
+typedef unsigned long long ULONG64, *PULONG64;
+#define WINAPI __stdcall
+#define CALLBACK __stdcall
+
+typedef WINBOOL(CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);