Skip to content

Commit e98f000

Browse files
committed
C++ front-end: permit GCC attributes in using declarations
LLVM's standard library uses these in type_traits.
1 parent 07b41cd commit e98f000

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

regression/cpp/type_traits_essentials1/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ struct G<T(A......)>
2626
using i=int;
2727
template<typename T> using x=V<T>;
2828

29+
#ifdef __GNUC__
30+
using type __attribute__((__nodebug__)) = int;
31+
#endif
32+
2933
template<typename T>
3034
class C
3135
{

src/cpp/parse.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,23 @@ bool Parser::rDefinition(cpp_itemt &item)
583583
else if(t==TOK_INLINE && lex.LookAhead(1)==TOK_NAMESPACE)
584584
return rNamespaceSpec(item.make_namespace_spec());
585585
else if(t==TOK_USING)
586-
return rUsingOrTypedef(item);
586+
{
587+
cpp_token_buffert::post pos = lex.Save();
588+
589+
cpp_tokent tk;
590+
lex.get_token(tk);
591+
typet discard;
592+
if(
593+
is_identifier(lex.get_token(tk)) && optAttribute(discard) &&
594+
lex.LookAhead(0) == '=')
595+
{
596+
lex.Restore(pos);
597+
return rTypedefUsing(item.make_declaration());
598+
}
599+
600+
lex.Restore(pos);
601+
return rUsing(item.make_using());
602+
}
587603
else if(t==TOK_STATIC_ASSERT)
588604
return rStaticAssert(item.make_static_assert());
589605
else

0 commit comments

Comments
 (0)